diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-28 14:41:01 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-28 16:06:08 +0200 |
commit | df3cd2fd569a880d918bb52dd850846f8fca539a (patch) | |
tree | d3df5ccced561e626b39eed56865be3cb7893a85 /Userland | |
parent | 52a1be5eae81bd2eea767cfce569e089ec1bb3df (diff) | |
download | serenity-df3cd2fd569a880d918bb52dd850846f8fca539a.zip |
LibWeb: Treat width:auto on tables as fit-content
Tables, unlike other block-level elements, should not stretch to fit
their containing block by default.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index b577eb4459..85d4396bcd 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -29,6 +29,7 @@ void TableFormattingContext::run(Box& box, LayoutMode) { compute_width(box); + float total_content_width = 0; float total_content_height = 0; box.for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) { @@ -41,20 +42,28 @@ void TableFormattingContext::run(Box& box, LayoutMode) calculate_column_widths(row, column_widths); }); + float content_width = 0; float content_height = 0; row_group_box.template for_each_child_of_type<TableRowBox>([&](auto& row) { row.set_offset(0, content_height); layout_row(row, column_widths); + content_width = max(content_width, row.width()); content_height += row.height(); }); + if (row_group_box.computed_values().width().is_auto()) + row_group_box.set_width(content_width); row_group_box.set_height(content_height); row_group_box.set_offset(0, total_content_height); total_content_height += content_height; + total_content_width = max(total_content_width, row_group_box.width()); }); + if (box.computed_values().width().is_auto()) + box.set_width(total_content_width); + // FIXME: This is a total hack, we should respect the 'height' property. box.set_height(total_content_height); } |