From 0e47754ac82b3c9996732fc29dac9d2a1abed8ac Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 4 Sep 2022 16:55:50 +0200 Subject: LibWeb: Make LocationObject a PlatformObject --- Userland/Libraries/LibWeb/Bindings/LocationObject.cpp | 13 +++++++++++-- Userland/Libraries/LibWeb/Bindings/LocationObject.h | 17 ++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index a1091c9102..37d388e2cf 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -23,9 +23,18 @@ namespace Web::Bindings { // https://html.spec.whatwg.org/multipage/history.html#the-location-interface LocationObject::LocationObject(JS::Realm& realm) - : Object(verify_cast(realm.global_object()).cached_web_prototype("Location")) - , m_default_properties(heap()) + : PlatformObject(realm) { + set_prototype(&verify_cast(realm.global_object()).cached_web_prototype("Location")); +} + +LocationObject::~LocationObject() = default; + +void LocationObject::visit_edges(Cell::Visitor& visitor) +{ + Base::visit_edges(visitor); + for (auto& property : m_default_properties) + visitor.visit(property); } void LocationObject::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.h b/Userland/Libraries/LibWeb/Bindings/LocationObject.h index f48ee23114..6bb3716f25 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.h @@ -10,20 +10,18 @@ #include #include #include -#include #include +#include #include namespace Web { namespace Bindings { -class LocationObject final : public JS::Object { - JS_OBJECT(LocationObject, JS::Object); +class LocationObject final : public Bindings::PlatformObject { + JS_OBJECT(LocationObject, Bindings::PlatformObject); public: - explicit LocationObject(JS::Realm&); - virtual void initialize(JS::Realm&) override; - virtual ~LocationObject() override = default; + virtual ~LocationObject() override; virtual JS::ThrowCompletionOr internal_get_prototype_of() const override; virtual JS::ThrowCompletionOr internal_set_prototype_of(Object* prototype) override; @@ -40,6 +38,11 @@ public: CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; } private: + explicit LocationObject(JS::Realm&); + + virtual void initialize(JS::Realm&) override; + virtual void visit_edges(Cell::Visitor&) override; + DOM::Document const* relevant_document() const; AK::URL url() const; @@ -61,7 +64,7 @@ private: CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map; // [[DefaultProperties]], https://html.spec.whatwg.org/multipage/history.html#defaultproperties - JS::MarkedVector m_default_properties; + Vector m_default_properties; }; } -- cgit v1.2.3