Skip to content

Truly independent web browser

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

#pragma once

#include <LibWeb/SVG/SVGGeometryElement.h>

namespace Web::SVG {

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

public:
    virtual ~SVGCircleElement() override = default;

    // AD-HOC: The spec states that the cx, cy and r IDL attributes reflect the respective computed values and their
    //         corresponding presentation attributes but other browsers reflect the attribute values instead - see
    //         https://github.com/w3c/svgwg/issues/1153

    // https://w3c.github.io/svgwg/svg2-draft/shapes.html#__svg__SVGCircleElement__cx
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(cx, Horizontal, SVGLengthValue::number(0));

    // https://w3c.github.io/svgwg/svg2-draft/shapes.html#__svg__SVGCircleElement__cy
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(cy, Vertical, SVGLengthValue::number(0));

    // https://w3c.github.io/svgwg/svg2-draft/shapes.html#__svg__SVGCircleElement__r
    REFLECT_ANIMATED_LENGTH_ATTRIBUTE(r, Unspecified, SVGLengthValue::number(0));

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

    SVGCircleElement(DOM::Document&, DOM::QualifiedName);
};

}

namespace Web::DOM {

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

}