mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibWeb: Improvements to Node::invalidate_style()
- Access members directly instead of going through accessors, avoiding a lot of redundant traversal done by accessors. - Cross shadow boundaries and make sure that shadow trees get their dirty bits updated as well. - Do the minimum amount of traversal needed when setting the "child needs style update" bit upwards through ancestors.
This commit is contained in:
parent
544c796bcf
commit
03d6e1953f
1 changed files with 14 additions and 2 deletions
|
@ -176,10 +176,22 @@ void Node::set_node_value(const String& value)
|
||||||
|
|
||||||
void Node::invalidate_style()
|
void Node::invalidate_style()
|
||||||
{
|
{
|
||||||
for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
for_each_in_inclusive_subtree([&](Node& node) {
|
||||||
element.set_needs_style_update(true);
|
node.m_needs_style_update = true;
|
||||||
|
if (node.has_children())
|
||||||
|
node.m_child_needs_style_update = true;
|
||||||
|
if (auto* shadow_root = node.is_element() ? static_cast<DOM::Element&>(node).shadow_root() : nullptr) {
|
||||||
|
shadow_root->m_needs_style_update = true;
|
||||||
|
if (shadow_root->has_children())
|
||||||
|
shadow_root->m_child_needs_style_update = true;
|
||||||
|
}
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
for (auto* ancestor = parent_or_shadow_host(); 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();
|
document().schedule_style_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue