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
parent 92ac702c0c
commit dc8343cc23
7 changed files with 55 additions and 16 deletions

View File

@@ -1297,10 +1297,13 @@ void Document::update_layout()
if (is<Element>(node)) {
if (needs_full_style_update || node.needs_style_update()) {
invalidation |= static_cast<Element&>(node).recompute_style();
} else if (node.needs_inherited_style_update()) {
invalidation |= static_cast<Element&>(node).recompute_inherited_style();
}
is_display_none = static_cast<Element&>(node).computed_properties()->display().is_none();
}
node.set_needs_style_update(false);
node.set_needs_inherited_style_update(false);
if (needs_full_style_update || node.child_needs_style_update()) {
if (node.is_element()) {
@@ -1314,7 +1317,7 @@ void Document::update_layout()
}
node.for_each_child([&](auto& child) {
if (needs_full_style_update || child.needs_style_update() || child.child_needs_style_update()) {
if (needs_full_style_update || child.needs_style_update() || child.needs_inherited_style_update() || child.child_needs_style_update()) {
auto subtree_invalidation = update_style_recursively(child, style_computer);
if (!is_display_none)
invalidation |= subtree_invalidation;