From cd9344d4c11c63b1fa23a15be4a23b3fe2e27da4 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 7 Dec 2023 12:49:13 +0000 Subject: [PATCH] LibWeb: Clarify naming of TokenStreams in parse_css_value() Originally, the input was named `tokens`, and we later created a `tokens_without_whitespace` from the filtered contents of `tokens`. Since `tokens_without_whitespace` is what we actually want to use while parsing, let's rename `tokens` -> `unprocessed_tokens` and use the `tokens` name for the processed ones. --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index ceb732c18b..292f0feaef 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5652,18 +5652,18 @@ bool block_contains_var_or_attr(Block const& block) return false; } -Parser::ParseErrorOr> Parser::parse_css_value(PropertyID property_id, TokenStream& tokens) +Parser::ParseErrorOr> Parser::parse_css_value(PropertyID property_id, TokenStream& unprocessed_tokens) { m_context.set_current_property_id(property_id); Vector component_values; bool contains_var_or_attr = false; bool const property_accepts_custom_ident = property_accepts_type(property_id, ValueType::CustomIdent); - while (tokens.has_next_token()) { - auto const& token = tokens.next_token(); + while (unprocessed_tokens.has_next_token()) { + auto const& token = unprocessed_tokens.next_token(); if (token.is(Token::Type::Semicolon)) { - tokens.reconsume_current_input_token(); + unprocessed_tokens.reconsume_current_input_token(); break; } @@ -5697,6 +5697,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property } // Special-case property handling + auto tokens = TokenStream { component_values }; switch (property_id) { case PropertyID::AspectRatio: if (auto parsed_value = parse_aspect_ratio_value(component_values)) @@ -5778,8 +5779,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::FontFamily: { - auto tokens_without_whitespace = TokenStream { component_values }; - if (auto parsed_value = parse_font_family_value(tokens_without_whitespace)) + if (auto parsed_value = parse_font_family_value(tokens)) return parsed_value.release_nonnull(); return ParseError::SyntaxError; }