mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Avoid iterating in children_changed unless necessary
Previously when one child of an element changed we would iterate over every child to check whether they needed to be invalidated because they relied on tree counting functions. We now skip this in most cases by only doing it when at least one child relies on tree counting functions.
This commit is contained in:
parent
6afd39b16a
commit
a4184fda1f
Notes:
github-actions[bot]
2025-10-21 23:02:12 +00:00
Author: https://github.com/Calme1709
Commit: a4184fda1f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6526
Reviewed-by: https://github.com/gmta ✅
2 changed files with 20 additions and 9 deletions
|
|
@ -1395,14 +1395,15 @@ void Element::children_changed(ChildrenChangedMetadata const* metadata)
|
|||
{
|
||||
Node::children_changed(metadata);
|
||||
set_needs_style_update(true);
|
||||
for_each_child([&](DOM::Node& child) {
|
||||
if (auto* element = as_if<DOM::Element>(child); element && element->style_uses_tree_counting_function()) {
|
||||
element->set_needs_style_update(true);
|
||||
set_child_needs_style_update(true);
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
if (child_style_uses_tree_counting_function()) {
|
||||
for_each_child_of_type<Element>([&](Element& element) {
|
||||
element.set_needs_style_update(true);
|
||||
set_child_needs_style_update(true);
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Element::set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::PseudoElement pseudo_element, GC::Ptr<Layout::NodeWithStyle> pseudo_element_node)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue