1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 13:35:07 +00:00

LibHTML: Batch style updates and make them start from the root

Use a zero-timer to schedule a style update after invalidating style
on any node. Nodes now have a needs_style_update flag which helps us
batch and coalesce the work.

We also start style updates at the root and work our way through the
document, updating any node that has the needs_style_update flag set.
This is slower than what we were doing before, but far more correct.

There is a ton of room for improvement here. :^)
This commit is contained in:
Andreas Kling 2019-10-19 18:57:02 +02:00
parent 0d8aaaaa44
commit 96f34d26c9
5 changed files with 46 additions and 10 deletions

View file

@ -70,8 +70,9 @@ RefPtr<LayoutNode> Node::create_layout_node(const StyleProperties*) const
void Node::invalidate_style()
{
for (auto* node = this; node; node = node->parent()) {
if (is<Element>(*node))
to<Element>(*node).recompute_style();
}
for_each_in_subtree([&](auto& node) {
if (is<Element>(node))
node.set_needs_style_update(true);
});
document().schedule_style_update();
}