LibWeb: Invalidate pseudo-elements on hover even when not yet created

The hover invalidation code only tried matching ::before/::after
selectors when has_pseudo_element() returned true, which requires an
existing layout node. A pseudo-element that doesn't exist yet (because
its content is only set by a hover rule) has no layout node, so the
match was skipped and hovering never triggered a style recompute.
Always try ::before/::after selectors during hover invalidation.
This commit is contained in:
Jelle Raaijmakers
2026-03-24 13:35:58 +01:00
committed by Tim Flynn
parent 77b9fcf7f9
commit 16dffe39a0
Notes: github-actions[bot] 2026-03-24 14:28:09 +00:00
5 changed files with 43 additions and 44 deletions

View File

@@ -2076,14 +2076,10 @@ void Document::invalidate_style_for_elements_affected_by_pseudo_class_change(CSS
SelectorEngine::MatchContext context;
if (SelectorEngine::matches(selector, element, {}, context, {}))
return true;
if (element.has_pseudo_element(CSS::PseudoElement::Before)) {
if (SelectorEngine::matches(selector, element, {}, context, CSS::PseudoElement::Before))
return true;
}
if (element.has_pseudo_element(CSS::PseudoElement::After)) {
if (SelectorEngine::matches(selector, element, {}, context, CSS::PseudoElement::After))
return true;
}
if (SelectorEngine::matches(selector, element, {}, context, CSS::PseudoElement::Before))
return true;
if (SelectorEngine::matches(selector, element, {}, context, CSS::PseudoElement::After))
return true;
return false;
};