diff options
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index dfe99831e1..a8eb9e4315 100644 --- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -48,38 +48,38 @@ EventLoop& main_thread_event_loop() // https://html.spec.whatwg.org/multipage/webappapis.html#spin-the-event-loop void EventLoop::spin_until(Function<bool()> goal_condition) { - // FIXME: This is an ad-hoc hack until we implement the proper mechanism. - Core::EventLoop loop; - loop.spin_until([&]() -> bool { - if (goal_condition()) - return true; - perform_a_microtask_checkpoint(); - return goal_condition(); - }); - - // Real spec steps: - // 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. + // 3. Let old stack be a copy of the JavaScript execution context stack. + // 4. Empty the JavaScript execution context stack. + auto& vm = Bindings::main_thread_vm(); + vm.save_execution_context_stack(); - // FIXME: 5. Perform a microtask checkpoint. - - // FIXME: 6. In parallel: + // 5. Perform a microtask checkpoint. + perform_a_microtask_checkpoint(); - // FIXME: 1. Wait until the condition goal is met. + // 6. In parallel: + // NOTE: We do these in reverse order here, but it shouldn't matter. - // FIXME: 2. Queue a task on task source to: + // 2. Queue a task on task source to: + // 1. Replace the JavaScript execution context stack with old stack. + vm.restore_execution_context_stack(); + // 2. Perform any steps that appear after this spin the event loop instance in the original algorithm. + // NOTE: This is achieved by returning from the function. - // FIXME: 1. Replace the JavaScript execution context stack with old stack. + // 1. Wait until the condition goal is met. + Core::EventLoop loop; + loop.spin_until([&]() -> bool { + if (goal_condition()) + return true; - // FIXME: 2. Perform any steps that appear after this spin the event loop instance in the original algorithm. + return goal_condition(); + }); - // FIXME: 7. Stop task, allowing whatever algorithm that invoked it to resume. + // 7. Stop task, allowing whatever algorithm that invoked it to resume. + // NOTE: This is achieved by returning from the function. } // https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model |