diff options
author | Andrew Kaster <akaster@serenityos.org> | 2022-09-25 18:04:39 -0600 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-01 21:05:32 +0100 |
commit | 320dddde6a382c16a73020e065076909ad61a300 (patch) | |
tree | 09aac0172d27458f752b6c99e38ad022c98e68b3 | |
parent | 62a8c26b73e874005c94969da9605fb9fd421b3c (diff) | |
download | serenity-320dddde6a382c16a73020e065076909ad61a300.zip |
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.
20 files changed, 87 insertions, 93 deletions
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index 57d57cd903..7ebbfefb22 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -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) { diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h index b4ade6d2dd..aba7ba31ba 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h @@ -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; diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index 3641755289..cb338dd951 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -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()); diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h index 59f709996a..452d8b65e7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h @@ -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; diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index 9f49512c2b..158c21862d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -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)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index d83755c259..fa09f2ba05 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -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() diff --git a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp index 882084e5e8..ba23a7605c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp @@ -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() diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index 328d9e6a7f..d377e54900 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -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) diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index 83eead0c8f..47de2e3e99 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -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)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 8485f50883..2c56eadce2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -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); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index 68234dc4cb..501d7a8ec7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -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 diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp index cc9df8c642..6919433e10 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -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; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.h b/Userland/Libraries/LibWeb/SVG/SVGLength.h index fac3a8cf0a..afd248ad11 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.h @@ -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 }; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp index c165cd31ef..127c0d3e9d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -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)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp index 78fec14251..12e9a07155 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -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) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp index 00d2644b6d..05d9004d46 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp @@ -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) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp index 38ff8c81c9..3447f99e74 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp @@ -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) diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp index d3930d331b..f2c8c4baaa 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -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)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 00574762f1..640b4d7edc 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -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) diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp index 948377ef3f..c5eb5e7155 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp @@ -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 |