Skip to content

Commit 12c9da2

Browse files
Calme1709AtkinsSJ
authored andcommitted
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.
1 parent 7d81823 commit 12c9da2

File tree

7 files changed

+30
-27
lines changed

7 files changed

+30
-27
lines changed

Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
383383
auto& rows = longhand(PropertyID::GridTemplateRows)->as_grid_track_size_list();
384384
auto& columns = longhand(PropertyID::GridTemplateColumns)->as_grid_track_size_list();
385385

386+
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)
387+
return "none"_string;
388+
386389
auto construct_rows_string = [&]() {
387390
StringBuilder builder;
388391
size_t idx = 0;

Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ All supported properties and their default values exposed from CSSStylePropertie
383383
'fontWidth': 'normal'
384384
'font-width': 'normal'
385385
'gap': 'normal'
386-
'grid': ''
386+
'grid': 'none'
387387
'gridArea': 'auto'
388388
'grid-area': 'auto'
389389
'gridAutoColumns': 'auto'
@@ -410,8 +410,8 @@ All supported properties and their default values exposed from CSSStylePropertie
410410
'grid-row-gap': 'normal'
411411
'gridRowStart': 'auto'
412412
'grid-row-start': 'auto'
413-
'gridTemplate': ''
414-
'grid-template': ''
413+
'gridTemplate': 'none'
414+
'grid-template': 'none'
415415
'gridTemplateAreas': 'none'
416416
'grid-template-areas': 'none'
417417
'gridTemplateColumns': 'none'

Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-shorthand-invalid.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ Harness status: OK
22

33
Found 34 tests
44

5-
21 Pass
6-
13 Fail
5+
16 Pass
6+
18 Fail
77
Pass e.style['grid'] = "none none" should not set the property value
88
Pass e.style['grid'] = "none []" should not set the property value
99
Fail e.style['grid'] = "10px" should not set the property value
1010
Fail e.style['grid'] = "20%" should not set the property value
1111
Fail e.style['grid'] = "5fr" should not set the property value
12-
Pass e.style['grid'] = "[a]" should not set the property value
12+
Fail e.style['grid'] = "[a]" should not set the property value
1313
Fail e.style['grid'] = "[a] 10px" should not set the property value
1414
Fail e.style['grid'] = "[a] 10px []" should not set the property value
15-
Pass e.style['grid'] = "[]" should not set the property value
15+
Fail e.style['grid'] = "[]" should not set the property value
1616
Fail e.style['grid'] = "10px \"a\"" should not set the property value
1717
Fail e.style['grid'] = "[] 10px \"a\"" should not set the property value
1818
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
2828
Pass e.style['grid'] = "\"a\" \"a\" [a] [a]" should not set the property value
2929
Pass e.style['grid'] = "\"a\" [a] [a] / none" should not set the property value
3030
Pass e.style['grid'] = "\"a\" \"a\" [a] [a] / none" should not set the property value
31-
Pass e.style['grid'] = "none / \"a\"" should not set the property value
31+
Fail e.style['grid'] = "none / \"a\"" should not set the property value
3232
Pass e.style['grid'] = "\"a\" / none" should not set the property value
33-
Pass e.style['grid'] = "none / [] \"a\"" should not set the property value
33+
Fail e.style['grid'] = "none / [] \"a\"" should not set the property value
3434
Pass e.style['grid'] = "none / \"a\" []" should not set the property value
3535
Pass e.style['grid'] = "none / \"a\" [] 10px" should not set the property value
3636
Pass e.style['grid'] = "auto-flow 100px" should not set the property value
37-
Pass e.style['grid'] = "auto-flow / auto-flow" should not set the property value
37+
Fail e.style['grid'] = "auto-flow / auto-flow" should not set the property value
3838
Pass e.style['grid'] = "auto-flow 1fr / auto-flow 1fr" should not set the property value
3939
Pass e.style['grid'] = "dense auto-flow / dense auto-flow" should not set the property value
4040
Pass e.style['grid'] = "auto / auto-flow foo()" should not set the property value

Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-shorthand-valid.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Harness status: OK
22

33
Found 49 tests
44

5-
5 Pass
6-
44 Fail
7-
Fail e.style['grid'] = "none" should set the property value
8-
Fail e.style['grid'] = "none / none" should set the property value
5+
7 Pass
6+
42 Fail
7+
Pass e.style['grid'] = "none" should set the property value
8+
Pass e.style['grid'] = "none / none" should set the property value
99
Pass e.style['grid'] = "auto / auto" should set the property value
1010
Fail e.style['grid'] = "none / [a] 0px" should set the property value
1111
Fail e.style['grid'] = "none / [] 0px" should set the property value

Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-template-shorthand-invalid.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Harness status: OK
22

33
Found 66 tests
44

5-
19 Pass
6-
47 Fail
5+
15 Pass
6+
51 Fail
77
Fail e.style['grid-template'] = "auto" should not set the property value
88
Pass e.style['grid-template'] = "none none" should not set the property value
99
Pass e.style['grid-template'] = "none []" should not set the property value
1010
Fail e.style['grid-template'] = "10px" should not set the property value
1111
Fail e.style['grid-template'] = "20%" should not set the property value
1212
Fail e.style['grid-template'] = "5fr" should not set the property value
13-
Pass e.style['grid-template'] = "[a]" should not set the property value
13+
Fail e.style['grid-template'] = "[a]" should not set the property value
1414
Fail e.style['grid-template'] = "[a] 10px" should not set the property value
1515
Fail e.style['grid-template'] = "[a] repeat(2, 10px)" should not set the property value
1616
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
1919
Fail e.style['grid-template'] = "[a] repeat(2, 10px) []" should not set the property value
2020
Fail e.style['grid-template'] = "[a] repeat(auto-fill, 10px) []" should not set the property value
2121
Fail e.style['grid-template'] = "[a] repeat(auto-fit, 10px) []" should not set the property value
22-
Pass e.style['grid-template'] = "[]" should not set the property value
22+
Fail e.style['grid-template'] = "[]" should not set the property value
2323
Fail e.style['grid-template'] = "10px \"a\"" should not set the property value
2424
Fail e.style['grid-template'] = "repeat(2, 10px) \"a\"" should not set the property value
2525
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
6262
Pass e.style['grid-template'] = "\"a\" \"a\" [a] [a]" should not set the property value
6363
Pass e.style['grid-template'] = "\"a\" [a] [a] / none" should not set the property value
6464
Pass e.style['grid-template'] = "\"a\" \"a\" [a] [a] / none" should not set the property value
65-
Pass e.style['grid-template'] = "none / \"a\"" should not set the property value
65+
Fail e.style['grid-template'] = "none / \"a\"" should not set the property value
6666
Pass e.style['grid-template'] = "\"a\" / none" should not set the property value
67-
Pass e.style['grid-template'] = "none / [] \"a\"" should not set the property value
67+
Fail e.style['grid-template'] = "none / [] \"a\"" should not set the property value
6868
Pass e.style['grid-template'] = "none / \"a\" []" should not set the property value
6969
Pass e.style['grid-template'] = "none / \"a\" [] 10px" should not set the property value
7070
Pass e.style['grid-template'] = "none / \"a\" [] repeat(2, 10px)" should not set the property value

Tests/LibWeb/Text/expected/wpt-import/css/css-grid/parsing/grid-template-shorthand-valid.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Harness status: OK
22

33
Found 40 tests
44

5-
5 Pass
6-
35 Fail
7-
Fail e.style['grid-template'] = "none" should set the property value
8-
Fail e.style['grid-template'] = "none / none" should set the property value
5+
7 Pass
6+
33 Fail
7+
Pass e.style['grid-template'] = "none" should set the property value
8+
Pass e.style['grid-template'] = "none / none" should set the property value
99
Pass e.style['grid-template'] = "auto / auto" should set the property value
1010
Fail e.style['grid-template'] = "none / [a] 0px" should set the property value
1111
Fail e.style['grid-template'] = "none / [] 0px" should set the property value

Tests/LibWeb/Text/expected/wpt-import/css/cssom/cssom-getPropertyValue-common-checks.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Harness status: OK
22

33
Found 11 tests
44

5-
6 Pass
6-
5 Fail
5+
7 Pass
6+
4 Fail
77
Fail All properties can serialize 'initial'
8-
Fail All properties (except 'all') can serialize their initial value (computed)
8+
Pass All properties (except 'all') can serialize their initial value (computed)
99
Fail All properties (except 'all') can serialize their initial value (specified)
1010
Fail All shorthands can serialize their longhands set to 'initial'
1111
Fail All shorthands (except 'all') can serialize their longhands set to their initial value

0 commit comments

Comments
 (0)