Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/accessibility/browser_accessibility_android.h" | 5 #include "content/browser/accessibility/browser_accessibility_android.h" |
| 6 | 6 |
| 7 #include "base/i18n/break_iterator.h" | 7 #include "base/i18n/break_iterator.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 if (HasState(ui::AX_STATE_CHECKED)) | 147 if (HasState(ui::AX_STATE_CHECKED)) |
| 148 checkable = true; | 148 checkable = true; |
| 149 return checkable; | 149 return checkable; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool BrowserAccessibilityAndroid::IsChecked() const { | 152 bool BrowserAccessibilityAndroid::IsChecked() const { |
| 153 return (HasState(ui::AX_STATE_CHECKED) || HasState(ui::AX_STATE_PRESSED)); | 153 return (HasState(ui::AX_STATE_CHECKED) || HasState(ui::AX_STATE_PRESSED)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool BrowserAccessibilityAndroid::IsClickable() const { | 156 bool BrowserAccessibilityAndroid::IsClickable() const { |
| 157 if (!PlatformIsLeaf()) | 157 // A node is clickable if it's focusable or if it has a default action. |
| 158 return false; | 158 return IsFocusable() || HasStringAttribute(ui::AX_ATTR_ACTION); |
| 159 | |
| 160 // We are very aggressive about returning true with IsClickable on Android | |
| 161 // because there is no way to know for sure what might have a click handler. | |
|
David Tseng
2016/10/12 20:28:35
Is this no longer a concern or do you have a more
dmazzoni
2016/10/12 22:41:58
An older version of TalkBack was skipping over any
| |
| 162 return IsFocusable() || !GetText().empty(); | |
| 163 } | 159 } |
| 164 | 160 |
| 165 bool BrowserAccessibilityAndroid::IsCollapsed() const { | 161 bool BrowserAccessibilityAndroid::IsCollapsed() const { |
| 166 return HasState(ui::AX_STATE_COLLAPSED); | 162 return HasState(ui::AX_STATE_COLLAPSED); |
| 167 } | 163 } |
| 168 | 164 |
| 169 bool BrowserAccessibilityAndroid::IsCollection() const { | 165 bool BrowserAccessibilityAndroid::IsCollection() const { |
| 170 return (GetRole() == ui::AX_ROLE_GRID || | 166 return (GetRole() == ui::AX_ROLE_GRID || |
| 171 GetRole() == ui::AX_ROLE_LIST || | 167 GetRole() == ui::AX_ROLE_LIST || |
| 172 GetRole() == ui::AX_ROLE_LIST_BOX || | 168 GetRole() == ui::AX_ROLE_LIST_BOX || |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 200 | 196 |
| 201 bool BrowserAccessibilityAndroid::IsEnabled() const { | 197 bool BrowserAccessibilityAndroid::IsEnabled() const { |
| 202 return !HasState(ui::AX_STATE_DISABLED); | 198 return !HasState(ui::AX_STATE_DISABLED); |
| 203 } | 199 } |
| 204 | 200 |
| 205 bool BrowserAccessibilityAndroid::IsExpanded() const { | 201 bool BrowserAccessibilityAndroid::IsExpanded() const { |
| 206 return HasState(ui::AX_STATE_EXPANDED); | 202 return HasState(ui::AX_STATE_EXPANDED); |
| 207 } | 203 } |
| 208 | 204 |
| 209 bool BrowserAccessibilityAndroid::IsFocusable() const { | 205 bool BrowserAccessibilityAndroid::IsFocusable() const { |
| 210 bool focusable = HasState(ui::AX_STATE_FOCUSABLE); | 206 // Don't count iframes as focusable. |
| 211 if (IsIframe() || | 207 if (IsIframe()) |
| 212 GetRole() == ui::AX_ROLE_WEB_AREA) { | 208 return false; |
| 213 focusable = false; | 209 |
| 214 } | 210 // Only the root of the tree, and not child frames, are focusable. |
|
David Tseng
2016/10/12 20:28:35
Seems strange to have this restriction; what if a
dmazzoni
2016/10/12 22:41:58
Agreed. I changed it so that we skip iframes and c
| |
| 215 return focusable; | 211 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) |
| 212 return !GetParent(); | |
| 213 | |
| 214 return HasState(ui::AX_STATE_FOCUSABLE); | |
| 216 } | 215 } |
| 217 | 216 |
| 218 bool BrowserAccessibilityAndroid::IsFocused() const { | 217 bool BrowserAccessibilityAndroid::IsFocused() const { |
| 219 return manager()->GetFocus() == this; | 218 return manager()->GetFocus() == this; |
| 220 } | 219 } |
| 221 | 220 |
| 222 bool BrowserAccessibilityAndroid::IsHeading() const { | 221 bool BrowserAccessibilityAndroid::IsHeading() const { |
| 223 BrowserAccessibilityAndroid* parent = | 222 BrowserAccessibilityAndroid* parent = |
| 224 static_cast<BrowserAccessibilityAndroid*>(GetParent()); | 223 static_cast<BrowserAccessibilityAndroid*>(GetParent()); |
| 225 if (parent && parent->IsHeading()) | 224 if (parent && parent->IsHeading()) |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1420 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1419 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
| 1421 int count = 0; | 1420 int count = 0; |
| 1422 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1421 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
| 1423 if (PlatformGetChild(i)->GetRole() == role) | 1422 if (PlatformGetChild(i)->GetRole() == role) |
| 1424 count++; | 1423 count++; |
| 1425 } | 1424 } |
| 1426 return count; | 1425 return count; |
| 1427 } | 1426 } |
| 1428 | 1427 |
| 1429 } // namespace content | 1428 } // namespace content |
| OLD | NEW |