From 6811264b111545608618136a3132af4ea27a38d8 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 18 Mar 2025 15:03:35 +0000 Subject: [PATCH] LibWeb: Ensure shortest serialization is used for `grid-row` values --- .../LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp | 2 +- .../css/css-grid/parsing/grid-area-computed.txt | 6 +++--- .../css/css-grid/parsing/grid-area-valid.txt | 10 +++++----- .../parsing/grid-row-shortest-serialization.txt | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp index 90363c03366..0640f1e2704 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp @@ -337,7 +337,7 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const case PropertyID::GridRow: { auto start = longhand(PropertyID::GridRowStart); auto end = longhand(PropertyID::GridRowEnd); - 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-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-computed.txt index d6bb6d0ba8d..41438e56586 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-computed.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-area-computed.txt @@ -2,8 +2,8 @@ Harness status: OK Found 30 tests -12 Pass -18 Fail +13 Pass +17 Fail Fail Property grid-area value 'auto / auto / auto / auto' Pass Property grid-row value 'auto / auto' Pass Property grid-column-end value 'auto' @@ -12,7 +12,7 @@ Pass Property grid-row-start value 'AZ' Fail Property grid-column-start value '-_π' Pass Property grid-row-end value '_9' Fail Property grid-area value '1 / 90 -a- / auto / auto' -Fail Property grid-row value '2 az / auto' +Pass Property grid-row value '2 az / auto' Pass Property grid-column value '9 / -19 zA' Pass Property grid-row-start value '-19' Fail Property grid-row-start value '9 -Z_' 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 78aecb39938..997e8a8f1c6 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 -15 Pass -42 Fail +18 Pass +39 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 @@ -15,13 +15,13 @@ Pass e.style['grid-column-end'] = "AuTo" should set the property value Fail e.style['grid-area'] = "--a" should set the property value Fail e.style['grid-row'] = "-zπ" should set the property value Fail e.style['grid-row'] = "-zπ/-zπ" should set the property value -Fail e.style['grid-row'] = "i / i" should set the property value +Pass e.style['grid-row'] = "i / i" should set the property value Pass e.style['grid-row-start'] = "AZ" should set the property value Fail e.style['grid-column-start'] = "-_π" should set the property value Pass e.style['grid-row-end'] = "_9" should set the property value Fail e.style['grid-area'] = "1" should set the property value Fail e.style['grid-area'] = "+90 -a-" should set the property value -Fail e.style['grid-row'] = "az 2" 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 Fail e.style['grid-column'] = "-A0 33" should set the property value @@ -55,7 +55,7 @@ Fail e.style['grid-area'] = "auto / i / 2 j" should set the property value Fail e.style['grid-area'] = "auto / i / 2 j / span 3 k" should set the property value Pass e.style['grid-row'] = "auto / i" should set the property value Fail e.style['grid-row'] = "i / auto" should set the property value -Fail e.style['grid-row'] = "2 i / auto" should set the property value +Pass e.style['grid-row'] = "2 i / auto" should set the property value Pass e.style['grid-row'] = "1 / auto" should set the property value Fail e.style['grid-column'] = "2 j / span 3 k" should set the property value Fail e.style['grid-column-end'] = "\\31st" should set the property value diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-row-shortest-serialization.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-row-shortest-serialization.txt index 068179b6c19..e78a09c8569 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-row-shortest-serialization.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-row-shortest-serialization.txt @@ -2,8 +2,8 @@ Harness status: OK Found 15 tests -8 Pass -7 Fail +11 Pass +4 Fail Pass Property grid-row value 'auto / auto' Pass Property grid-row value 'auto' Pass Property grid-row value '10 / auto' @@ -12,10 +12,10 @@ Pass Property grid-row value '-10 / auto' Pass Property grid-row value '-10' Pass Property grid-row value 'span 2 / auto' Pass Property grid-row value 'span 2' -Fail Property grid-row value '3 last / auto' -Fail Property grid-row value '3 last' +Pass Property grid-row value '3 last / auto' +Pass Property grid-row value '3 last' Fail Property grid-row value 'span first / auto' Fail Property grid-row value 'span first' Fail Property grid-row value 'span 2 first / auto' Fail Property grid-row value 'span 2 first' -Fail Property grid-row value 'last / last' \ No newline at end of file +Pass Property grid-row value 'last / last' \ No newline at end of file