From 21b65de1ec4136593ff5294b798fc5ff113b4d45 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 23 Oct 2021 13:05:38 +0100 Subject: [PATCH] LibGfx+LibWeb: Move "transparent" keyword into Color::from_string() It seemed odd to have this one color handled separately, when `Color::from_string()` implements all other CSS colors. --- Userland/Libraries/LibGfx/Color.cpp | 3 +++ Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index 2dbdb5a5e5a..bed286acb12 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -245,6 +245,9 @@ Optional Color::from_string(const StringView& string) { 0x000000, nullptr } }; + if (string == "transparent") + return Color::from_rgba(0x00000000); + for (size_t i = 0; !web_colors[i].name.is_null(); ++i) { if (string == web_colors[i].name) return Color::from_rgb(web_colors[i].color); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 66089b547ca..a49b40cacb6 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -2087,8 +2087,6 @@ Optional Parser::parse_color(ParsingContext const&, StyleComponentValueRu // https://www.w3.org/TR/css-color-3/ if (component_value.is(Token::Type::Ident)) { auto ident = component_value.token().ident(); - if (ident.equals_ignoring_case("transparent")) - return Color::from_rgba(0x00000000); auto color = Color::from_string(ident.to_string().to_lowercase()); if (color.has_value())