LibWeb: Serialize grid/grid-template as "none" when applicable

This exposes a bunch of false-positives in the
grid-{shorthand,template}-invalid.html WPT tests, but gains us some
new passes as well.
This commit is contained in:
Callum Law 2025-06-12 20:39:03 +12:00 committed by Sam Atkins
parent 7d81823eb3
commit 12c9da2d3f
Notes: github-actions[bot] 2025-06-16 11:38:44 +00:00
7 changed files with 30 additions and 27 deletions

View file

@ -383,6 +383,9 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
auto& rows = longhand(PropertyID::GridTemplateRows)->as_grid_track_size_list();
auto& columns = longhand(PropertyID::GridTemplateColumns)->as_grid_track_size_list();
if (areas.grid_template_area().size() == 0 && rows.grid_track_size_list().track_list().size() == 0 && columns.grid_track_size_list().track_list().size() == 0)
return "none"_string;
auto construct_rows_string = [&]() {
StringBuilder builder;
size_t idx = 0;

View file

@ -383,7 +383,7 @@ All supported properties and their default values exposed from CSSStylePropertie
'fontWidth': 'normal'
'font-width': 'normal'
'gap': 'normal'
'grid': ''
'grid': 'none'
'gridArea': 'auto'
'grid-area': 'auto'
'gridAutoColumns': 'auto'
@ -410,8 +410,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'grid-row-gap': 'normal'
'gridRowStart': 'auto'
'grid-row-start': 'auto'
'gridTemplate': ''
'grid-template': ''
'gridTemplate': 'none'
'grid-template': 'none'
'gridTemplateAreas': 'none'
'grid-template-areas': 'none'
'gridTemplateColumns': 'none'

View file

@ -2,17 +2,17 @@ Harness status: OK
Found 34 tests
21 Pass
13 Fail
16 Pass
18 Fail
Pass e.style['grid'] = "none none" should not set the property value
Pass e.style['grid'] = "none []" should not set the property value
Fail e.style['grid'] = "10px" should not set the property value
Fail e.style['grid'] = "20%" should not set the property value
Fail e.style['grid'] = "5fr" should not set the property value
Pass e.style['grid'] = "[a]" should not set the property value
Fail e.style['grid'] = "[a]" should not set the property value
Fail e.style['grid'] = "[a] 10px" should not set the property value
Fail e.style['grid'] = "[a] 10px []" should not set the property value
Pass e.style['grid'] = "[]" should not set the property value
Fail e.style['grid'] = "[]" should not set the property value
Fail e.style['grid'] = "10px \"a\"" should not set the property value
Fail e.style['grid'] = "[] 10px \"a\"" should not set the property value
Fail e.style['grid'] = "10px [] \"a\"" should not set the property value
@ -28,13 +28,13 @@ Pass e.style['grid'] = "[a] \"a\" [a] [a]" should not set the property value
Pass e.style['grid'] = "\"a\" \"a\" [a] [a]" should not set the property value
Pass e.style['grid'] = "\"a\" [a] [a] / none" should not set the property value
Pass e.style['grid'] = "\"a\" \"a\" [a] [a] / none" should not set the property value
Pass e.style['grid'] = "none / \"a\"" should not set the property value
Fail e.style['grid'] = "none / \"a\"" should not set the property value
Pass e.style['grid'] = "\"a\" / none" should not set the property value
Pass e.style['grid'] = "none / [] \"a\"" should not set the property value
Fail e.style['grid'] = "none / [] \"a\"" should not set the property value
Pass e.style['grid'] = "none / \"a\" []" should not set the property value
Pass e.style['grid'] = "none / \"a\" [] 10px" should not set the property value
Pass e.style['grid'] = "auto-flow 100px" should not set the property value
Pass e.style['grid'] = "auto-flow / auto-flow" should not set the property value
Fail e.style['grid'] = "auto-flow / auto-flow" should not set the property value
Pass e.style['grid'] = "auto-flow 1fr / auto-flow 1fr" should not set the property value
Pass e.style['grid'] = "dense auto-flow / dense auto-flow" should not set the property value
Pass e.style['grid'] = "auto / auto-flow foo()" should not set the property value

View file

@ -2,10 +2,10 @@ Harness status: OK
Found 49 tests
5 Pass
44 Fail
Fail e.style['grid'] = "none" should set the property value
Fail e.style['grid'] = "none / none" should set the property value
7 Pass
42 Fail
Pass e.style['grid'] = "none" should set the property value
Pass e.style['grid'] = "none / none" should set the property value
Pass e.style['grid'] = "auto / auto" should set the property value
Fail e.style['grid'] = "none / [a] 0px" should set the property value
Fail e.style['grid'] = "none / [] 0px" should set the property value

View file

@ -2,15 +2,15 @@ Harness status: OK
Found 66 tests
19 Pass
47 Fail
15 Pass
51 Fail
Fail e.style['grid-template'] = "auto" should not set the property value
Pass e.style['grid-template'] = "none none" should not set the property value
Pass e.style['grid-template'] = "none []" should not set the property value
Fail e.style['grid-template'] = "10px" should not set the property value
Fail e.style['grid-template'] = "20%" should not set the property value
Fail e.style['grid-template'] = "5fr" should not set the property value
Pass e.style['grid-template'] = "[a]" should not set the property value
Fail e.style['grid-template'] = "[a]" should not set the property value
Fail e.style['grid-template'] = "[a] 10px" should not set the property value
Fail e.style['grid-template'] = "[a] repeat(2, 10px)" should not set the property value
Fail e.style['grid-template'] = "[a] repeat(auto-fill, 10px)" should not set the property value
@ -19,7 +19,7 @@ Fail e.style['grid-template'] = "[a] 10px []" should not set the property value
Fail e.style['grid-template'] = "[a] repeat(2, 10px) []" should not set the property value
Fail e.style['grid-template'] = "[a] repeat(auto-fill, 10px) []" should not set the property value
Fail e.style['grid-template'] = "[a] repeat(auto-fit, 10px) []" should not set the property value
Pass e.style['grid-template'] = "[]" should not set the property value
Fail e.style['grid-template'] = "[]" should not set the property value
Fail e.style['grid-template'] = "10px \"a\"" should not set the property value
Fail e.style['grid-template'] = "repeat(2, 10px) \"a\"" should not set the property value
Fail e.style['grid-template'] = "repeat(auto-fill, 10px) \"a\"" should not set the property value
@ -62,9 +62,9 @@ Pass e.style['grid-template'] = "[a] \"a\" [a] [a]" should not set the property
Pass e.style['grid-template'] = "\"a\" \"a\" [a] [a]" should not set the property value
Pass e.style['grid-template'] = "\"a\" [a] [a] / none" should not set the property value
Pass e.style['grid-template'] = "\"a\" \"a\" [a] [a] / none" should not set the property value
Pass e.style['grid-template'] = "none / \"a\"" should not set the property value
Fail e.style['grid-template'] = "none / \"a\"" should not set the property value
Pass e.style['grid-template'] = "\"a\" / none" should not set the property value
Pass e.style['grid-template'] = "none / [] \"a\"" should not set the property value
Fail e.style['grid-template'] = "none / [] \"a\"" should not set the property value
Pass e.style['grid-template'] = "none / \"a\" []" should not set the property value
Pass e.style['grid-template'] = "none / \"a\" [] 10px" should not set the property value
Pass e.style['grid-template'] = "none / \"a\" [] repeat(2, 10px)" should not set the property value

View file

@ -2,10 +2,10 @@ Harness status: OK
Found 40 tests
5 Pass
35 Fail
Fail e.style['grid-template'] = "none" should set the property value
Fail e.style['grid-template'] = "none / none" should set the property value
7 Pass
33 Fail
Pass e.style['grid-template'] = "none" should set the property value
Pass e.style['grid-template'] = "none / none" should set the property value
Pass e.style['grid-template'] = "auto / auto" should set the property value
Fail e.style['grid-template'] = "none / [a] 0px" should set the property value
Fail e.style['grid-template'] = "none / [] 0px" should set the property value

View file

@ -2,10 +2,10 @@ Harness status: OK
Found 11 tests
6 Pass
5 Fail
7 Pass
4 Fail
Fail All properties can serialize 'initial'
Fail All properties (except 'all') can serialize their initial value (computed)
Pass All properties (except 'all') can serialize their initial value (computed)
Fail All properties (except 'all') can serialize their initial value (specified)
Fail All shorthands can serialize their longhands set to 'initial'
Fail All shorthands (except 'all') can serialize their longhands set to their initial value