LibWeb: Implement basic focus indication for :focus-visible

This causes links to no longer show an outline when clicked; only when
using keyboard navigation with the tab key will the outline show up.
This commit is contained in:
Jelle Raaijmakers 2025-06-13 14:12:35 +02:00 committed by Alexander Kalenik
commit 15c436b332
Notes: github-actions[bot] 2025-06-13 15:40:20 +00:00
3 changed files with 39 additions and 2 deletions

View file

@ -549,8 +549,7 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
case CSS::PseudoClass::Focus:
return element.is_focused();
case CSS::PseudoClass::FocusVisible:
// FIXME: We should only apply this when a visible focus is useful. Decide when that is!
return element.is_focused();
return element.is_focused() && element.should_indicate_focus();
case CSS::PseudoClass::FocusWithin: {
auto* focused_element = element.document().focused_element();
return focused_element && element.is_inclusive_ancestor_of(*focused_element);