LibWeb: Parse grid track placements closer to spec

This brings parsing of grid-row-* and grid-column-* properties (and
their associated shorthands) more inline with spec.

Changes:
- Only set omitted properties for combined-value shorthands (e.g.
  `grid-row: a` rather than `grid-row: a / b`) if the single value is
  `<custom-ident>`.

- `[ [ <integer [-∞,-1]> | <integer [1,∞]> ] && <custom-ident>? ]`:
  - Properly resolve `calc`s for `<integer>` that rely on compute-time
    information.

- `[ span && [ <integer [1,∞]> || <custom-ident> ] ]`
  - Allow `calc`s for `<integer>`
  - Allow `<custom-ident>`

There is still work to be done to properly use these parsed values.

Gains us 46 WPT tests.
This commit is contained in:
Callum Law 2025-07-08 14:31:40 +12:00 committed by Tim Ledbetter
commit 36e2d25efa
Notes: github-actions[bot] 2025-07-08 16:27:31 +00:00
12 changed files with 153 additions and 171 deletions

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 33 tests
18 Pass
15 Fail
24 Pass
9 Fail
Pass Property grid-area value 'auto / auto / auto / auto'
Pass Property grid-row value 'auto / auto'
Pass Property grid-column-end value 'auto'
@ -22,18 +22,18 @@ Pass Property grid-column-end value '5 π_'
Fail Property grid-row-start value 'calc(1.1) -a-'
Fail Property grid-row-start value 'calc(10) -a-'
Fail Property grid-row-start value 'calc(10 + (sign(2cqw - 10px) * 5)) -a-'
Fail Property grid-area value 'span 2 i / auto / auto / auto'
Pass Property grid-area value 'span 2 i / auto / auto / auto'
Pass Property grid-row value 'span 2 / auto'
Fail Property grid-column-start value 'span 1 i'
Pass Property grid-column-start value 'span 1 i'
Pass Property grid-row-start value 'span 1'
Fail Property grid-row-end value 'span 2 i'
Pass Property grid-row-end value 'span 2 i'
Pass Property grid-column-end value 'span 2'
Fail Property grid-row-start value 'span i'
Fail Property grid-row value 'span i / auto'
Pass Property grid-row-start value 'span i'
Pass Property grid-row value 'span i / auto'
Fail Property grid-area value 'auto / i / auto / i'
Fail Property grid-area value 'auto / i / 2 j'
Fail Property grid-area value 'auto / i / 2 j / span 3 k'
Pass Property grid-row value 'auto / i'
Fail Property grid-column value '2 j / span 3 k'
Pass Property grid-column value '2 j / span 3 k'
Fail Property grid-column-end value '\31st'
Fail Property grid-column-end value '\31 st'

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 53 tests
46 Pass
7 Fail
48 Pass
5 Fail
Pass e.style['grid-area'] = "auto" should set grid-column-end
Pass e.style['grid-area'] = "auto" should set grid-column-start
Pass e.style['grid-area'] = "auto" should set grid-row-end
@ -54,6 +54,6 @@ Pass e.style['grid-column'] = "5 span" should not set unrelated longhands
Pass e.style['grid-column'] = "1 / two" should set grid-column-end
Pass e.style['grid-column'] = "1 / two" should set grid-column-start
Pass e.style['grid-column'] = "1 / two" should not set unrelated longhands
Fail e.style['grid-column'] = "span 1 two / four 3 span" should set grid-column-end
Fail e.style['grid-column'] = "span 1 two / four 3 span" should set grid-column-start
Pass e.style['grid-column'] = "span 1 two / four 3 span" should set grid-column-end
Pass e.style['grid-column'] = "span 1 two / four 3 span" should set grid-column-start
Pass e.style['grid-column'] = "span 1 two / four 3 span" should not set unrelated longhands

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 57 tests
30 Pass
27 Fail
40 Pass
17 Fail
Pass e.style['grid-area'] = "auto" should set the property value
Pass e.style['grid-area'] = "auto / auto" should set the property value
Pass e.style['grid-area'] = "auto / auto / auto" should set the property value
@ -19,7 +19,7 @@ Pass e.style['grid-row'] = "i / i" should set the property value
Pass e.style['grid-row-start'] = "AZ" should set the property value
Pass 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
Pass 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
@ -31,20 +31,20 @@ Pass e.style['grid-column-start'] = "+90" should set the property value
Pass e.style['grid-column-start'] = "Z -44" should set the property value
Pass e.style['grid-row-end'] = "1 -πA" should set the property value
Pass e.style['grid-column-end'] = "π_ +5" should set the property value
Fail e.style['grid-area'] = "span 2 i" should set the property value
Fail e.style['grid-area'] = "i 2 SpAn" should set the property value
Fail e.style['grid-area'] = "span 1 i" should set the property value
Pass e.style['grid-area'] = "span 2 i" should set the property value
Pass e.style['grid-area'] = "i 2 SpAn" should set the property value
Pass e.style['grid-area'] = "span 1 i" should set the property value
Pass e.style['grid-row'] = "span 2" should set the property value
Fail e.style['grid-column'] = "i SpAn" should set the property value
Fail e.style['grid-row-start'] = "span i" should set the property value
Fail e.style['grid-column-start'] = "SpAn i 2" should set the property value
Fail e.style['grid-row-end'] = "2 i span" should set the property value
Pass e.style['grid-column'] = "i SpAn" should set the property value
Pass e.style['grid-row-start'] = "span i" should set the property value
Pass e.style['grid-column-start'] = "SpAn i 2" should set the property value
Pass e.style['grid-row-end'] = "2 i span" should set the property value
Pass e.style['grid-column-end'] = "2 SpAn" should set the property value
Fail e.style['grid-area'] = "auto / i" should set the property value
Fail e.style['grid-area'] = "auto / i / auto / i" should set the property value
Fail e.style['grid-area'] = "auto / i / auto / 2 i" should set the property value
Fail e.style['grid-area'] = "1 / i / auto / i" should set the property value
Fail e.style['grid-area'] = "1 / auto / auto / auto" should set the property value
Pass e.style['grid-area'] = "1 / auto / auto / auto" should set the property value
Fail e.style['grid-area'] = "1 / auto / i / auto" should set the property value
Pass e.style['grid-area'] = "1 / j / i / k" should set the property value
Fail e.style['grid-area'] = "1 / auto / 2 / auto" should set the property value
@ -57,7 +57,7 @@ Pass e.style['grid-row'] = "auto / i" should set the property value
Fail e.style['grid-row'] = "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
Pass 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
Fail e.style['grid-column-end'] = "\\31 st" should set the property value
Fail e.style['grid-column'] = "\\31st / \\31 st" should set the property value

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 16 tests
12 Pass
4 Fail
16 Pass
Pass Property grid-column value 'auto / auto'
Pass Property grid-column value 'auto'
Pass Property grid-column value '10 / auto'
@ -16,7 +15,7 @@ Pass Property grid-column value 'span 2 / auto'
Pass Property grid-column value 'span 2'
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'
Fail Property grid-column value 'span 2 first'
Pass Property grid-column value 'span first / auto'
Pass Property grid-column value 'span first'
Pass Property grid-column value 'span 2 first / auto'
Pass Property grid-column value 'span 2 first'

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 48 tests
38 Pass
10 Fail
48 Pass
Pass e.style['grid-column'] = "auto / auto" should set grid-column-end
Pass e.style['grid-column'] = "auto / auto" should set grid-column-start
Pass e.style['grid-column'] = "auto / auto" should not set unrelated longhands
@ -31,20 +30,20 @@ Pass e.style['grid-column'] = "span 2" should not set unrelated longhands
Pass e.style['grid-column'] = "3 last / auto" should set grid-column-end
Pass e.style['grid-column'] = "3 last / auto" should set grid-column-start
Pass e.style['grid-column'] = "3 last / auto" should not set unrelated longhands
Fail e.style['grid-column'] = "3 last" should set grid-column-end
Pass e.style['grid-column'] = "3 last" should set grid-column-end
Pass e.style['grid-column'] = "3 last" should set grid-column-start
Pass e.style['grid-column'] = "3 last" should not set unrelated longhands
Fail e.style['grid-column'] = "span first / auto" should set grid-column-end
Fail e.style['grid-column'] = "span first / auto" should set grid-column-start
Fail e.style['grid-column'] = "span first / auto" should not set unrelated longhands
Fail e.style['grid-column'] = "span first" should set grid-column-end
Fail e.style['grid-column'] = "span first" should set grid-column-start
Fail e.style['grid-column'] = "span first" should not set unrelated longhands
Pass e.style['grid-column'] = "span first / auto" should set grid-column-end
Pass e.style['grid-column'] = "span first / auto" should set grid-column-start
Pass e.style['grid-column'] = "span first / auto" should not set unrelated longhands
Pass e.style['grid-column'] = "span first" should set grid-column-end
Pass e.style['grid-column'] = "span first" should set grid-column-start
Pass e.style['grid-column'] = "span first" should not set unrelated longhands
Pass e.style['grid-column'] = "span 2 first / auto" should set grid-column-end
Fail e.style['grid-column'] = "span 2 first / auto" should set grid-column-start
Pass e.style['grid-column'] = "span 2 first / auto" should set grid-column-start
Pass e.style['grid-column'] = "span 2 first / auto" should not set unrelated longhands
Fail e.style['grid-column'] = "span 2 first" should set grid-column-end
Fail e.style['grid-column'] = "span 2 first" should set grid-column-start
Pass e.style['grid-column'] = "span 2 first" should set grid-column-end
Pass e.style['grid-column'] = "span 2 first" should set grid-column-start
Pass e.style['grid-column'] = "span 2 first" should not set unrelated longhands
Pass e.style['grid-column'] = "last / last" should set grid-column-end
Pass e.style['grid-column'] = "last / last" should set grid-column-start

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 15 tests
11 Pass
4 Fail
15 Pass
Pass Property grid-row value 'auto / auto'
Pass Property grid-row value 'auto'
Pass Property grid-row value '10 / auto'
@ -14,8 +13,8 @@ Pass Property grid-row value 'span 2 / auto'
Pass Property grid-row value 'span 2'
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'
Pass Property grid-row value 'span first / auto'
Pass Property grid-row value 'span first'
Pass Property grid-row value 'span 2 first / auto'
Pass Property grid-row value 'span 2 first'
Pass Property grid-row value 'last / last'

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 48 tests
38 Pass
10 Fail
48 Pass
Pass e.style['grid-row'] = "auto / auto" should set grid-row-end
Pass e.style['grid-row'] = "auto / auto" should set grid-row-start
Pass e.style['grid-row'] = "auto / auto" should not set unrelated longhands
@ -31,20 +30,20 @@ Pass e.style['grid-row'] = "span 2" should not set unrelated longhands
Pass e.style['grid-row'] = "3 last / auto" should set grid-row-end
Pass e.style['grid-row'] = "3 last / auto" should set grid-row-start
Pass e.style['grid-row'] = "3 last / auto" should not set unrelated longhands
Fail e.style['grid-row'] = "3 last" should set grid-row-end
Pass e.style['grid-row'] = "3 last" should set grid-row-end
Pass e.style['grid-row'] = "3 last" should set grid-row-start
Pass e.style['grid-row'] = "3 last" should not set unrelated longhands
Fail e.style['grid-row'] = "span first / auto" should set grid-row-end
Fail e.style['grid-row'] = "span first / auto" should set grid-row-start
Fail e.style['grid-row'] = "span first / auto" should not set unrelated longhands
Fail e.style['grid-row'] = "span first" should set grid-row-end
Fail e.style['grid-row'] = "span first" should set grid-row-start
Fail e.style['grid-row'] = "span first" should not set unrelated longhands
Pass e.style['grid-row'] = "span first / auto" should set grid-row-end
Pass e.style['grid-row'] = "span first / auto" should set grid-row-start
Pass e.style['grid-row'] = "span first / auto" should not set unrelated longhands
Pass e.style['grid-row'] = "span first" should set grid-row-end
Pass e.style['grid-row'] = "span first" should set grid-row-start
Pass e.style['grid-row'] = "span first" should not set unrelated longhands
Pass e.style['grid-row'] = "span 2 first / auto" should set grid-row-end
Fail e.style['grid-row'] = "span 2 first / auto" should set grid-row-start
Pass e.style['grid-row'] = "span 2 first / auto" should set grid-row-start
Pass e.style['grid-row'] = "span 2 first / auto" should not set unrelated longhands
Fail e.style['grid-row'] = "span 2 first" should set grid-row-end
Fail e.style['grid-row'] = "span 2 first" should set grid-row-start
Pass e.style['grid-row'] = "span 2 first" should set grid-row-end
Pass e.style['grid-row'] = "span 2 first" should set grid-row-start
Pass e.style['grid-row'] = "span 2 first" should not set unrelated longhands
Pass e.style['grid-row'] = "last / last" should set grid-row-end
Pass e.style['grid-row'] = "last / last" should set grid-row-start