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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "content/app/strings/grit/content_strings.h" | 12 #include "content/app/strings/grit/content_strings.h" |
13 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
14 #include "content/common/accessibility_messages.h" | 14 #include "content/common/accessibility_messages.h" |
15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "ui/accessibility/ax_role_properties.h" |
17 #include "ui/accessibility/platform/ax_android_constants.h" | 18 #include "ui/accessibility/platform/ax_android_constants.h" |
18 #include "ui/accessibility/platform/ax_snapshot_node_android_platform.h" | 19 #include "ui/accessibility/platform/ax_snapshot_node_android_platform.h" |
19 | 20 |
20 namespace aria_strings { | 21 namespace aria_strings { |
21 const char kAriaLivePolite[] = "polite"; | 22 const char kAriaLivePolite[] = "polite"; |
22 const char kAriaLiveAssertive[] = "assertive"; | 23 const char kAriaLiveAssertive[] = "assertive"; |
23 } | 24 } |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Otherwise return true if it's focusable, but skip web areas and iframes. | 162 // Otherwise return true if it's focusable, but skip web areas and iframes. |
162 if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) | 163 if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) |
163 return false; | 164 return false; |
164 return IsFocusable(); | 165 return IsFocusable(); |
165 } | 166 } |
166 | 167 |
167 bool BrowserAccessibilityAndroid::IsCollapsed() const { | 168 bool BrowserAccessibilityAndroid::IsCollapsed() const { |
168 return HasState(ui::AX_STATE_COLLAPSED); | 169 return HasState(ui::AX_STATE_COLLAPSED); |
169 } | 170 } |
170 | 171 |
| 172 // TODO(dougt) Move to ax_role_properties? |
171 bool BrowserAccessibilityAndroid::IsCollection() const { | 173 bool BrowserAccessibilityAndroid::IsCollection() const { |
172 return (IsTableLikeRole() || GetRole() == ui::AX_ROLE_LIST || | 174 return (ui::IsTableLikeRole(GetRole()) || GetRole() == ui::AX_ROLE_LIST || |
173 GetRole() == ui::AX_ROLE_LIST_BOX || | 175 GetRole() == ui::AX_ROLE_LIST_BOX || |
174 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || | 176 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || |
175 GetRole() == ui::AX_ROLE_TREE); | 177 GetRole() == ui::AX_ROLE_TREE); |
176 } | 178 } |
177 | 179 |
178 bool BrowserAccessibilityAndroid::IsCollectionItem() const { | 180 bool BrowserAccessibilityAndroid::IsCollectionItem() const { |
179 return (GetRole() == ui::AX_ROLE_CELL || | 181 return (GetRole() == ui::AX_ROLE_CELL || |
180 GetRole() == ui::AX_ROLE_COLUMN_HEADER || | 182 GetRole() == ui::AX_ROLE_COLUMN_HEADER || |
181 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || | 183 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || |
182 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || | 184 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 else if (live == "assertive") | 1140 else if (live == "assertive") |
1139 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE; | 1141 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE; |
1140 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE; | 1142 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE; |
1141 } | 1143 } |
1142 | 1144 |
1143 int BrowserAccessibilityAndroid::AndroidRangeType() const { | 1145 int BrowserAccessibilityAndroid::AndroidRangeType() const { |
1144 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT; | 1146 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT; |
1145 } | 1147 } |
1146 | 1148 |
1147 int BrowserAccessibilityAndroid::RowCount() const { | 1149 int BrowserAccessibilityAndroid::RowCount() const { |
1148 if (IsTableLikeRole()) { | 1150 if (ui::IsTableLikeRole(GetRole())) { |
1149 return CountChildrenWithRole(ui::AX_ROLE_ROW); | 1151 return CountChildrenWithRole(ui::AX_ROLE_ROW); |
1150 } | 1152 } |
1151 | 1153 |
1152 if (GetRole() == ui::AX_ROLE_LIST || | 1154 if (GetRole() == ui::AX_ROLE_LIST || |
1153 GetRole() == ui::AX_ROLE_LIST_BOX || | 1155 GetRole() == ui::AX_ROLE_LIST_BOX || |
1154 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || | 1156 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || |
1155 GetRole() == ui::AX_ROLE_TREE) { | 1157 GetRole() == ui::AX_ROLE_TREE) { |
1156 return PlatformChildCount(); | 1158 return PlatformChildCount(); |
1157 } | 1159 } |
1158 | 1160 |
1159 return 0; | 1161 return 0; |
1160 } | 1162 } |
1161 | 1163 |
1162 int BrowserAccessibilityAndroid::ColumnCount() const { | 1164 int BrowserAccessibilityAndroid::ColumnCount() const { |
1163 if (IsTableLikeRole()) { | 1165 if (ui::IsTableLikeRole(GetRole())) { |
1164 return CountChildrenWithRole(ui::AX_ROLE_COLUMN); | 1166 return CountChildrenWithRole(ui::AX_ROLE_COLUMN); |
1165 } | 1167 } |
1166 return 0; | 1168 return 0; |
1167 } | 1169 } |
1168 | 1170 |
1169 int BrowserAccessibilityAndroid::RowIndex() const { | 1171 int BrowserAccessibilityAndroid::RowIndex() const { |
1170 if (GetRole() == ui::AX_ROLE_LIST_ITEM || | 1172 if (GetRole() == ui::AX_ROLE_LIST_ITEM || |
1171 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || | 1173 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || |
1172 GetRole() == ui::AX_ROLE_TREE_ITEM) { | 1174 GetRole() == ui::AX_ROLE_TREE_ITEM) { |
1173 return GetIndexInParent(); | 1175 return GetIndexInParent(); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1408 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
1407 int count = 0; | 1409 int count = 0; |
1408 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1410 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
1409 if (PlatformGetChild(i)->GetRole() == role) | 1411 if (PlatformGetChild(i)->GetRole() == role) |
1410 count++; | 1412 count++; |
1411 } | 1413 } |
1412 return count; | 1414 return count; |
1413 } | 1415 } |
1414 | 1416 |
1415 } // namespace content | 1417 } // namespace content |
OLD | NEW |