LibWeb/CSS: Simplify calculations after parsing them

If a calculation was simplified down to a single numeric node, then most
of the time we can instead return a regular StyleValue, for example
`calc(2px + 3px)` would be simplified down to a `5px` LengthStyleValue.
This means that parse_calculated_value() can't return a
CalculatedStyleValue directly, and its callers all have to handle
non-calculated values as well as calculated ones.

This simplification is reflected in the new test results. Serialization
is not yet correct in all cases but we're closer than we were. :^)
This commit is contained in:
Sam Atkins
2025-01-28 16:24:39 +00:00
committed by Andreas Kling
parent 39cefd7abf
commit ee712bd98f
Notes: github-actions[bot] 2025-01-30 18:32:52 +00:00
15 changed files with 295 additions and 228 deletions

View File

@@ -2,8 +2,8 @@ Harness status: OK
Found 126 tests
122 Pass
4 Fail
124 Pass
2 Fail
Pass new DOMMatrix()
Pass new DOMMatrix(undefined)
Pass new DOMMatrix(new DOMMatrix())
@@ -23,7 +23,7 @@ Pass new DOMMatrix(sequence) 6 elements
Pass new DOMMatrix("scale(2) translateX(5px) translateY(5px)")
Pass new DOMMatrix("scale(2, 2) translateX(5px) translateY(5px)")
Pass new DOMMatrix("scale(2)translateX(5px)translateY(5px)")
Fail new DOMMatrix("scale(2) translateX(calc(2 * 2.5px)) translateY(5px)")
Pass new DOMMatrix("scale(2) translateX(calc(2 * 2.5px)) translateY(5px)")
Pass new DOMMatrix("scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)")
Pass new DOMMatrix("translateX (5px)")
Pass new DOMMatrix("scale(2 2) translateX(5) translateY(5)")
@@ -86,7 +86,7 @@ Pass new DOMMatrixReadOnly(sequence) 6 elements
Pass new DOMMatrixReadOnly("scale(2) translateX(5px) translateY(5px)")
Pass new DOMMatrixReadOnly("scale(2, 2) translateX(5px) translateY(5px)")
Pass new DOMMatrixReadOnly("scale(2)translateX(5px)translateY(5px)")
Fail new DOMMatrixReadOnly("scale(2) translateX(calc(2 * 2.5px)) translateY(5px)")
Pass new DOMMatrixReadOnly("scale(2) translateX(calc(2 * 2.5px)) translateY(5px)")
Pass new DOMMatrixReadOnly("scale(2) translateX(5px) translateY(5px) rotate(5deg) rotate(-5deg)")
Pass new DOMMatrixReadOnly("translateX (5px)")
Pass new DOMMatrixReadOnly("scale(2 2) translateX(5) translateY(5)")