mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibWeb: Implement painting for svg text
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.
This commit is contained in:
parent
81a6976e90
commit
0d8d7ae94e
9 changed files with 216 additions and 0 deletions
33
Userland/Libraries/LibWeb/Painting/SVGTextPaintable.h
Normal file
33
Userland/Libraries/LibWeb/Painting/SVGTextPaintable.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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&);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue