mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00

Previously, all SVG <text> elements were zero-sized boxes, that were only actually positioned and sized during painting. This led to a number of problems, the most visible of which being that text could not be scaled based on the viewBox. Which this patch, <text> elements get a correctly sized layout box, that can be hit-tested and respects the SVG viewBox. To share code with SVGGeometryElement's the PathData (from the prior commit) has been split into a computed path and computed transforms. The computed path is specific to geometry elements, but the computed transforms are shared between all SVG graphics elements.
31 lines
725 B
C++
31 lines
725 B
C++
/*
|
|
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/SVGTextBox.h>
|
|
#include <LibWeb/Painting/SVGGraphicsPaintable.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class SVGTextPaintable final : public SVGGraphicsPaintable {
|
|
JS_CELL(SVGTextPaintable, SVGGraphicsPaintable);
|
|
|
|
public:
|
|
static JS::NonnullGCPtr<SVGTextPaintable> create(Layout::SVGTextBox const&);
|
|
|
|
virtual void paint(PaintContext&, PaintPhase) const override;
|
|
|
|
Layout::SVGTextBox const& layout_box() const
|
|
{
|
|
return static_cast<Layout::SVGTextBox const&>(layout_node());
|
|
}
|
|
|
|
protected:
|
|
SVGTextPaintable(Layout::SVGTextBox const&);
|
|
};
|
|
|
|
}
|