LibWeb: Initialize HTML::EventLoop with its type

This commit is contained in:
Andrew Kaster 2024-07-09 02:59:25 -06:00 committed by Andreas Kling
parent aa4e18fca5
commit 5d8784318d
Notes: sideshowbarker 2024-07-16 19:42:24 +09:00
10 changed files with 12 additions and 11 deletions

View file

@ -68,7 +68,7 @@ ErrorOr<int> 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())

View file

@ -161,7 +161,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

@ -66,7 +66,7 @@ ErrorOr<int> 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<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

@ -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<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>());