diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-05-18 16:41:43 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-25 06:36:10 +0200 |
commit | 5d8b01ad04f1a60f730402bdbb72834eba63f646 (patch) | |
tree | 55a510fda6efad30a78f4426aa058af260098925 /Userland/Libraries/LibWeb | |
parent | 91c9d10a78d1f7b5d859d12b16bc95ae396c3d4c (diff) | |
download | serenity-5d8b01ad04f1a60f730402bdbb72834eba63f646.zip |
LibWeb: Use new StyleValue parsing for border and its sided versions
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 43da26250b..235601c6d8 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4719,31 +4719,35 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_border_value(Vector<ComponentValue> co RefPtr<StyleValue> border_color; RefPtr<StyleValue> border_style; - for (auto const& part : component_values) { - auto value = TRY(parse_css_value(part)); - if (!value) + auto remaining_longhands = Vector { PropertyID::BorderWidth, PropertyID::BorderColor, PropertyID::BorderStyle }; + + auto tokens = TokenStream { component_values }; + while (tokens.has_next_token()) { + 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); - if (property_accepts_value(PropertyID::BorderWidth, *value)) { - if (border_width) - return nullptr; + switch (property_and_value.property) { + case PropertyID::BorderWidth: { + VERIFY(!border_width); border_width = value.release_nonnull(); continue; } - if (property_accepts_value(PropertyID::BorderColor, *value)) { - if (border_color) - return nullptr; + case PropertyID::BorderColor: { + VERIFY(!border_color); border_color = value.release_nonnull(); continue; } - if (property_accepts_value(PropertyID::BorderStyle, *value)) { - if (border_style) - return nullptr; + case PropertyID::BorderStyle: { + VERIFY(!border_style); border_style = value.release_nonnull(); continue; } - - return nullptr; + default: + VERIFY_NOT_REACHED(); + } } if (!border_width) |