소스 검색

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.
Sam Atkins 1 년 전
부모
커밋
cd9344d4c1
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

+ 6 - 6
Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

@@ -5652,18 +5652,18 @@ bool block_contains_var_or_attr(Block const& block)
     return false;
 }
 
-Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
+Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& unprocessed_tokens)
 {
     m_context.set_current_property_id(property_id);
     Vector<ComponentValue> 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<NonnullRefPtr<StyleValue>> 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<NonnullRefPtr<StyleValue>> 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;
     }