From f0917ea150fa1e75dd6910f8ec41e32b508942ea Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 18 Mar 2025 15:08:05 +0000 Subject: [PATCH] LibWeb: Ensure shortest serialization is used for `grid-column` values --- .../LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp | 2 +- .../css/css-grid/parsing/grid-area-valid.txt | 6 +++--- .../parsing/grid-column-shortest-serialization.txt | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp index 0640f1e2704..7404336b8c4 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp @@ -330,7 +330,7 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const case PropertyID::GridColumn: { auto start = longhand(PropertyID::GridColumnStart); auto end = longhand(PropertyID::GridColumnEnd); - if (end->as_grid_track_placement().grid_track_placement().is_auto()) + if (end->as_grid_track_placement().grid_track_placement().is_auto() || start == end) return start->to_string(mode); return MUST(String::formatted("{} / {}", start->to_string(mode), end->to_string(mode))); } diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-valid.txt index 997e8a8f1c6..ef2b5ae2a44 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-valid.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-valid.txt @@ -2,8 +2,8 @@ Harness status: OK Found 57 tests -18 Pass -39 Fail +19 Pass +38 Fail Fail e.style['grid-area'] = "auto" should set the property value Fail e.style['grid-area'] = "auto / auto" should set the property value Fail e.style['grid-area'] = "auto / auto / auto" should set the property value @@ -23,7 +23,7 @@ Fail e.style['grid-area'] = "1" should set the property value Fail e.style['grid-area'] = "+90 -a-" should set the property value Pass e.style['grid-row'] = "az 2" should set the property value Pass e.style['grid-column'] = "9" should set the property value -Fail e.style['grid-column'] = "-19 zA" should set the property value +Pass e.style['grid-column'] = "-19 zA" should set the property value Fail e.style['grid-column'] = "-A0 33" should set the property value Pass e.style['grid-row-start'] = "-19" should set the property value Fail e.style['grid-row-start'] = "9 -Z_" should set the property value diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-column-shortest-serialization.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-column-shortest-serialization.txt index 6f53df75fcf..995e97f5880 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-column-shortest-serialization.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-column-shortest-serialization.txt @@ -2,20 +2,20 @@ Harness status: OK Found 16 tests -8 Pass -8 Fail +12 Pass +4 Fail Pass Property grid-column value 'auto / auto' Pass Property grid-column value 'auto' Pass Property grid-column value '10 / auto' Pass Property grid-column value '10' Pass Property grid-column value '-10 / auto' Pass Property grid-column value '-10' -Fail Property grid-column value 'first / first' -Fail Property grid-column value 'first' +Pass Property grid-column value 'first / first' +Pass Property grid-column value 'first' Pass Property grid-column value 'span 2 / auto' Pass Property grid-column value 'span 2' -Fail Property grid-column value '2 first / auto' -Fail Property grid-column value '2 first' +Pass Property grid-column value '2 first / auto' +Pass Property grid-column value '2 first' Fail Property grid-column value 'span first / auto' Fail Property grid-column value 'span first' Fail Property grid-column value 'span 2 first / auto'