1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:28:11 +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:
Timothy Flynn 2023-01-10 06:28:20 -05:00 committed by Andreas Kling
parent 7bd8fd000f
commit 834202aeb9
339 changed files with 1294 additions and 187 deletions

View file

@ -19,8 +19,6 @@ JS::NonnullGCPtr<MessageChannel> MessageChannel::construct_impl(JS::Realm& realm
MessageChannel::MessageChannel(JS::Realm& realm)
: PlatformObject(realm)
{
set_prototype(&Bindings::cached_web_prototype(realm, "MessageChannel"));
// 1. Set this's port 1 to a new MessagePort in this's relevant Realm.
m_port1 = MessagePort::create(realm);
@ -40,6 +38,12 @@ void MessageChannel::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_port2.ptr());
}
void MessageChannel::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::MessageChannelPrototype>(realm, "MessageChannel"));
}
MessagePort* MessageChannel::port1()
{
return m_port1;