EventLoop.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/VM.h>
  7. #include <LibWeb/Bindings/MainThreadVM.h>
  8. #include <LibWeb/HTML/EventLoop/EventLoop.h>
  9. namespace Web::HTML {
  10. EventLoop::EventLoop()
  11. {
  12. }
  13. EventLoop::~EventLoop()
  14. {
  15. }
  16. EventLoop& main_thread_event_loop()
  17. {
  18. return static_cast<Bindings::WebEngineCustomData*>(Bindings::main_thread_vm().custom_data())->event_loop;
  19. }
  20. // https://html.spec.whatwg.org/multipage/webappapis.html#spin-the-event-loop
  21. void EventLoop::spin_until([[maybe_unused]] Function<bool()> goal_condition)
  22. {
  23. // FIXME: 1. Let task be the event loop's currently running task.
  24. // FIXME: 2. Let task source be task's source.
  25. // FIXME: 3. Let old stack be a copy of the JavaScript execution context stack.
  26. // FIXME: 4. Empty the JavaScript execution context stack.
  27. // FIXME: 5. Perform a microtask checkpoint.
  28. // FIXME: 6. In parallel:
  29. // FIXME: 1. Wait until the condition goal is met.
  30. // FIXME: 2. Queue a task on task source to:
  31. // FIXME: 1. Replace the JavaScript execution context stack with old stack.
  32. // FIXME: 2. Perform any steps that appear after this spin the event loop instance in the original algorithm.
  33. // FIXME: 7. Stop task, allowing whatever algorithm that invoked it to resume.
  34. }
  35. }