1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 19:37:34 +00:00

LibWeb: Make SVGLength and SVGAnimatedLength GC-allocated

This commit is contained in:
Andreas Kling 2022-09-02 14:04:59 +02:00
parent 16fbb91aa1
commit 3905d54a9c
14 changed files with 139 additions and 126 deletions

View file

@ -473,8 +473,6 @@ class ResizeObserverWrapper;
class SelectionWrapper; class SelectionWrapper;
class StorageWrapper; class StorageWrapper;
class SubtleCryptoWrapper; class SubtleCryptoWrapper;
class SVGAnimatedLengthWrapper;
class SVGLengthWrapper;
class TextDecoderWrapper; class TextDecoderWrapper;
class TextEncoderWrapper; class TextEncoderWrapper;
class TextMetricsWrapper; class TextMetricsWrapper;

View file

@ -4,21 +4,35 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/Bindings/SVGAnimatedLengthPrototype.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/SVG/SVGAnimatedLength.h> #include <LibWeb/SVG/SVGAnimatedLength.h>
namespace Web::SVG { namespace Web::SVG {
NonnullRefPtr<SVGAnimatedLength> SVGAnimatedLength::create(NonnullRefPtr<SVGLength> base_val, NonnullRefPtr<SVGLength> anim_val) JS::NonnullGCPtr<SVGAnimatedLength> SVGAnimatedLength::create(HTML::Window& window, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
{ {
return adopt_ref(*new SVGAnimatedLength(move(base_val), move(anim_val))); return *window.heap().allocate<SVGAnimatedLength>(window.realm(), window, move(base_val), move(anim_val));
} }
SVGAnimatedLength::SVGAnimatedLength(NonnullRefPtr<SVGLength> base_val, NonnullRefPtr<SVGLength> anim_val) SVGAnimatedLength::SVGAnimatedLength(HTML::Window& window, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
: m_base_val(move(base_val)) : PlatformObject(window.realm())
, m_base_val(move(base_val))
, m_anim_val(move(anim_val)) , m_anim_val(move(anim_val))
{ {
set_prototype(&window.ensure_web_prototype<Bindings::SVGAnimatedLengthPrototype>("SVGAnimatedLength"));
// The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated. // The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated.
VERIFY(m_base_val.ptr() != m_anim_val.ptr()); VERIFY(m_base_val.ptr() != m_anim_val.ptr());
} }
SVGAnimatedLength::~SVGAnimatedLength() = default;
void SVGAnimatedLength::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_base_val.ptr());
visitor.visit(m_anim_val.ptr());
}
} }

View file

