소스 검색

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`.
Aliaksandr Kalenik 1 년 전
부모
커밋
b2b99aba95
2개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 2
      Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
  2. 1 1
      Userland/Libraries/LibWeb/HTML/BrowsingContext.h

+ 2 - 2
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;

+ 1 - 1
Userland/Libraries/LibWeb/HTML/BrowsingContext.h

@@ -321,7 +321,7 @@ private:
     JS::GCPtr<HTML::WindowProxy> m_window_proxy;
 
     DOM::Position m_cursor_position;
-    RefPtr<Platform::Timer> m_cursor_blink_timer;
+    RefPtr<Core::Timer> m_cursor_blink_timer;
     bool m_cursor_blink_state { false };
 
     HashTable<ViewportClient*> m_viewport_clients;