From 9997f46593a0d126b488727ca47086016f574768 Mon Sep 17 00:00:00 2001 From: MacDue Date: Fri, 28 Jul 2023 22:24:36 +0100 Subject: [PATCH] LibWeb: Resolve currentColor when used for SVG gradient s A small workaround is needed here as elements don't create a layout node, so we can't get the current color from value->to_color(). This fixes the gradients in the Atlassian logo and icons. --- Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 31b4f02ac4..94624622d2 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -939,9 +940,15 @@ String StyleProperties::grid_area() const Color StyleProperties::stop_color() const { auto value = property(CSS::PropertyID::StopColor); + if (value->is_identifier()) { + // Workaround lack of layout node to resolve current color. + auto& ident = value->as_identifier(); + if (ident.id() == CSS::ValueID::Currentcolor) + value = property(CSS::PropertyID::Color); + } if (value->has_color()) { // FIXME: This is used by the SVGStopElement, which does not participate in layout, - // so can't pass a layout node (so can't resolve some colors, e.g. palette ones or currentColor) + // so can't pass a layout node (so can't resolve some colors, e.g. palette ones) return value->to_color({}); } return Color::Black;