From 64a44b719e6f9ff1691f37565abe9c058ec1e2e4 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 7 Dec 2023 15:16:51 +0000 Subject: [PATCH] LibWeb: Parse FilterValueListStyleValue using TokenStream --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 11 +++++++---- Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 47e58337788..ff3f915ac66 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -3635,12 +3635,14 @@ RefPtr Parser::parse_display_value(TokenStream& toke return nullptr; } -RefPtr Parser::parse_filter_value_list_value(Vector const& component_values) +RefPtr Parser::parse_filter_value_list_value(TokenStream& tokens) { - TokenStream tokens { component_values }; + auto transaction = tokens.begin_transaction(); - if (contains_single_none_ident(tokens)) + if (contains_single_none_ident(tokens)) { + transaction.commit(); return parse_identifier_value(tokens.next_token()); + } // FIXME: s are ignored for now // = [ | ]+ @@ -3810,6 +3812,7 @@ RefPtr Parser::parse_filter_value_list_value(Vector if (filter_value_list.is_empty()) return nullptr; + transaction.commit(); return FilterValueListStyleValue::create(move(filter_value_list)); } @@ -5737,7 +5740,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::BackdropFilter: - if (auto parsed_value = parse_filter_value_list_value(component_values)) + if (auto parsed_value = parse_filter_value_list_value(tokens); parsed_value && !tokens.has_next_token()) return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::Background: diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 207469a1653..27115b58b14 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -220,11 +220,12 @@ private: BackgroundPosition, }; RefPtr parse_position_value(TokenStream&, PositionParsingMode = PositionParsingMode::Normal); + RefPtr parse_filter_value_list_value(TokenStream&); + template RefPtr parse_comma_separated_value_list(TokenStream&, ParseFunction); RefPtr parse_simple_comma_separated_value_list(PropertyID, TokenStream&); - RefPtr parse_filter_value_list_value(Vector const&); RefPtr parse_aspect_ratio_value(TokenStream&); RefPtr parse_background_value(Vector const&); RefPtr parse_single_background_position_x_or_y_value(TokenStream&, PropertyID);