From acfd2e6de4055d7cf3b44c60350eef98b83f79d6 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Tue, 21 Jan 2025 06:34:05 -0800 Subject: [PATCH] layout: Fix conflict resolution for collapsed borders differing in color (#35100) https://www.w3.org/TR/CSS21/tables.html#border-conflict-resolution > If border styles differ only in color, then a style set on a cell wins > over one on a row, which wins over a row group, column, column group > and, lastly, table. We were actually using the opposite order. Signed-off-by: Oriol Brufau --- components/layout_2020/table/layout.rs | 62 ++++---- tests/wpt/meta/MANIFEST.json | 13 ++ .../subpixel-collapsed-borders-003.html.ini | 2 - .../borders/border-conflict-style-107.html | 135 ++++++++++++++++++ 4 files changed, 179 insertions(+), 33 deletions(-) delete mode 100644 tests/wpt/meta/css/css-tables/subpixel-collapsed-borders-003.html.ini create mode 100644 tests/wpt/tests/css/CSS2/borders/border-conflict-style-107.html diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index b0b0036922d..3cc94676e61 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -2130,37 +2130,8 @@ impl<'a> TableLayout<'a> { }; let all_rows = 0..self.table.size.height; let all_columns = 0..self.table.size.width; - apply_border(&self.table.layout_style_for_grid(), &all_rows, &all_columns); - for column_group in &self.table.column_groups { - apply_border( - &column_group.layout_style(), - &all_rows, - &column_group.track_range, - ); - } - for (column_index, column) in self.table.columns.iter().enumerate() { - apply_border( - &column.layout_style(), - &all_rows, - &(column_index..column_index + 1), - ); - } - for row_group in &self.table.row_groups { - apply_border( - &row_group.layout_style(), - &row_group.track_range, - &all_columns, - ); - } - for (row_index, row) in self.table.rows.iter().enumerate() { - apply_border( - &row.layout_style(), - &(row_index..row_index + 1), - &all_columns, - ); - } - for row_index in 0..self.table.size.height { - for column_index in 0..self.table.size.width { + for row_index in all_rows.clone() { + for column_index in all_columns.clone() { let cell = match self.table.slots[row_index][column_index] { TableSlot::Cell(ref cell) => cell, _ => continue, @@ -2173,6 +2144,35 @@ impl<'a> TableLayout<'a> { ); } } + for (row_index, row) in self.table.rows.iter().enumerate() { + apply_border( + &row.layout_style(), + &(row_index..row_index + 1), + &all_columns, + ); + } + for row_group in &self.table.row_groups { + apply_border( + &row_group.layout_style(), + &row_group.track_range, + &all_columns, + ); + } + for (column_index, column) in self.table.columns.iter().enumerate() { + apply_border( + &column.layout_style(), + &all_rows, + &(column_index..column_index + 1), + ); + } + for column_group in &self.table.column_groups { + apply_border( + &column_group.layout_style(), + &all_rows, + &column_group.track_range, + ); + } + apply_border(&self.table.layout_style_for_grid(), &all_rows, &all_columns); self.collapsed_borders = Some(collapsed_borders); } diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 59a503639f5..0c6174c1abb 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -45915,6 +45915,19 @@ {} ] ], + "border-conflict-style-107.html": [ + "8b1c72d2bc3af7c5a7feab1d44db10c3acca1ae7", + [ + null, + [ + [ + "/css/reference/ref-filled-green-200px-square.html", + "==" + ] + ], + {} + ] + ], "border-dynamic-001.xht": [ "dc73fecbfa648689495586e9baa02e7c3f480ca6", [ diff --git a/tests/wpt/meta/css/css-tables/subpixel-collapsed-borders-003.html.ini b/tests/wpt/meta/css/css-tables/subpixel-collapsed-borders-003.html.ini deleted file mode 100644 index cd3f1ae3a88..00000000000 --- a/tests/wpt/meta/css/css-tables/subpixel-collapsed-borders-003.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[subpixel-collapsed-borders-003.html] - expected: FAIL diff --git a/tests/wpt/tests/css/CSS2/borders/border-conflict-style-107.html b/tests/wpt/tests/css/CSS2/borders/border-conflict-style-107.html new file mode 100644 index 00000000000..8b1c72d2bc3 --- /dev/null +++ b/tests/wpt/tests/css/CSS2/borders/border-conflict-style-107.html @@ -0,0 +1,135 @@ + +CSS Test: border conflict resolution - border styles that differ only in color + + + + + + +

Test passes if there is a filled green square and no red.

+ + + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ +
+ + + + +
+ + + + + + + + +
+ + + + + + + +
+ + + + + + + +
+ +
+ + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + +
+ +
+ + + + + + + +
+ + + + + +
+ + + + + +
+ + + + +