1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:35:09 +00:00

LibHTML: Implement basic partial style invalidation

This patch makes it possible to call Node::invalidate_style() and have
that node and all of its ancestors recompute their style.

We then figure out if the new style is visually different from the old
style, and if so do a paint invalidation with set_needs_display().
Note that the "are they visually different" code is very incomplete!

Use this to make hover effects a lot more efficient. They no longer
cause a full relayout+repaint, but only a style invalidation.
Style invalidations are still quite heavy though, and there's a lot of
room for improvement there. :^)
This commit is contained in:
Andreas Kling 2019-10-14 18:32:02 +02:00
parent 667b31746a
commit 735f02900b
8 changed files with 94 additions and 1 deletions

View file

@ -102,3 +102,11 @@ RefPtr<LayoutNode> Node::create_layout_node(const StyleResolver&, const StylePro
{
return nullptr;
}
void Node::invalidate_style()
{
for (auto* node = this; node; node = node->parent()) {
if (is<Element>(*node))
to<Element>(*node).recompute_style();
}
}