mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:12:43 +00:00 
			
		
		
		
	LibWeb: Spec-comment parse_a_list_of_component_values()
				
					
				
			This commit is contained in:
		
							parent
							
								
									34b3c09462
								
							
						
					
					
						commit
						6ec92f5527
					
				
					 2 changed files with 15 additions and 11 deletions
				
			
		|  | @ -2008,25 +2008,28 @@ Optional<StyleComponentValueRule> Parser::parse_a_component_value(TokenStream<T> | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| Vector<StyleComponentValueRule> 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<typename T> | ||||
| Vector<StyleComponentValueRule> Parser::parse_a_list_of_component_values(TokenStream<T>& tokens) | ||||
| { | ||||
|     Vector<StyleComponentValueRule> 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 <EOF-token> is returned, appending the returned values (except the final <EOF-token>) into a list. Return the list.
 | ||||
|     Vector<StyleComponentValueRule> 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<Vector<StyleComponentValueRule>> Parser::parse_as_comma_separated_list_of_component_values() | ||||
|  | @ -4322,7 +4325,7 @@ RefPtr<StyleValue> Parser::parse_transform_origin_value(Vector<StyleComponentVal | |||
| 
 | ||||
| RefPtr<StyleValue> 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()) | ||||
|  |  | |||
|  | @ -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<StyleComponentValueRule> parse_as_list_of_component_values(); | ||||
|     Vector<Vector<StyleComponentValueRule>> parse_as_comma_separated_list_of_component_values(); | ||||
| 
 | ||||
|     NonnullRefPtr<CSSStyleSheet> parse_as_css_stylesheet(Optional<AK::URL> 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<typename T> | ||||
|     Optional<StyleComponentValueRule> parse_a_component_value(TokenStream<T>&); | ||||
| 
 | ||||
|     // "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<typename T> | ||||
|     Vector<StyleComponentValueRule> parse_a_list_of_component_values(TokenStream<T>&); | ||||
| 
 | ||||
|     template<typename T> | ||||
|     Vector<Vector<StyleComponentValueRule>> parse_a_comma_separated_list_of_component_values(TokenStream<T>&); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins