Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1114)

Unified Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 2323043002: Too many accessible nodes were marked as clickable on Android (Closed)
Patch Set: Fix item markers Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_manager_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility_android.cc
diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc
index 028d76d2bc4e4fe2777da635d0c436869305a37e..c3a50a485617adcb7004ffd0b78f4958a4b0279e 100644
--- a/content/browser/accessibility/browser_accessibility_android.cc
+++ b/content/browser/accessibility/browser_accessibility_android.cc
@@ -154,12 +154,14 @@ bool BrowserAccessibilityAndroid::IsChecked() const {
}
bool BrowserAccessibilityAndroid::IsClickable() const {
- if (!PlatformIsLeaf())
- return false;
+ // If it has a default action, it's definitely clickable.
+ if (HasStringAttribute(ui::AX_ATTR_ACTION))
+ return true;
- // We are very aggressive about returning true with IsClickable on Android
- // because there is no way to know for sure what might have a click handler.
- return IsFocusable() || !GetText().empty();
+ // Otherwise return true if it's focusable, but skip web areas and iframes.
+ if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA))
+ return false;
+ return IsFocusable();
}
bool BrowserAccessibilityAndroid::IsCollapsed() const {
@@ -207,12 +209,14 @@ bool BrowserAccessibilityAndroid::IsExpanded() const {
}
bool BrowserAccessibilityAndroid::IsFocusable() const {
- bool focusable = HasState(ui::AX_STATE_FOCUSABLE);
- if (IsIframe() ||
- GetRole() == ui::AX_ROLE_WEB_AREA) {
- focusable = false;
- }
- return focusable;
+ // If it's an iframe element, or the root element of a child frame,
+ // only mark it as focusable if the element has an explicit name.
+ // Otherwise mark it as not focusable to avoid the user landing on
+ // empty container elements in the tree.
+ if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && GetParent()))
+ return HasStringAttribute(ui::AX_ATTR_NAME);
+
+ return HasState(ui::AX_STATE_FOCUSABLE);
}
bool BrowserAccessibilityAndroid::IsFocused() const {
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_manager_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698