Skip to content

Commit 5d8b01a

Browse files
AtkinsSJawesomekling
authored andcommitted
LibWeb: Use new StyleValue parsing for border and its sided versions
1 parent 91c9d10 commit 5d8b01a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,31 +4719,35 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_border_value(Vector<ComponentValue> co
47194719
RefPtr<StyleValue> border_color;
47204720
RefPtr<StyleValue> border_style;
47214721

4722-
for (auto const& part : component_values) {
4723-
auto value = TRY(parse_css_value(part));
4724-
if (!value)
4722+
auto remaining_longhands = Vector { PropertyID::BorderWidth, PropertyID::BorderColor, PropertyID::BorderStyle };
4723+
4724+
auto tokens = TokenStream { component_values };
4725+
while (tokens.has_next_token()) {
4726+
auto property_and_value = TRY(parse_css_value_for_properties(remaining_longhands, tokens));
4727+
if (!property_and_value.style_value)
47254728
return nullptr;
4729+
auto& value = property_and_value.style_value;
4730+
remove_property(remaining_longhands, property_and_value.property);
47264731

4727-
if (property_accepts_value(PropertyID::BorderWidth, *value)) {
4728-
if (border_width)
4729-
return nullptr;
4732+
switch (property_and_value.property) {
4733+
case PropertyID::BorderWidth: {
4734+
VERIFY(!border_width);
47304735
border_width = value.release_nonnull();
47314736
continue;
47324737
}
4733-
if (property_accepts_value(PropertyID::BorderColor, *value)) {
4734-
if (border_color)
4735-
return nullptr;
4738+
case PropertyID::BorderColor: {
4739+
VERIFY(!border_color);
47364740
border_color = value.release_nonnull();
47374741
continue;
47384742
}
4739-
if (property_accepts_value(PropertyID::BorderStyle, *value)) {
4740-
if (border_style)
4741-
return nullptr;
4743+
case PropertyID::BorderStyle: {
4744+
VERIFY(!border_style);
47424745
border_style = value.release_nonnull();
47434746
continue;
47444747
}
4745-
4746-
return nullptr;
4748+
default:
4749+
VERIFY_NOT_REACHED();
4750+
}
47474751
}
47484752

47494753
if (!border_width)

0 commit comments

Comments
 (0)