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 <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-01-21 06:34:05 -08:00 committed by GitHub
parent c17668bb0e
commit acfd2e6de4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 179 additions and 33 deletions

View file

@ -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);
}