diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index 35706199167e15..a1bbda4ac2ee3c 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc @@ -3519,11 +3519,26 @@ bool Element::SupportsSpatialNavigationFocus() const { // events). if (!IsSpatialNavigationEnabled(GetDocument().GetFrame())) return false; + + if (!GetLayoutObject()) + return false; + if (HasEventListeners(event_type_names::kClick) || HasEventListeners(event_type_names::kKeydown) || HasEventListeners(event_type_names::kKeypress) || HasEventListeners(event_type_names::kKeyup)) return true; + + // Some web apps use click-handlers to react on clicks within rects that are + // styled with {cursor: pointer}. Such rects *look* clickable so they probably + // are. Here we make Hand-trees' tip, the first (biggest) node with {cursor: + // pointer}, navigable because users shouldn't need to navigate through every + // sub element that inherit this CSS. + if (GetComputedStyle()->Cursor() == ECursor::kPointer && + ParentComputedStyle()->Cursor() != ECursor::kPointer) { + return true; + } + if (!IsSVGElement()) return false; return (HasEventListeners(event_type_names::kFocus) || diff --git a/third_party/blink/web_tests/fast/spatial-navigation/snav-cursor_pointer-clickable.html b/third_party/blink/web_tests/fast/spatial-navigation/snav-cursor_pointer-clickable.html new file mode 100644 index 00000000000000..91b7905fc4917e --- /dev/null +++ b/third_party/blink/web_tests/fast/spatial-navigation/snav-cursor_pointer-clickable.html @@ -0,0 +1,29 @@ + + + + + +
+ +

A typical popup dialog that listens for clicks on its two custom buttons.

+ + + + + + +

Manual test instruction: Ensure that all buttons can be focused.