summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/IntersectionObserver
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-01-10 06:28:20 -0500
committerAndreas Kling <kling@serenityos.org>2023-01-10 16:08:14 +0100
commit834202aeb9a47c544ab4e61deb813de50bc03946 (patch)
treec120e9231fa5451b527131f6e423fac2645253bb /Userland/Libraries/LibWeb/IntersectionObserver
parent7bd8fd000f3f8e92ff632be2370a279ac2309250 (diff)
downloadserenity-834202aeb9a47c544ab4e61deb813de50bc03946.zip
LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created.
Diffstat (limited to 'Userland/Libraries/LibWeb/IntersectionObserver')
-rw-r--r--Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp7
-rw-r--r--Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp
index ec4522deeb..e14bf17609 100644
--- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp
+++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp
@@ -23,11 +23,16 @@ JS::NonnullGCPtr<IntersectionObserver> IntersectionObserver::construct_impl(JS::
IntersectionObserver::IntersectionObserver(JS::Realm& realm)
: PlatformObject(realm)
{
- set_prototype(&Bindings::cached_web_prototype(realm, "IntersectionObserver"));
}
IntersectionObserver::~IntersectionObserver() = default;
+void IntersectionObserver::initialize(JS::Realm& realm)
+{
+ Base::initialize(realm);
+ set_prototype(&Bindings::ensure_web_prototype<Bindings::IntersectionObserverPrototype>(realm, "IntersectionObserver"));
+}
+
// https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe
void IntersectionObserver::observe(DOM::Element& target)
{
diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h
index 82b73a443f..326385ed1e 100644
--- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h
+++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h
@@ -32,6 +32,8 @@ public:
private:
explicit IntersectionObserver(JS::Realm&);
+
+ virtual void initialize(JS::Realm&) override;
};
}