1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

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.
This commit is contained in:
Aliaksandr Kalenik 2023-07-20 12:59:03 +02:00 committed by Andreas Kling
parent 8ec691057f
commit 608a730bd6
2 changed files with 7 additions and 7 deletions

View file

@ -11,6 +11,7 @@
#include <AK/Debug.h> #include <AK/Debug.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <AK/Utf8View.h> #include <AK/Utf8View.h>
#include <LibCore/Timer.h>
#include <LibJS/Interpreter.h> #include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Array.h> #include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/FunctionObject.h>
@ -84,7 +85,6 @@
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h> #include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
#include <LibWeb/Platform/Timer.h>
#include <LibWeb/SVG/SVGElement.h> #include <LibWeb/SVG/SVGElement.h>
#include <LibWeb/SVG/SVGTitleElement.h> #include <LibWeb/SVG/SVGTitleElement.h>
#include <LibWeb/SVG/TagNames.h> #include <LibWeb/SVG/TagNames.h>
@ -319,13 +319,13 @@ Document::Document(JS::Realm& realm, const AK::URL& url)
{ {
HTML::main_thread_event_loop().register_document({}, *this); 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(); 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(); update_layout();
}); }).release_value_but_fixme_should_propagate_errors();
} }
Document::~Document() Document::~Document()

View file

@ -531,8 +531,8 @@ private:
Optional<Color> m_active_link_color; Optional<Color> m_active_link_color;
Optional<Color> m_visited_link_color; Optional<Color> m_visited_link_color;
RefPtr<Platform::Timer> m_style_update_timer; RefPtr<Core::Timer> m_style_update_timer;
RefPtr<Platform::Timer> m_layout_update_timer; RefPtr<Core::Timer> m_layout_update_timer;
JS::GCPtr<HTML::HTMLParser> m_parser; JS::GCPtr<HTML::HTMLParser> m_parser;
bool m_active_parser_was_aborted { false }; bool m_active_parser_was_aborted { false };