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

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

Issue 2812003004: A treegrid should expose its rows in MSAA/IA2 as outlineitems. (Closed)
Patch Set: Fix test for aria-level 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 5400 matching lines...) Expand 10 before | Expand all | Expand 10 after
5411 ia_role = ROLE_SYSTEM_GROUPING; 5411 ia_role = ROLE_SYSTEM_GROUPING;
5412 break; 5412 break;
5413 case ui::AX_ROLE_REGION: 5413 case ui::AX_ROLE_REGION:
5414 if (html_tag == L"section") { 5414 if (html_tag == L"section") {
5415 ia_role = ROLE_SYSTEM_GROUPING; 5415 ia_role = ROLE_SYSTEM_GROUPING;
5416 ia2_role = IA2_ROLE_SECTION; 5416 ia2_role = IA2_ROLE_SECTION;
5417 } else { 5417 } else {
5418 ia_role = ROLE_SYSTEM_PANE; 5418 ia_role = ROLE_SYSTEM_PANE;
5419 } 5419 }
5420 break; 5420 break;
5421 case ui::AX_ROLE_ROW: 5421 case ui::AX_ROLE_ROW: {
5422 ia_role = ROLE_SYSTEM_ROW; 5422 // Role changes depending on whether row is inside a treegrid
5423 // https://www.w3.org/TR/core-aam-1.1/#role-map-row
5424 ia_role = IsInTreeGrid(this) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW;
5423 break; 5425 break;
5426 }
5424 case ui::AX_ROLE_ROW_HEADER: 5427 case ui::AX_ROLE_ROW_HEADER:
5425 ia_role = ROLE_SYSTEM_ROWHEADER; 5428 ia_role = ROLE_SYSTEM_ROWHEADER;
5426 break; 5429 break;
5427 case ui::AX_ROLE_RUBY: 5430 case ui::AX_ROLE_RUBY:
5428 ia_role = ROLE_SYSTEM_TEXT; 5431 ia_role = ROLE_SYSTEM_TEXT;
5429 ia2_role = IA2_ROLE_TEXT_FRAME; 5432 ia2_role = IA2_ROLE_TEXT_FRAME;
5430 break; 5433 break;
5431 case ui::AX_ROLE_RULER: 5434 case ui::AX_ROLE_RULER:
5432 ia_role = ROLE_SYSTEM_CLIENT; 5435 ia_role = ROLE_SYSTEM_CLIENT;
5433 ia2_role = IA2_ROLE_RULER; 5436 ia2_role = IA2_ROLE_RULER;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
5589 if (!ia2_role) 5592 if (!ia2_role)
5590 ia2_role = ia_role; 5593 ia2_role = ia_role;
5591 5594
5592 win_attributes_->ia_role = ia_role; 5595 win_attributes_->ia_role = ia_role;
5593 win_attributes_->ia_state = ia_state; 5596 win_attributes_->ia_state = ia_state;
5594 win_attributes_->role_name = role_name; 5597 win_attributes_->role_name = role_name;
5595 win_attributes_->ia2_role = ia2_role; 5598 win_attributes_->ia2_role = ia2_role;
5596 win_attributes_->ia2_state = ia2_state; 5599 win_attributes_->ia2_state = ia2_state;
5597 } 5600 }
5598 5601
5602 bool BrowserAccessibilityWin::IsInTreeGrid(const BrowserAccessibility* item) {
5603 BrowserAccessibility* container = item->PlatformGetParent();
5604 if (container && container->GetRole() == ui::AX_ROLE_GROUP) {
5605 // If parent was a rowgroup, we need to look at the grandparent
5606 container = container->PlatformGetParent();
5607 }
5608
5609 if (!container) {
5610 return false;
5611 }
5612
5613 const ui::AXRole role = container->GetRole();
5614 return role == ui::AX_ROLE_TREE_GRID ||
5615 (role == ui::AX_ROLE_TABLE &&
dmazzoni 2017/04/12 20:35:12 Can you add a comment explaining why we'd have som
aleventhal 2017/04/17 22:06:42 I was following the code in InitRoleAndState() her
5616 container->GetString16Attribute(ui::AX_ATTR_ROLE) == L"treegrid");
dmazzoni 2017/04/12 20:35:12 nit: call GetStringAttribute(ui::AX_ATTR_ROLE) ==
aleventhal 2017/04/17 22:06:42 Assuming we keep this code, should I change it in
5617 }
5618
5599 BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) { 5619 BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) {
5600 DCHECK(!obj || obj->IsNative()); 5620 DCHECK(!obj || obj->IsNative());
5601 return static_cast<BrowserAccessibilityWin*>(obj); 5621 return static_cast<BrowserAccessibilityWin*>(obj);
5602 } 5622 }
5603 5623
5604 const BrowserAccessibilityWin* 5624 const BrowserAccessibilityWin*
5605 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { 5625 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) {
5606 DCHECK(!obj || obj->IsNative()); 5626 DCHECK(!obj || obj->IsNative());
5607 return static_cast<const BrowserAccessibilityWin*>(obj); 5627 return static_cast<const BrowserAccessibilityWin*>(obj);
5608 } 5628 }
5609 5629
5610 } // namespace content 5630 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698