diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index b4d977c356..f5fc02ecd3 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -2841,6 +2841,7 @@ using namespace Web::NavigationTiming; using namespace Web::RequestIdleCallback; using namespace Web::ResizeObserver; using namespace Web::Selection; +using namespace Web::SVG; using namespace Web::URL; using namespace Web::WebSockets; using namespace Web::XHR; 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 #include +#include +#include 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 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 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 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 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 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 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)); +} + } diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h index e180deca57..22f6726b7f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h @@ -22,6 +22,13 @@ public: virtual Gfx::Path& get_path() override; + NonnullRefPtr x() const; + NonnullRefPtr y() const; + NonnullRefPtr width() const; + NonnullRefPtr height() const; + NonnullRefPtr rx() const; + NonnullRefPtr ry() const; + private: Gfx::FloatPoint calculate_used_corner_radius_values(); diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.idl b/Userland/Libraries/LibWeb/SVG/SVGRectElement.idl index 801742b95d..be89d154fd 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.idl +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.idl @@ -1,11 +1,12 @@ +#import #import [Exposed=Window] interface SVGRectElement : SVGGeometryElement { - // [SameObject] readonly attribute SVGAnimatedLength x; - // [SameObject] readonly attribute SVGAnimatedLength y; - // [SameObject] readonly attribute SVGAnimatedLength width; - // [SameObject] readonly attribute SVGAnimatedLength height; - // [SameObject] readonly attribute SVGAnimatedLength rx; - // [SameObject] readonly attribute SVGAnimatedLength ry; + [SameObject] readonly attribute SVGAnimatedLength x; + [SameObject] readonly attribute SVGAnimatedLength y; + [SameObject] readonly attribute SVGAnimatedLength width; + [SameObject] readonly attribute SVGAnimatedLength height; + [SameObject] readonly attribute SVGAnimatedLength rx; + [SameObject] readonly attribute SVGAnimatedLength ry; };