diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index a2f7bb0820d..0bb3df4bdce 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -84,6 +84,15 @@ static void log_parse_error(SourceLocation const& location = SourceLocation::cur namespace Web::CSS::Parser { +static bool contains_single_none_ident(TokenStream& tokens) +{ + if (tokens.remaining_token_count() > 1) + return false; + if (auto token = tokens.peek_token(); token.is_ident("none"sv)) + return true; + return false; +} + ErrorOr Parser::create(ParsingContext const& context, StringView input, StringView encoding) { auto tokens = TRY(Tokenizer::tokenize(input, encoding)); @@ -3300,11 +3309,8 @@ RefPtr Parser::parse_shadow_value(Vector const& comp TokenStream tokens { component_values }; // "none" - if (component_values.size() == 1 && component_values.first().is(Token::Type::Ident)) { - auto ident = parse_identifier_value(component_values.first()); - if (ident && ident->to_identifier() == ValueID::None) - return ident; - } + if (contains_single_none_ident(tokens)) + return parse_identifier_value(tokens.next_token()); return parse_comma_separated_value_list(tokens, [this, allow_inset_keyword](auto& tokens) { return parse_single_shadow_value(tokens, allow_inset_keyword); @@ -3604,14 +3610,11 @@ RefPtr Parser::parse_display_value(Vector const& com RefPtr Parser::parse_filter_value_list_value(Vector const& component_values) { - if (component_values.size() == 1 && component_values.first().is(Token::Type::Ident)) { - auto ident = parse_identifier_value(component_values.first()); - if (ident && ident->to_identifier() == ValueID::None) - return ident; - } - TokenStream tokens { component_values }; + if (contains_single_none_ident(tokens)) + return parse_identifier_value(tokens.next_token()); + // FIXME: s are ignored for now // = [ | ]+ @@ -5230,17 +5233,16 @@ Optional Parser::parse_track_sizing_function(ComponentVa RefPtr Parser::parse_grid_track_size_list(Vector const& component_values, bool allow_separate_line_name_blocks) { - if (component_values.size() == 1 && component_values.first().is(Token::Type::Ident)) { - auto ident = parse_identifier_value(component_values.first()); - if (ident && ident->to_identifier() == ValueID::None) { - return GridTrackSizeListStyleValue::make_none(); - } + TokenStream tokens { component_values }; + + if (contains_single_none_ident(tokens)) { + tokens.next_token(); + return GridTrackSizeListStyleValue::make_none(); } Vector track_list; Vector> line_names_list; auto last_object_was_line_names = false; - TokenStream tokens { component_values }; while (tokens.has_next_token()) { auto token = tokens.next_token(); if (token.is_block()) {