LibWeb/CSS: Implement calc-serialization spec algorithms

This gets us 37 new subtest passes in css/css-values, and 13 passes in
our other in-tree tests (and probably some random other ones!)

As noted in comments, a few parts of this algorithm have ad-hoc
behaviour to handle some issues in the spec.
This commit is contained in:
Sam Atkins 2025-02-26 14:08:20 +00:00 committed by Andreas Kling
commit a63879330f
Notes: github-actions[bot] 2025-02-27 20:43:46 +00:00
11 changed files with 412 additions and 54 deletions

View file

@ -11,8 +11,8 @@ computed: 10px 20%
inline: 10px top
computed: 10px 0%
inline: right 10px bottom 20%
computed: calc(100% + (0 - 10px)) 80%
computed: calc(100% - 10px) 80%
inline: center center, left bottom
computed: 50% 50%, 0% 100%
inline: left 10px bottom 20%, right 10px top 20%
computed: 10px 80%, calc(100% + (0 - 10px)) 20%
computed: 10px 80%, calc(100% - 10px) 20%

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 13 tests
12 Pass
1 Fail
13 Pass
Pass e.style['font-size'] = "xx-small" should set the property value
Pass e.style['font-size'] = "x-small" should set the property value
Pass e.style['font-size'] = "small" should set the property value
@ -16,4 +15,4 @@ Pass e.style['font-size'] = "larger" should set the property value
Pass e.style['font-size'] = "smaller" should set the property value
Pass e.style['font-size'] = "10px" should set the property value
Pass e.style['font-size'] = "20%" should set the property value
Fail e.style['font-size'] = "calc(30% - 40px)" should set the property value
Pass e.style['font-size'] = "calc(30% - 40px)" should set the property value

View file

