LibWeb: Avoid style invalidation when entire document has invalid style

If the entire document is invalidated, we know a full style update is
coming soon, and there's no need to try and invalidate a smaller part.

This avoids a *lot* of work on some pages. As an example, we are able to
skip ~1.5 million style invalidations on https://html.spec.whatwg.org/
This commit is contained in:
Andreas Kling 2024-01-13 11:38:30 +01:00
parent de32b77ceb
commit c3059701b0
Notes: sideshowbarker 2024-07-17 23:02:37 +09:00

View File

@ -261,6 +261,11 @@ void Node::invalidate_style()
return;
}
// If the document is already marked for a full style update, there's no need to do anything here.
if (document().needs_full_style_update()) {
return;
}
for_each_in_inclusive_subtree([&](Node& node) {
node.m_needs_style_update = true;
if (node.has_children())