1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 19:47:42 +00:00

LibWeb: Use new StyleValue parsing for flex-flow

This commit is contained in:
Sam Atkins 2023-05-18 17:10:09 +01:00 committed by Andreas Kling
parent 5d8b01ad04
commit 100adffdfb

View file

@ -5464,21 +5464,26 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_flow_value(Vector<ComponentValue>
RefPtr<StyleValue> flex_direction; RefPtr<StyleValue> flex_direction;
RefPtr<StyleValue> flex_wrap; RefPtr<StyleValue> flex_wrap;
for (auto const& part : component_values) { auto remaining_longhands = Vector { PropertyID::FlexDirection, PropertyID::FlexWrap };
auto value = TRY(parse_css_value(part)); auto tokens = TokenStream { component_values };
if (!value) 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; return nullptr;
if (property_accepts_value(PropertyID::FlexDirection, *value)) { auto& value = property_and_value.style_value;
if (flex_direction) remove_property(remaining_longhands, property_and_value.property);
return nullptr;
switch (property_and_value.property) {
case PropertyID::FlexDirection:
VERIFY(!flex_direction);
flex_direction = value.release_nonnull(); flex_direction = value.release_nonnull();
continue; continue;
} case PropertyID::FlexWrap:
if (property_accepts_value(PropertyID::FlexWrap, *value)) { VERIFY(!flex_wrap);
if (flex_wrap)
return nullptr;
flex_wrap = value.release_nonnull(); flex_wrap = value.release_nonnull();
continue; continue;
default:
VERIFY_NOT_REACHED();
} }
} }