From a910c4d984559d704cec8b16971b85d1ecbe00d7 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sat, 17 Jun 2023 19:25:54 +0100 Subject: [PATCH] LibWeb: Fix end position for objectBoundingBox SVG s The translation to the bounding box location is handled by the gradient transform, also doing it here breaks things. This fixes the MDN example. --- Base/res/html/misc/svg-gradients.html | 18 ++++++++++++++++++ .../LibWeb/SVG/SVGRadialGradientElement.cpp | 6 ++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Base/res/html/misc/svg-gradients.html b/Base/res/html/misc/svg-gradients.html index 25ac91736b..2eaa9b1357 100644 --- a/Base/res/html/misc/svg-gradients.html +++ b/Base/res/html/misc/svg-gradients.html @@ -31,6 +31,24 @@

+MDN radialGradient example (gradientUnits=objectBoundingBox) +
+ + + + + + + + + + + +
+
Simple radialGradient gradientUnits=objectBoundingBox
diff --git a/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp index aa700a6d2d..51a0c58b8f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp @@ -136,11 +136,9 @@ Optional SVGRadialGradientElement::to_gfx_paint_style(SV // is established using the bounding box of the element to which the gradient is applied (see Object bounding box units) // and then applying the transform specified by attribute ‘gradientTransform’. Percentages represent values relative // to the bounding box for the object. - start_center = Gfx::FloatPoint { - start_circle_x().value(), start_circle_y().value() - }; + start_center = Gfx::FloatPoint { start_circle_x().value(), start_circle_y().value() }; start_radius = start_circle_radius().value(); - end_center = paint_context.path_bounding_box.location() + Gfx::FloatPoint { end_circle_x().value(), end_circle_y().value() }; + end_center = Gfx::FloatPoint { end_circle_x().value(), end_circle_y().value() }; end_radius = end_circle_radius().value(); } else { // GradientUnits::UserSpaceOnUse