@ -6,32 +6,31 @@
#pragma once #pragma once
#include <AK/RefCounted.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/SVG/SVGLength.h> #include <LibWeb/SVG/SVGLength.h>
namespace Web::SVG { namespace Web::SVG {
// https://www.w3.org/TR/SVG11/types.html#InterfaceSVGAnimatedLength // https://www.w3.org/TR/SVG11/types.html#InterfaceSVGAnimatedLength
class SVGAnimatedLength class SVGAnimatedLength final : public Bindings::PlatformObject {
: public RefCounted<SVGAnimatedLength> WEB_PLATFORM_OBJECT(SVGAnimatedLength, Bindings::PlatformObject);
, public Bindings::Wrappable
, public Weakable<SVGAnimatedLength> {
public: public:
using WrapperType = Bindings::SVGAnimatedLengthWrapper; static JS::NonnullGCPtr<SVGAnimatedLength> create(HTML::Window&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
virtual ~SVGAnimatedLength() override;
static NonnullRefPtr<SVGAnimatedLength> create(NonnullRefPtr<SVGLength> base_val, NonnullRefPtr<SVGLength> anim_val); JS::NonnullGCPtr<SVGLength> base_val() const { return m_base_val; }
virtual ~SVGAnimatedLength() = default; JS::NonnullGCPtr<SVGLength> anim_val() const { return m_anim_val; }
NonnullRefPtr<SVGLength> const& base_val() const { return m_base_val; }
NonnullRefPtr<SVGLength> const& anim_val() const { return m_anim_val; }
private: private:
SVGAnimatedLength(NonnullRefPtr<SVGLength> base_val, NonnullRefPtr<SVGLength> anim_val); SVGAnimatedLength(HTML::Window&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
NonnullRefPtr<SVGLength> m_base_val; virtual void visit_edges(Cell::Visitor&) override;
NonnullRefPtr<SVGLength> m_anim_val;
JS::NonnullGCPtr<SVGLength> m_base_val;
JS::NonnullGCPtr<SVGLength> m_anim_val;
}; };
} }
WRAPPER_HACK(SVGAnimatedLength, Web::SVG)

View file

@ -74,33 +74,33 @@ Gfx::Path& SVGCircleElement::get_path()
} }
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCXAttribute // https://www.w3.org/TR/SVG11/shapes.html#CircleElementCXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGCircleElement::cx() const JS::NonnullGCPtr<SVGAnimatedLength> SVGCircleElement::cx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_center_x.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(0, m_center_x.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_center_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCYAttribute // https://www.w3.org/TR/SVG11/shapes.html#CircleElementCYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGCircleElement::cy() const JS::NonnullGCPtr<SVGAnimatedLength> SVGCircleElement::cy() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_center_y.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(0, m_center_y.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_center_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute // https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute
NonnullRefPtr<SVGAnimatedLength> SVGCircleElement::r() const JS::NonnullGCPtr<SVGAnimatedLength> SVGCircleElement::r() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_radius.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_radius.value_or(0));
auto anim_length = SVGLength::create(0, m_radius.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_radius.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
} }

View file

@ -21,9 +21,9 @@ public:
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;
NonnullRefPtr<SVGAnimatedLength> cx() const; JS::NonnullGCPtr<SVGAnimatedLength> cx() const;
NonnullRefPtr<SVGAnimatedLength> cy() const; JS::NonnullGCPtr<SVGAnimatedLength> cy() const;
NonnullRefPtr<SVGAnimatedLength> r() const; JS::NonnullGCPtr<SVGAnimatedLength> r() const;
private: private:
SVGCircleElement(DOM::Document&, DOM::QualifiedName); SVGCircleElement(DOM::Document&, DOM::QualifiedName);

View file

@ -79,43 +79,43 @@ Gfx::Path& SVGEllipseElement::get_path()
} }
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCXAttribute // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::cx() const JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::cx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_center_x.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(0, m_center_x.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_center_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCYAttribute // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::cy() const JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::cy() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_center_y.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(0, m_center_y.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_center_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRXAttribute // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::rx() const JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::rx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_radius_x.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(0, m_radius_x.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::ry() const JS::NonnullGCPtr<SVGAnimatedLength> SVGEllipseElement::ry() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_radius_y.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(0, m_radius_y.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
} }

View file

@ -21,10 +21,10 @@ public:
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;
NonnullRefPtr<SVGAnimatedLength> cx() const; JS::NonnullGCPtr<SVGAnimatedLength> cx() const;
NonnullRefPtr<SVGAnimatedLength> cy() const; JS::NonnullGCPtr<SVGAnimatedLength> cy() const;
NonnullRefPtr<SVGAnimatedLength> rx() const; JS::NonnullGCPtr<SVGAnimatedLength> rx() const;
NonnullRefPtr<SVGAnimatedLength> ry() const; JS::NonnullGCPtr<SVGAnimatedLength> ry() const;
private: private:
SVGEllipseElement(DOM::Document&, DOM::QualifiedName); SVGEllipseElement(DOM::Document&, DOM::QualifiedName);

View file

