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

LibWeb: Refactor SVG files into their own directory; follow spec layout

This commit is contained in:
Matthew Olsson 2020-07-23 09:44:42 -07:00 committed by Andreas Kling
parent 2e73082203
commit b1299f972c
17 changed files with 386 additions and 172 deletions

View file

@ -27,16 +27,16 @@
#include <LibGUI/Painter.h>
#include <LibGfx/Font.h>
#include <LibGfx/StylePainter.h>
#include <LibWeb/Layout/LayoutSvg.h>
#include <LibWeb/Layout/LayoutSVG.h>
namespace Web {
LayoutSvg::LayoutSvg(Document& document, const HTMLSvgElement& element, NonnullRefPtr<StyleProperties> style)
LayoutSVG::LayoutSVG(Document& document, const SVG::SVGSVGElement& element, NonnullRefPtr<StyleProperties> style)
: LayoutReplaced(document, element, move(style))
{
}
void LayoutSvg::layout(LayoutMode layout_mode)
void LayoutSVG::layout(LayoutMode layout_mode)
{
set_has_intrinsic_width(true);
set_has_intrinsic_height(true);
@ -45,7 +45,7 @@ void LayoutSvg::layout(LayoutMode layout_mode)
LayoutReplaced::layout(layout_mode);
}
void LayoutSvg::paint(PaintContext& context, PaintPhase phase)
void LayoutSVG::paint(PaintContext& context, PaintPhase phase)
{
if (!is_visible())
return;
@ -57,7 +57,7 @@ void LayoutSvg::paint(PaintContext& context, PaintPhase phase)
return;
if (!node().bitmap())
node().create_bitmap();
node().create_bitmap_as_top_level_svg_element();
ASSERT(node().bitmap());
context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *node().bitmap(), node().bitmap()->rect());

View file

@ -26,21 +26,22 @@
#pragma once
#include <LibWeb/DOM/HTMLSvgElement.h>
#include <LibWeb/SVG/SVGSVGElement.h>
#include <LibWeb/Layout/LayoutReplaced.h>
#include <LibWeb/SVG/SVGSVGElement.h>
namespace Web {
class HTMLSvgElement;
class SVGSVGElement;
class LayoutSvg : public LayoutReplaced {
class LayoutSVG : public LayoutReplaced {
public:
LayoutSvg(Document&, const HTMLSvgElement&, NonnullRefPtr<StyleProperties>);
virtual ~LayoutSvg() override = default;
LayoutSVG(Document&, const SVG::SVGSVGElement&, NonnullRefPtr<StyleProperties>);
virtual ~LayoutSVG() override = default;
virtual void layout(LayoutMode = LayoutMode::Default) override;
virtual void paint(PaintContext&, PaintPhase) override;
HTMLSvgElement& node() { return static_cast<HTMLSvgElement&>(LayoutReplaced::node()); }
SVG::SVGSVGElement& node() { return static_cast<SVG::SVGSVGElement&>(LayoutReplaced::node()); }
private:
virtual const char* class_name() const override { return "LayoutSvg"; }