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 12 tests
8 Pass
4 Fail
9 Pass
3 Fail
Pass Property flex-basis value '1px'
Pass Property flex-basis value '400%'
Pass Property flex-basis value 'auto'
@@ -13,6 +13,6 @@ Pass Property flex-basis value 'min-content'
Pass Property flex-basis value 'max-content'
Fail Property flex-basis value 'calc(10px + 0.5em)'
Fail Property flex-basis value 'calc(10px - 0.5em)'
Fail Property flex-basis value 'calc(10%)'
Pass Property flex-basis value 'calc(10%)'
Pass Property flex-basis value 'calc(0% + 10px)'
Fail Property flex-basis value 'calc(10% + 0px)'