From eda429111ec04004bbc78651c404126c9d841758 Mon Sep 17 00:00:00 2001 From: MacDue Date: Tue, 2 May 2023 22:52:04 +0100 Subject: [PATCH] LibWeb: Don't inherit SVG color stops if current gradient has stops The previous behaviour was incorrect, the template's stops should only be used if the current gradient does not have any stops. --- Userland/Libraries/LibWeb/SVG/SVGGradientElement.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h index 380a1be774..d4e975132c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h @@ -44,11 +44,15 @@ protected: template Callback> void for_each_color_stop(Callback const& callback) const { + bool color_stops_found = false; for_each_child_of_type([&](auto& stop) { + color_stops_found = true; callback(stop); }); - if (auto href = xlink_href()) - href->for_each_color_stop(callback); + if (!color_stops_found) { + if (auto href = xlink_href()) + href->for_each_color_stop(callback); + } } private: