diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index 8c89652543..5642ae46f8 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -23,4 +23,30 @@ EventLoop& main_thread_event_loop() return static_cast(Bindings::main_thread_vm().custom_data())->event_loop; } +// https://html.spec.whatwg.org/multipage/webappapis.html#spin-the-event-loop +void EventLoop::spin_until([[maybe_unused]] Function goal_condition) +{ + // FIXME: 1. Let task be the event loop's currently running task. + + // FIXME: 2. Let task source be task's source. + + // FIXME: 3. Let old stack be a copy of the JavaScript execution context stack. + + // FIXME: 4. Empty the JavaScript execution context stack. + + // FIXME: 5. Perform a microtask checkpoint. + + // FIXME: 6. In parallel: + + // FIXME: 1. Wait until the condition goal is met. + + // FIXME: 2. Queue a task on task source to: + + // FIXME: 1. Replace the JavaScript execution context stack with old stack. + + // FIXME: 2. Perform any steps that appear after this spin the event loop instance in the original algorithm. + + // FIXME: 7. Stop task, allowing whatever algorithm that invoked it to resume. +} + } diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h index 5f1ecf878e..9e55ca4369 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.h @@ -19,6 +19,8 @@ public: TaskQueue& task_queue() { return m_task_queue; } TaskQueue const& task_queue() const { return m_task_queue; } + void spin_until(Function goal_condition); + private: TaskQueue m_task_queue; };