@ -4,21 +4,27 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/Bindings/SVGLengthPrototype.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/SVG/SVGLength.h> #include <LibWeb/SVG/SVGLength.h>
namespace Web::SVG { namespace Web::SVG {
NonnullRefPtr<SVGLength> SVGLength::create(u8 unit_type, float value) JS::NonnullGCPtr<SVGLength> SVGLength::create(HTML::Window& window, u8 unit_type, float value)
{ {
return adopt_ref(*new SVGLength(unit_type, value)); return *window.heap().allocate<SVGLength>(window.realm(), window, unit_type, value);
} }
SVGLength::SVGLength(u8 unit_type, float value) SVGLength::SVGLength(HTML::Window& window, u8 unit_type, float value)
: m_unit_type(unit_type) : PlatformObject(window.realm())
, m_unit_type(unit_type)
, m_value(value) , m_value(value)
{ {
set_prototype(&window.ensure_web_prototype<Bindings::SVGLengthPrototype>("SVGLength"));
} }
SVGLength::~SVGLength() = default;
// https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value // https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
DOM::ExceptionOr<void> SVGLength::set_value(float value) DOM::ExceptionOr<void> SVGLength::set_value(float value)
{ {

View file

@ -6,24 +6,18 @@
#pragma once #pragma once
#include <AK/RefCounted.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <AK/Types.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/DOM/ExceptionOr.h>
namespace Web::SVG { namespace Web::SVG {
// https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength // https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength
class SVGLength class SVGLength : public Bindings::PlatformObject {
: public RefCounted<SVGLength> WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject);
, public Bindings::Wrappable
, public Weakable<SVGLength> {
public:
using WrapperType = Bindings::SVGLengthWrapper;
static NonnullRefPtr<SVGLength> create(u8 unit_type, float value); public:
virtual ~SVGLength() = default; static JS::NonnullGCPtr<SVGLength> create(HTML::Window&, u8 unit_type, float value);
virtual ~SVGLength() override;
u8 unit_type() const { return m_unit_type; } u8 unit_type() const { return m_unit_type; }
@ -31,10 +25,12 @@ public:
DOM::ExceptionOr<void> set_value(float value); DOM::ExceptionOr<void> set_value(float value);
private: private:
SVGLength(u8 unit_type, float value); SVGLength(HTML::Window&, u8 unit_type, float value);
u8 m_unit_type { 0 }; u8 m_unit_type { 0 };
float m_value { 0 }; float m_value { 0 };
}; };
} }
WRAPPER_HACK(SVGLength, Web::SVG)

View file

@ -59,43 +59,43 @@ Gfx::Path& SVGLineElement::get_path()
} }
// https://www.w3.org/TR/SVG11/shapes.html#LineElementX1Attribute // https://www.w3.org/TR/SVG11/shapes.html#LineElementX1Attribute
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::x1() const JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::x1() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_x1.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_x1.value_or(0));
auto anim_length = SVGLength::create(0, m_x1.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_x1.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#LineElementY1Attribute // https://www.w3.org/TR/SVG11/shapes.html#LineElementY1Attribute
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::y1() const JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::y1() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_y1.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_y1.value_or(0));
auto anim_length = SVGLength::create(0, m_y1.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_y1.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#LineElementX2Attribute // https://www.w3.org/TR/SVG11/shapes.html#LineElementX2Attribute
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::x2() const JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::x2() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_x2.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_x2.value_or(0));
auto anim_length = SVGLength::create(0, m_x2.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_x2.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#LineElementY2Attribute // https://www.w3.org/TR/SVG11/shapes.html#LineElementY2Attribute
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::y2() const JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::y2() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_y2.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_y2.value_or(0));
auto anim_length = SVGLength::create(0, m_y2.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_y2.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
} }

View file

@ -21,10 +21,10 @@ public:
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;
NonnullRefPtr<SVGAnimatedLength> x1() const; JS::NonnullGCPtr<SVGAnimatedLength> x1() const;
NonnullRefPtr<SVGAnimatedLength> y1() const; JS::NonnullGCPtr<SVGAnimatedLength> y1() const;
NonnullRefPtr<SVGAnimatedLength> x2() const; JS::NonnullGCPtr<SVGAnimatedLength> x2() const;
NonnullRefPtr<SVGAnimatedLength> y2() const; JS::NonnullGCPtr<SVGAnimatedLength> y2() const;
private: private:
SVGLineElement(DOM::Document&, DOM::QualifiedName); SVGLineElement(DOM::Document&, DOM::QualifiedName);

