LibWeb: Initialize HTML::EventLoop with its type

(cherry picked from commit 5d8784318d8240413e555bf2e55bc00d95ea0749)
This commit is contained in:
Andrew Kaster 2024-07-09 02:59:25 -06:00 committed by Nico Weber
parent fd55229c0e
commit f2e3d117a2
9 changed files with 11 additions and 10 deletions

View file

@ -153,7 +153,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Web::Platform::FontPlugin::install(*new Ladybird::FontPlugin(is_layout_test_mode));
TRY(Web::Bindings::initialize_main_thread_vm());
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Window));
if (log_all_js_exceptions) {
JS::g_log_all_js_exceptions = true;

View file

@ -49,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(initialize_lagom_networking(request_server_socket));
TRY(Web::Bindings::initialize_main_thread_vm());
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Worker));
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebWorker::ConnectionFromClient>());

View file

@ -17,7 +17,7 @@ struct Globals {
Globals::Globals()
{
Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
MUST(Web::Bindings::initialize_main_thread_vm());
MUST(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Window));
}
}

View file

@ -76,7 +76,7 @@ HTML::Script* active_script()
});
}
ErrorOr<void> initialize_main_thread_vm()
ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
{
VERIFY(!s_main_thread_vm);
@ -90,7 +90,7 @@ ErrorOr<void> initialize_main_thread_vm()
s_main_thread_vm->ref();
auto& custom_data = verify_cast<WebEngineCustomData>(*s_main_thread_vm->custom_data());
custom_data.event_loop = s_main_thread_vm->heap().allocate_without_realm<HTML::EventLoop>();
custom_data.event_loop = s_main_thread_vm->heap().allocate_without_realm<HTML::EventLoop>(type);
// These strings could potentially live on the VM similar to CommonPropertyNames.
DOM::MutationType::initialize_strings();

View file

@ -80,7 +80,7 @@ struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData
HTML::Script* active_script();
ErrorOr<void> initialize_main_thread_vm();
ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type);
JS::VM& main_thread_vm();
void queue_mutation_observer_microtask(DOM::Document const&);

View file

@ -23,7 +23,8 @@ namespace Web::HTML {
JS_DEFINE_ALLOCATOR(EventLoop);
EventLoop::EventLoop()
EventLoop::EventLoop(Type type)
: m_type(type)
{
m_task_queue = heap().allocate_without_realm<TaskQueue>(*this);
m_microtask_queue = heap().allocate_without_realm<TaskQueue>(*this);

View file

@ -76,7 +76,7 @@ public:
bool execution_paused() const { return m_execution_paused; }
private:
EventLoop();
explicit EventLoop(Type);
virtual void visit_edges(Visitor&) override;

View file

@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
});
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
TRY(Web::Bindings::initialize_main_thread_vm());
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Window));
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebContent::ConnectionFromClient>());
return event_loop.exec();

View file

@ -36,7 +36,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
Web::Platform::FontPlugin::install(*new Web::Platform::FontPluginSerenity);
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
TRY(Web::Bindings::initialize_main_thread_vm());
TRY(Web::Bindings::initialize_main_thread_vm(Web::HTML::EventLoop::Type::Worker));
auto client = TRY(IPC::take_over_accepted_client_from_system_server<WebWorker::ConnectionFromClient>());