1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

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.
This commit is contained in:
Andreas Kling 2021-10-07 23:44:45 +02:00
parent 23f4ff7247
commit 13361bc47d

View file

@ -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<Layout::InitialContainingBlock>(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();
}