mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 23:59:49 +00:00
LibWeb: Implement pausing the event loop a bit closer to the spec
Namely, this is to update the rendering before pausing the event loop.
This commit is contained in:
parent
5431db8c1c
commit
f4111ef1e1
Notes:
github-actions[bot]
2024-11-06 09:51:32 +00:00
Author: https://github.com/trflynn89
Commit: f4111ef1e1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2178
3 changed files with 60 additions and 6 deletions
|
@ -7,10 +7,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/HTML/EventLoop/TaskQueue.h>
|
||||
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -18,6 +21,18 @@ class EventLoop : public JS::Cell {
|
|||
JS_CELL(EventLoop, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(EventLoop);
|
||||
|
||||
struct PauseHandle {
|
||||
PauseHandle(EventLoop&, JS::Object const& global, HighResolutionTime::DOMHighResTimeStamp);
|
||||
~PauseHandle();
|
||||
|
||||
AK_MAKE_NONCOPYABLE(PauseHandle);
|
||||
AK_MAKE_NONMOVABLE(PauseHandle);
|
||||
|
||||
JS::NonnullGCPtr<EventLoop> event_loop;
|
||||
JS::NonnullGCPtr<JS::Object const> global;
|
||||
HighResolutionTime::DOMHighResTimeStamp const time_before_pause;
|
||||
};
|
||||
|
||||
public:
|
||||
enum class Type {
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#window-event-loop
|
||||
|
@ -71,8 +86,8 @@ public:
|
|||
|
||||
double compute_deadline() const;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#pause
|
||||
void set_execution_paused(bool execution_paused) { m_execution_paused = execution_paused; }
|
||||
[[nodiscard]] PauseHandle pause();
|
||||
void unpause(Badge<PauseHandle>, JS::Object const& global, HighResolutionTime::DOMHighResTimeStamp);
|
||||
bool execution_paused() const { return m_execution_paused; }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue