mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibWeb: Use new StyleValue parsing for list-style
This commit is contained in:
parent
7386ed7cfb
commit
2da15f987f
Notes:
sideshowbarker
2024-07-16 23:51:07 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/2da15f987f Pull-request: https://github.com/SerenityOS/serenity/pull/19028
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user