mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +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
|
@ -70,7 +70,8 @@ static WebIDL::ExceptionOr<Variant<GC::Ptr<Element>, GC::Ref<NodeList>>> scope_m
|
|||
// FIXME: This should be shadow-including. https://drafts.csswg.org/selectors-4/#match-a-selector-against-a-tree
|
||||
node.for_each_in_subtree_of_type<Element>([&](auto& element) {
|
||||
for (auto& selector : selectors) {
|
||||
if (SelectorEngine::matches(selector, {}, element, nullptr, {}, node)) {
|
||||
SelectorEngine::MatchContext context;
|
||||
if (SelectorEngine::matches(selector, element, nullptr, context, {}, node)) {
|
||||
if (return_matches == ReturnMatches::First) {
|
||||
single_result = &element;
|
||||
return TraversalDecision::Break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue