1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibWeb: Use Core::Timer instead for animation driver timer

Platform::Timer uses JS::SafeFunction that prevents document from ever
being deallocated because of strong reference.
This commit is contained in:
Aliaksandr Kalenik 2024-03-11 03:58:47 +01:00 committed by Andreas Kling
parent 2129c5d8b0
commit fd63ffb8c3
2 changed files with 3 additions and 3 deletions

View file

@ -4023,7 +4023,7 @@ void Document::ensure_animation_timer()
{
constexpr static auto timer_delay_ms = 1000 / 60;
if (!m_animation_driver_timer) {
m_animation_driver_timer = Platform::Timer::create_repeating(timer_delay_ms, [this] {
m_animation_driver_timer = MUST(Core::Timer::create_repeating(timer_delay_ms, [this] {
bool has_animations = false;
for (auto& timeline : m_associated_animation_timelines) {
if (!timeline->associated_animations().is_empty()) {
@ -4042,7 +4042,7 @@ void Document::ensure_animation_timer()
for (auto& animation : timeline->associated_animations())
dispatch_events_for_animation_if_necessary(animation);
}
});
}));
}
m_animation_driver_timer->start();

View file

@ -828,7 +828,7 @@ private:
// https://www.w3.org/TR/web-animations-1/#pending-animation-event-queue
Vector<PendingAnimationEvent> m_pending_animation_event_queue;
RefPtr<Platform::Timer> m_animation_driver_timer;
RefPtr<Core::Timer> m_animation_driver_timer;
bool m_needs_to_call_page_did_load { false };