LibWeb: Return the ID of queued global events

This will allow callers to track the event.
This commit is contained in:
Timothy Flynn 2024-03-22 15:24:03 -04:00 committed by Andreas Kling
commit 4806cf9527
Notes: sideshowbarker 2024-07-17 05:18:58 +09:00
2 changed files with 4 additions and 2 deletions

View file

@ -339,7 +339,7 @@ void EventLoop::process()
}
// https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-global-task
void queue_global_task(HTML::Task::Source source, JS::Object& global_object, JS::SafeFunction<void()> steps)
int queue_global_task(HTML::Task::Source source, JS::Object& global_object, JS::SafeFunction<void()> steps)
{
// 1. Let event loop be global's relevant agent's event loop.
auto& global_custom_data = verify_cast<Bindings::WebEngineCustomData>(*global_object.vm().custom_data());
@ -354,6 +354,8 @@ void queue_global_task(HTML::Task::Source source, JS::Object& global_object, JS:
// 3. Queue a task given source, event loop, document, and steps.
event_loop.task_queue().add(HTML::Task::create(source, document, move(steps)));
return event_loop.task_queue().last_added_task()->id();
}
// https://html.spec.whatwg.org/#queue-a-microtask