From 7d81823eb3d70ebddee21c26a1c43ec926ef2b16 Mon Sep 17 00:00:00 2001 From: Callum Law Date: Thu, 12 Jun 2025 19:50:51 +1200 Subject: [PATCH] LibWeb: Handle CSS-wide keywords in `style_property_for_sided_shorthand` CSS-wide keywords should not be concatenated in the same way as other values unless they are all the same. --- Libraries/LibWeb/CSS/CSSStyleProperties.cpp | 3 +++ .../css/cssom/cssom-getPropertyValue-common-checks.txt | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index 6ed81ab349a..9ce8552d405 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -479,6 +479,9 @@ static Optional style_property_for_sided_shorthand(PropertyID pro bool const top_and_bottom_same = top_value == bottom_value; bool const left_and_right_same = left_value == right_value; + if ((top_value->is_css_wide_keyword() || right_value->is_css_wide_keyword() || bottom_value->is_css_wide_keyword() || left_value->is_css_wide_keyword()) && (!top_and_bottom_same || !left_and_right_same || top_value != left_value)) + return {}; + RefPtr value; if (top_and_bottom_same && left_and_right_same && top_value == left_value) { diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-getPropertyValue-common-checks.txt b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-getPropertyValue-common-checks.txt index 3c4b53ef90b..c92763a34b9 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-getPropertyValue-common-checks.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-getPropertyValue-common-checks.txt @@ -2,8 +2,8 @@ Harness status: OK Found 11 tests -5 Pass -6 Fail +6 Pass +5 Fail Fail All properties can serialize 'initial' Fail All properties (except 'all') can serialize their initial value (computed) Fail All properties (except 'all') can serialize their initial value (specified) @@ -11,7 +11,7 @@ Fail All shorthands can serialize their longhands set to 'initial' Fail All shorthands (except 'all') can serialize their longhands set to their initial value Pass All aliases can serialize target property set to 'initial' Pass All aliases can serialize target property set to its initial value -Fail Can't serialize shorthand when longhands are set to different css-wide keywords +Pass Can't serialize shorthand when longhands are set to different css-wide keywords Pass Can't serialize shorthand when longhands have different priority Pass Can't serialize shorthand set to 'initial' when some longhand is missing Pass Can't serialize shorthand set to initial value when some longhand is missing \ No newline at end of file