summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-05-18 17:10:09 +0100
committerAndreas Kling <kling@serenityos.org>2023-05-25 06:36:10 +0200
commit100adffdfb1692bd8f1a4fa31b784649f367efff (patch)
tree9c5485171303ce9a891a76f85e98e0ad672763a8 /Userland/Libraries
parent5d8b01ad04f1a60f730402bdbb72834eba63f646 (diff)
downloadserenity-100adffdfb1692bd8f1a4fa31b784649f367efff.zip
LibWeb: Use new StyleValue parsing for flex-flow
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 235601c6d8..d941406e52 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -5464,21 +5464,26 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_flow_value(Vector<ComponentValue>
RefPtr<StyleValue> flex_direction;
RefPtr<StyleValue> flex_wrap;
- for (auto const& part : component_values) {
- auto value = TRY(parse_css_value(part));
- if (!value)
+ auto remaining_longhands = Vector { PropertyID::FlexDirection, PropertyID::FlexWrap };
+ 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;
- if (property_accepts_value(PropertyID::FlexDirection, *value)) {
- if (flex_direction)
- return nullptr;
+ auto& value = property_and_value.style_value;
+ remove_property(remaining_longhands, property_and_value.property);
+
+ switch (property_and_value.property) {
+ case PropertyID::FlexDirection:
+ VERIFY(!flex_direction);
flex_direction = value.release_nonnull();
continue;
- }
- if (property_accepts_value(PropertyID::FlexWrap, *value)) {
- if (flex_wrap)
- return nullptr;
+ case PropertyID::FlexWrap:
+ VERIFY(!flex_wrap);
flex_wrap = value.release_nonnull();
continue;
+ default:
+ VERIFY_NOT_REACHED();
}
}