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

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

Issue 2422773002: Improve Android accessible hit testing. (Closed)
Patch Set: Address feedback 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
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 c3a50a485617adcb7004ffd0b78f4958a4b0279e..70e85b87d39f9499dc3172abb2ec861cc5e6fdf3 100644
--- a/content/browser/accessibility/browser_accessibility_android.cc
+++ b/content/browser/accessibility/browser_accessibility_android.cc
@@ -277,6 +277,42 @@ bool BrowserAccessibilityAndroid::IsVisibleToUser() const {
return !HasState(ui::AX_STATE_INVISIBLE);
}
+bool BrowserAccessibilityAndroid::IsInterestingOnAndroid() const {
+ // Focusable nodes are always interesting. 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.
+ if (IsFocusable())
+ return true;
+
+ // If it's not focusable but has a control role, then it's interesting.
+ if (IsControl())
+ return true;
+
+ // Otherwise, the interesting nodes are leaf nodes with text.
+ return PlatformIsLeaf() && !GetText().empty();
+}
+
+const BrowserAccessibilityAndroid*
+ BrowserAccessibilityAndroid::GetSoleInterestingDescendant() const {
+ if (IsInterestingOnAndroid())
+ return this;
+
+ const BrowserAccessibilityAndroid* sole_interesting_descendant = nullptr;
+ for (uint32_t i = 0; i < PlatformChildCount(); ++i) {
+ const BrowserAccessibilityAndroid* interesting_descendant =
+ static_cast<const BrowserAccessibilityAndroid*>(PlatformGetChild(i))->
+ GetSoleInterestingDescendant();
+ if (interesting_descendant && sole_interesting_descendant) {
+ // If there are two interesting descendants, return nullptr.
+ return nullptr;
+ } else if (interesting_descendant) {
+ sole_interesting_descendant = interesting_descendant;
+ }
+ }
+
+ return sole_interesting_descendant;
+}
+
bool BrowserAccessibilityAndroid::CanOpenPopup() const {
return HasState(ui::AX_STATE_HASPOPUP);
}

Powered by Google App Engine
This is Rietveld 408576698