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

Side by Side Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 2825803002: Expose internal treegrid role, do some cleanup for table/grid/treegrid handling (Closed)
Patch Set: Expose table properties for <table role=grid> Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) 167 if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA))
168 return false; 168 return false;
169 return IsFocusable(); 169 return IsFocusable();
170 } 170 }
171 171
172 bool BrowserAccessibilityAndroid::IsCollapsed() const { 172 bool BrowserAccessibilityAndroid::IsCollapsed() const {
173 return HasState(ui::AX_STATE_COLLAPSED); 173 return HasState(ui::AX_STATE_COLLAPSED);
174 } 174 }
175 175
176 bool BrowserAccessibilityAndroid::IsCollection() const { 176 bool BrowserAccessibilityAndroid::IsCollection() const {
177 return (GetRole() == ui::AX_ROLE_GRID || 177 return (IsTableOrGridOrTreeGridRole() || GetRole() == ui::AX_ROLE_LIST ||
dmazzoni 2017/04/18 21:59:38 Maybe IsTableLikeRole?
aleventhal 2017/04/19 20:24:02 Done.
178 GetRole() == ui::AX_ROLE_LIST ||
179 GetRole() == ui::AX_ROLE_LIST_BOX || 178 GetRole() == ui::AX_ROLE_LIST_BOX ||
180 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || 179 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST ||
181 GetRole() == ui::AX_ROLE_TABLE ||
182 GetRole() == ui::AX_ROLE_TREE); 180 GetRole() == ui::AX_ROLE_TREE);
183 } 181 }
184 182
185 bool BrowserAccessibilityAndroid::IsCollectionItem() const { 183 bool BrowserAccessibilityAndroid::IsCollectionItem() const {
186 return (GetRole() == ui::AX_ROLE_CELL || 184 return (GetRole() == ui::AX_ROLE_CELL ||
187 GetRole() == ui::AX_ROLE_COLUMN_HEADER || 185 GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
188 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || 186 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM ||
189 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || 187 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
190 GetRole() == ui::AX_ROLE_LIST_ITEM || 188 GetRole() == ui::AX_ROLE_LIST_ITEM ||
191 GetRole() == ui::AX_ROLE_ROW_HEADER || 189 GetRole() == ui::AX_ROLE_ROW_HEADER ||
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 class_name = ui::kAXImageClassname; 366 class_name = ui::kAXImageClassname;
369 break; 367 break;
370 case ui::AX_ROLE_METER: 368 case ui::AX_ROLE_METER:
371 case ui::AX_ROLE_PROGRESS_INDICATOR: 369 case ui::AX_ROLE_PROGRESS_INDICATOR:
372 class_name = ui::kAXProgressBarClassname; 370 class_name = ui::kAXProgressBarClassname;
373 break; 371 break;
374 case ui::AX_ROLE_TAB_LIST: 372 case ui::AX_ROLE_TAB_LIST:
375 class_name = ui::kAXTabWidgetClassname; 373 class_name = ui::kAXTabWidgetClassname;
376 break; 374 break;
377 case ui::AX_ROLE_GRID: 375 case ui::AX_ROLE_GRID:
376 case ui::AX_ROLE_TREE_GRID:
378 case ui::AX_ROLE_TABLE: 377 case ui::AX_ROLE_TABLE:
379 class_name = ui::kAXGridViewClassname; 378 class_name = ui::kAXGridViewClassname;
380 break; 379 break;
381 case ui::AX_ROLE_LIST: 380 case ui::AX_ROLE_LIST:
382 case ui::AX_ROLE_LIST_BOX: 381 case ui::AX_ROLE_LIST_BOX:
383 case ui::AX_ROLE_DESCRIPTION_LIST: 382 case ui::AX_ROLE_DESCRIPTION_LIST:
384 class_name = ui::kAXListViewClassname; 383 class_name = ui::kAXListViewClassname;
385 break; 384 break;
386 case ui::AX_ROLE_DIALOG: 385 case ui::AX_ROLE_DIALOG:
387 class_name = ui::kAXDialogClassname; 386 class_name = ui::kAXDialogClassname;
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 else if (live == "assertive") 1238 else if (live == "assertive")
1240 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE; 1239 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE;
1241 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE; 1240 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE;
1242 } 1241 }
1243 1242
1244 int BrowserAccessibilityAndroid::AndroidRangeType() const { 1243 int BrowserAccessibilityAndroid::AndroidRangeType() const {
1245 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT; 1244 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT;
1246 } 1245 }
1247 1246
1248 int BrowserAccessibilityAndroid::RowCount() const { 1247 int BrowserAccessibilityAndroid::RowCount() const {
1249 if (GetRole() == ui::AX_ROLE_GRID || 1248 if (IsTableOrGridOrTreeGridRole()) {
1250 GetRole() == ui::AX_ROLE_TABLE) {
1251 return CountChildrenWithRole(ui::AX_ROLE_ROW); 1249 return CountChildrenWithRole(ui::AX_ROLE_ROW);
1252 } 1250 }
1253 1251
1254 if (GetRole() == ui::AX_ROLE_LIST || 1252 if (GetRole() == ui::AX_ROLE_LIST ||
1255 GetRole() == ui::AX_ROLE_LIST_BOX || 1253 GetRole() == ui::AX_ROLE_LIST_BOX ||
1256 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || 1254 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST ||
1257 GetRole() == ui::AX_ROLE_TREE) { 1255 GetRole() == ui::AX_ROLE_TREE) {
1258 return PlatformChildCount(); 1256 return PlatformChildCount();
1259 } 1257 }
1260 1258
1261 return 0; 1259 return 0;
1262 } 1260 }
1263 1261
1264 int BrowserAccessibilityAndroid::ColumnCount() const { 1262 int BrowserAccessibilityAndroid::ColumnCount() const {
1265 if (GetRole() == ui::AX_ROLE_GRID || 1263 if (IsTableOrGridOrTreeGridRole()) {
1266 GetRole() == ui::AX_ROLE_TABLE) {
1267 return CountChildrenWithRole(ui::AX_ROLE_COLUMN); 1264 return CountChildrenWithRole(ui::AX_ROLE_COLUMN);
1268 } 1265 }
1269 return 0; 1266 return 0;
1270 } 1267 }
1271 1268
1272 int BrowserAccessibilityAndroid::RowIndex() const { 1269 int BrowserAccessibilityAndroid::RowIndex() const {
1273 if (GetRole() == ui::AX_ROLE_LIST_ITEM || 1270 if (GetRole() == ui::AX_ROLE_LIST_ITEM ||
1274 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || 1271 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
1275 GetRole() == ui::AX_ROLE_TREE_ITEM) { 1272 GetRole() == ui::AX_ROLE_TREE_ITEM) {
1276 return GetIndexInParent(); 1273 return GetIndexInParent();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1504 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1508 int count = 0; 1505 int count = 0;
1509 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1506 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1510 if (PlatformGetChild(i)->GetRole() == role) 1507 if (PlatformGetChild(i)->GetRole() == role)
1511 count++; 1508 count++;
1512 } 1509 }
1513 return count; 1510 return count;
1514 } 1511 }
1515 1512
1516 } // namespace content 1513 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698