mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb+WebContent: Add abstraction layer for event loop and timers
Instead of using Core::EventLoop and Core::Timer directly, LibWeb now goes through a Web::Platform abstraction layer instead. This will allow us to plug in Qt's event loop (and QTimer) over in Ladybird, to avoid having to deal with multiple event loops.
This commit is contained in:
parent
7e5a8bd4b0
commit
9567e211e7
Notes:
sideshowbarker
2024-07-17 18:38:54 +09:00
Author: https://github.com/awesomekling
Commit: 9567e211e7
28 changed files with 365 additions and 42 deletions
|
@ -5,8 +5,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
@ -15,6 +13,8 @@
|
|||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/Platform/Timer.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -29,7 +29,7 @@ EventLoop::~EventLoop() = default;
|
|||
void EventLoop::schedule()
|
||||
{
|
||||
if (!m_system_event_loop_timer) {
|
||||
m_system_event_loop_timer = Core::Timer::create_single_shot(0, [this] {
|
||||
m_system_event_loop_timer = Platform::Timer::create_single_shot(0, [this] {
|
||||
process();
|
||||
});
|
||||
}
|
||||
|
@ -74,13 +74,7 @@ void EventLoop::spin_until(Function<bool()> goal_condition)
|
|||
// NOTE: This is achieved by returning from the function.
|
||||
|
||||
// 1. Wait until the condition goal is met.
|
||||
Core::EventLoop loop;
|
||||
loop.spin_until([&]() -> bool {
|
||||
if (goal_condition())
|
||||
return true;
|
||||
|
||||
return goal_condition();
|
||||
});
|
||||
Platform::EventLoopPlugin::the().spin_until(move(goal_condition));
|
||||
|
||||
// 7. Stop task, allowing whatever algorithm that invoked it to resume.
|
||||
// NOTE: This is achieved by returning from the function.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue