mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:47:44 +00:00
LibWeb: Move SVGPathElement methods into SVGGeometryElement
From the spec: > Interface SVGGeometryElement represents SVG elements whose rendering > is defined by geometry with an equivalent path, and which can be > filled and stroked. This includes paths and the basic shapes. - https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement Making them all create an SVGPathBox, and return a Path from get_path(), means we can implement the "basic shapes" using the path system we already have. :^)
This commit is contained in:
parent
49fe232bc7
commit
326a5a82eb
6 changed files with 22 additions and 18 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Layout/SVGPathBox.h>
|
||||
#include <LibWeb/SVG/SVGGeometryElement.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
@ -13,4 +14,9 @@ SVGGeometryElement::SVGGeometryElement(DOM::Document& document, QualifiedName qu
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> SVGGeometryElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
return adopt_ref(*new Layout::SVGPathBox(document(), *this, move(style)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,10 +10,15 @@
|
|||
|
||||
namespace Web::SVG {
|
||||
|
||||
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement
|
||||
class SVGGeometryElement : public SVGGraphicsElement {
|
||||
public:
|
||||
using WrapperType = Bindings::SVGGeometryElementWrapper;
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
virtual Gfx::Path& get_path() = 0;
|
||||
|
||||
protected:
|
||||
SVGGeometryElement(DOM::Document& document, QualifiedName qualified_name);
|
||||
};
|
||||
|
|
|
@ -443,11 +443,6 @@ SVGPathElement::SVGPathElement(DOM::Document& document, QualifiedName qualified_
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Layout::Node> SVGPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
return adopt_ref(*new Layout::SVGPathBox(document(), *this, move(style)));
|
||||
}
|
||||
|
||||
void SVGPathElement::parse_attribute(const FlyString& name, const String& value)
|
||||
{
|
||||
SVGGeometryElement::parse_attribute(name, value);
|
||||
|
|
|
@ -89,11 +89,9 @@ public:
|
|||
SVGPathElement(DOM::Document&, QualifiedName);
|
||||
virtual ~SVGPathElement() override = default;
|
||||
|
||||
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
virtual void parse_attribute(const FlyString& name, const String& value) override;
|
||||
|
||||
Gfx::Path& get_path();
|
||||
virtual Gfx::Path& get_path() override;
|
||||
|
||||
private:
|
||||
Vector<PathInstruction> m_instructions;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue