LibWeb: Paint SVGDecodedImageData via Navigable::paint()

Going via the `ViewportPaintable` missed some steps (in particular
computing clip rects), which meant nested SVGs within SVGs-as-images
were completely clipped.
This commit is contained in:
MacDue 2024-03-30 19:32:05 +00:00 committed by Andreas Kling
parent 4b66f5662b
commit 06ed56f4f6
4 changed files with 20 additions and 4 deletions

View file

@ -0,0 +1,5 @@
<svg width="22" height="22" xmlns="http://www.w3.org/2000/svg">
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" x="5" y="5">
<rect width="12" height="12" fill="red" />
</svg>
</svg>

After

Width:  |  Height:  |  Size: 237 B

View file

@ -0,0 +1,5 @@
<style>
img { border: 1px solid black; }
</style>
<img src="./assets/nested-svg.svg">
<link rel="match" href="reference/nested-svg-as-img-ref.html" />

View file

@ -0,0 +1,8 @@
<svg width="22" height="22" xmlns="http://www.w3.org/2000/svg">
<rect x="5" y="5" width="12" height="12" fill="red" />
</svg>
<style>
svg {
border: 1px solid black;
}
</style>

After

Width:  |  Height:  |  Size: 186 B

View file

@ -133,11 +133,9 @@ RefPtr<Gfx::Bitmap> SVGDecodedImageData::render(Gfx::IntSize size) const
Painting::CommandList painting_commands;
Painting::RecordingPainter recording_painter(painting_commands);
PaintContext context(recording_painter, m_page_client->palette(), m_page_client->device_pixels_per_css_pixel());
m_document->paintable()->paint_all_phases(context);
Painting::CommandExecutorCPU executor { *bitmap };
m_document->navigable()->paint(recording_painter, {});
painting_commands.execute(executor);
return bitmap;