From 13361bc47d854466fd14763ce80118a712b3d802 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 7 Oct 2021 23:44:45 +0200 Subject: [PATCH] LibWeb: Update style (if needed) before updating layout Layout depends on style (and not the other way around), so if the document has dirty style when we enter update_layout(), make sure we call update_style() before proceeding with the layout work. This has the pleasant effect of coalescing some redundant layouts. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 2fb688d00f..2f92de9182 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -430,6 +430,8 @@ void Document::update_layout() if (!browsing_context()) return; + update_style(); + if (!m_layout_root) { Layout::TreeBuilder tree_builder; m_layout_root = static_ptr_cast(tree_builder.build(*this)); @@ -468,6 +470,8 @@ void Document::update_style() { if (!browsing_context()) return; + if (!needs_style_update() && !child_needs_style_update()) + return; update_style_recursively(*this); set_needs_layout(); }