LibWeb: Remove unecessary dependence on Window from SVG classes

These classes only needed Window to get at its realm. Pass a realm
directly to construct SCG classes.
This commit is contained in:
Andrew Kaster 2022-09-25 18:04:39 -06:00 committed by Linus Groh
parent 62a8c26b73
commit 320dddde6a
Notes: sideshowbarker 2024-07-17 07:19:27 +09:00
20 changed files with 87 additions and 93 deletions

View file

@ -15,11 +15,6 @@ JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x,
return *realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w);
}
JS::NonnullGCPtr<DOMPoint> DOMPoint::create_with_global_object(HTML::Window& window, double x, double y, double z, double w)
{
return construct_impl(window.realm(), x, y, z, w);
}
DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
: DOMPointReadOnly(realm, x, y, z, w)
{

View file

@ -16,7 +16,6 @@ class DOMPoint final : public DOMPointReadOnly {
public:
static JS::NonnullGCPtr<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 0);
static JS::NonnullGCPtr<DOMPoint> create_with_global_object(HTML::Window&, double x = 0, double y = 0, double z = 0, double w = 0);
virtual ~DOMPoint() override;

View file

@ -4,22 +4,22 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/SVG/SVGAnimatedLength.h>
namespace Web::SVG {
JS::NonnullGCPtr<SVGAnimatedLength> SVGAnimatedLength::create(HTML::Window& window, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
JS::NonnullGCPtr<SVGAnimatedLength> SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
{
return *window.heap().allocate<SVGAnimatedLength>(window.realm(), window, move(base_val), move(anim_val));
return *realm.heap().allocate<SVGAnimatedLength>(realm, realm, move(base_val), move(anim_val));
}
SVGAnimatedLength::SVGAnimatedLength(HTML::Window& window, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
: PlatformObject(window.realm())
SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
: PlatformObject(realm)
, m_base_val(move(base_val))
, m_anim_val(move(anim_val))
{
set_prototype(&window.cached_web_prototype("SVGAnimatedLength"));
set_prototype(&Bindings::cached_web_prototype(realm, "SVGAnimatedLength"));
// 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());

View file

@ -16,14 +16,14 @@ class SVGAnimatedLength final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(SVGAnimatedLength, Bindings::PlatformObject);
public:
static JS::NonnullGCPtr<SVGAnimatedLength> create(HTML::Window&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
static JS::NonnullGCPtr<SVGAnimatedLength> create(JS::Realm&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
virtual ~SVGAnimatedLength() override;
JS::NonnullGCPtr<SVGLength> base_val() const { return m_base_val; }
JS::NonnullGCPtr<SVGLength> anim_val() const { return m_anim_val; }
private:
SVGAnimatedLength(HTML::Window&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
SVGAnimatedLength(JS::Realm&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val);
virtual void visit_edges(Cell::Visitor&) override;

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGCircleElement.h>
@ -14,7 +14,7 @@ namespace Web::SVG {
SVGCircleElement::SVGCircleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGCircleElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGCircleElement"));
}
void SVGCircleElement::parse_attribute(FlyString const& name, String const& value)
@ -77,9 +77,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> 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(window(), 0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_center_x.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCYAttribute
@ -87,9 +87,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> 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(window(), 0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_center_y.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute
@ -97,9 +97,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> 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(window(), 0, m_radius.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_radius.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
}

View file

@ -12,7 +12,7 @@ namespace Web::SVG {
SVGClipPathElement::SVGClipPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGElement(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("SVGClipPathElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGClipPathElement"));
}
SVGClipPathElement::~SVGClipPathElement()

View file

@ -12,7 +12,7 @@ namespace Web::SVG {
SVGDefsElement::SVGDefsElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGraphicsElement(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("SVGDefsElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGDefsElement"));
}
SVGDefsElement::~SVGDefsElement()

View file

@ -13,7 +13,7 @@ SVGElement::SVGElement(DOM::Document& document, DOM::QualifiedName qualified_nam
: Element(document, move(qualified_name))
, m_dataset(HTML::DOMStringMap::create(*this))
{
set_prototype(&window().cached_web_prototype("SVGElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGElement"));
}
void SVGElement::visit_edges(Cell::Visitor& visitor)

View file

@ -14,7 +14,7 @@ namespace Web::SVG {
SVGEllipseElement::SVGEllipseElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGEllipseElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGEllipseElement"));
}
void SVGEllipseElement::parse_attribute(FlyString const& name, String const& value)
@ -82,9 +82,9 @@ JS::NonnullGCPtr<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(window(), 0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_center_x.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCYAttribute
@ -92,9 +92,9 @@ JS::NonnullGCPtr<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(window(), 0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_center_y.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRXAttribute
@ -102,9 +102,9 @@ JS::NonnullGCPtr<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(window(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute
@ -112,9 +112,9 @@ JS::NonnullGCPtr<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(window(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Layout/SVGGeometryBox.h>
#include <LibWeb/SVG/SVGGeometryElement.h>
@ -13,7 +13,7 @@ namespace Web::SVG {
SVGGeometryElement::SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGraphicsElement(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("SVGGeometryElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGGeometryElement"));
}
RefPtr<Layout::Node> SVGGeometryElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
@ -29,7 +29,7 @@ float SVGGeometryElement::get_total_length()
JS::NonnullGCPtr<Geometry::DOMPoint> SVGGeometryElement::get_point_at_length(float distance)
{
(void)distance;
return Geometry::DOMPoint::create_with_global_object(window(), 0, 0, 0, 0);
return Geometry::DOMPoint::construct_impl(realm(), 0, 0, 0, 0);
}
}

View file

@ -16,7 +16,7 @@ namespace Web::SVG {
SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGElement(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("SVGGraphicsElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGGraphicsElement"));
}
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const

View file

@ -4,22 +4,22 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/SVG/SVGLength.h>
namespace Web::SVG {
JS::NonnullGCPtr<SVGLength> SVGLength::create(HTML::Window& window, u8 unit_type, float value)
JS::NonnullGCPtr<SVGLength> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
{
return *window.heap().allocate<SVGLength>(window.realm(), window, unit_type, value);
return *realm.heap().allocate<SVGLength>(realm, realm, unit_type, value);
}
SVGLength::SVGLength(HTML::Window& window, u8 unit_type, float value)
: PlatformObject(window.realm())
SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
: PlatformObject(realm)
, m_unit_type(unit_type)
, m_value(value)
{
set_prototype(&window.cached_web_prototype("SVGLength"));
set_prototype(&Bindings::cached_web_prototype(realm, "SVGLength"));
}
SVGLength::~SVGLength() = default;

View file

@ -16,7 +16,7 @@ class SVGLength : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject);
public:
static JS::NonnullGCPtr<SVGLength> create(HTML::Window&, u8 unit_type, float value);
static JS::NonnullGCPtr<SVGLength> create(JS::Realm&, u8 unit_type, float value);
virtual ~SVGLength() override;
u8 unit_type() const { return m_unit_type; }
@ -25,7 +25,7 @@ public:
WebIDL::ExceptionOr<void> set_value(float value);
private:
SVGLength(HTML::Window&, u8 unit_type, float value);
SVGLength(JS::Realm&, u8 unit_type, float value);
u8 m_unit_type { 0 };
float m_value { 0 };

View file

@ -14,7 +14,7 @@ namespace Web::SVG {
SVGLineElement::SVGLineElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGLineElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGLineElement"));
}
void SVGLineElement::parse_attribute(FlyString const& name, String const& value)
@ -62,9 +62,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::x1() 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(window(), 0, m_x1.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_x1.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_x1.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#LineElementY1Attribute
@ -72,9 +72,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::y1() 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(window(), 0, m_y1.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_y1.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_y1.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#LineElementX2Attribute
@ -82,9 +82,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::x2() 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(window(), 0, m_x2.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_x2.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_x2.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#LineElementY2Attribute
@ -92,9 +92,9 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGLineElement::y2() 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(window(), 0, m_y2.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_y2.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_y2.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
}

View file

@ -86,7 +86,7 @@ namespace Web::SVG {
SVGPathElement::SVGPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("SVGPathElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPathElement"));
}
void SVGPathElement::parse_attribute(FlyString const& name, String const& value)

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGPolygonElement.h>
@ -14,7 +14,7 @@ namespace Web::SVG {
SVGPolygonElement::SVGPolygonElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGPolygonElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPolygonElement"));
}
void SVGPolygonElement::parse_attribute(FlyString const& name, String const& value)

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGPolylineElement.h>
@ -14,7 +14,7 @@ namespace Web::SVG {
SVGPolylineElement::SVGPolylineElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGPolylineElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGPolylineElement"));
}
void SVGPolylineElement::parse_attribute(FlyString const& name, String const& value)

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGAnimatedLength.h>
@ -16,7 +16,7 @@ namespace Web::SVG {
SVGRectElement::SVGRectElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGeometryElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGRectElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGRectElement"));
}
void SVGRectElement::parse_attribute(FlyString const& name, String const& value)
@ -159,9 +159,9 @@ JS::NonnullGCPtr<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(window(), 0, m_x.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_x.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute
@ -169,9 +169,9 @@ JS::NonnullGCPtr<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(window(), 0, m_y.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_y.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute
@ -179,9 +179,9 @@ JS::NonnullGCPtr<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(window(), 0, m_width.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_width.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute
@ -189,9 +189,9 @@ JS::NonnullGCPtr<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(window(), 0, m_height.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_height.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute
@ -199,9 +199,9 @@ JS::NonnullGCPtr<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(window(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRYAttribute
@ -209,9 +209,9 @@ JS::NonnullGCPtr<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(window(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(window(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(window(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
}
}

View file

@ -20,7 +20,7 @@ namespace Web::SVG {
SVGSVGElement::SVGSVGElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGraphicsElement(document, qualified_name)
{
set_prototype(&window().cached_web_prototype("SVGSVGElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGSVGElement"));
}
RefPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)

View file

@ -13,7 +13,7 @@ namespace Web::SVG {
SVGTextContentElement::SVGTextContentElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: SVGGraphicsElement(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("SVGTextContentElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "SVGTextContentElement"));
}
// https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars