2022-03-10 14:02:25 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-10 14:02:25 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-08-09 14:00:10 +02:00
|
|
|
#include <LibGfx/Path.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2023-11-04 21:31:35 +00:00
|
|
|
#include <LibWeb/Layout/SVGGraphicsBox.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
#include <LibWeb/Painting/SVGGraphicsPaintable.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API SVGPathPaintable final : public SVGGraphicsPaintable {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(SVGPathPaintable, SVGGraphicsPaintable);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(SVGPathPaintable);
|
2023-01-11 12:51:49 +01:00
|
|
|
|
2022-03-10 14:02:25 +01:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static GC::Ref<SVGPathPaintable> create(Layout::SVGGraphicsBox const&);
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2024-02-13 21:34:07 +01:00
|
|
|
virtual TraversalDecision hit_test(CSSPixelPoint, HitTestType, Function<TraversalDecision(HitTestResult)> const& callback) const override;
|
2023-04-10 12:35:33 +01:00
|
|
|
|
2025-07-31 23:07:26 +02:00
|
|
|
virtual void paint(DisplayListRecordingContext&, PaintPhase) const override;
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2025-10-13 17:38:52 +02:00
|
|
|
SVG::SVGGraphicsElement const& dom_node() const { return as<SVG::SVGGraphicsElement>(*Paintable::dom_node()); }
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2024-08-09 14:00:10 +02:00
|
|
|
void set_computed_path(Gfx::Path path)
|
2023-10-29 17:08:35 +00:00
|
|
|
{
|
2023-10-29 19:11:46 +00:00
|
|
|
m_computed_path = move(path);
|
2023-10-29 17:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-09 14:00:10 +02:00
|
|
|
Optional<Gfx::Path> const& computed_path() const { return m_computed_path; }
|
2023-10-29 17:08:35 +00:00
|
|
|
|
2022-03-10 14:02:25 +01:00
|
|
|
protected:
|
2023-11-04 21:31:35 +00:00
|
|
|
SVGPathPaintable(Layout::SVGGraphicsBox const&);
|
2023-10-29 17:08:35 +00:00
|
|
|
|
2024-08-09 14:00:10 +02:00
|
|
|
Optional<Gfx::Path> m_computed_path = {};
|
2025-09-21 14:14:39 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual bool is_svg_path_paintable() const final { return true; }
|
2025-09-24 09:34:04 +02:00
|
|
|
|
|
|
|
|
virtual void resolve_paint_properties() override;
|
|
|
|
|
|
|
|
|
|
float m_stroke_thickness { 0 };
|
|
|
|
|
float m_stroke_dashoffset { 0 };
|
|
|
|
|
Vector<float> m_stroke_dasharray;
|
2022-03-10 14:02:25 +01:00
|
|
|
};
|
|
|
|
|
|
2025-09-21 14:14:39 +02:00
|
|
|
template<>
|
|
|
|
|
inline bool Paintable::fast_is<SVGPathPaintable>() const { return is_svg_path_paintable(); }
|
|
|
|
|
|
2022-03-10 14:02:25 +01:00
|
|
|
}
|