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

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

Issue 2825803002: Expose internal treegrid role, do some cleanup for table/grid/treegrid handling (Closed)
Patch Set: Fix mac tests 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 (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 3784 matching lines...) Expand 10 before | Expand all | Expand 10 after
3795 break; 3795 break;
3796 case ui::AX_ARIA_CURRENT_STATE_TIME: 3796 case ui::AX_ARIA_CURRENT_STATE_TIME:
3797 win_attributes_->ia2_attributes.push_back(L"current:time"); 3797 win_attributes_->ia2_attributes.push_back(L"current:time");
3798 break; 3798 break;
3799 } 3799 }
3800 } 3800 }
3801 3801
3802 // Expose table cell index. 3802 // Expose table cell index.
3803 if (IsCellOrTableHeaderRole()) { 3803 if (IsCellOrTableHeaderRole()) {
3804 BrowserAccessibility* table = PlatformGetParent(); 3804 BrowserAccessibility* table = PlatformGetParent();
3805 while (table && table->GetRole() != ui::AX_ROLE_TABLE) 3805 while (table && !table->IsTableLikeRole())
3806 table = table->PlatformGetParent(); 3806 table = table->PlatformGetParent();
3807 if (table) { 3807 if (table) {
3808 const std::vector<int32_t>& unique_cell_ids = 3808 const std::vector<int32_t>& unique_cell_ids =
3809 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 3809 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
3810 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { 3810 for (size_t i = 0; i < unique_cell_ids.size(); ++i) {
3811 if (unique_cell_ids[i] == GetId()) { 3811 if (unique_cell_ids[i] == GetId()) {
3812 win_attributes_->ia2_attributes.push_back( 3812 win_attributes_->ia2_attributes.push_back(
3813 base::string16(L"table-cell-index:") + base::IntToString16(i)); 3813 base::string16(L"table-cell-index:") + base::IntToString16(i));
3814 } 3814 }
3815 } 3815 }
3816 } 3816 }
3817 } 3817 }
3818 3818
3819 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. 3819 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid.
3820 if (IsTableOrGridOrTreeGridRole()) { 3820 if (IsTableLikeRole()) {
3821 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_COUNT, "colcount"); 3821 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_COUNT, "colcount");
3822 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); 3822 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount");
3823 } 3823 }
3824 3824
3825 // Expose aria-colindex and aria-rowindex in a cell or row. 3825 // Expose aria-colindex and aria-rowindex in a cell or row.
3826 if (IsCellOrTableHeaderRole() || GetRole() == ui::AX_ROLE_ROW) { 3826 if (IsCellOrTableHeaderRole() || GetRole() == ui::AX_ROLE_ROW) {
3827 if (GetRole() != ui::AX_ROLE_ROW) 3827 if (GetRole() != ui::AX_ROLE_ROW)
3828 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_INDEX, "colindex"); 3828 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_INDEX, "colindex");
3829 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_INDEX, "rowindex"); 3829 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_INDEX, "rowindex");
3830 } 3830 }
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
5299 case ui::AX_ROLE_FORM: 5299 case ui::AX_ROLE_FORM:
5300 role_name = L"form"; 5300 role_name = L"form";
5301 ia2_role = IA2_ROLE_FORM; 5301 ia2_role = IA2_ROLE_FORM;
5302 break; 5302 break;
5303 case ui::AX_ROLE_FOOTER: 5303 case ui::AX_ROLE_FOOTER:
5304 ia_role = ROLE_SYSTEM_GROUPING; 5304 ia_role = ROLE_SYSTEM_GROUPING;
5305 ia2_role = IA2_ROLE_FOOTER; 5305 ia2_role = IA2_ROLE_FOOTER;
5306 break; 5306 break;
5307 case ui::AX_ROLE_GRID: 5307 case ui::AX_ROLE_GRID:
5308 ia_role = ROLE_SYSTEM_TABLE; 5308 ia_role = ROLE_SYSTEM_TABLE;
5309 ia_state |= STATE_SYSTEM_READONLY; 5309 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1,
5310 // need to determine whether grids/treegrids should really be readonly
5311 // or editable by default
5312 // ia_state |= STATE_SYSTEM_READONLY;
5310 break; 5313 break;
5311 case ui::AX_ROLE_GROUP: { 5314 case ui::AX_ROLE_GROUP: {
5312 base::string16 aria_role = GetString16Attribute( 5315 base::string16 aria_role = GetString16Attribute(
5313 ui::AX_ATTR_ROLE); 5316 ui::AX_ATTR_ROLE);
5314 if (aria_role == L"group" || html_tag == L"fieldset") { 5317 if (aria_role == L"group" || html_tag == L"fieldset") {
5315 ia_role = ROLE_SYSTEM_GROUPING; 5318 ia_role = ROLE_SYSTEM_GROUPING;
5316 } else if (html_tag == L"li") { 5319 } else if (html_tag == L"li") {
5317 ia_role = ROLE_SYSTEM_LISTITEM; 5320 ia_role = ROLE_SYSTEM_LISTITEM;
5318 ia_state |= STATE_SYSTEM_READONLY; 5321 ia_state |= STATE_SYSTEM_READONLY;
5319 } else { 5322 } else {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
5530 case ui::AX_ROLE_SVG_ROOT: 5533 case ui::AX_ROLE_SVG_ROOT:
5531 ia_role = ROLE_SYSTEM_GRAPHIC; 5534 ia_role = ROLE_SYSTEM_GRAPHIC;
5532 break; 5535 break;
5533 case ui::AX_ROLE_SWITCH: 5536 case ui::AX_ROLE_SWITCH:
5534 role_name = L"switch"; 5537 role_name = L"switch";
5535 ia2_role = IA2_ROLE_TOGGLE_BUTTON; 5538 ia2_role = IA2_ROLE_TOGGLE_BUTTON;
5536 break; 5539 break;
5537 case ui::AX_ROLE_TAB: 5540 case ui::AX_ROLE_TAB:
5538 ia_role = ROLE_SYSTEM_PAGETAB; 5541 ia_role = ROLE_SYSTEM_PAGETAB;
5539 break; 5542 break;
5540 case ui::AX_ROLE_TABLE: { 5543 case ui::AX_ROLE_TABLE:
5541 base::string16 aria_role = GetString16Attribute( 5544 ia_role = ROLE_SYSTEM_TABLE;
5542 ui::AX_ATTR_ROLE);
5543 if (aria_role == L"treegrid") {
5544 ia_role = ROLE_SYSTEM_OUTLINE;
5545 } else {
5546 ia_role = ROLE_SYSTEM_TABLE;
5547 }
5548 break; 5545 break;
5549 }
5550 case ui::AX_ROLE_TABLE_HEADER_CONTAINER: 5546 case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
5551 ia_role = ROLE_SYSTEM_GROUPING; 5547 ia_role = ROLE_SYSTEM_GROUPING;
5552 ia2_role = IA2_ROLE_SECTION; 5548 ia2_role = IA2_ROLE_SECTION;
5553 ia_state |= STATE_SYSTEM_READONLY; 5549 ia_state |= STATE_SYSTEM_READONLY;
5554 break; 5550 break;
5555 case ui::AX_ROLE_TAB_LIST: 5551 case ui::AX_ROLE_TAB_LIST:
5556 ia_role = ROLE_SYSTEM_PAGETABLIST; 5552 ia_role = ROLE_SYSTEM_PAGETABLIST;
5557 break; 5553 break;
5558 case ui::AX_ROLE_TAB_PANEL: 5554 case ui::AX_ROLE_TAB_PANEL:
5559 ia_role = ROLE_SYSTEM_PROPERTYPAGE; 5555 ia_role = ROLE_SYSTEM_PROPERTYPAGE;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5661 BrowserAccessibility* container = item->PlatformGetParent(); 5657 BrowserAccessibility* container = item->PlatformGetParent();
5662 if (container && container->GetRole() == ui::AX_ROLE_GROUP) { 5658 if (container && container->GetRole() == ui::AX_ROLE_GROUP) {
5663 // If parent was a rowgroup, we need to look at the grandparent 5659 // If parent was a rowgroup, we need to look at the grandparent
5664 container = container->PlatformGetParent(); 5660 container = container->PlatformGetParent();
5665 } 5661 }
5666 5662
5667 if (!container) { 5663 if (!container) {
5668 return false; 5664 return false;
5669 } 5665 }
5670 5666
5671 const ui::AXRole role = container->GetRole(); 5667 return container->GetRole() == ui::AX_ROLE_TREE_GRID;
5672 return role == ui::AX_ROLE_TREE_GRID ||
5673 (role == ui::AX_ROLE_TABLE &&
5674 container->GetString16Attribute(ui::AX_ATTR_ROLE) == L"treegrid");
5675 } 5668 }
5676 5669
5677 BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) { 5670 BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) {
5678 DCHECK(!obj || obj->IsNative()); 5671 DCHECK(!obj || obj->IsNative());
5679 return static_cast<BrowserAccessibilityWin*>(obj); 5672 return static_cast<BrowserAccessibilityWin*>(obj);
5680 } 5673 }
5681 5674
5682 const BrowserAccessibilityWin* 5675 const BrowserAccessibilityWin*
5683 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { 5676 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) {
5684 DCHECK(!obj || obj->IsNative()); 5677 DCHECK(!obj || obj->IsNative());
5685 return static_cast<const BrowserAccessibilityWin*>(obj); 5678 return static_cast<const BrowserAccessibilityWin*>(obj);
5686 } 5679 }
5687 5680
5688 } // namespace content 5681 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698