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
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

@ -61,6 +61,7 @@ protected:
private:
// ^PlatformObject
virtual Optional<JS::Value> item_value(size_t index) const override;
Optional<StyleProperty> get_property_internal(PropertyID) const;
};
class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration {