From b2b99aba95cf4496bbf05fb02e1b0d73a52bcd93 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 19 Aug 2023 16:19:52 +0200 Subject: [PATCH] LibWeb: Use `Core::Timer` for cursor blink timer in `BrowsingContext` Using `Core::Timer` that doesn't implicitly convert callback to `JS::SafeFunction` fixes the bug when `BrowsingContext` is never destroyed because of cyclic dependency between callback and `BrowsingContext`. --- Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 4 ++-- Userland/Libraries/LibWeb/HTML/BrowsingContext.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index f7ba33c166..26866de0f9 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -439,14 +439,14 @@ BrowsingContext::BrowsingContext(Page& page, HTML::NavigableContainer* container , m_event_handler({}, *this) , m_container(container) { - m_cursor_blink_timer = Platform::Timer::create_repeating(500, [this] { + m_cursor_blink_timer = Core::Timer::create_repeating(500, [this] { if (!is_focused_context()) return; if (m_cursor_position.node() && m_cursor_position.node()->layout_node()) { m_cursor_blink_state = !m_cursor_blink_state; m_cursor_position.node()->layout_node()->set_needs_display(); } - }); + }).release_value_but_fixme_should_propagate_errors(); } BrowsingContext::~BrowsingContext() = default; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index 81cbdc7976..a58e1c4dad 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -321,7 +321,7 @@ private: JS::GCPtr m_window_proxy; DOM::Position m_cursor_position; - RefPtr m_cursor_blink_timer; + RefPtr m_cursor_blink_timer; bool m_cursor_blink_state { false }; HashTable m_viewport_clients;