Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_manager_android.cc |
| diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc |
| index 8a5a498f49a74d1c464e395b42e2219e66ec8a2a..bed7f345183b28e3e7b7c058853ee1a5c03d82b9 100644 |
| --- a/content/browser/accessibility/browser_accessibility_manager_android.cc |
| +++ b/content/browser/accessibility/browser_accessibility_manager_android.cc |
| @@ -54,6 +54,20 @@ bool SectionPredicate( |
| } |
| } |
| +bool AllInterestingNodesPredicate( |
| + BrowserAccessibility* start, BrowserAccessibility* node) { |
| + // Focusable nodes should never be skipped. Note that IsFocusable() |
| + // already skips over things like iframes and child frames that are |
| + // technically focusable but shouldn't be exposed as focusable on Android. |
| + BrowserAccessibilityAndroid* android_node = |
| + static_cast<BrowserAccessibilityAndroid*>(node); |
| + if (android_node->IsFocusable()) |
| + return true; |
| + |
| + // Otherwise, the interesting nodes are leaf nodes with text. |
|
David Tseng
2016/10/12 20:28:35
If I have a <div role="button"> (no text content,
dmazzoni
2016/10/12 22:41:58
Good idea, I can have it return true if it's a con
|
| + return node->PlatformIsLeaf() && !node->GetText().empty(); |
| +} |
| + |
| void AddToPredicateMap(const char* search_key_ascii, |
| AccessibilityMatchPredicate predicate) { |
| base::string16 search_key_utf16 = base::ASCIIToUTF16(search_key_ascii); |
| @@ -105,14 +119,9 @@ AccessibilityMatchPredicate PredicateForSearchKey( |
| if (iter != g_search_key_to_predicate_map.Get().end()) |
| return iter->second; |
| - // If we don't recognize the selector, return any element that's clickable. |
| - // We mark all focusable nodes and leaf nodes as clickable because it's |
| - // impossible to know whether a web node has a click handler or not, so |
| - // to be safe we have to allow accessibility services to click on nearly |
| - // anything that could possibly respond to a click. |
| - return [](BrowserAccessibility* start, BrowserAccessibility* node) { |
| - return static_cast<BrowserAccessibilityAndroid*>(node)->IsClickable(); |
| - }; |
| + // If we don't recognize the selector, return any element that a |
| + // screen reader should navigate to. |
| + return AllInterestingNodesPredicate; |
| } |
| } // anonymous namespace |