diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-05-10 17:34:44 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-25 06:36:10 +0200 |
commit | aad2f0963f91b9ebf971cf4c00fee0ed2647c5c4 (patch) | |
tree | 0b8f16578717548d26c638a141288e04e424dcfb | |
parent | 465ecf37c201ee893aac536869ea40cddd629186 (diff) | |
download | serenity-aad2f0963f91b9ebf971cf4c00fee0ed2647c5c4.zip |
LibWeb: Teach the CSS parser about extra color keywords
All of these identifiers can be treated as a color, so let's make sure
the parser understands that.
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 9237950e6e..325f9d111e 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4029,6 +4029,72 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_color_value(ComponentValue const& comp if (color.has_value()) return ColorStyleValue::create(color.value()); + if (component_value.is(Token::Type::Ident)) { + if (auto ident = value_id_from_string(component_value.token().ident()); ident.has_value()) { + switch (ident.value()) { + case ValueID::Currentcolor: + case ValueID::LibwebLink: + case ValueID::LibwebPaletteActiveLink: + case ValueID::LibwebPaletteActiveWindowBorder1: + case ValueID::LibwebPaletteActiveWindowBorder2: + case ValueID::LibwebPaletteActiveWindowTitle: + case ValueID::LibwebPaletteBase: + case ValueID::LibwebPaletteBaseText: + case ValueID::LibwebPaletteButton: + case ValueID::LibwebPaletteButtonText: + case ValueID::LibwebPaletteDesktopBackground: + case ValueID::LibwebPaletteFocusOutline: + case ValueID::LibwebPaletteHighlightWindowBorder1: + case ValueID::LibwebPaletteHighlightWindowBorder2: + case ValueID::LibwebPaletteHighlightWindowTitle: + case ValueID::LibwebPaletteHoverHighlight: + case ValueID::LibwebPaletteInactiveSelection: + case ValueID::LibwebPaletteInactiveSelectionText: + case ValueID::LibwebPaletteInactiveWindowBorder1: + case ValueID::LibwebPaletteInactiveWindowBorder2: + case ValueID::LibwebPaletteInactiveWindowTitle: + case ValueID::LibwebPaletteLink: + case ValueID::LibwebPaletteMenuBase: + case ValueID::LibwebPaletteMenuBaseText: + case ValueID::LibwebPaletteMenuSelection: + case ValueID::LibwebPaletteMenuSelectionText: + case ValueID::LibwebPaletteMenuStripe: + case ValueID::LibwebPaletteMovingWindowBorder1: + case ValueID::LibwebPaletteMovingWindowBorder2: + case ValueID::LibwebPaletteMovingWindowTitle: + case ValueID::LibwebPaletteRubberBandBorder: + case ValueID::LibwebPaletteRubberBandFill: + case ValueID::LibwebPaletteRuler: + case ValueID::LibwebPaletteRulerActiveText: + case ValueID::LibwebPaletteRulerBorder: + case ValueID::LibwebPaletteRulerInactiveText: + case ValueID::LibwebPaletteSelection: + case ValueID::LibwebPaletteSelectionText: + case ValueID::LibwebPaletteSyntaxComment: + case ValueID::LibwebPaletteSyntaxControlKeyword: + case ValueID::LibwebPaletteSyntaxIdentifier: + case ValueID::LibwebPaletteSyntaxKeyword: + case ValueID::LibwebPaletteSyntaxNumber: + case ValueID::LibwebPaletteSyntaxOperator: + case ValueID::LibwebPaletteSyntaxPreprocessorStatement: + case ValueID::LibwebPaletteSyntaxPreprocessorValue: + case ValueID::LibwebPaletteSyntaxPunctuation: + case ValueID::LibwebPaletteSyntaxString: + case ValueID::LibwebPaletteSyntaxType: + case ValueID::LibwebPaletteTextCursor: + case ValueID::LibwebPaletteThreedHighlight: + case ValueID::LibwebPaletteThreedShadow1: + case ValueID::LibwebPaletteThreedShadow2: + case ValueID::LibwebPaletteVisitedLink: + case ValueID::LibwebPaletteWindow: + case ValueID::LibwebPaletteWindowText: + return IdentifierStyleValue::create(ident.value()); + default: + break; + } + } + } + return nullptr; } |