LibWeb/CSS: Support nested shorthands in CSSStyleDeclaration

Without this, getting a property's value from `element.style.foo` would
fail if `foo` is a shorthand property which has a longhand that is also
a shorthand. For example, `border` expands to `border-width` which
expands to `border-top-width`.

This is because we used `property()` to get a longhand's value, but this
returns nothing if the property is a shorthand.

This commit solves that by moving most of get_property_value() into a
separate method that returns a StyleProperty instead of a String, and
which calls itself recursively for shorthands. Also move the manual
shorthand construction out of ResolvedCSSStyleDeclaration so that all
CSSStyleDeclarations can use it.
This commit is contained in:
Sam Atkins
2025-02-06 11:10:36 +00:00
parent 006c8ba2d4
commit 412b758107
Notes: github-actions[bot] 2025-02-12 16:02:13 +00:00
7 changed files with 237 additions and 207 deletions

View File

@@ -2,7 +2,8 @@ Harness status: OK
Found 3 tests
3 Fail
Fail Declaration with border longhands is not serialized to a border shorthand declaration.
Fail Declaration with border longhands and border-image is not serialized to a border shorthand declaration.
2 Pass
1 Fail
Pass Declaration with border longhands is not serialized to a border shorthand declaration.
Pass Declaration with border longhands and border-image is not serialized to a border shorthand declaration.
Fail Border shorthand is serialized correctly if all border-image-* are set to their initial specified values.