From 2fbcaadef03967eba1da0a35b12c4d3440ed19c1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 14 Apr 2024 09:58:01 +0200 Subject: [PATCH] LibWeb: Don't schedule style/layout updates in detached documents There's no need to do any kind of style or layout work in documents that aren't attached to a browsing context. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index cff8665e072..a864fdb1d20 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -699,12 +699,18 @@ void Document::set_origin(HTML::Origin const& origin) void Document::schedule_style_update() { + if (!browsing_context()) + return; + // NOTE: Update of the style is a step in HTML event loop processing. HTML::main_thread_event_loop().schedule(); } void Document::schedule_layout_update() { + if (!browsing_context()) + return; + // NOTE: Update of the layout is a step in HTML event loop processing. HTML::main_thread_event_loop().schedule(); }