1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +00:00

LibWeb: Avoid layout invalidation for some CSS property changes

Use the new CSS::property_affects_layout() helper to figure out if we
actually need to perform a full relayout after recomputing style.

There are three tiers of required invalidation after an element receives
new style: none, repaint only, or full relayout.

This avoids the need to rebuild the layout tree (and perform layout on
it) when trivial properties like "color" etc are changed.
This commit is contained in:
Andreas Kling 2022-03-16 17:48:50 +01:00
parent 275db39c94
commit f1711a562a
3 changed files with 60 additions and 10 deletions

View file

@ -87,7 +87,11 @@ public:
virtual void parse_attribute(const FlyString& name, const String& value);
virtual void did_remove_attribute(FlyString const&) { }
void recompute_style();
enum class NeedsRelayout {
No = 0,
Yes = 1,
};
NeedsRelayout recompute_style();
Layout::NodeWithStyle* layout_node() { return static_cast<Layout::NodeWithStyle*>(Node::layout_node()); }
const Layout::NodeWithStyle* layout_node() const { return static_cast<const Layout::NodeWithStyle*>(Node::layout_node()); }