diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index 5516d78e71..265d362541 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -70,4 +70,34 @@ Gfx::Path& SVGCircleElement::get_path() return m_path.value(); } +// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCXAttribute +NonnullRefPtr SVGCircleElement::cx() const +{ + // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). + // FIXME: Create a proper animated value when animations are supported. + auto base_length = SVGLength::create(0, m_center_x.value_or(0)); + auto anim_length = SVGLength::create(0, m_center_x.value_or(0)); + return SVGAnimatedLength::create(move(base_length), move(anim_length)); +} + +// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCYAttribute +NonnullRefPtr SVGCircleElement::cy() const +{ + // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). + // FIXME: Create a proper animated value when animations are supported. + auto base_length = SVGLength::create(0, m_center_y.value_or(0)); + auto anim_length = SVGLength::create(0, m_center_y.value_or(0)); + return SVGAnimatedLength::create(move(base_length), move(anim_length)); +} + +// https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute +NonnullRefPtr SVGCircleElement::r() const +{ + // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). + // FIXME: Create a proper animated value when animations are supported. + auto base_length = SVGLength::create(0, m_radius.value_or(0)); + auto anim_length = SVGLength::create(0, m_radius.value_or(0)); + return SVGAnimatedLength::create(move(base_length), move(anim_length)); +} + } diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h index d03820c5bc..4899a59cf6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace Web::SVG { @@ -21,6 +22,10 @@ public: virtual Gfx::Path& get_path() override; + NonnullRefPtr cx() const; + NonnullRefPtr cy() const; + NonnullRefPtr r() const; + private: Optional m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.idl b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.idl index 0e28614626..bb4f0a5178 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.idl +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.idl @@ -1,8 +1,9 @@ +#import #import [Exposed=Window] interface SVGCircleElement : SVGGeometryElement { - // [SameObject] readonly attribute SVGAnimatedLength cx; - // [SameObject] readonly attribute SVGAnimatedLength cy; - // [SameObject] readonly attribute SVGAnimatedLength r; + [SameObject] readonly attribute SVGAnimatedLength cx; + [SameObject] readonly attribute SVGAnimatedLength cy; + [SameObject] readonly attribute SVGAnimatedLength r; };