1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:07:34 +00:00

LibWeb: Make SVG <svg> elements behave as CSS replaced elements

This makes SVG-in-HTML behave quite a bit better by following general
replaced layout rules. It also turns <svg> elements into inline-level
boxes instead of block-level boxes.
This commit is contained in:
Andreas Kling 2022-03-18 22:13:26 +01:00
parent 48abbefb99
commit 28b771560a
10 changed files with 21 additions and 14 deletions

View file

@ -10,7 +10,7 @@
namespace Web::Painting {
SVGPaintable::SVGPaintable(Layout::SVGBox const& layout_box)
: PaintableWithLines(layout_box)
: PaintableBox(layout_box)
{
}

View file

@ -11,7 +11,7 @@
namespace Web::Painting {
class SVGPaintable : public PaintableWithLines {
class SVGPaintable : public PaintableBox {
public:
virtual void before_children_paint(PaintContext&, PaintPhase) const override;
virtual void after_children_paint(PaintContext&, PaintPhase) const override;

View file

@ -15,7 +15,7 @@ NonnullRefPtr<SVGSVGPaintable> SVGSVGPaintable::create(Layout::SVGSVGBox const&
}
SVGSVGPaintable::SVGSVGPaintable(Layout::SVGSVGBox const& layout_box)
: SVGGraphicsPaintable(layout_box)
: PaintableBox(layout_box)
{
}
@ -32,12 +32,12 @@ void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase ph
if (!context.has_svg_context())
context.set_svg_context(SVGContext(absolute_rect()));
SVGGraphicsPaintable::before_children_paint(context, phase);
PaintableBox::before_children_paint(context, phase);
}
void SVGSVGPaintable::after_children_paint(PaintContext& context, PaintPhase phase) const
{
SVGGraphicsPaintable::after_children_paint(context, phase);
PaintableBox::after_children_paint(context, phase);
if (phase != PaintPhase::Foreground)
return;
context.clear_svg_context();

View file

@ -7,11 +7,11 @@
#pragma once
#include <LibWeb/Layout/SVGSVGBox.h>
#include <LibWeb/Painting/SVGGraphicsPaintable.h>
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
class SVGSVGPaintable : public SVGGraphicsPaintable {
class SVGSVGPaintable : public PaintableBox {
public:
static NonnullRefPtr<SVGSVGPaintable> create(Layout::SVGSVGBox const&);