From d1b967bca526b72787dc98760bfb4b104d09ed46 Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:34:35 +1100 Subject: [PATCH] LibWeb: Consider every row when calculating table width --- .../table/clip-spans-to-table-end.txt | 30 ++++----- .../expected/table/colspan-overflow-crash.txt | 61 +++++++++++++++++++ .../input/table/colspan-overflow-crash.html | 10 +++ .../Libraries/LibWeb/Layout/TableGrid.cpp | 2 +- 4 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/table/colspan-overflow-crash.txt create mode 100644 Tests/LibWeb/Layout/input/table/colspan-overflow-crash.html diff --git a/Tests/LibWeb/Layout/expected/table/clip-spans-to-table-end.txt b/Tests/LibWeb/Layout/expected/table/clip-spans-to-table-end.txt index 3abf7037af2e..2a628c6839df 100644 --- a/Tests/LibWeb/Layout/expected/table/clip-spans-to-table-end.txt +++ b/Tests/LibWeb/Layout/expected/table/clip-spans-to-table-end.txt @@ -1,12 +1,12 @@ 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 784x117 children: not-inline - TableWrapper <(anonymous)> at (8,8) content-size 92.359375x117 [BFC] children: not-inline - Box at (8,8) content-size 92.359375x117 table-box [TFC] children: not-inline + TableWrapper <(anonymous)> at (8,8) content-size 93.359375x117 [BFC] children: not-inline + Box
at (8,8) content-size 93.359375x117 table-box [TFC] children: not-inline BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> - Box at (8,8) content-size 92.359375x117 table-row-group children: not-inline - Box at (8,8) content-size 92.359375x39 table-row children: not-inline + Box at (8,8) content-size 93.359375x117 table-row-group children: not-inline + Box at (8,8) content-size 93.359375x39 table-row children: not-inline BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> BlockContainer at (8,47) content-size 92.359375x39 table-row children: not-inline + Box at (8,47) content-size 93.359375x39 table-row children: not-inline BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> BlockContainer at (8,86) content-size 92.359375x39 table-row children: not-inline + Box at (8,86) content-size 93.359375x39 table-row children: not-inline BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> BlockContainer
at (19,19) content-size 8.453125x17 table-cell [BFC] children: inline @@ -27,9 +27,10 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline TextNode <#text> BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> + BlockContainer <(anonymous)> at (101.359375,27.5) content-size 0x0 table-cell [BFC] children: not-inline BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> - Box
at (19,58) content-size 8.453125x17 table-cell [BFC] children: inline @@ -38,7 +39,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline TextNode <#text> BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> - BlockContainer at (49.453125,77.5) content-size 39.90625x17 table-cell [BFC] children: inline + BlockContainer at (49.453125,77.5) content-size 40.90625x17 table-cell [BFC] children: inline frag 0 from TextNode start: 0, length: 3, rect: [49.453125,77.5 24.046875x17] baseline: 13.296875 "6-9" TextNode <#text> @@ -46,7 +47,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline TextNode <#text> BlockContainer <(anonymous)> (not painted) children: inline TextNode <#text> - Box
at (19,97) content-size 8.453125x17 table-cell [BFC] children: inline @@ -61,21 +62,22 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x600] PaintableWithLines (BlockContainer) [8,8 784x117] - PaintableWithLines (TableWrapper(anonymous)) [8,8 92.359375x117] - PaintableBox (Box) [8,8 92.359375x117] - PaintableBox (Box) [8,8 92.359375x117] - PaintableBox (Box) [8,8 92.359375x39] + PaintableWithLines (TableWrapper(anonymous)) [8,8 93.359375x117] + PaintableBox (Box
) [8,8 93.359375x117] + PaintableBox (Box) [8,8 93.359375x117] + PaintableBox (Box) [8,8 93.359375x39] PaintableWithLines (BlockContainer) [8,47 92.359375x39] + PaintableWithLines (BlockContainer(anonymous)) [100.359375,8 1x39] + PaintableBox (Box) [8,47 93.359375x39] PaintableWithLines (BlockContainer) [8,86 92.359375x39] + PaintableBox (Box) [8,86 93.359375x39] PaintableWithLines (BlockContainer
) [8,8 30.453125x39] TextPaintable (TextNode<#text>) PaintableWithLines (BlockContainer) [38.453125,8 30.8125x39] TextPaintable (TextNode<#text>) PaintableWithLines (BlockContainer) [69.265625,8 31.09375x39] TextPaintable (TextNode<#text>) - PaintableBox (Box
) [8,47 30.453125x39] TextPaintable (TextNode<#text>) - PaintableWithLines (BlockContainer) [38.453125,47 61.90625x78] + PaintableWithLines (BlockContainer) [38.453125,47 62.90625x78] TextPaintable (TextNode<#text>) - PaintableBox (Box
) [8,86 30.453125x39] TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/expected/table/colspan-overflow-crash.txt b/Tests/LibWeb/Layout/expected/table/colspan-overflow-crash.txt new file mode 100644 index 000000000000..25bac49b4bab --- /dev/null +++ b/Tests/LibWeb/Layout/expected/table/colspan-overflow-crash.txt @@ -0,0 +1,61 @@ +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 784x61 children: not-inline + TableWrapper <(anonymous)> at (8,8) content-size 27.90625x44 [BFC] children: not-inline + Box at (8,8) content-size 27.90625x44 table-box [TFC] children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box at (10,10) content-size 23.90625x40 table-row-group children: not-inline + Box at (10,10) content-size 23.90625x19 table-row children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (10,31) content-size 23.90625x19 table-row children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer
at (11,11) content-size 6.8125x17 table-cell [BFC] children: inline + frag 0 from TextNode start: 0, length: 1, rect: [11,11 6.34375x17] baseline: 13.296875 + "1" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> at (20.8125,19.5) content-size 0x0 table-cell [BFC] children: not-inline + BlockContainer <(anonymous)> at (22.8125,19.5) content-size 11.09375x0 table-cell [BFC] children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box
at (11,32) content-size 8.8125x17 table-cell [BFC] children: inline + frag 0 from TextNode start: 0, length: 1, rect: [11,32 8.8125x17] baseline: 13.296875 + "2" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (23.8125,32) content-size 9.09375x17 table-cell [BFC] children: inline + frag 0 from TextNode start: 0, length: 1, rect: [23.8125,32 9.09375x17] baseline: 13.296875 + "3" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> at (8,52) content-size 784x17 children: inline + frag 0 from TextNode start: 1, length: 19, rect: [8,52 162.109375x17] baseline: 13.296875 + "PASS (didn't crash)" + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x600] + PaintableWithLines (BlockContainer) [8,8 784x61] + PaintableWithLines (TableWrapper(anonymous)) [8,8 27.90625x44] + PaintableBox (Box) [8,8 27.90625x44] + PaintableBox (Box) [10,10 23.90625x40] + PaintableBox (Box) [10,10 23.90625x19] + PaintableWithLines (BlockContainer) [10,31 23.90625x19] + PaintableWithLines (BlockContainer
) [10,10 8.8125x19] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer(anonymous)) [20.8125,10 0x19] + PaintableWithLines (BlockContainer(anonymous)) [22.8125,10 11.09375x19] + PaintableBox (Box
) [10,31 10.8125x19] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer) [22.8125,31 11.09375x19] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer(anonymous)) [8,52 784x17] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/table/colspan-overflow-crash.html b/Tests/LibWeb/Layout/input/table/colspan-overflow-crash.html new file mode 100644 index 000000000000..33214b646a35 --- /dev/null +++ b/Tests/LibWeb/Layout/input/table/colspan-overflow-crash.html @@ -0,0 +1,10 @@ + + + + + + + + +
1
23
+PASS (didn't crash) diff --git a/Userland/Libraries/LibWeb/Layout/TableGrid.cpp b/Userland/Libraries/LibWeb/Layout/TableGrid.cpp index 0bbe57ba2997..d73c293ea750 100644 --- a/Userland/Libraries/LibWeb/Layout/TableGrid.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableGrid.cpp @@ -43,7 +43,7 @@ TableGrid TableGrid::calculate_row_column_grid(Box const& box, Vector& cel rowspan = node.row_span(); } - if (x_width < x_current + colspan && y_current == 0) + if (x_width < x_current + colspan) x_width = x_current + colspan; if (y_height < y_current + rowspan) y_height = y_current + rowspan;