mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-23 17:58:59 +00:00
LibWeb: Parse longhands of border
as ShorthandStyleValue
s
Previously we would instead parse these as single values and rely on ad-hoc functionality in `for_each_property_expanding_shorthands` to expand them to longhands. This gets us a step closer to removing that ad-hoc functionality.
This commit is contained in:
parent
17e5289524
commit
b1e77b3522
Notes:
github-actions[bot]
2025-09-09 09:47:11 +00:00
Author: https://github.com/Calme1709
Commit: b1e77b3522
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6136
Reviewed-by: https://github.com/gmta ✅
1 changed files with 10 additions and 3 deletions
|
@ -1552,6 +1552,13 @@ RefPtr<StyleValue const> Parser::parse_border_value(PropertyID property_id, Toke
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
auto const make_single_value_shorthand = [&](PropertyID property_id, Vector<PropertyID> const& longhands, ValueComparingNonnullRefPtr<StyleValue const> const& value) {
|
||||
Vector<ValueComparingNonnullRefPtr<StyleValue const>> longhand_values;
|
||||
longhand_values.resize_with_default_value(longhands.size(), value);
|
||||
|
||||
return ShorthandStyleValue::create(property_id, longhands, longhand_values);
|
||||
};
|
||||
|
||||
auto remaining_longhands = Vector { width_property, color_property, style_property };
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
|
@ -1564,13 +1571,13 @@ RefPtr<StyleValue const> Parser::parse_border_value(PropertyID property_id, Toke
|
|||
|
||||
if (property_and_value->property == width_property) {
|
||||
VERIFY(!border_width);
|
||||
border_width = value.release_nonnull();
|
||||
border_width = make_single_value_shorthand(width_property, longhands_for_shorthand(width_property), value.release_nonnull());
|
||||
} else if (property_and_value->property == color_property) {
|
||||
VERIFY(!border_color);
|
||||
border_color = value.release_nonnull();
|
||||
border_color = make_single_value_shorthand(color_property, longhands_for_shorthand(color_property), value.release_nonnull());
|
||||
} else if (property_and_value->property == style_property) {
|
||||
VERIFY(!border_style);
|
||||
border_style = value.release_nonnull();
|
||||
border_style = make_single_value_shorthand(style_property, longhands_for_shorthand(style_property), value.release_nonnull());
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue