diff --git a/Ladybird/Android/src/main/cpp/WebContentService.cpp b/Ladybird/Android/src/main/cpp/WebContentService.cpp index 930a724b38f..e03cfc99660 100644 --- a/Ladybird/Android/src/main/cpp/WebContentService.cpp +++ b/Ladybird/Android/src/main/cpp/WebContentService.cpp @@ -68,7 +68,7 @@ ErrorOr service_main(int ipc_socket) Web::HTML::Window::set_internals_object_exposed(is_layout_test_mode); 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)); auto maybe_content_filter_error = load_content_filters(); if (maybe_content_filter_error.is_error()) diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp index b040309b887..f8f9e75484c 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -161,7 +161,7 @@ ErrorOr 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; diff --git a/Ladybird/WebWorker/main.cpp b/Ladybird/WebWorker/main.cpp index a60b490f36a..4041a00965f 100644 --- a/Ladybird/WebWorker/main.cpp +++ b/Ladybird/WebWorker/main.cpp @@ -66,7 +66,7 @@ ErrorOr serenity_main(Main::Arguments arguments) #endif 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()); diff --git a/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp b/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp index a3c50a19dea..9b9dce45912 100644 --- a/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp +++ b/Meta/Lagom/Fuzzers/FuzzCSSParser.cpp @@ -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)); } } diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index d3c877e1b63..9496f649721 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -76,7 +76,7 @@ HTML::Script* active_script() }); } -ErrorOr initialize_main_thread_vm() +ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) { VERIFY(!s_main_thread_vm); @@ -90,7 +90,7 @@ ErrorOr initialize_main_thread_vm() s_main_thread_vm->ref(); auto& custom_data = verify_cast(*s_main_thread_vm->custom_data()); - custom_data.event_loop = s_main_thread_vm->heap().allocate_without_realm(); + custom_data.event_loop = s_main_thread_vm->heap().allocate_without_realm(type); // These strings could potentially live on the VM similar to CommonPropertyNames. DOM::MutationType::initialize_strings(); diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h index bdafaea7615..0dea1815f52 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h @@ -80,7 +80,7 @@ struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData HTML::Script* active_script(); -ErrorOr initialize_main_thread_vm(); +ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type); JS::VM& main_thread_vm(); void queue_mutation_observer_microtask(DOM::Document const&); diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index 47f8353e086..e95dd29dc88 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -24,7 +24,8 @@ namespace Web::HTML { JS_DEFINE_ALLOCATOR(EventLoop); -EventLoop::EventLoop() +EventLoop::EventLoop(Type type) + : m_type(type) { m_task_queue = heap().allocate_without_realm(*this); m_microtask_queue = heap().allocate_without_realm(*this); diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h index 23a1b56afb8..206e708d468 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h @@ -76,7 +76,7 @@ public: bool execution_paused() const { return m_execution_paused; } private: - EventLoop(); + explicit EventLoop(Type); virtual void visit_edges(Visitor&) override; diff --git a/Userland/Services/WebContent/main.cpp b/Userland/Services/WebContent/main.cpp index b7c69eeecbf..4e49e8c064e 100644 --- a/Userland/Services/WebContent/main.cpp +++ b/Userland/Services/WebContent/main.cpp @@ -51,7 +51,7 @@ ErrorOr 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()); return event_loop.exec(); diff --git a/Userland/Services/WebWorker/main.cpp b/Userland/Services/WebWorker/main.cpp index 14dcc60980e..12e38415e56 100644 --- a/Userland/Services/WebWorker/main.cpp +++ b/Userland/Services/WebWorker/main.cpp @@ -36,7 +36,7 @@ ErrorOr 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());