From 5676e181941412082b84252d2c36685e5cc20198 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 10 Aug 2026 00:33:35 +0100 Subject: [PATCH] LibWeb: Propagate `vertical-align` to anonymous table wrapper boxes Previously, a table's computed `vertical-align` value remained on the table box, where it had no effect. Inline tables were therefore always baseline aligned. The value is now moved to the anonymous table wrapper box, which participates in inline layout in place of the table box. --- Libraries/LibWeb/Layout/Node.cpp | 4 ++ .../borders/border-bottom-applies-to-014.xht | 45 ++++++++++++++++++ .../border-bottom-color-applies-to-014.xht | 47 +++++++++++++++++++ .../borders/border-top-applies-to-014.xht | 45 ++++++++++++++++++ .../border-top-color-applies-to-014.xht | 47 +++++++++++++++++++ 5 files changed, 188 insertions(+) create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-applies-to-014.xht create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-color-applies-to-014.xht create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-applies-to-014.xht create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-color-applies-to-014.xht diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index b76f23bf37ded..0718c53198c83 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -1094,6 +1094,7 @@ void NodeWithStyle::reset_table_box_computed_values_used_by_wrapper_to_init_valu // Note that there may be more properties that need to be added to this list. values.set_z_index(CSS::InitialValues::z_index()); values.set_clip(CSS::InitialValues::clip()); + values.set_vertical_align(CSS::InitialValues::vertical_align()); }); } @@ -1125,6 +1126,9 @@ void NodeWithStyle::transfer_table_box_computed_values_to_wrapper_computed_value builder->set_z_index(computed_values().z_index()); // "clip" only takes effect on absolutely-positioned elements; the table box isn't one — the wrapper is. builder->set_clip(computed_values().clip()); + // AD-HOC: The wrapper box participates in inline layout in place of the table box, so vertical-align + // must be moved to the wrapper to have any effect. + builder->set_vertical_align(computed_values().vertical_align()); reset_table_box_computed_values_used_by_wrapper_to_init_values(); } diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-applies-to-014.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-applies-to-014.xht new file mode 100644 index 0000000000000..544138be3fccd --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-applies-to-014.xht @@ -0,0 +1,45 @@ + + + + CSS Test: Border-bottom applied to element with 'display' set to 'inline-table' + + + + + + + + + + +

Test passes if there is a short horizontal green line.

+ +
+
+
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-color-applies-to-014.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-color-applies-to-014.xht new file mode 100644 index 0000000000000..dedd30863d520 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-bottom-color-applies-to-014.xht @@ -0,0 +1,47 @@ + + + + CSS Test: Border-bottom-color applied to element with display inline-table + + + + + + + + + + +

Test passes if there is a short horizontal green line.

+ +
+
+
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-applies-to-014.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-applies-to-014.xht new file mode 100644 index 0000000000000..2f9e4f72404be --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-applies-to-014.xht @@ -0,0 +1,45 @@ + + + + CSS Test: Border-top applied to element with display inline-table + + + + + + + + + + +

Test passes if there is a short horizontal green line.

+ +
+
+
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-color-applies-to-014.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-color-applies-to-014.xht new file mode 100644 index 0000000000000..13773a9c39b77 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/borders/border-top-color-applies-to-014.xht @@ -0,0 +1,47 @@ + + + + CSS Test: Border-top-color applied to element with display inline-table + + + + + + + + + + +

Test passes if there is a short horizontal green line.

+ +
+
+
+
+ +
+
+
+
+ + + \ No newline at end of file