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

@ -200,8 +200,8 @@ All supported properties and their default values exposed from CSSStyleDeclarati
'border-bottom-width': 'medium'
'borderCollapse': 'separate'
'border-collapse': 'separate'
'borderColor': 'rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0)'
'border-color': 'rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0)'
'borderColor': 'rgb(0, 0, 0)'
'border-color': 'rgb(0, 0, 0)'
'borderLeft': 'medium none rgb(0, 0, 0)'
'border-left': 'medium none rgb(0, 0, 0)'
'borderLeftColor': 'rgb(0, 0, 0)'
@ -222,8 +222,8 @@ All supported properties and their default values exposed from CSSStyleDeclarati
'border-right-width': 'medium'
'borderSpacing': '0px'
'border-spacing': '0px'
'borderStyle': 'none none none none'
'border-style': 'none none none none'
'borderStyle': 'none'
'border-style': 'none'
'borderTop': 'medium none rgb(0, 0, 0)'
'border-top': 'medium none rgb(0, 0, 0)'
'borderTopColor': 'rgb(0, 0, 0)'
@ -236,8 +236,8 @@ All supported properties and their default values exposed from CSSStyleDeclarati
'border-top-style': 'none'
'borderTopWidth': 'medium'
'border-top-width': 'medium'
'borderWidth': 'medium medium medium medium'
'border-width': 'medium medium medium medium'
'borderWidth': 'medium'
'border-width': 'medium'
'bottom': 'auto'
'boxShadow': 'none'
'box-shadow': 'none'
@ -407,7 +407,7 @@ All supported properties and their default values exposed from CSSStyleDeclarati
'list-style-position': 'outside'
'listStyleType': 'disc'
'list-style-type': 'disc'
'margin': '8px 8px 8px 8px'
'margin': '8px'
'marginBlock': '8px 8px 8px 8px'
'margin-block': '8px 8px 8px 8px'
'marginBlockEnd': '8px'
@ -477,7 +477,7 @@ All supported properties and their default values exposed from CSSStyleDeclarati
'overflow-x': 'visible'
'overflowY': 'visible'
'overflow-y': 'visible'
'padding': '0px 0px 0px 0px'
'padding': '0px'
'paddingBlock': '0px 0px 0px 0px'
'padding-block': '0px 0px 0px 0px'
'paddingBlockEnd': '0px'