From 88da6250f958af8201c88be99443856f538b496f Mon Sep 17 00:00:00 2001
From: Ruben <96021831+rubenqwertyuiop@users.noreply.github.com>
Date: Wed, 4 Jun 2025 14:40:22 +0200
Subject: [PATCH] LibWeb: Use the correct definition of separated-borders mode
We previously checked the cell's computed values for the border-collapse
property, but a cell is only in separated-borders mode if the table has
border-collapse set to separate. Curiously in some other placed where
this mode is checked we already did the correct thing.
---
.../LibWeb/Layout/TableFormattingContext.cpp | 4 ++--
.../LibWeb/Painting/TableBordersPainting.cpp | 2 +-
.../table-collapse-ignored-in-cells-ref.html | 18 ++++++++++++++++++
.../input/table-collapse-ignored-in-cells.html | 18 ++++++++++++++++++
4 files changed, 39 insertions(+), 3 deletions(-)
create mode 100644 Tests/LibWeb/Ref/expected/table-collapse-ignored-in-cells-ref.html
create mode 100644 Tests/LibWeb/Ref/input/table-collapse-ignored-in-cells.html
diff --git a/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Libraries/LibWeb/Layout/TableFormattingContext.cpp
index 74a18425702..434832b323e 100644
--- a/Libraries/LibWeb/Layout/TableFormattingContext.cpp
+++ b/Libraries/LibWeb/Layout/TableFormattingContext.cpp
@@ -862,7 +862,7 @@ void TableFormattingContext::compute_table_height()
cell_state.padding_left = cell.box->computed_values().padding().left().to_px(cell.box, width_of_containing_block);
cell_state.padding_right = cell.box->computed_values().padding().right().to_px(cell.box, width_of_containing_block);
- if (cell.box->computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
+ if (table_box().computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
cell_state.border_top = cell.box->computed_values().border_top().width;
cell_state.border_bottom = cell.box->computed_values().border_bottom().width;
cell_state.border_left = cell.box->computed_values().border_left().width;
@@ -1286,7 +1286,7 @@ void TableFormattingContext::border_conflict_resolution()
.column_index = cell.column_index,
.row_span = cell.row_span,
.column_span = cell.column_span });
- if (cell.box->computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
+ if (table_box().computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
continue;
}
Painting::PaintableBox::BordersDataWithElementKind override_borders_data;
diff --git a/Libraries/LibWeb/Painting/TableBordersPainting.cpp b/Libraries/LibWeb/Painting/TableBordersPainting.cpp
index 6b8086812f0..564cf47179c 100644
--- a/Libraries/LibWeb/Painting/TableBordersPainting.cpp
+++ b/Libraries/LibWeb/Painting/TableBordersPainting.cpp
@@ -377,7 +377,7 @@ void paint_table_borders(PaintContext& context, PaintableBox const& table_painta
}
auto cell_coordinates_to_device_rect = snap_cells_to_device_coordinates(cell_coordinates_to_box, row_count, column_count, context);
for (auto const& cell_box : cell_boxes) {
- if (cell_box.computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
+ if (table_paintable.computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
paint_separate_cell_borders(cell_box, cell_coordinates_to_device_rect, context);
continue;
}
diff --git a/Tests/LibWeb/Ref/expected/table-collapse-ignored-in-cells-ref.html b/Tests/LibWeb/Ref/expected/table-collapse-ignored-in-cells-ref.html
new file mode 100644
index 00000000000..846902a9a42
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/table-collapse-ignored-in-cells-ref.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Ref/input/table-collapse-ignored-in-cells.html b/Tests/LibWeb/Ref/input/table-collapse-ignored-in-cells.html
new file mode 100644
index 00000000000..01b2e825959
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/table-collapse-ignored-in-cells.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+