Chromium Code Reviews| 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..b0fdd15733f2eeb5abe1999c60577eafd0d80db8 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::GetInterestingChild() const { |
|
aboxhall
2016/10/18 21:03:24
Trying to think of a less confusing name for this
dmazzoni
2016/10/18 22:09:36
Good idea, I changed it to GetSoleInterestingDesce
|
| + if (IsInterestingOnAndroid()) |
| + return this; |
| + |
| + const BrowserAccessibilityAndroid* interesting_child = nullptr; |
| + for (uint32_t i = 0; i < PlatformChildCount(); ++i) { |
| + const BrowserAccessibilityAndroid* result = |
| + static_cast<const BrowserAccessibilityAndroid*>(PlatformGetChild(i))-> |
| + GetInterestingChild(); |
| + if (result && interesting_child) { |
|
aboxhall
2016/10/18 21:03:24
Maybe s/result/interesting_child/ and s/interestin
dmazzoni
2016/10/18 22:09:36
Done.
|
| + // If there are two interesting children, return nullptr |
| + return nullptr; |
| + } else if (result) { |
| + interesting_child = result; |
| + } |
| + } |
| + |
| + return interesting_child; |
| +} |
| + |
| bool BrowserAccessibilityAndroid::CanOpenPopup() const { |
| return HasState(ui::AX_STATE_HASPOPUP); |
| } |