1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LibWeb: Clip SVG content to parent <svg> element bounding box

This commit is contained in:
MacDue 2023-04-17 01:18:42 +01:00 committed by Andreas Kling
parent d4e114a31e
commit 5a12e9f222

View file

@ -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<int>());
}
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();
}