| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> | 
					
						
							| 
									
										
										
										
											2025-07-10 12:17:27 +01:00
										 |  |  |  * Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:28:41 +01:00
										 |  |  | #include "KeywordStyleValue.h"
 | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | #include <LibGfx/Palette.h>
 | 
					
						
							| 
									
										
										
										
											2025-08-14 12:44:03 +01:00
										 |  |  | #include <LibWeb/CSS/CSSKeywordValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-23 17:17:15 +01:00
										 |  |  | #include <LibWeb/CSS/SystemColor.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | #include <LibWeb/DOM/Document.h>
 | 
					
						
							|  |  |  | #include <LibWeb/Layout/Node.h>
 | 
					
						
							| 
									
										
										
										
											2023-09-19 19:16:50 +02:00
										 |  |  | #include <LibWeb/Page/Page.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:28:41 +01:00
										 |  |  | String KeywordStyleValue::to_string(SerializationMode) const | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     return MUST(String::from_utf8(string_from_keyword(keyword()))); | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:28:41 +01:00
										 |  |  | bool KeywordStyleValue::is_color(Keyword keyword) | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     switch (keyword) { | 
					
						
							|  |  |  |     case Keyword::Accentcolor: | 
					
						
							|  |  |  |     case Keyword::Accentcolortext: | 
					
						
							|  |  |  |     case Keyword::Activeborder: | 
					
						
							|  |  |  |     case Keyword::Activecaption: | 
					
						
							|  |  |  |     case Keyword::Activetext: | 
					
						
							|  |  |  |     case Keyword::Appworkspace: | 
					
						
							|  |  |  |     case Keyword::Background: | 
					
						
							|  |  |  |     case Keyword::Buttonborder: | 
					
						
							|  |  |  |     case Keyword::Buttonface: | 
					
						
							|  |  |  |     case Keyword::Buttonhighlight: | 
					
						
							|  |  |  |     case Keyword::Buttonshadow: | 
					
						
							|  |  |  |     case Keyword::Buttontext: | 
					
						
							|  |  |  |     case Keyword::Canvas: | 
					
						
							|  |  |  |     case Keyword::Canvastext: | 
					
						
							|  |  |  |     case Keyword::Captiontext: | 
					
						
							|  |  |  |     case Keyword::Currentcolor: | 
					
						
							|  |  |  |     case Keyword::Field: | 
					
						
							|  |  |  |     case Keyword::Fieldtext: | 
					
						
							|  |  |  |     case Keyword::Graytext: | 
					
						
							|  |  |  |     case Keyword::Highlight: | 
					
						
							|  |  |  |     case Keyword::Highlighttext: | 
					
						
							|  |  |  |     case Keyword::Inactiveborder: | 
					
						
							|  |  |  |     case Keyword::Inactivecaption: | 
					
						
							|  |  |  |     case Keyword::Inactivecaptiontext: | 
					
						
							|  |  |  |     case Keyword::Infobackground: | 
					
						
							|  |  |  |     case Keyword::Infotext: | 
					
						
							| 
									
										
										
										
											2025-04-30 18:49:59 +02:00
										 |  |  |     case Keyword::LibwebButtonfacedisabled: | 
					
						
							|  |  |  |     case Keyword::LibwebButtonfacehover: | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebLink: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteActiveLink: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteActiveWindowBorder1: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteActiveWindowBorder2: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteActiveWindowTitle: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteBase: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteBaseText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteButton: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteButtonText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteDesktopBackground: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteFocusOutline: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteHighlightWindowBorder1: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteHighlightWindowBorder2: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteHighlightWindowTitle: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteHoverHighlight: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteInactiveSelection: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteInactiveSelectionText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteInactiveWindowBorder1: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteInactiveWindowBorder2: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteInactiveWindowTitle: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteLink: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMenuBase: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMenuBaseText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMenuSelection: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMenuSelectionText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMenuStripe: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMovingWindowBorder1: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMovingWindowBorder2: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteMovingWindowTitle: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteRubberBandBorder: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteRubberBandFill: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteRuler: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteRulerActiveText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteRulerBorder: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteRulerInactiveText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSelection: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSelectionText: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxComment: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxControlKeyword: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxIdentifier: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxKeyword: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxNumber: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxOperator: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxPreprocessorStatement: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxPreprocessorValue: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxPunctuation: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxString: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteSyntaxType: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteTextCursor: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteThreedHighlight: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteThreedShadow1: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteThreedShadow2: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteVisitedLink: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteWindow: | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteWindowText: | 
					
						
							|  |  |  |     case Keyword::Linktext: | 
					
						
							|  |  |  |     case Keyword::Mark: | 
					
						
							|  |  |  |     case Keyword::Marktext: | 
					
						
							|  |  |  |     case Keyword::Menu: | 
					
						
							|  |  |  |     case Keyword::Menutext: | 
					
						
							|  |  |  |     case Keyword::Scrollbar: | 
					
						
							|  |  |  |     case Keyword::Selecteditem: | 
					
						
							|  |  |  |     case Keyword::Selecteditemtext: | 
					
						
							|  |  |  |     case Keyword::Threeddarkshadow: | 
					
						
							|  |  |  |     case Keyword::Threedface: | 
					
						
							|  |  |  |     case Keyword::Threedhighlight: | 
					
						
							|  |  |  |     case Keyword::Threedlightshadow: | 
					
						
							|  |  |  |     case Keyword::Threedshadow: | 
					
						
							|  |  |  |     case Keyword::Visitedtext: | 
					
						
							|  |  |  |     case Keyword::Window: | 
					
						
							|  |  |  |     case Keyword::Windowframe: | 
					
						
							|  |  |  |     case Keyword::Windowtext: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:28:41 +01:00
										 |  |  | bool KeywordStyleValue::has_color() const | 
					
						
							| 
									
										
										
										
											2023-08-23 15:40:17 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     return is_color(keyword()); | 
					
						
							| 
									
										
										
										
											2023-08-23 15:40:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:28:41 +01:00
										 |  |  | Optional<Color> KeywordStyleValue::to_color(ColorResolutionContext color_resolution_context) const | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     if (keyword() == Keyword::Currentcolor) { | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |         return color_resolution_context.current_color.value_or(Color::Black); | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |     PreferredColorScheme scheme = color_resolution_context.color_scheme.value_or(PreferredColorScheme::Light); | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // First, handle <system-color>s, since they don't strictly require a node.
 | 
					
						
							| 
									
										
										
										
											2023-08-23 17:17:15 +01:00
										 |  |  |     // https://www.w3.org/TR/css-color-4/#css-system-colors
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/css-color-4/#deprecated-system-colors
 | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     switch (keyword()) { | 
					
						
							|  |  |  |     case Keyword::Accentcolor: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::accent_color(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Accentcolortext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::accent_color_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Buttonborder: | 
					
						
							|  |  |  |     case Keyword::Activeborder: | 
					
						
							|  |  |  |     case Keyword::Inactiveborder: | 
					
						
							|  |  |  |     case Keyword::Threeddarkshadow: | 
					
						
							|  |  |  |     case Keyword::Threedhighlight: | 
					
						
							|  |  |  |     case Keyword::Threedlightshadow: | 
					
						
							|  |  |  |     case Keyword::Threedshadow: | 
					
						
							|  |  |  |     case Keyword::Windowframe: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::button_border(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Buttonface: | 
					
						
							|  |  |  |     case Keyword::Buttonhighlight: | 
					
						
							|  |  |  |     case Keyword::Buttonshadow: | 
					
						
							|  |  |  |     case Keyword::Threedface: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::button_face(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Buttontext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::button_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Canvas: | 
					
						
							|  |  |  |     case Keyword::Appworkspace: | 
					
						
							|  |  |  |     case Keyword::Background: | 
					
						
							|  |  |  |     case Keyword::Inactivecaption: | 
					
						
							|  |  |  |     case Keyword::Infobackground: | 
					
						
							|  |  |  |     case Keyword::Menu: | 
					
						
							|  |  |  |     case Keyword::Scrollbar: | 
					
						
							|  |  |  |     case Keyword::Window: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::canvas(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Canvastext: | 
					
						
							|  |  |  |     case Keyword::Activecaption: | 
					
						
							|  |  |  |     case Keyword::Captiontext: | 
					
						
							|  |  |  |     case Keyword::Infotext: | 
					
						
							|  |  |  |     case Keyword::Menutext: | 
					
						
							|  |  |  |     case Keyword::Windowtext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::canvas_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Field: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::field(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Fieldtext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::field_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Graytext: | 
					
						
							|  |  |  |     case Keyword::Inactivecaptiontext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::gray_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Highlight: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::highlight(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Highlighttext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::highlight_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Mark: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::mark(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Marktext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::mark_text(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Selecteditem: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::selected_item(scheme); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::Selecteditemtext: | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |         return SystemColor::selected_item_text(scheme); | 
					
						
							| 
									
										
										
										
											2025-04-30 18:49:59 +02:00
										 |  |  |     case Keyword::LibwebButtonfacedisabled: | 
					
						
							|  |  |  |         return SystemColor::button_face(scheme).with_alpha(128); | 
					
						
							|  |  |  |     case Keyword::LibwebButtonfacehover: | 
					
						
							|  |  |  |         return SystemColor::button_face(scheme).darkened(0.8f); | 
					
						
							| 
									
										
										
										
											2023-08-23 17:17:15 +01:00
										 |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |     if (!color_resolution_context.document) { | 
					
						
							|  |  |  |         // FIXME: Can't resolve palette colors without a document.
 | 
					
						
							| 
									
										
										
										
											2023-04-19 18:31:00 +01:00
										 |  |  |         return Color::Black; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |     switch (keyword()) { | 
					
						
							|  |  |  |     case Keyword::LibwebLink: | 
					
						
							|  |  |  |     case Keyword::Linktext: | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |         return color_resolution_context.document->normal_link_color().value_or(SystemColor::link_text(scheme)); | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |     case Keyword::Visitedtext: | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |         return color_resolution_context.document->visited_link_color().value_or(SystemColor::visited_text(scheme)); | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |     case Keyword::Activetext: | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |         return color_resolution_context.document->active_link_color().value_or(SystemColor::active_text(scheme)); | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-19 11:31:07 +12:00
										 |  |  |     auto palette = color_resolution_context.document->page().palette(); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     switch (keyword()) { | 
					
						
							|  |  |  |     case Keyword::LibwebPaletteDesktopBackground: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::DesktopBackground); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteActiveWindowBorder1: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ActiveWindowBorder1); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteActiveWindowBorder2: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ActiveWindowBorder2); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteActiveWindowTitle: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ActiveWindowTitle); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteInactiveWindowBorder1: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::InactiveWindowBorder1); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteInactiveWindowBorder2: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::InactiveWindowBorder2); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteInactiveWindowTitle: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::InactiveWindowTitle); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMovingWindowBorder1: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MovingWindowBorder1); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMovingWindowBorder2: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MovingWindowBorder2); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMovingWindowTitle: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MovingWindowTitle); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteHighlightWindowBorder1: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::HighlightWindowBorder1); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteHighlightWindowBorder2: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::HighlightWindowBorder2); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteHighlightWindowTitle: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::HighlightWindowTitle); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMenuStripe: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MenuStripe); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMenuBase: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MenuBase); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMenuBaseText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MenuBaseText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMenuSelection: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MenuSelection); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteMenuSelectionText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::MenuSelectionText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteWindow: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::Window); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteWindowText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::WindowText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteButton: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::Button); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteButtonText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ButtonText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteBase: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::Base); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteBaseText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::BaseText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteThreedHighlight: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ThreedHighlight); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteThreedShadow1: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ThreedShadow1); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteThreedShadow2: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ThreedShadow2); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteHoverHighlight: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::HoverHighlight); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSelection: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::Selection); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSelectionText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SelectionText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteInactiveSelection: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::InactiveSelection); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteInactiveSelectionText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::InactiveSelectionText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteRubberBandFill: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::RubberBandFill); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteRubberBandBorder: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::RubberBandBorder); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteLink: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::Link); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteActiveLink: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::ActiveLink); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteVisitedLink: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::VisitedLink); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteRuler: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::Ruler); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteRulerBorder: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::RulerBorder); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteRulerActiveText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::RulerActiveText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteRulerInactiveText: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::RulerInactiveText); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteTextCursor: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::TextCursor); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteFocusOutline: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::FocusOutline); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxComment: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxComment); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxNumber: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxNumber); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxString: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxString); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxType: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxType); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxPunctuation: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxPunctuation); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxOperator: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxOperator); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxKeyword: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxKeyword); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxControlKeyword: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxControlKeyword); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxIdentifier: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxIdentifier); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxPreprocessorStatement: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxPreprocessorStatement); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     case Keyword::LibwebPaletteSyntaxPreprocessorValue: | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  |         return palette.color(ColorRole::SyntaxPreprocessorValue); | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:28:41 +01:00
										 |  |  | Vector<Parser::ComponentValue> KeywordStyleValue::tokenize() const | 
					
						
							| 
									
										
										
										
											2025-07-10 12:17:27 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return { Parser::Token::create_ident(FlyString::from_utf8_without_validation(string_from_keyword(m_keyword).bytes())) }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-14 12:44:03 +01:00
										 |  |  | // https://drafts.css-houdini.org/css-typed-om-1/#reify-ident
 | 
					
						
							|  |  |  | GC::Ref<CSSStyleValue> KeywordStyleValue::reify(JS::Realm& realm, String const&) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // 1. Return a new CSSKeywordValue with its value internal slot set to the serialization of ident.
 | 
					
						
							|  |  |  |     return CSSKeywordValue::create(realm, FlyString::from_utf8_without_validation(string_from_keyword(m_keyword).bytes())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-24 15:04:24 +00:00
										 |  |  | } |