diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-10 06:28:20 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-10 16:08:14 +0100 |
commit | 834202aeb9a47c544ab4e61deb813de50bc03946 (patch) | |
tree | c120e9231fa5451b527131f6e423fac2645253bb /Userland/Libraries/LibWeb/XHR | |
parent | 7bd8fd000f3f8e92ff632be2370a279ac2309250 (diff) | |
download | serenity-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/XHR')
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/ProgressEvent.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h | 1 |
4 files changed, 15 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp index d26f53cce2..f8332a2556 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp @@ -25,9 +25,14 @@ ProgressEvent::ProgressEvent(JS::Realm& realm, DeprecatedFlyString const& event_ , m_loaded(event_init.loaded) , m_total(event_init.total) { - set_prototype(&Bindings::cached_web_prototype(realm, "ProgressEvent")); } ProgressEvent::~ProgressEvent() = default; +void ProgressEvent::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ProgressEventPrototype>(realm, "ProgressEvent")); +} + } diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h index 3ef9daf643..abc7305fa9 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h @@ -35,6 +35,8 @@ public: private: ProgressEvent(JS::Realm&, DeprecatedFlyString const& event_name, ProgressEventInit const& event_init); + virtual void initialize(JS::Realm&) override; + bool m_length_computable { false }; u64 m_loaded { 0 }; u64 m_total { 0 }; diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 888a61ac5a..eda2f78fbe 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -55,11 +55,16 @@ XMLHttpRequest::XMLHttpRequest(HTML::Window& window, Fetch::Infrastructure::Head , m_response_type(Bindings::XMLHttpRequestResponseType::Empty) { set_overrides_must_survive_garbage_collection(true); - set_prototype(&Bindings::cached_web_prototype(window.realm(), "XMLHttpRequest")); } XMLHttpRequest::~XMLHttpRequest() = default; +void XMLHttpRequest::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::XMLHttpRequestPrototype>(realm, "XMLHttpRequest")); +} + void XMLHttpRequest::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 8c5eb38fff..ca29cede33 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -72,6 +72,7 @@ public: void abort(); private: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual bool must_survive_garbage_collection() const override; |