LibWeb: Add mechanism to invalidate only inherited styles

We can now mark an element as needing an "inherited style update" rather
than a full "style update". This effectively means that the next style
update will visit the element and pull all of its inherited properties
from the relevant ancestor element.

This is now used for descendants of elements with animated style.
This commit is contained in:
Andreas Kling 2024-12-22 11:59:58 +01:00 committed by Andreas Kling
commit dc8343cc23
Notes: github-actions[bot] 2024-12-23 16:06:18 +00:00
7 changed files with 55 additions and 16 deletions

View file

@ -1249,6 +1249,22 @@ EventTarget* Node::get_parent(Event const&)
return parent();
}
void Node::set_needs_inherited_style_update(bool value)
{
if (m_needs_inherited_style_update == value)
return;
m_needs_inherited_style_update = value;
if (m_needs_inherited_style_update) {
for (auto* ancestor = parent_or_shadow_host(); ancestor; 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();
}
}
void Node::set_needs_style_update(bool value)
{
if (m_needs_style_update == value)