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/Fetch | |
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/Fetch')
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Headers.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Headers.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/HeadersIterator.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Request.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Request.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Response.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Response.h | 1 |
8 files changed, 28 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Headers.cpp index 759dac9596..7db1bb3691 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Headers.cpp @@ -33,11 +33,16 @@ Headers::Headers(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::HeaderList> : PlatformObject(realm) , m_header_list(header_list) { - set_prototype(&Bindings::cached_web_prototype(realm, "Headers")); } Headers::~Headers() = default; +void Headers::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersPrototype>(realm, "Headers")); +} + void Headers::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.h b/Userland/Libraries/LibWeb/Fetch/Headers.h index 5a905240ed..2a9b6b5474 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.h +++ b/Userland/Libraries/LibWeb/Fetch/Headers.h @@ -60,6 +60,7 @@ private: Headers(JS::Realm&, JS::NonnullGCPtr<Infrastructure::HeaderList>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; WebIDL::ExceptionOr<bool> validate(Infrastructure::Header const&) const; diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index 342f290c1e..9a1f682dfa 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -33,11 +33,16 @@ HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKin , m_headers(headers) , m_iteration_kind(iteration_kind) { - set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersIteratorPrototype>(headers.realm(), "HeadersIterator")); } HeadersIterator::~HeadersIterator() = default; +void HeadersIterator::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersIteratorPrototype>(realm, "HeadersIterator")); +} + void HeadersIterator::visit_edges(JS::Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h index a6a8c25ee1..68771b4134 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h @@ -22,6 +22,7 @@ public: JS::ThrowCompletionOr<JS::Object*> next(); private: + virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; HeadersIterator(Headers const&, JS::Object::PropertyKind iteration_kind); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index 47b7a0fc22..bb46a039c5 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -25,11 +25,16 @@ Request::Request(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::Request> req : PlatformObject(realm) , m_request(request) { - set_prototype(&Bindings::cached_web_prototype(realm, "Request")); } Request::~Request() = default; +void Request::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::RequestPrototype>(realm, "Request")); +} + void Request::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.h b/Userland/Libraries/LibWeb/Fetch/Request.h index c7d17f24e5..1a4ff6d914 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.h +++ b/Userland/Libraries/LibWeb/Fetch/Request.h @@ -98,6 +98,7 @@ public: private: Request(JS::Realm&, JS::NonnullGCPtr<Infrastructure::Request>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://fetch.spec.whatwg.org/#concept-request-request diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 7a3b53b9d4..92bf6188e4 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -22,11 +22,16 @@ Response::Response(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::Response> : PlatformObject(realm) , m_response(response) { - set_prototype(&Bindings::cached_web_prototype(realm, "Response")); } Response::~Response() = default; +void Response::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype<Bindings::ResponsePrototype>(realm, "Response")); +} + void Response::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); diff --git a/Userland/Libraries/LibWeb/Fetch/Response.h b/Userland/Libraries/LibWeb/Fetch/Response.h index 4adb0afbda..7487911108 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.h +++ b/Userland/Libraries/LibWeb/Fetch/Response.h @@ -62,6 +62,7 @@ public: private: Response(JS::Realm&, JS::NonnullGCPtr<Infrastructure::Response>); + virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::ExceptionOr<void> initialize_response(ResponseInit const&, Optional<Infrastructure::BodyWithType> const&); |