From 5a12e9f22292cd6b6393b5d4b09165ebdee3a8bb Mon Sep 17 00:00:00 2001 From: MacDue Date: Mon, 17 Apr 2023 01:18:42 +0100 Subject: [PATCH] LibWeb: Clip SVG content to parent element bounding box --- Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp index 3ed1439806..0f4135cad6 100644 --- a/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp @@ -26,13 +26,15 @@ Layout::SVGSVGBox const& SVGSVGPaintable::layout_box() const void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase phase) const { + PaintableBox::before_children_paint(context, phase); if (phase != PaintPhase::Foreground) return; if (!context.has_svg_context()) context.set_svg_context(SVGContext(absolute_rect())); - PaintableBox::before_children_paint(context, phase); + context.painter().save(); + context.painter().add_clip_rect(context.enclosing_device_rect(absolute_rect()).to_type()); } void SVGSVGPaintable::after_children_paint(PaintContext& context, PaintPhase phase) const @@ -40,6 +42,8 @@ void SVGSVGPaintable::after_children_paint(PaintContext& context, PaintPhase pha PaintableBox::after_children_paint(context, phase); if (phase != PaintPhase::Foreground) return; + + context.painter().restore(); context.clear_svg_context(); }