mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 12:45:08 +00:00

The implementation of painting for SVG text follows the same pattern as the implementation of painting for SVG geometries. However, instead of reusing the existing PaintableWithLines to draw text, a new class called SVGTextPaintable is introduced. because everything that is painted inside an SVG is expected to inherit from SVGGraphicsPaintable. Therefore reusing the text painting from regular text nodes would require significant refactoring.
33 lines
815 B
C++
33 lines
815 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 Optional<HitTestResult> hit_test(CSSPixelPoint, HitTestType) const override;
|
|
|
|
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&);
|
|
};
|
|
|
|
}
|