summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-03-14 06:55:34 -0400
committerTim Flynn <trflynn89@pm.me>2023-03-14 09:07:40 -0400
commitb579093ad02dbfe04dc332a0036c5a71fca39fa2 (patch)
tree2fa056c2d98a487bbce4fecf08d0d260477d3b45 /Userland
parentea11a843327560087079273a9287df51be272d87 (diff)
downloadserenity-b579093ad02dbfe04dc332a0036c5a71fca39fa2.zip
LibWeb: Change HTML::Timer to store its owning window as a JS::Object
Rather than being limited to a Window object, it will also need to be ownable by a WorkerGlobalScope.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Timer.cpp11
-rw-r--r--Userland/Libraries/LibWeb/HTML/Timer.h6
2 files changed, 9 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Timer.cpp b/Userland/Libraries/LibWeb/HTML/Timer.cpp
index 28fcfde499..8357cf758a 100644
--- a/Userland/Libraries/LibWeb/HTML/Timer.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Timer.cpp
@@ -4,19 +4,20 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibJS/Runtime/Object.h>
#include <LibWeb/HTML/Timer.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Platform/Timer.h>
namespace Web::HTML {
-JS::NonnullGCPtr<Timer> Timer::create(Window& window, i32 milliseconds, Function<void()> callback, i32 id)
+JS::NonnullGCPtr<Timer> Timer::create(JS::Object& window_or_worker_global_scope, i32 milliseconds, Function<void()> callback, i32 id)
{
- return window.heap().allocate_without_realm<Timer>(window, milliseconds, move(callback), id);
+ return window_or_worker_global_scope.heap().allocate_without_realm<Timer>(window_or_worker_global_scope, milliseconds, move(callback), id);
}
-Timer::Timer(Window& window, i32 milliseconds, Function<void()> callback, i32 id)
- : m_window(window)
+Timer::Timer(JS::Object& window_or_worker_global_scope, i32 milliseconds, Function<void()> callback, i32 id)
+ : m_window_or_worker_global_scope(window_or_worker_global_scope)
, m_callback(move(callback))
, m_id(id)
{
@@ -28,7 +29,7 @@ Timer::Timer(Window& window, i32 milliseconds, Function<void()> callback, i32 id
void Timer::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
- visitor.visit(m_window.ptr());
+ visitor.visit(m_window_or_worker_global_scope.ptr());
}
Timer::~Timer()
diff --git a/Userland/Libraries/LibWeb/HTML/Timer.h b/Userland/Libraries/LibWeb/HTML/Timer.h
index 2f1aab762e..fb931e7be5 100644
--- a/Userland/Libraries/LibWeb/HTML/Timer.h
+++ b/Userland/Libraries/LibWeb/HTML/Timer.h
@@ -20,18 +20,18 @@ class Timer final : public JS::Cell {
JS_CELL(Timer, JS::Cell);
public:
- static JS::NonnullGCPtr<Timer> create(Window&, i32 milliseconds, Function<void()> callback, i32 id);
+ static JS::NonnullGCPtr<Timer> create(JS::Object&, i32 milliseconds, Function<void()> callback, i32 id);
virtual ~Timer() override;
void start();
private:
- Timer(Window& window, i32 milliseconds, Function<void()> callback, i32 id);
+ Timer(JS::Object& window, i32 milliseconds, Function<void()> callback, i32 id);
virtual void visit_edges(Cell::Visitor&) override;
RefPtr<Platform::Timer> m_timer;
- JS::NonnullGCPtr<Window> m_window;
+ JS::NonnullGCPtr<JS::Object> m_window_or_worker_global_scope;
Function<void()> m_callback;
i32 m_id { 0 };
};