LibWeb: Skip tree traversal if invalidation set doesn't have properties

This allows us to skip unnecessary tree traversal to mark style for
recalculation when invalidation set only has `InvalidateSelf`.
This commit is contained in:
Aliaksandr Kalenik 2025-07-13 19:32:57 +02:00 committed by Jelle Raaijmakers
parent 80ccb12a12
commit 9bb5e70f5a
Notes: github-actions[bot] 2025-07-14 07:33:15 +00:00
2 changed files with 7 additions and 2 deletions

View file

@ -516,13 +516,17 @@ void Node::invalidate_style(StyleInvalidationReason reason, Vector<CSS::Invalida
if (invalidation_set.is_empty())
return;
if (invalidation_set.needs_invalidate_self()) {
set_needs_style_update(true);
}
if (invalidation_set.needs_invalidate_whole_subtree()) {
invalidate_style(reason);
return;
}
if (invalidation_set.needs_invalidate_self()) {
set_needs_style_update(true);
if (!invalidation_set.has_properties() && !options.invalidate_elements_that_use_css_custom_properties) {
return;
}
auto invalidate_entire_subtree = [&](Node& subtree_root) {