From 5331571fdc598f7c2233c6a247b79b3c07af43e1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 26 Feb 2025 12:23:05 +0100 Subject: [PATCH] LibWeb: Handle interleaved table-row and table-row-group boxes Before this change, we were always processing all row groups first, and then all rows. This led to incorrect table layouts when rows and row groups were encountered in anything but that order. --- Libraries/LibWeb/Layout/TableGrid.cpp | 13 +++-- .../tables/table-anonymous-objects-059.xht | 55 +++++++++++++++++++ .../tables/table-anonymous-objects-060.xht | 55 +++++++++++++++++++ 3 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-059.xht create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-060.xht diff --git a/Libraries/LibWeb/Layout/TableGrid.cpp b/Libraries/LibWeb/Layout/TableGrid.cpp index d73c293ea75..bf548218fe9 100644 --- a/Libraries/LibWeb/Layout/TableGrid.cpp +++ b/Libraries/LibWeb/Layout/TableGrid.cpp @@ -75,15 +75,18 @@ TableGrid TableGrid::calculate_row_column_grid(Box const& box, Vector& cel process_col_group(column_group_box); }); - for_each_child_box_matching(box, is_table_row_group, [&](auto& row_group_box) { - for_each_child_box_matching(row_group_box, is_table_row, [&](auto& row_box) { + auto process_row_group = [&](auto& row_group) { + for_each_child_box_matching(row_group, is_table_row, [&](auto& row_box) { process_row(row_box); return IterationDecision::Continue; }); - }); + }; - for_each_child_box_matching(box, is_table_row, [&](auto& row_box) { - process_row(row_box); + box.for_each_child_of_type([&](auto& child) { + if (is_table_row_group(child)) + process_row_group(child); + else if (is_table_row(child)) + process_row(child); return IterationDecision::Continue; }); diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-059.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-059.xht new file mode 100644 index 00000000000..c7247f53cb8 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-059.xht @@ -0,0 +1,55 @@ + + + + + CSS Test: Auto-imported from Gecko test infer-first-row.html + + + + + +

There should be no red below, except for antialiasing issues.

+
+
+ + + Row 1, Col 1 + Row 1, Col 2 + Row 1, Col 3 + + + Row 22, Col 1 + Row 22, Col 2 + Row 22, Col 3 + + + Row 333, Col 1 + Row 333, Col 2 + Row 333, Col 3 + + + +
+
+ + + + + + + + + + + + + + + + + +
Row 1, Col 1Row 1, Col 2Row 1, Col 3
Row 22, Col 1Row 22, Col 2Row 22, Col 3
Row 333, Col 1Row 333, Col 2Row 333, Col 3
+
+
+ + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-060.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-060.xht new file mode 100644 index 00000000000..fa5695fca70 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/tables/table-anonymous-objects-060.xht @@ -0,0 +1,55 @@ + + + + + CSS Test: Auto-imported from Gecko test infer-first-row.html + + + + + +

There should be no red below, except for antialiasing issues.

+
+
+ + + Row 1, Col 1 + Row 1, Col 2 + Row 1, Col 3 + + + Row 22, Col 1 + Row 22, Col 2 + Row 22, Col 3 + + + Row 333, Col 1 + Row 333, Col 2 + Row 333, Col 3 + + + +
+
+ + + + + + + + + + + + + + + + + +
Row 1, Col 1Row 1, Col 2Row 1, Col 3
Row 22, Col 1Row 22, Col 2Row 22, Col 3
Row 333, Col 1Row 333, Col 2Row 333, Col 3
+
+
+ +