summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp')
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp
index 3822a66689..eeefaac8a8 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp
@@ -7,6 +7,8 @@
#include "SVGRectElement.h"
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/AttributeParser.h>
+#include <LibWeb/SVG/SVGAnimatedLength.h>
+#include <LibWeb/SVG/SVGLength.h>
namespace Web::SVG {
@@ -150,4 +152,64 @@ Gfx::FloatPoint SVGRectElement::calculate_used_corner_radius_values()
return Gfx::FloatPoint { rx, ry };
}
+// https://www.w3.org/TR/SVG11/shapes.html#RectElementXAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGRectElement::x() 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_x.value_or(0));
+ auto anim_length = SVGLength::create(0, m_x.value_or(0));
+ return SVGAnimatedLength::create(move(base_length), move(anim_length));
+}
+
+// https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGRectElement::y() 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_y.value_or(0));
+ auto anim_length = SVGLength::create(0, m_y.value_or(0));
+ return SVGAnimatedLength::create(move(base_length), move(anim_length));
+}
+
+// https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGRectElement::width() 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_width.value_or(0));
+ auto anim_length = SVGLength::create(0, m_width.value_or(0));
+ return SVGAnimatedLength::create(move(base_length), move(anim_length));
+}
+
+// https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGRectElement::height() 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_height.value_or(0));
+ auto anim_length = SVGLength::create(0, m_height.value_or(0));
+ return SVGAnimatedLength::create(move(base_length), move(anim_length));
+}
+
+// https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGRectElement::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#RectElementRYAttribute
+NonnullRefPtr<SVGAnimatedLength> SVGRectElement::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));
+}
+
}