mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:32:43 +00:00 
			
		
		
		
	LibHTML: Respect the CSS "color" property for text
Also remove the color values from the ComputedStyle object and get them via StyleProperties instead. At the moment, we only handle colors that Color::from_string() parses.
This commit is contained in:
		
							parent
							
								
									b8cab2a934
								
							
						
					
					
						commit
						62cbaa74f3
					
				
					 7 changed files with 56 additions and 10 deletions
				
			
		|  | @ -3,6 +3,16 @@ | |||
| #include <ctype.h> | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| static Optional<Color> parse_css_color(const StringView& view) | ||||
| { | ||||
|     auto color = Color::from_string(view); | ||||
|     if (color.has_value()) | ||||
|         return color; | ||||
| 
 | ||||
|     // FIXME: Parse all valid color strings :^)
 | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| NonnullRefPtr<StyleValue> parse_css_value(const StringView& view) | ||||
| { | ||||
|     String string(view); | ||||
|  | @ -19,6 +29,11 @@ NonnullRefPtr<StyleValue> parse_css_value(const StringView& view) | |||
|         return InitialStyleValue::create(); | ||||
|     if (string == "auto") | ||||
|         return LengthStyleValue::create(Length()); | ||||
| 
 | ||||
|     auto color = parse_css_color(view); | ||||
|     if (color.has_value()) | ||||
|         return ColorStyleValue::create(color.value()); | ||||
| 
 | ||||
|     return StringStyleValue::create(string); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling