diff --git a/Libraries/LibWeb/Painting/SVGMaskable.cpp b/Libraries/LibWeb/Painting/SVGMaskable.cpp index 22e781ff1703..4ee9098c8c17 100644 --- a/Libraries/LibWeb/Painting/SVGMaskable.cpp +++ b/Libraries/LibWeb/Painting/SVGMaskable.cpp @@ -87,7 +87,11 @@ RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& co DisplayListRecorder display_list_recorder(*display_list); display_list_recorder.translate(-mask_rect.location().to_type()); auto paint_context = context.clone(display_list_recorder); - paint_context.set_svg_transform(graphics_element.get_transform()); + auto const& mask_element = verify_cast(*paintable.dom_node()); + paint_context.set_svg_transform( + graphics_element.get_transform() + .multiply(mask_element.get_transform().inverse().value()) + .multiply(mask_element.element_transform())); paint_context.set_draw_svg_geometry_for_clip_path(is(paintable)); StackingContext::paint_svg(paint_context, paintable, PaintPhase::Foreground); DisplayListPlayerSkia display_list_player { *mask_bitmap }; diff --git a/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index a4d8d2610efd..3f7ccf23b7d5 100644 --- a/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -14,7 +14,7 @@ namespace Web::SVG { GC_DEFINE_ALLOCATOR(SVGClipPathElement); SVGClipPathElement::SVGClipPathElement(DOM::Document& document, DOM::QualifiedName qualified_name) - : SVGElement(document, move(qualified_name)) + : SVGGraphicsElement(document, move(qualified_name)) { } diff --git a/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Libraries/LibWeb/SVG/SVGClipPathElement.h index e3ccb9e98159..8c845a8de0e9 100644 --- a/Libraries/LibWeb/SVG/SVGClipPathElement.h +++ b/Libraries/LibWeb/SVG/SVGClipPathElement.h @@ -8,13 +8,14 @@ #include #include +#include #include namespace Web::SVG { -class SVGClipPathElement final : public SVGElement +class SVGClipPathElement final : public SVGGraphicsElement , public SVGViewport { - WEB_PLATFORM_OBJECT(SVGClipPathElement, SVGElement); + WEB_PLATFORM_OBJECT(SVGClipPathElement, SVGGraphicsElement); GC_DECLARE_ALLOCATOR(SVGClipPathElement); public: @@ -48,5 +49,4 @@ class SVGClipPathElement final : public SVGElement Optional m_clip_path_units = {}; }; - } diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Libraries/LibWeb/SVG/SVGGraphicsElement.h index f54084335a9d..d4fb41cc8d75 100644 --- a/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -67,16 +67,16 @@ class SVGGraphicsElement : public SVGElement { GC::Ptr get_screen_ctm(); -protected: - SVGGraphicsElement(DOM::Document&, DOM::QualifiedName); - - virtual void initialize(JS::Realm&) override; - virtual Gfx::AffineTransform element_transform() const { return m_transform; } +protected: + SVGGraphicsElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; + Optional svg_paint_computed_value_to_gfx_paint_style(SVGPaintContext const& paint_context, Optional const& paint_value) const; Gfx::AffineTransform m_transform = {}; diff --git a/Tests/LibWeb/Screenshot/expected/svg-clip-path-transform-ref.html b/Tests/LibWeb/Screenshot/expected/svg-clip-path-transform-ref.html new file mode 100644 index 000000000000..7e1088f46aef --- /dev/null +++ b/Tests/LibWeb/Screenshot/expected/svg-clip-path-transform-ref.html @@ -0,0 +1,10 @@ + + diff --git a/Tests/LibWeb/Screenshot/images/svg-clip-path-transform-ref.png b/Tests/LibWeb/Screenshot/images/svg-clip-path-transform-ref.png new file mode 100644 index 000000000000..408c5b758100 Binary files /dev/null and b/Tests/LibWeb/Screenshot/images/svg-clip-path-transform-ref.png differ diff --git a/Tests/LibWeb/Screenshot/input/svg-clip-path-transform.html b/Tests/LibWeb/Screenshot/input/svg-clip-path-transform.html new file mode 100644 index 000000000000..20837356ffbd --- /dev/null +++ b/Tests/LibWeb/Screenshot/input/svg-clip-path-transform.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + +