summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-05-24 17:09:25 +0100
committerAndreas Kling <kling@serenityos.org>2023-05-25 06:36:10 +0200
commit2da15f987fe3931f8ba2af56a8e9d3d21fc8c0e2 (patch)
treedc4ecf34f51065bd7c528abc2342acc5c02bcf03 /Userland/Libraries
parent7386ed7cfb55774a34c747f5c6e2e3ddcba8ff6a (diff)
downloadserenity-2da15f987fe3931f8ba2af56a8e9d3d21fc8c0e2.zip
LibWeb: Use new StyleValue parsing for list-style
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 4d05cd5d85..ffcc604ec1 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -5910,34 +5910,41 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_list_style_value(Vector<ComponentValue
RefPtr<StyleValue> list_type;
int found_nones = 0;
- for (auto const& part : component_values) {
- auto value = TRY(parse_css_value(part));
- if (!value)
- return nullptr;
+ Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType };
- 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++;
continue;
}
- if (property_accepts_value(PropertyID::ListStylePosition, *value)) {
- if (list_position)
- return nullptr;
+ 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);
+
+ switch (property_and_value.property) {
+ case PropertyID::ListStylePosition: {
+ VERIFY(!list_position);
list_position = value.release_nonnull();
continue;
}
- if (property_accepts_value(PropertyID::ListStyleImage, *value)) {
- if (list_image)
- return nullptr;
+ case PropertyID::ListStyleImage: {
+ VERIFY(!list_image);
list_image = value.release_nonnull();
continue;
}
- if (property_accepts_value(PropertyID::ListStyleType, *value)) {
- if (list_type)
- return nullptr;
+ case PropertyID::ListStyleType: {
+ VERIFY(!list_type);
list_type = value.release_nonnull();
continue;
}
+ default:
+ VERIFY_NOT_REACHED();
+ }
}
if (found_nones > 2)