mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-23 08:30:50 +00:00
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.
46 lines
970 B
Text
46 lines
970 B
Text
Setting flex: 'none'; becomes...
|
|
flex-basis: 'auto'
|
|
flex-grow: '0'
|
|
flex-shrink: '0'
|
|
flex: '0 0 auto'
|
|
e.style.length: 3
|
|
> [0] flex-grow
|
|
> [1] flex-shrink
|
|
> [2] flex-basis
|
|
|
|
Setting flex: 'auto 1 2'; becomes...
|
|
flex-basis: 'auto'
|
|
flex-grow: '1'
|
|
flex-shrink: '2'
|
|
flex: '1 2 auto'
|
|
e.style.length: 3
|
|
> [0] flex-grow
|
|
> [1] flex-shrink
|
|
> [2] flex-basis
|
|
|
|
Setting flex: ''; becomes...
|
|
flex-basis: ''
|
|
flex-grow: ''
|
|
flex-shrink: ''
|
|
flex: ''
|
|
e.style.length: 0
|
|
|
|
Setting border: '1px solid red'; becomes...
|
|
border-width: '1px'
|
|
border-style: 'solid'
|
|
border-color: 'red'
|
|
border: '1px solid red'
|
|
e.style.length: 12
|
|
> [0] border-top-width
|
|
> [1] border-right-width
|
|
> [2] border-bottom-width
|
|
> [3] border-left-width
|
|
> [4] border-top-style
|
|
> [5] border-right-style
|
|
> [6] border-bottom-style
|
|
> [7] border-left-style
|
|
> [8] border-top-color
|
|
> [9] border-right-color
|
|
> [10] border-bottom-color
|
|
> [11] border-left-color
|
|
|