Skip to content

Truly independent web browser

1.3 KB
Raw Blame
/*
 * Copyright (c) 2022, Sam Atkins <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/SVG/SVGGeometryElement.h>
#include <LibWeb/SVG/SVGPointList.h>

namespace Web::SVG {

class SVGPolygonElement final
    : public SVGGeometryElement
    , public SVGAnimatedPoints {
    WEB_WRAPPABLE(SVGPolygonElement, SVGGeometryElement);
    GC_DECLARE_ALLOCATOR(SVGPolygonElement);

public:
    virtual ~SVGPolygonElement() override = default;

    virtual void attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_) override;

    // The parsed `points` list, as the element publishes it to layout.
    ReadonlySpan<Gfx::FloatPoint> points() const { return m_points; }

private:
    virtual bool is_svg_polygon_element() const final { return true; }

    SVGPolygonElement(DOM::Document&, DOM::QualifiedName);

    virtual void visit_edges(Cell::Visitor&) override;

    // ^SVGAnimatedPoints
    virtual SVGElement& svg_animated_points_element() override { return *this; }

    Vector<Gfx::FloatPoint> m_points;
};

}

namespace Web::DOM {

template<>
inline bool Node::fast_is<SVG::SVGPolygonElement>() const { return is_svg_polygon_element(); }

}