mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	LibWeb: Move check for CSS-wide keywords to ValueID.h
This feels like a better home for it. The new name better reflects the spec phrasing.
This commit is contained in:
		
							parent
							
								
									bf8aa33b68
								
							
						
					
					
						commit
						e9b58ff096
					
				
					 3 changed files with 10 additions and 10 deletions
				
			
		|  | @ -70,6 +70,14 @@ enum class ValueID { | ||||||
| Optional<ValueID> value_id_from_string(StringView); | Optional<ValueID> value_id_from_string(StringView); | ||||||
| StringView string_from_value_id(ValueID); | StringView string_from_value_id(ValueID); | ||||||
| 
 | 
 | ||||||
|  | // https://www.w3.org/TR/css-values-4/#common-keywords
 | ||||||
|  | inline bool is_css_wide_keyword(StringView name) | ||||||
|  | { | ||||||
|  |     return name.equals_ignoring_ascii_case("inherit"sv) | ||||||
|  |         || name.equals_ignoring_ascii_case("initial"sv) | ||||||
|  |         || name.equals_ignoring_ascii_case("unset"sv); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| )~~~"); | )~~~"); | ||||||
|  |  | ||||||
|  | @ -1488,7 +1488,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule) | ||||||
|                 return {}; |                 return {}; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (name_token.is(Token::Type::Ident) && (is_builtin(name_token.ident()) || name_token.ident().equals_ignoring_ascii_case("none"sv))) { |             if (name_token.is(Token::Type::Ident) && (is_css_wide_keyword(name_token.ident()) || name_token.ident().equals_ignoring_ascii_case("none"sv))) { | ||||||
|                 dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @keyframes rule name is invalid: {}; discarding.", name_token.ident()); |                 dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @keyframes rule name is invalid: {}; discarding.", name_token.ident()); | ||||||
|                 return {}; |                 return {}; | ||||||
|             } |             } | ||||||
|  | @ -4246,7 +4246,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens) | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|                 if (part.is(Token::Type::Ident)) { |                 if (part.is(Token::Type::Ident)) { | ||||||
|                     if (is_builtin(part.token().ident())) { |                     if (is_css_wide_keyword(part.token().ident())) { | ||||||
|                         dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face font-family format invalid; discarding."); |                         dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face font-family format invalid; discarding."); | ||||||
|                         had_syntax_error = true; |                         had_syntax_error = true; | ||||||
|                         break; |                         break; | ||||||
|  | @ -6483,13 +6483,6 @@ bool Parser::has_ignored_vendor_prefix(StringView string) | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool Parser::is_builtin(StringView name) |  | ||||||
| { |  | ||||||
|     return name.equals_ignoring_ascii_case("inherit"sv) |  | ||||||
|         || name.equals_ignoring_ascii_case("initial"sv) |  | ||||||
|         || name.equals_ignoring_ascii_case("unset"sv); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(Badge<StyleComputer>, ParsingContext const& context, ComponentValue const& token) | RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(Badge<StyleComputer>, ParsingContext const& context, ComponentValue const& token) | ||||||
| { | { | ||||||
|     auto parser = MUST(Parser::create(context, ""sv)); |     auto parser = MUST(Parser::create(context, ""sv)); | ||||||
|  |  | ||||||
|  | @ -286,7 +286,6 @@ private: | ||||||
|     Optional<Supports::Feature> parse_supports_feature(TokenStream<ComponentValue>&); |     Optional<Supports::Feature> parse_supports_feature(TokenStream<ComponentValue>&); | ||||||
| 
 | 
 | ||||||
|     static bool has_ignored_vendor_prefix(StringView); |     static bool has_ignored_vendor_prefix(StringView); | ||||||
|     static bool is_builtin(StringView); |  | ||||||
| 
 | 
 | ||||||
|     struct PropertiesAndCustomProperties { |     struct PropertiesAndCustomProperties { | ||||||
|         Vector<StyleProperty> properties; |         Vector<StyleProperty> properties; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins