summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-03-22 16:57:00 +0000
committerAndreas Kling <kling@serenityos.org>2022-03-22 22:33:17 +0100
commitccee8953d0c61b6497f00d96fa233dfa218d738d (patch)
treece579bc8e01776a23c93bfe59c122c2d3256089a /Userland/Libraries
parent1a3d6c68ef4978e3e471a8592a1f45f46bcd4f90 (diff)
downloadserenity-ccee8953d0c61b6497f00d96fa233dfa218d738d.zip
LibWeb: Expose SVGEllipseElement attributes to JS
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp40
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h6
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGEllipseElement.idl9
3 files changed, 51 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp
index a989f5c132..13fe18332c 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp
@@ -75,4 +75,44 @@ Gfx::Path& SVGEllipseElement::get_path()
return m_path.value();
}
+// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCXAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::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#EllipseElementCYAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::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#EllipseElementRXAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::rx() 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_x.value_or(0));
+ auto anim_length = SVGLength::create(0, m_radius_x.value_or(0));
+ return SVGAnimatedLength::create(move(base_length), move(anim_length));
+}
+
+// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::ry() 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_y.value_or(0));
+ auto anim_length = SVGLength::create(0, m_radius_y.value_or(0));
+ return SVGAnimatedLength::create(move(base_length), move(anim_length));
+}
+
}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h
index dc415967fb..6975476a07 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h
+++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h
@@ -6,6 +6,7 @@
#pragma once
+#include <LibWeb/SVG/SVGAnimatedLength.h>
#include <LibWeb/SVG/SVGGeometryElement.h>
namespace Web::SVG {
@@ -21,6 +22,11 @@ public:
virtual Gfx::Path& get_path() override;
+ NonnullRefPtr<SVGAnimatedLength> cx() const;
+ NonnullRefPtr<SVGAnimatedLength> cy() const;
+ NonnullRefPtr<SVGAnimatedLength> rx() const;
+ NonnullRefPtr<SVGAnimatedLength> ry() const;
+
private:
Optional<Gfx::Path> m_path;
diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.idl b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.idl
index 4fa0a60261..34015474b3 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.idl
+++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.idl
@@ -1,9 +1,10 @@
+#import <SVG/SVGAnimatedLength.idl>
#import <SVG/SVGGeometryElement.idl>
[Exposed=Window]
interface SVGEllipseElement : SVGGeometryElement {
- // [SameObject] readonly attribute SVGAnimatedLength cx;
- // [SameObject] readonly attribute SVGAnimatedLength cy;
- // [SameObject] readonly attribute SVGAnimatedLength rx;
- // [SameObject] readonly attribute SVGAnimatedLength ry;
+ [SameObject] readonly attribute SVGAnimatedLength cx;
+ [SameObject] readonly attribute SVGAnimatedLength cy;
+ [SameObject] readonly attribute SVGAnimatedLength rx;
+ [SameObject] readonly attribute SVGAnimatedLength ry;
};