LibWeb: Support border-{block,inline} shorthands

Gains us 4 WPT tests
This commit is contained in:
Callum Law 2025-07-09 20:47:34 +12:00 committed by Sam Atkins
commit da40419c5b
Notes: github-actions[bot] 2025-07-09 09:12:04 +00:00
5 changed files with 41 additions and 8 deletions

View file

@ -523,6 +523,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_css_value
return parsed_value.release_nonnull(); return parsed_value.release_nonnull();
return ParseError::SyntaxError; return ParseError::SyntaxError;
case PropertyID::Border: case PropertyID::Border:
case PropertyID::BorderBlock:
case PropertyID::BorderInline:
if (auto parsed_value = parse_border_value(property_id, tokens); parsed_value && !tokens.has_next_token()) if (auto parsed_value = parse_border_value(property_id, tokens); parsed_value && !tokens.has_next_token())
return parsed_value.release_nonnull(); return parsed_value.release_nonnull();
return ParseError::SyntaxError; return ParseError::SyntaxError;
@ -1597,6 +1599,17 @@ RefPtr<CSSStyleValue const> Parser::parse_border_value(PropertyID property_id, T
style_property = PropertyID::BorderStyle; style_property = PropertyID::BorderStyle;
width_property = PropertyID::BorderWidth; width_property = PropertyID::BorderWidth;
break; break;
case PropertyID::BorderBlock:
color_property = PropertyID::BorderBlockColor;
style_property = PropertyID::BorderBlockStyle;
width_property = PropertyID::BorderBlockWidth;
break;
case PropertyID::BorderInline:
color_property = PropertyID::BorderInlineColor;
style_property = PropertyID::BorderInlineStyle;
width_property = PropertyID::BorderInlineWidth;
break;
default: default:
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }

View file

@ -497,6 +497,15 @@
"border-color" "border-color"
] ]
}, },
"border-block": {
"inherited": false,
"initial": "medium currentcolor none",
"longhands": [
"border-block-width",
"border-block-style",
"border-block-color"
]
},
"border-block-color": { "border-block-color": {
"inherited": false, "inherited": false,
"initial": "currentcolor", "initial": "currentcolor",
@ -778,6 +787,15 @@
"auto" "auto"
] ]
}, },
"border-inline": {
"inherited": false,
"initial": "medium currentcolor none",
"longhands": [
"border-inline-width",
"border-inline-style",
"border-inline-color"
]
},
"border-inline-color": { "border-inline-color": {
"inherited": false, "inherited": false,
"initial": "currentcolor", "initial": "currentcolor",

View file

@ -201,6 +201,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'blockSize': '0px' 'blockSize': '0px'
'block-size': '0px' 'block-size': '0px'
'border': '0px rgb(0, 0, 0)' 'border': '0px rgb(0, 0, 0)'
'borderBlock': '0px rgb(0, 0, 0)'
'border-block': '0px rgb(0, 0, 0)'
'borderBlockColor': 'rgb(0, 0, 0)' 'borderBlockColor': 'rgb(0, 0, 0)'
'border-block-color': 'rgb(0, 0, 0)' 'border-block-color': 'rgb(0, 0, 0)'
'borderBlockEnd': '0px rgb(0, 0, 0)' 'borderBlockEnd': '0px rgb(0, 0, 0)'
@ -255,6 +257,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'border-image-source': 'none' 'border-image-source': 'none'
'borderImageWidth': '1' 'borderImageWidth': '1'
'border-image-width': '1' 'border-image-width': '1'
'borderInline': '0px rgb(0, 0, 0)'
'border-inline': '0px rgb(0, 0, 0)'
'borderInlineColor': 'rgb(0, 0, 0)' 'borderInlineColor': 'rgb(0, 0, 0)'
'border-inline-color': 'rgb(0, 0, 0)' 'border-inline-color': 'rgb(0, 0, 0)'
'borderInlineEnd': '0px rgb(0, 0, 0)' 'borderInlineEnd': '0px rgb(0, 0, 0)'

View file

@ -2,10 +2,9 @@ Harness status: OK
Found 6 tests Found 6 tests
4 Pass 6 Pass
2 Fail Pass e.style['border-block'] = "1px dotted red" should set the property value
Fail e.style['border-block'] = "1px dotted red" should set the property value Pass e.style['border-block'] = "double" should set the property value
Fail e.style['border-block'] = "double" should set the property value
Pass e.style['border-block-start'] = "green double thin" should set the property value Pass e.style['border-block-start'] = "green double thin" should set the property value
Pass e.style['border-block-start'] = "green" should set the property value Pass e.style['border-block-start'] = "green" should set the property value
Pass e.style['border-block-end'] = "thin" should set the property value Pass e.style['border-block-end'] = "thin" should set the property value

View file

@ -2,10 +2,9 @@ Harness status: OK
Found 6 tests Found 6 tests
4 Pass 6 Pass
2 Fail Pass e.style['border-inline'] = "1px dotted red" should set the property value
Fail e.style['border-inline'] = "1px dotted red" should set the property value Pass e.style['border-inline'] = "double" should set the property value
Fail e.style['border-inline'] = "double" should set the property value
Pass e.style['border-inline-start'] = "green double thin" should set the property value Pass e.style['border-inline-start'] = "green double thin" should set the property value
Pass e.style['border-inline-start'] = "green" should set the property value Pass e.style['border-inline-start'] = "green" should set the property value
Pass e.style['border-inline-end'] = "thin" should set the property value Pass e.style['border-inline-end'] = "thin" should set the property value