From a27c9d8b05aaf031af0239903c6ffdf332e8e990 Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Tue, 11 Jul 2023 10:48:52 +0000 Subject: [PATCH] LibWeb: Use max width from content for cells unless length is specified Max width shouldn't be tied to min width, commit d33b99d went too far and made them the same when the table-root had a specified percentage width. Fixes #19940. --- ...-auto-max-width-table-percentage-width.txt | 43 +++++++++++++++++++ ...auto-max-width-table-percentage-width.html | 22 ++++++++++ .../LibWeb/Layout/TableFormattingContext.cpp | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/cell-auto-max-width-table-percentage-width.txt create mode 100644 Tests/LibWeb/Layout/input/cell-auto-max-width-table-percentage-width.html diff --git a/Tests/LibWeb/Layout/expected/cell-auto-max-width-table-percentage-width.txt b/Tests/LibWeb/Layout/expected/cell-auto-max-width-table-percentage-width.txt new file mode 100644 index 0000000000..1d7bad67ce --- /dev/null +++ b/Tests/LibWeb/Layout/expected/cell-auto-max-width-table-percentage-width.txt @@ -0,0 +1,43 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x23.46875 children: not-inline + BlockContainer at (8,8) content-size 80x23.46875 children: not-inline + BlockContainer <(anonymous)> at (8,8) content-size 80x0 children: inline + TextNode <#text> + TableWrapper <(anonymous)> at (8,8) content-size 80x23.46875 [BFC] children: not-inline + Box at (8,8) content-size 80x23.46875 table-box [TFC] children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box at (8,8) content-size 72x19.46875 table-row-group children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box at (10,10) content-size 72x19.46875 table-row children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (11,11) content-size 14.265625x17.46875 table-cell [BFC] children: inline + line 0 width: 14.265625, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [11,11 14.265625x17.46875] + "A" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (29.265625,11) content-size 9.34375x17.46875 table-cell [BFC] children: inline + line 0 width: 9.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [29.265625,11 9.34375x17.46875] + "B" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (42.609375,11) content-size 42.390625x17.46875 table-cell [BFC] children: inline + line 0 width: 29.453125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 3, rect: [42.609375,11 29.453125x17.46875] + "C D" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> at (8,31.46875) content-size 80x0 children: inline + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/cell-auto-max-width-table-percentage-width.html b/Tests/LibWeb/Layout/input/cell-auto-max-width-table-percentage-width.html new file mode 100644 index 0000000000..49a010f92b --- /dev/null +++ b/Tests/LibWeb/Layout/input/cell-auto-max-width-table-percentage-width.html @@ -0,0 +1,22 @@ + + + +
+ + + + + + + + +
ABC D
+
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 02be400e2e..936048e1cc 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -196,7 +196,7 @@ void TableFormattingContext::compute_cell_measures(AvailableSpace const& availab min_width = max(min_width, computed_values.min_width().to_px(cell.box, containing_block.content_width())); CSSPixels max_height = computed_values.height().is_auto() ? max_content_height : height; - CSSPixels max_width = (computed_values.width().is_length() || !table_width_is_auto) ? width : max_content_width; + CSSPixels max_width = computed_values.width().is_length() ? width : max_content_width; if (!should_treat_max_height_as_none(cell.box, available_space.height)) max_height = min(max_height, computed_values.max_height().to_px(cell.box, containing_block.content_height())); if (!should_treat_max_width_as_none(cell.box, available_space.width))