From 608a730bd666f549f803c12b47eb79a5e0498005 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 20 Jul 2023 12:59:03 +0200 Subject: [PATCH] LibWeb: Use Core::Timer for style and layout update timers in Document Fixes leaking of DOM::Document by capturing it into JS::SafeFunction callback when using Platform::Timer for style and layout update timers. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 10 +++++----- Userland/Libraries/LibWeb/DOM/Document.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 99809e8ae6..8d825b4d02 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -84,7 +85,6 @@ #include #include #include -#include #include #include #include @@ -319,13 +319,13 @@ Document::Document(JS::Realm& realm, const AK::URL& url) { HTML::main_thread_event_loop().register_document({}, *this); - m_style_update_timer = Platform::Timer::create_single_shot(0, [this] { + m_style_update_timer = Core::Timer::create_single_shot(0, [this] { update_style(); - }); + }).release_value_but_fixme_should_propagate_errors(); - m_layout_update_timer = Platform::Timer::create_single_shot(0, [this] { + m_layout_update_timer = Core::Timer::create_single_shot(0, [this] { update_layout(); - }); + }).release_value_but_fixme_should_propagate_errors(); } Document::~Document() diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 724f1c2921..e2b34fc916 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -531,8 +531,8 @@ private: Optional m_active_link_color; Optional m_visited_link_color; - RefPtr m_style_update_timer; - RefPtr m_layout_update_timer; + RefPtr m_style_update_timer; + RefPtr m_layout_update_timer; JS::GCPtr m_parser; bool m_active_parser_was_aborted { false };