mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 22:55:23 +00:00
LibWeb: Optimize inherited style update
This commit changes the strategy for updating inherited styles. Instead of marking all potentially affected nodes during style invalidation, the decision is now made on-the-fly during style recalculation. Child nodes will only have their inherited styles recalculated if their parent's properties have changed. On Discord this allows to 1000x reduce number of nodes with recalculated inherited style.
This commit is contained in:
committed by
Andreas Kling
parent
bf15c7fa4b
commit
761e9aeaf7
@@ -533,11 +533,8 @@ void Node::invalidate_style(StyleInvalidationReason, Vector<CSS::InvalidationSet
|
||||
} else if (options.invalidate_elements_that_use_css_custom_properties && element.style_uses_css_custom_properties()) {
|
||||
needs_style_recalculation = true;
|
||||
}
|
||||
if (needs_style_recalculation) {
|
||||
if (needs_style_recalculation)
|
||||
element.set_needs_style_update(true);
|
||||
} else {
|
||||
element.set_needs_inherited_style_update(true);
|
||||
}
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
};
|
||||
@@ -1394,22 +1391,6 @@ EventTarget* Node::get_parent(Event const&)
|
||||
return parent();
|
||||
}
|
||||
|
||||
void Node::set_needs_inherited_style_update(bool value)
|
||||
{
|
||||
if (m_needs_inherited_style_update == value)
|
||||
return;
|
||||
m_needs_inherited_style_update = value;
|
||||
|
||||
if (m_needs_inherited_style_update) {
|
||||
for (auto* ancestor = parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host()) {
|
||||
if (ancestor->m_child_needs_style_update)
|
||||
break;
|
||||
ancestor->m_child_needs_style_update = true;
|
||||
}
|
||||
document().schedule_style_update();
|
||||
}
|
||||
}
|
||||
|
||||
void Node::set_needs_layout_tree_update(bool value)
|
||||
{
|
||||
if (m_needs_layout_tree_update == value)
|
||||
|
||||
Reference in New Issue
Block a user