LibWeb: Optimize :hover style invalidation

Instead of recalculating styles for all nodes in the common ancestor of
the new and old hovered nodes' subtrees, this change introduces the
following approach:
- While calculating ComputedProperties, a flag is saved if any rule
  applied to an element is affected by the hover state during the
  execution of SelectorEngine::matches().
- When the hovered element changes, styles are marked for recalculation
  only if the flag saved in ComputedProperties indicates that the
  element could be affected by the hover state.
This commit is contained in:
Aliaksandr Kalenik 2025-01-03 20:39:25 +03:00 committed by Andreas Kling
commit e465e922bd
Notes: github-actions[bot] 2025-01-04 19:33:47 +00:00
9 changed files with 124 additions and 77 deletions

View file

@ -213,6 +213,9 @@ public:
static float resolve_opacity_value(CSSStyleValue const& value);
bool did_match_any_hover_rules() const { return m_did_match_any_hover_rules; }
void set_did_match_any_hover_rules() { m_did_match_any_hover_rules = true; }
private:
friend class StyleComputer;
@ -236,6 +239,8 @@ private:
mutable RefPtr<Gfx::FontCascadeList> m_font_list;
Optional<CSSPixels> m_line_height;
bool m_did_match_any_hover_rules { false };
};
}