View file

@ -156,63 +156,63 @@ Gfx::FloatPoint SVGRectElement::calculate_used_corner_radius_values()
} }
// https://www.w3.org/TR/SVG11/shapes.html#RectElementXAttribute // https://www.w3.org/TR/SVG11/shapes.html#RectElementXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGRectElement::x() const JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::x() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_x.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_x.value_or(0));
auto anim_length = SVGLength::create(0, m_x.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute // https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGRectElement::y() const JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::y() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_y.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_y.value_or(0));
auto anim_length = SVGLength::create(0, m_y.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute // https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute
NonnullRefPtr<SVGAnimatedLength> SVGRectElement::width() const JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::width() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_width.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_width.value_or(0));
auto anim_length = SVGLength::create(0, m_width.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_width.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute // https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute
NonnullRefPtr<SVGAnimatedLength> SVGRectElement::height() const JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::height() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_height.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_height.value_or(0));
auto anim_length = SVGLength::create(0, m_height.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_height.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute // https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGRectElement::rx() const JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::rx() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_radius_x.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(0, m_radius_x.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRYAttribute // https://www.w3.org/TR/SVG11/shapes.html#RectElementRYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGRectElement::ry() const JS::NonnullGCPtr<SVGAnimatedLength> SVGRectElement::ry() const
{ {
// FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported. // FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(0, m_radius_y.value_or(0)); auto base_length = SVGLength::create(window(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(0, m_radius_y.value_or(0)); auto anim_length = SVGLength::create(window(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length)); return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
} }
} }

View file

@ -21,12 +21,12 @@ public:
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;
NonnullRefPtr<SVGAnimatedLength> x() const; JS::NonnullGCPtr<SVGAnimatedLength> x() const;
NonnullRefPtr<SVGAnimatedLength> y() const; JS::NonnullGCPtr<SVGAnimatedLength> y() const;
NonnullRefPtr<SVGAnimatedLength> width() const; JS::NonnullGCPtr<SVGAnimatedLength> width() const;
NonnullRefPtr<SVGAnimatedLength> height() const; JS::NonnullGCPtr<SVGAnimatedLength> height() const;
NonnullRefPtr<SVGAnimatedLength> rx() const; JS::NonnullGCPtr<SVGAnimatedLength> rx() const;
NonnullRefPtr<SVGAnimatedLength> ry() const; JS::NonnullGCPtr<SVGAnimatedLength> ry() const;
private: private:
SVGRectElement(DOM::Document&, DOM::QualifiedName); SVGRectElement(DOM::Document&, DOM::QualifiedName);

View file

@ -159,7 +159,7 @@ libweb_js_wrapper(IntersectionObserver/IntersectionObserver)
libweb_js_wrapper(NavigationTiming/PerformanceTiming NO_INSTANCE) libweb_js_wrapper(NavigationTiming/PerformanceTiming NO_INSTANCE)
libweb_js_wrapper(RequestIdleCallback/IdleDeadline) libweb_js_wrapper(RequestIdleCallback/IdleDeadline)
libweb_js_wrapper(ResizeObserver/ResizeObserver) libweb_js_wrapper(ResizeObserver/ResizeObserver)
libweb_js_wrapper(SVG/SVGAnimatedLength) libweb_js_wrapper(SVG/SVGAnimatedLength NO_INSTANCE)
libweb_js_wrapper(SVG/SVGClipPathElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGClipPathElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGDefsElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGDefsElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGElement NO_INSTANCE)
@ -167,7 +167,7 @@ libweb_js_wrapper(SVG/SVGGeometryElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGGraphicsElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGGraphicsElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGCircleElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGCircleElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGEllipseElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGEllipseElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGLength) libweb_js_wrapper(SVG/SVGLength NO_INSTANCE)
libweb_js_wrapper(SVG/SVGLineElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGLineElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGPathElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGPathElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGPolygonElement NO_INSTANCE) libweb_js_wrapper(SVG/SVGPolygonElement NO_INSTANCE)