mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibWeb: Use new StyleValue parsing for border and its sided versions
This commit is contained in:
parent
91c9d10a78
commit
5d8b01ad04
Notes:
sideshowbarker
2024-07-16 19:44:42 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/5d8b01ad04 Pull-request: https://github.com/SerenityOS/serenity/pull/19028
@ -4719,31 +4719,35 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_border_value(Vector<ComponentValue> co
|
|||||||
RefPtr<StyleValue> border_color;
|
RefPtr<StyleValue> border_color;
|
||||||
RefPtr<StyleValue> border_style;
|
RefPtr<StyleValue> border_style;
|
||||||
|
|
||||||
for (auto const& part : component_values) {
|
auto remaining_longhands = Vector { PropertyID::BorderWidth, PropertyID::BorderColor, PropertyID::BorderStyle };
|
||||||
auto value = TRY(parse_css_value(part));
|
|
||||||
if (!value)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (property_accepts_value(PropertyID::BorderWidth, *value)) {
|
auto tokens = TokenStream { component_values };
|
||||||
if (border_width)
|
while (tokens.has_next_token()) {
|
||||||
return nullptr;
|
auto property_and_value = TRY(parse_css_value_for_properties(remaining_longhands, tokens));
|
||||||
|
if (!property_and_value.style_value)
|
||||||
|
return nullptr;
|
||||||
|
auto& value = property_and_value.style_value;
|
||||||
|
remove_property(remaining_longhands, property_and_value.property);
|
||||||
|
|
||||||
|
switch (property_and_value.property) {
|
||||||
|
case PropertyID::BorderWidth: {
|
||||||
|
VERIFY(!border_width);
|
||||||
border_width = value.release_nonnull();
|
border_width = value.release_nonnull();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (property_accepts_value(PropertyID::BorderColor, *value)) {
|
case PropertyID::BorderColor: {
|
||||||
if (border_color)
|
VERIFY(!border_color);
|
||||||
return nullptr;
|
|
||||||
border_color = value.release_nonnull();
|
border_color = value.release_nonnull();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (property_accepts_value(PropertyID::BorderStyle, *value)) {
|
case PropertyID::BorderStyle: {
|
||||||
if (border_style)
|
VERIFY(!border_style);
|
||||||
return nullptr;
|
|
||||||
border_style = value.release_nonnull();
|
border_style = value.release_nonnull();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
return nullptr;
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!border_width)
|
if (!border_width)
|
||||||
|
Loading…
Reference in New Issue
Block a user