diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 5f506ef495..c5a8bd51b4 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -2008,25 +2008,28 @@ Optional Parser::parse_a_component_value(TokenStream return {}; } -Vector Parser::parse_as_list_of_component_values() -{ - return parse_a_list_of_component_values(m_token_stream); -} - +// 5.3.10. Parse a list of component values +// https://www.w3.org/TR/css-syntax-3/#parse-list-of-component-values template Vector Parser::parse_a_list_of_component_values(TokenStream& tokens) { - Vector rules; + // To parse a list of component values from input: + + // 1. Normalize input, and set input to the result. + // Note: This is done when initializing the Parser. + + // 2. Repeatedly consume a component value from input until an is returned, appending the returned values (except the final ) into a list. Return the list. + Vector component_values; for (;;) { if (tokens.peek_token().is(Token::Type::EndOfFile)) { break; } - rules.append(consume_a_component_value(tokens)); + component_values.append(consume_a_component_value(tokens)); } - return rules; + return component_values; } Vector> Parser::parse_as_comma_separated_list_of_component_values() @@ -4322,7 +4325,7 @@ RefPtr Parser::parse_transform_origin_value(Vector Parser::parse_as_css_value(PropertyID property_id) { - auto component_values = parse_as_list_of_component_values(); + auto component_values = parse_a_list_of_component_values(m_token_stream); auto tokens = TokenStream(component_values); auto parsed_value = parse_css_value(property_id, tokens); if (parsed_value.is_error()) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 66c178f9b3..116f3d24d7 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -89,8 +89,6 @@ public: Parser(ParsingContext const&, StringView input, String const& encoding = "utf-8"); ~Parser() = default; - // For the contents of presentational attributes, which parse text into a single declaration’s value, or for parsing a stand-alone selector [SELECT] or list of Media Queries [MEDIAQ], as in Selectors API or the media HTML attribute. - Vector parse_as_list_of_component_values(); Vector> parse_as_comma_separated_list_of_component_values(); NonnullRefPtr parse_as_css_stylesheet(Optional location); @@ -152,8 +150,11 @@ private: // "Parse a component value" is for things that need to consume a single value, like the parsing rules for attr(). template Optional parse_a_component_value(TokenStream&); + + // "Parse a list of component values" is for the contents of presentational attributes, which parse text into a single declaration’s value, or for parsing a stand-alone selector [SELECT] or list of Media Queries [MEDIAQ], as in Selectors API or the media HTML attribute. template Vector parse_a_list_of_component_values(TokenStream&); + template Vector> parse_a_comma_separated_list_of_component_values(TokenStream&);