1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:27:36 +00:00

LibWeb: Use new StyleValue parsing for list-style

This commit is contained in:
Sam Atkins 2023-05-24 17:09:25 +01:00 committed by Andreas Kling
parent 7386ed7cfb
commit 2da15f987f

View file

@ -5910,34 +5910,41 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_list_style_value(Vector<ComponentValue
RefPtr<StyleValue> list_type; RefPtr<StyleValue> list_type;
int found_nones = 0; int found_nones = 0;
for (auto const& part : component_values) { Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType };
auto value = TRY(parse_css_value(part));
if (!value)
return nullptr;
if (value->to_identifier() == ValueID::None) { auto tokens = TokenStream { component_values };
while (tokens.has_next_token()) {
if (auto peek = tokens.peek_token(); peek.is(Token::Type::Ident) && peek.token().ident().equals_ignoring_ascii_case("none"sv)) {
(void)tokens.next_token();
found_nones++; found_nones++;
continue; continue;
} }
if (property_accepts_value(PropertyID::ListStylePosition, *value)) { auto property_and_value = TRY(parse_css_value_for_properties(remaining_longhands, tokens));
if (list_position) if (!property_and_value.style_value)
return nullptr; return nullptr;
auto& value = property_and_value.style_value;
remove_property(remaining_longhands, property_and_value.property);
switch (property_and_value.property) {
case PropertyID::ListStylePosition: {
VERIFY(!list_position);
list_position = value.release_nonnull(); list_position = value.release_nonnull();
continue; continue;
} }
if (property_accepts_value(PropertyID::ListStyleImage, *value)) { case PropertyID::ListStyleImage: {
if (list_image) VERIFY(!list_image);
return nullptr;
list_image = value.release_nonnull(); list_image = value.release_nonnull();
continue; continue;
} }
if (property_accepts_value(PropertyID::ListStyleType, *value)) { case PropertyID::ListStyleType: {
if (list_type) VERIFY(!list_type);
return nullptr;
list_type = value.release_nonnull(); list_type = value.release_nonnull();
continue; continue;
} }
default:
VERIFY_NOT_REACHED();
}
} }
if (found_nones > 2) if (found_nones > 2)