mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +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:
parent
bf15c7fa4b
commit
761e9aeaf7
Notes:
github-actions[bot]
2025-02-11 18:24:07 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 761e9aeaf7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3541
3 changed files with 13 additions and 44 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue