mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-27 01:50:24 +00:00
LibWeb: Parse list-style property using TokenStream
This commit is contained in:
parent
14e2e2bac4
commit
6e0a550a03
Notes:
sideshowbarker
2024-07-18 04:38:32 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/6e0a550a03 Pull-request: https://github.com/SerenityOS/serenity/pull/22439
2 changed files with 5 additions and 7 deletions
|
@ -4366,11 +4366,8 @@ Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>
|
|||
return supported_sources;
|
||||
}
|
||||
|
||||
RefPtr<StyleValue> Parser::parse_list_style_value(Vector<ComponentValue> const& component_values)
|
||||
RefPtr<StyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (component_values.size() > 3)
|
||||
return nullptr;
|
||||
|
||||
RefPtr<StyleValue> list_position;
|
||||
RefPtr<StyleValue> list_image;
|
||||
RefPtr<StyleValue> list_type;
|
||||
|
@ -4378,7 +4375,7 @@ RefPtr<StyleValue> Parser::parse_list_style_value(Vector<ComponentValue> const&
|
|||
|
||||
Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType };
|
||||
|
||||
auto tokens = TokenStream { component_values };
|
||||
auto transaction = tokens.begin_transaction();
|
||||
while (tokens.has_next_token()) {
|
||||
if (auto peek = tokens.peek_token(); peek.is_ident("none"sv)) {
|
||||
(void)tokens.next_token();
|
||||
|
@ -4440,6 +4437,7 @@ RefPtr<StyleValue> Parser::parse_list_style_value(Vector<ComponentValue> const&
|
|||
if (!list_type)
|
||||
list_type = property_initial_value(m_context.realm(), PropertyID::ListStyleType);
|
||||
|
||||
transaction.commit();
|
||||
return ShorthandStyleValue::create(PropertyID::ListStyle,
|
||||
{ PropertyID::ListStylePosition, PropertyID::ListStyleImage, PropertyID::ListStyleType },
|
||||
{ list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull() });
|
||||
|
@ -5905,7 +5903,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
|||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::ListStyle:
|
||||
if (auto parsed_value = parse_list_style_value(component_values))
|
||||
if (auto parsed_value = parse_list_style_value(tokens); parsed_value && !tokens.has_next_token())
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::MathDepth:
|
||||
|
|
|
@ -240,7 +240,7 @@ private:
|
|||
RefPtr<StyleValue> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_font_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_font_family_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_list_style_value(Vector<ComponentValue> const&);
|
||||
RefPtr<StyleValue> parse_list_style_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<StyleValue> parse_math_depth_value(Vector<ComponentValue> const&);
|
||||
RefPtr<StyleValue> parse_overflow_value(Vector<ComponentValue> const&);
|
||||
RefPtr<StyleValue> parse_place_content_value(Vector<ComponentValue> const&);
|
||||
|
|
Loading…
Reference in a new issue