mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
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:
parent
db58986e5f
commit
e465e922bd
Notes:
github-actions[bot]
2025-01-04 19:33:47 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: e465e922bd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3121
9 changed files with 124 additions and 77 deletions
|
@ -16,9 +16,14 @@ enum class SelectorKind {
|
|||
Relative,
|
||||
};
|
||||
|
||||
bool matches(CSS::Selector const&, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host, Optional<CSS::Selector::PseudoElement::Type> = {}, GC::Ptr<DOM::ParentNode const> scope = {}, SelectorKind selector_kind = SelectorKind::Normal, GC::Ptr<DOM::Element const> anchor = nullptr);
|
||||
struct MatchContext {
|
||||
GC::Ptr<CSS::CSSStyleSheet const> style_sheet_for_rule {};
|
||||
bool did_match_any_hover_rules { false };
|
||||
};
|
||||
|
||||
[[nodiscard]] bool fast_matches(CSS::Selector const&, Optional<CSS::CSSStyleSheet const&> style_sheet_for_rule, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host);
|
||||
bool matches(CSS::Selector const&, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host, MatchContext& context, Optional<CSS::Selector::PseudoElement::Type> = {}, GC::Ptr<DOM::ParentNode const> scope = {}, SelectorKind selector_kind = SelectorKind::Normal, GC::Ptr<DOM::Element const> anchor = nullptr);
|
||||
|
||||
[[nodiscard]] bool fast_matches(CSS::Selector const&, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host, MatchContext& context);
|
||||
[[nodiscard]] bool can_use_fast_matches(CSS::Selector const&);
|
||||
|
||||
[[nodiscard]] bool matches_hover_pseudo_class(DOM::Element const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue