mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:17:44 +00:00
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.
This commit is contained in:
parent
7bd8fd000f
commit
834202aeb9
339 changed files with 1294 additions and 187 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue