From 65854c3411f758d8664772350279efd52c4081d8 Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Wed, 16 Aug 2023 08:18:07 +0000 Subject: [PATCH] LibWeb: Set table wrapper width from the table box Fixes #20385 and some Wikipedia pages, for example: https://en.wikipedia.org/wiki/2022%E2%80%9323_UEFA_Champions_League_knockout_phase --- .../display-table-inline-children.txt | 4 +- .../grid/floating-table-wrapper-width.txt | 50 +++++++++++++++++++ .../grid/floating-table-wrapper-width.html | 23 +++++++++ .../LibWeb/Layout/TableFormattingContext.cpp | 2 + 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/grid/floating-table-wrapper-width.txt create mode 100644 Tests/LibWeb/Layout/input/grid/floating-table-wrapper-width.html diff --git a/Tests/LibWeb/Layout/expected/display-table-inline-children.txt b/Tests/LibWeb/Layout/expected/display-table-inline-children.txt index 075a126828..586b0a1060 100644 --- a/Tests/LibWeb/Layout/expected/display-table-inline-children.txt +++ b/Tests/LibWeb/Layout/expected/display-table-inline-children.txt @@ -5,7 +5,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (8,8) content-size 784x600 children: not-inline BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline TextNode <#text> - TableWrapper <(anonymous)> at (8,8) content-size 784x600 [BFC] children: not-inline + TableWrapper <(anonymous)> at (8,8) content-size 1200x600 [BFC] children: not-inline Box at (8,8) content-size 1200x600 table-box [TFC] children: inline Box <(anonymous)> at (8,8) content-size 1200x600 table-row children: inline BlockContainer <(anonymous)> at (8,8) content-size 1200x600 table-cell [BFC] children: inline @@ -25,7 +25,7 @@ PaintableWithLines (Viewport<#document>) [0,0 800x600] overflow: [0,0 1208x616] PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0] PaintableWithLines (BlockContainer) [8,8 784x600] overflow: [8,8 1200x600] PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0] - PaintableWithLines (TableWrapper(anonymous)) [8,8 784x600] overflow: [8,8 1200x600] + PaintableWithLines (TableWrapper(anonymous)) [8,8 1200x600] PaintableBox (Box
.aligncenter.block-image) [8,8 1200x600] PaintableBox (Box(anonymous)) [8,8 1200x600] PaintableWithLines (BlockContainer(anonymous)) [8,8 1200x600] diff --git a/Tests/LibWeb/Layout/expected/grid/floating-table-wrapper-width.txt b/Tests/LibWeb/Layout/expected/grid/floating-table-wrapper-width.txt new file mode 100644 index 0000000000..2c8b356364 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/floating-table-wrapper-width.txt @@ -0,0 +1,50 @@ +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 784x27.46875 children: not-inline + Box at (8,8) content-size 784x27.46875 [GFC] children: not-inline + BlockContainer
at (8,8) content-size 784x27.46875 [BFC] children: not-inline + BlockContainer at (8,8) content-size 6.34375x17.46875 floating [BFC] children: inline + line 0 width: 6.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [8,8 6.34375x17.46875] + "1" + TextNode <#text> + TableWrapper <(anonymous)> at (14.34375,8) content-size 156.796875x27.46875 floating [BFC] children: not-inline + Box at (15.34375,9) content-size 154.796875x25.46875 table-box [TFC] children: not-inline + Box at (15.34375,9) content-size 148.796875x21.46875 table-row-group children: not-inline + Box at (17.34375,11) content-size 148.796875x21.46875 table-row children: not-inline + BlockContainer at (19.34375,13) content-size 69.59375x17.46875 table-cell [BFC] children: inline + line 0 width: 8.8125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [19.34375,13 8.8125x17.46875] + "2" + TextNode <#text> + BlockContainer at (94.9375,13) content-size 71.203125x17.46875 table-cell [BFC] children: inline + line 0 width: 9.09375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [94.9375,13 9.09375x17.46875] + "3" + TextNode <#text> + BlockContainer at (171.140625,8) content-size 7.75x17.46875 floating [BFC] children: inline + line 0 width: 7.75, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [171.140625,8 7.75x17.46875] + "4" + TextNode <#text> + BlockContainer <(anonymous)> at (8,35.46875) content-size 784x0 children: inline + TextNode <#text> + +PaintableWithLines (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x600] + PaintableWithLines (BlockContainer) [8,8 784x27.46875] + PaintableBox (Box
.grid) [8,8 784x27.46875] + PaintableWithLines (BlockContainer
) [8,8 784x27.46875] + PaintableWithLines (BlockContainer
.left) [8,8 6.34375x17.46875] + TextPaintable (TextNode<#text>) + PaintableWithLines (TableWrapper(anonymous)) [14.34375,8 156.796875x27.46875] + PaintableBox (Box.middle) [14.34375,8 156.796875x27.46875] + PaintableBox (Box) [15.34375,9 148.796875x21.46875] overflow: [15.34375,9 152.796875x23.46875] + PaintableBox (Box) [17.34375,11 148.796875x21.46875] overflow: [17.34375,11 150.796875x21.46875] + PaintableWithLines (BlockContainer
) [17.34375,11 73.59375x21.46875] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer) [92.9375,11 75.203125x21.46875] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer
.right) [171.140625,8 7.75x17.46875] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer(anonymous)) [8,35.46875 784x0] diff --git a/Tests/LibWeb/Layout/input/grid/floating-table-wrapper-width.html b/Tests/LibWeb/Layout/input/grid/floating-table-wrapper-width.html new file mode 100644 index 0000000000..8faaaf2dfd --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/floating-table-wrapper-width.html @@ -0,0 +1,23 @@ +
1
23
4
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 39d7a97218..8bade807d0 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -638,6 +638,8 @@ void TableFormattingContext::compute_table_width() } table_box_state.set_content_width(used_width); + auto& table_wrapper_box_state = m_state.get_mutable(table_wrapper()); + table_wrapper_box_state.set_content_width(table_box_state.border_box_width()); } CSSPixels TableFormattingContext::compute_columns_total_used_width() const