@ -2,15 +2,14 @@ Harness status: OK
Found 10 tests
8 Pass
2 Fail
10 Pass
Pass e.style['height'] = "auto" should set the property value
Pass e.style['height'] = "min-content" should set the property value
Pass e.style['height'] = "max-content" should set the property value
Pass e.style['height'] = "0" should set the property value
Pass e.style['height'] = "10%" should set the property value
Pass e.style['height'] = "0.5em" should set the property value
Fail e.style['height'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['height'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['height'] = "fit-content(10%)" should set the property value
Pass e.style['height'] = "fit-content(0.5em)" should set the property value
Fail e.style['height'] = "fit-content(calc(10% - 0.5em))" should set the property value
Pass e.style['height'] = "fit-content(calc(10% - 0.5em))" should set the property value

View file

@ -2,15 +2,14 @@ Harness status: OK
Found 10 tests
8 Pass
2 Fail
10 Pass
Pass e.style['max-height'] = "none" should set the property value
Pass e.style['max-height'] = "min-content" should set the property value
Pass e.style['max-height'] = "max-content" should set the property value
Pass e.style['max-height'] = "0" should set the property value
Pass e.style['max-height'] = "10%" should set the property value
Pass e.style['max-height'] = "0.5em" should set the property value
Fail e.style['max-height'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['max-height'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['max-height'] = "fit-content(10%)" should set the property value
Pass e.style['max-height'] = "fit-content(0.5em)" should set the property value
Fail e.style['max-height'] = "fit-content(calc(10% - 0.5em))" should set the property value
Pass e.style['max-height'] = "fit-content(calc(10% - 0.5em))" should set the property value

View file

@ -2,15 +2,14 @@ Harness status: OK
Found 10 tests
8 Pass
2 Fail
10 Pass
Pass e.style['max-width'] = "none" should set the property value
Pass e.style['max-width'] = "min-content" should set the property value
Pass e.style['max-width'] = "max-content" should set the property value
Pass e.style['max-width'] = "0" should set the property value
Pass e.style['max-width'] = "10%" should set the property value
Pass e.style['max-width'] = "0.5em" should set the property value
Fail e.style['max-width'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['max-width'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['max-width'] = "fit-content(10%)" should set the property value
Pass e.style['max-width'] = "fit-content(0.5em)" should set the property value
Fail e.style['max-width'] = "fit-content(calc(10% - 0.5em))" should set the property value
Pass e.style['max-width'] = "fit-content(calc(10% - 0.5em))" should set the property value

View file

@ -2,15 +2,14 @@ Harness status: OK
Found 10 tests
8 Pass
2 Fail
10 Pass
Pass e.style['min-height'] = "auto" should set the property value
Pass e.style['min-height'] = "min-content" should set the property value
Pass e.style['min-height'] = "max-content" should set the property value
Pass e.style['min-height'] = "0" should set the property value
Pass e.style['min-height'] = "10%" should set the property value
Pass e.style['min-height'] = "0.5em" should set the property value
Fail e.style['min-height'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['min-height'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['min-height'] = "fit-content(10%)" should set the property value
Pass e.style['min-height'] = "fit-content(0.5em)" should set the property value
Fail e.style['min-height'] = "fit-content(calc(10% - 0.5em))" should set the property value
Pass e.style['min-height'] = "fit-content(calc(10% - 0.5em))" should set the property value

View file

@ -2,15 +2,14 @@ Harness status: OK
Found 10 tests
8 Pass
2 Fail
10 Pass
Pass e.style['min-width'] = "auto" should set the property value
Pass e.style['min-width'] = "min-content" should set the property value
Pass e.style['min-width'] = "max-content" should set the property value
Pass e.style['min-width'] = "0" should set the property value
Pass e.style['min-width'] = "10%" should set the property value
Pass e.style['min-width'] = "0.5em" should set the property value
Fail e.style['min-width'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['min-width'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['min-width'] = "fit-content(10%)" should set the property value
Pass e.style['min-width'] = "fit-content(0.5em)" should set the property value
Fail e.style['min-width'] = "fit-content(calc(10% - 0.5em))" should set the property value
Pass e.style['min-width'] = "fit-content(calc(10% - 0.5em))" should set the property value

View file

@ -2,15 +2,14 @@ Harness status: OK
Found 10 tests
8 Pass
2 Fail
10 Pass
Pass e.style['width'] = "auto" should set the property value
Pass e.style['width'] = "min-content" should set the property value
Pass e.style['width'] = "max-content" should set the property value
Pass e.style['width'] = "0" should set the property value
Pass e.style['width'] = "10%" should set the property value
Pass e.style['width'] = "0.5em" should set the property value
Fail e.style['width'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['width'] = "calc(10% - 0.5em)" should set the property value
Pass e.style['width'] = "fit-content(10%)" should set the property value
Pass e.style['width'] = "fit-content(0.5em)" should set the property value
Fail e.style['width'] = "fit-content(calc(10% - 0.5em))" should set the property value
Pass e.style['width'] = "fit-content(calc(10% - 0.5em))" should set the property value

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 24 tests
6 Pass
18 Fail
8 Pass
16 Fail
Fail testing calc(1vh + 2px + 3%)
Pass testing calc(4px + 1vh)
Fail testing calc(5px + 6em + 1vh)
@ -22,9 +22,9 @@ Fail testing calc(1vh - 7px)
Fail testing calc(5ex - 9ex)
Fail testing calc(-80px + 25.4mm)
Pass testing calc(2 * (10px + 1rem))
Fail testing calc(2 * (10px - 1rem))
Pass testing calc(2 * (10px - 1rem))
Pass testing calc((10px + 1rem) / 2)
Fail testing calc(2 * (min(10px, 20%) + max(1rem, 2%)))
Pass testing calc(2 * (min(10px, 20%) + max(1rem, 2%)))
Fail testing calc((min(10px, 20%) + max(1rem, 2%)) * 2)
Fail testing calc(1vmin - 14%)
Fail testing calc(4 * 3px + 4pc / 8)