diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-09-22 12:42:54 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-23 17:47:40 +0200 |
commit | 4a1dbb4f36c1289f6af9caaeb9d8d0a29d5d136c (patch) | |
tree | 2102736a0efc05bf92086de193d1598a2a9cb0e9 /Userland/Libraries/LibWeb/CSS/Parser | |
parent | a1bc89b814df123e07e4208d35552bea1a59e75f (diff) | |
download | serenity-4a1dbb4f36c1289f6af9caaeb9d8d0a29d5d136c.zip |
LibWeb: Move color identifier checking to StyleValue::is_color()
This allows us to perform this check outside of the CSS Parser.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Parser')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 75 |
1 files changed, 3 insertions, 72 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 4b5ecf53c3..d2640a7826 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1369,75 +1369,6 @@ Optional<float> Parser::try_parse_float(StringView string) return is_negative ? -value : value; } -static bool is_color(StyleValue& style_value) -{ - if (style_value.is_color()) - return true; - switch (style_value.to_identifier()) { - 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 true; - default: - break; - } - - return false; -} - RefPtr<StyleValue> Parser::parse_builtin_value(ParsingContext const&, StyleComponentValueRule const& component_value) { if (component_value.is(Token::Type::Ident)) { @@ -1848,7 +1779,7 @@ RefPtr<StyleValue> Parser::parse_background_value(ParsingContext const& context, return nullptr; } - if (is_color(*value)) { + if (value->is_color()) { if (background_color) return nullptr; background_color = value.release_nonnull(); @@ -2014,7 +1945,7 @@ RefPtr<StyleValue> Parser::parse_border_value(ParsingContext const& context, Vec border_width = value.release_nonnull(); continue; } - if (is_color(*value)) { + if (value->is_color()) { if (border_color) return nullptr; border_color = value.release_nonnull(); @@ -2756,7 +2687,7 @@ RefPtr<StyleValue> Parser::parse_text_decoration_value(ParsingContext const& con if (!value) return nullptr; - if (is_color(*value)) { + if (value->is_color()) { if (decoration_color) return nullptr; decoration_color = value.release_nonnull(); |