mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 02:26:10 +00:00
LibWeb: Clip SVG content to parent <svg> element bounding box
This commit is contained in:
parent
d4e114a31e
commit
5a12e9f222
Notes:
sideshowbarker
2024-07-17 02:28:18 +09:00
Author: https://github.com/MacDue
Commit: 5a12e9f222
Pull-request: https://github.com/SerenityOS/serenity/pull/18407
1 changed files with 5 additions and 1 deletions
|
@ -26,13 +26,15 @@ Layout::SVGSVGBox const& SVGSVGPaintable::layout_box() const
|
||||||
|
|
||||||
void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase phase) const
|
void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase phase) const
|
||||||
{
|
{
|
||||||
|
PaintableBox::before_children_paint(context, phase);
|
||||||
if (phase != PaintPhase::Foreground)
|
if (phase != PaintPhase::Foreground)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!context.has_svg_context())
|
if (!context.has_svg_context())
|
||||||
context.set_svg_context(SVGContext(absolute_rect()));
|
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
|
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);
|
PaintableBox::after_children_paint(context, phase);
|
||||||
if (phase != PaintPhase::Foreground)
|
if (phase != PaintPhase::Foreground)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
context.painter().restore();
|
||||||
context.clear_svg_context();
|
context.clear_svg_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue