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

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

Issue 1547643002: ARIA 1.1: implementation for aria-col-* and aria-row-*. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds MODULES_EXPORT Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 int columns; 1303 int columns;
1304 if (GetIntAttribute( 1304 if (GetIntAttribute(
1305 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns)) { 1305 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns)) {
1306 *column_count = columns; 1306 *column_count = columns;
1307 return S_OK; 1307 return S_OK;
1308 } 1308 }
1309 1309
1310 return S_FALSE; 1310 return S_FALSE;
1311 } 1311 }
1312 1312
1313 STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { 1313 STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) {
dmazzoni 2015/12/22 18:10:04 I was assuming that get_nRows would return a diffe
1314 if (!instance_active()) 1314 if (!instance_active())
1315 return E_FAIL; 1315 return E_FAIL;
1316 1316
1317 if (!row_count) 1317 if (!row_count)
1318 return E_INVALIDARG; 1318 return E_INVALIDARG;
1319 1319
1320 int rows; 1320 int rows;
1321 if (GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { 1321 if (GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) {
1322 *row_count = rows; 1322 *row_count = rows;
1323 return S_OK; 1323 return S_OK;
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 ui::AX_ATTR_UNIQUE_CELL_IDS); 3316 ui::AX_ATTR_UNIQUE_CELL_IDS);
3317 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { 3317 for (size_t i = 0; i < unique_cell_ids.size(); ++i) {
3318 if (unique_cell_ids[i] == GetId()) { 3318 if (unique_cell_ids[i] == GetId()) {
3319 win_attributes_->ia2_attributes.push_back( 3319 win_attributes_->ia2_attributes.push_back(
3320 base::string16(L"table-cell-index:") + base::IntToString16(i)); 3320 base::string16(L"table-cell-index:") + base::IntToString16(i));
3321 } 3321 }
3322 } 3322 }
3323 } 3323 }
3324 } 3324 }
3325 3325
3326 //Expose aria-colcount and aria-rowcount in a table, grid or treegrid
3327 if (IsTableOrGridOrTreeGridRole()) {
3328 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_COUNT, "colcount");
3329 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount");
3330 }
3331
3332 //Expose aria-colindex and aria-rowindex in a cell or row
3333 if (IsCellOrTableHeaderRole() || GetRole() == ui::AX_ROLE_ROW) {
3334 if (GetRole() != ui::AX_ROLE_ROW)
3335 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_INDEX, "colindex");
3336 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_INDEX, "rowindex");
3337 }
3338
3326 // Expose invalid state for form controls and elements with aria-invalid. 3339 // Expose invalid state for form controls and elements with aria-invalid.
3327 int invalid_state; 3340 int invalid_state;
3328 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { 3341 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) {
3329 // TODO(nektar): Handle the possibility of having multiple aria-invalid 3342 // TODO(nektar): Handle the possibility of having multiple aria-invalid
3330 // attributes defined, e.g., "invalid:spelling,grammar". 3343 // attributes defined, e.g., "invalid:spelling,grammar".
3331 switch (invalid_state) { 3344 switch (invalid_state) {
3332 case ui::AX_INVALID_STATE_FALSE: 3345 case ui::AX_INVALID_STATE_FALSE:
3333 win_attributes_->ia2_attributes.push_back(L"invalid:false"); 3346 win_attributes_->ia2_attributes.push_back(L"invalid:false");
3334 break; 3347 break;
3335 case ui::AX_INVALID_STATE_TRUE: 3348 case ui::AX_INVALID_STATE_TRUE:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 for (size_t i = 0; i < relations_.size(); ++i) 3419 for (size_t i = 0; i < relations_.size(); ++i)
3407 relations_[i]->Release(); 3420 relations_[i]->Release();
3408 relations_.clear(); 3421 relations_.clear();
3409 3422
3410 // Handle title UI element. 3423 // Handle title UI element.
3411 AddRelations(ui::AX_ATTR_CONTROLS_IDS, IA2_RELATION_CONTROLLER_FOR); 3424 AddRelations(ui::AX_ATTR_CONTROLS_IDS, IA2_RELATION_CONTROLLER_FOR);
3412 AddRelations(ui::AX_ATTR_DESCRIBEDBY_IDS, IA2_RELATION_DESCRIBED_BY); 3425 AddRelations(ui::AX_ATTR_DESCRIBEDBY_IDS, IA2_RELATION_DESCRIBED_BY);
3413 AddRelations(ui::AX_ATTR_FLOWTO_IDS, IA2_RELATION_FLOWS_TO); 3426 AddRelations(ui::AX_ATTR_FLOWTO_IDS, IA2_RELATION_FLOWS_TO);
3414 AddRelations(ui::AX_ATTR_LABELLEDBY_IDS, IA2_RELATION_LABELLED_BY); 3427 AddRelations(ui::AX_ATTR_LABELLEDBY_IDS, IA2_RELATION_LABELLED_BY);
3415 3428
3429 // Expose slider value.
3430 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR ||
3431 ia_role() == ROLE_SYSTEM_SCROLLBAR ||
3432 ia_role() == ROLE_SYSTEM_SLIDER) {
3433 base::string16 value_text = GetValueText();
3434 SanitizeStringAttributeForIA2(value_text, &value_text);
3435 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text);
3436 }
3437
3416 UpdateRequiredAttributes(); 3438 UpdateRequiredAttributes();
3417 // If this is a web area for a presentational iframe, give it a role of 3439 // If this is a web area for a presentational iframe, give it a role of
3418 // something other than DOCUMENT so that the fact that it's a separate doc 3440 // something other than DOCUMENT so that the fact that it's a separate doc
3419 // is not exposed to AT. 3441 // is not exposed to AT.
3420 if (IsWebAreaForPresentationalIframe()) { 3442 if (IsWebAreaForPresentationalIframe()) {
3421 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; 3443 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING;
3422 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; 3444 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING;
3423 } 3445 }
3424 } 3446 }
3425 3447
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 4067
4046 if (role == ui::AX_ROLE_MENU_LIST_OPTION && 4068 if (role == ui::AX_ROLE_MENU_LIST_OPTION &&
4047 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { 4069 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) {
4048 return true; 4070 return true;
4049 } 4071 }
4050 4072
4051 return false; 4073 return false;
4052 } 4074 }
4053 4075
4054 void BrowserAccessibilityWin::UpdateRequiredAttributes() { 4076 void BrowserAccessibilityWin::UpdateRequiredAttributes() {
4055 // Expose slider value. 4077 if (IsCellOrTableHeaderRole()) {
4056 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || 4078 // Expose colspan attribute.
4057 ia_role() == ROLE_SYSTEM_SCROLLBAR || 4079 base::string16 colspan;
4058 ia_role() == ROLE_SYSTEM_SLIDER) { 4080 if (GetHtmlAttribute("aria-colspan", &colspan)) {
4059 base::string16 value_text = GetValueText(); 4081 SanitizeStringAttributeForIA2(colspan, &colspan);
4060 SanitizeStringAttributeForIA2(value_text, &value_text); 4082 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan);
4061 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); 4083 }
4084 // Expose rowspan attribute.
4085 base::string16 rowspan;
4086 if (GetHtmlAttribute("aria-rowspan", &rowspan)) {
4087 SanitizeStringAttributeForIA2(rowspan, &rowspan);
4088 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan);
4089 }
4062 } 4090 }
4063 4091
4064 // Expose dropeffect attribute. 4092 // Expose dropeffect attribute.
4065 base::string16 drop_effect; 4093 base::string16 drop_effect;
4066 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { 4094 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) {
4067 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); 4095 SanitizeStringAttributeForIA2(drop_effect, &drop_effect);
4068 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); 4096 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect);
4069 } 4097 }
4070 4098
4071 // Expose grabbed attribute. 4099 // Expose grabbed attribute.
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
4680 ia2_role = ia_role; 4708 ia2_role = ia_role;
4681 4709
4682 win_attributes_->ia_role = ia_role; 4710 win_attributes_->ia_role = ia_role;
4683 win_attributes_->ia_state = ia_state; 4711 win_attributes_->ia_state = ia_state;
4684 win_attributes_->role_name = role_name; 4712 win_attributes_->role_name = role_name;
4685 win_attributes_->ia2_role = ia2_role; 4713 win_attributes_->ia2_role = ia2_role;
4686 win_attributes_->ia2_state = ia2_state; 4714 win_attributes_->ia2_state = ia2_state;
4687 } 4715 }
4688 4716
4689 } // namespace content 4717 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698