From 0c39d07b4d9ad6c62952b0cfc83c1135977b1e60 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 29 Nov 2024 13:37:25 +0000 Subject: [PATCH] LibWeb/CSS: Serialize overflow correctly When the x and y values are the same, we only want to serialize one. This gets us 10 local WPT subtest passes. :^) --- .../LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp | 10 ++++++++-- ...all-supported-properties-and-default-values.txt | 2 +- .../css/cssom/overflow-serialization.txt | 14 +++++++------- .../wpt-import/css/cssom/serialize-values.txt | 14 +++++++------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp index ef3b1d37b82..2ae516cdfc7 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp @@ -183,8 +183,14 @@ String ShorthandStyleValue::to_string() const } case PropertyID::ListStyle: return MUST(String::formatted("{} {} {}", longhand(PropertyID::ListStylePosition)->to_string(), longhand(PropertyID::ListStyleImage)->to_string(), longhand(PropertyID::ListStyleType)->to_string())); - case PropertyID::Overflow: - return MUST(String::formatted("{} {}", longhand(PropertyID::OverflowX)->to_string(), longhand(PropertyID::OverflowY)->to_string())); + case PropertyID::Overflow: { + auto overflow_x = longhand(PropertyID::OverflowX); + auto overflow_y = longhand(PropertyID::OverflowY); + if (overflow_x == overflow_y) + return overflow_x->to_string(); + + return MUST(String::formatted("{} {}", overflow_x->to_string(), overflow_y->to_string())); + } case PropertyID::PlaceContent: { auto align_content = longhand(PropertyID::AlignContent)->to_string(); auto justify_content = longhand(PropertyID::JustifyContent)->to_string(); diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt index 37799f22d28..eec621fd3ae 100644 --- a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt +++ b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt @@ -443,7 +443,7 @@ All supported properties and their default values exposed from CSSStyleDeclarati 'outline-style': 'none' 'outlineWidth': 'medium' 'outline-width': 'medium' -'overflow': 'visible visible' +'overflow': 'visible' 'overflowX': 'visible' 'overflow-x': 'visible' 'overflowY': 'visible' diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/overflow-serialization.txt b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/overflow-serialization.txt index 7d72c40716c..a2cb0fed92e 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/overflow-serialization.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/overflow-serialization.txt @@ -6,16 +6,16 @@ Rerun Found 10 tests -2 Pass -8 Fail +7 Pass +3 Fail Details Result Test Name MessagePass Single value overflow with CSS-wide keyword should serialize correctly. -Fail Single value overflow with non-CSS-wide keyword should serialize correctly. +Pass Single value overflow with non-CSS-wide keyword should serialize correctly. Fail Overflow-x/y longhands with same CSS-wide keyword should serialize correctly. Fail Overflow-x/y longhands with same non-CSS-wide keyword should serialize correctly. Fail Overflow-x/y longhands with different keywords should serialize correctly. -Fail Single value overflow on element with CSS-wide keyword should serialize correctly. -Fail Single value overflow on element with non-CSS-wide keyword should serialize correctly. -Fail Overflow-x/y longhands on element with same CSS-wide keyword should serialize correctly. -Fail Overflow-x/y longhands on element with same non-CSS-wide keyword should serialize correctly. +Pass Single value overflow on element with CSS-wide keyword should serialize correctly. +Pass Single value overflow on element with non-CSS-wide keyword should serialize correctly. +Pass Overflow-x/y longhands on element with same CSS-wide keyword should serialize correctly. +Pass Overflow-x/y longhands on element with same non-CSS-wide keyword should serialize correctly. Pass Overflow-x/y longhands on element with different keywords should serialize correctly. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt index b6b0840e7ca..9ada2785f50 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt @@ -6,8 +6,8 @@ Rerun Found 687 tests -466 Pass -221 Fail +471 Pass +216 Fail Details Result Test Name MessagePass background-attachment: scroll Pass background-attachment: fixed @@ -561,11 +561,11 @@ Pass outline-width: 0px Pass outline-width: 1px Pass outline-width: .1em Pass outline-width: inherit -Fail overflow: visible -Fail overflow: hidden -Fail overflow: scroll -Fail overflow: auto -Fail overflow: inherit +Pass overflow: visible +Pass overflow: hidden +Pass overflow: scroll +Pass overflow: auto +Pass overflow: inherit Pass padding-top: 0px Pass padding-top: 1px Pass padding-top: .1em