mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Skip invalidating :first-child
and :last-child
if possible
There is no need to invalidate siblings affected by these pseudo classes if invalidation reason is not insertion or removal of tree nodes.
This commit is contained in:
parent
0e057d3a36
commit
92a3419799
Notes:
github-actions[bot]
2025-03-09 17:41:38 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/92a34197999 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3877
1 changed files with 10 additions and 2 deletions
|
@ -461,8 +461,16 @@ void Node::invalidate_style(StyleInvalidationReason reason)
|
|||
}
|
||||
|
||||
for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) {
|
||||
if (auto* element = as_if<Element>(sibling); element && element->style_affected_by_structural_changes())
|
||||
element->set_entire_subtree_needs_style_update(true);
|
||||
if (auto* element = as_if<Element>(sibling)) {
|
||||
bool needs_to_invalidate = false;
|
||||
if (reason == StyleInvalidationReason::NodeInsertBefore || reason == StyleInvalidationReason::NodeRemove) {
|
||||
needs_to_invalidate = element->style_affected_by_structural_changes();
|
||||
} else {
|
||||
needs_to_invalidate = element->affected_by_sibling_combinator() || element->affected_by_nth_child_pseudo_class();
|
||||
}
|
||||
if (needs_to_invalidate)
|
||||
element->set_entire_subtree_needs_style_update(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* ancestor = parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host())
|
||||
|
|
Loading…
Add table
Reference in a new issue