mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Use HeapFunction for Platform::Timer
This commit is contained in:
parent
ede3c91688
commit
de1a805898
Notes:
github-actions[bot]
2024-10-30 19:57:21 +00:00
Author: https://github.com/shannonbooth
Commit: de1a805898
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2062
Reviewed-by: https://github.com/kalenikaliaksandr ✅
8 changed files with 28 additions and 18 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Heap/HeapFunction.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/Platform/Timer.h>
|
||||
|
||||
|
@ -11,12 +12,18 @@ namespace Web::Platform {
|
|||
|
||||
Timer::~Timer() = default;
|
||||
|
||||
void Timer::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(on_timeout);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Timer> Timer::create(JS::Heap& heap)
|
||||
{
|
||||
return EventLoopPlugin::the().create_timer(heap);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Timer> Timer::create_repeating(JS::Heap& heap, int interval_ms, JS::SafeFunction<void()>&& timeout_handler)
|
||||
JS::NonnullGCPtr<Timer> Timer::create_repeating(JS::Heap& heap, int interval_ms, JS::GCPtr<JS::HeapFunction<void()>> timeout_handler)
|
||||
{
|
||||
auto timer = EventLoopPlugin::the().create_timer(heap);
|
||||
timer->set_single_shot(false);
|
||||
|
@ -25,7 +32,7 @@ JS::NonnullGCPtr<Timer> Timer::create_repeating(JS::Heap& heap, int interval_ms,
|
|||
return timer;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Timer> Timer::create_single_shot(JS::Heap& heap, int interval_ms, JS::SafeFunction<void()>&& timeout_handler)
|
||||
JS::NonnullGCPtr<Timer> Timer::create_single_shot(JS::Heap& heap, int interval_ms, JS::GCPtr<JS::HeapFunction<void()>> timeout_handler)
|
||||
{
|
||||
auto timer = EventLoopPlugin::the().create_timer(heap);
|
||||
timer->set_single_shot(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue