mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibWeb: Avoid separate tree traversal to mark for inherited style update
...in hover style invalidation. Instead, pass down a flag that indicates all subsequent nodes in tree traversal have to be marked for inherited style update.
This commit is contained in:
parent
db47fa3db1
commit
748d316973
Notes:
github-actions[bot]
2025-01-28 17:56:34 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 748d316973
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3379
1 changed files with 8 additions and 7 deletions
|
@ -1706,7 +1706,11 @@ void Document::invalidate_style_for_elements_affected_by_hover_change(Node& old_
|
|||
return state;
|
||||
};
|
||||
|
||||
Function<void(Node&)> invalidate_hovered_elements_recursively = [&](Node& node) -> void {
|
||||
Function<void(Node&, bool)> invalidate_hovered_elements_recursively = [&](Node& node, bool descendants_need_inherited_style_update) -> void {
|
||||
if (descendants_need_inherited_style_update) {
|
||||
node.set_needs_inherited_style_update(true);
|
||||
}
|
||||
bool invalidated_any_elements = false;
|
||||
if (node.is_element()) {
|
||||
auto& element = static_cast<Element&>(node);
|
||||
style_computer.push_ancestor(element);
|
||||
|
@ -1716,16 +1720,13 @@ void Document::invalidate_style_for_elements_affected_by_hover_change(Node& old_
|
|||
auto selectors_match_state_after = compute_hover_selectors_match_state(element);
|
||||
if (selectors_match_state_before.view() != selectors_match_state_after.view()) {
|
||||
element.set_needs_style_update(true);
|
||||
element.for_each_in_subtree_of_type<Element>([](auto& element) {
|
||||
element.set_needs_inherited_style_update(true);
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
invalidated_any_elements = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node.for_each_child([&](auto& child) {
|
||||
invalidate_hovered_elements_recursively(child);
|
||||
invalidate_hovered_elements_recursively(child, descendants_need_inherited_style_update || invalidated_any_elements);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
|
@ -1733,7 +1734,7 @@ void Document::invalidate_style_for_elements_affected_by_hover_change(Node& old_
|
|||
style_computer.pop_ancestor(static_cast<Element&>(node));
|
||||
};
|
||||
|
||||
invalidate_hovered_elements_recursively(root);
|
||||
invalidate_hovered_elements_recursively(root, false);
|
||||
}
|
||||
|
||||
void Document::set_hovered_node(Node* node)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue