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

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

Issue 2967493005: Use MSAA_Role directly from BrowserAccessibility. (Closed)
Patch Set: Change tests to match internal ax tree. Created 3 years, 5 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) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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_com_win.h" 5 #include "content/browser/accessibility/browser_accessibility_com_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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 STDMETHODIMP BrowserAccessibilityComWin::get_accState(VARIANT var_id, 606 STDMETHODIMP BrowserAccessibilityComWin::get_accState(VARIANT var_id,
607 VARIANT* state) { 607 VARIANT* state) {
608 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE); 608 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE);
609 if (!owner()) 609 if (!owner())
610 return E_FAIL; 610 return E_FAIL;
611 611
612 return AXPlatformNodeWin::get_accState(var_id, state); 612 return AXPlatformNodeWin::get_accState(var_id, state);
613 } 613 }
614 614
615 bool BrowserAccessibilityComWin::IsRangeValueSupported() { 615 bool BrowserAccessibilityComWin::IsRangeValueSupported() {
616 switch (ia_role()) { 616 switch (MSAARole()) {
617 case ROLE_SYSTEM_PROGRESSBAR: 617 case ROLE_SYSTEM_PROGRESSBAR:
618 case ROLE_SYSTEM_SLIDER: 618 case ROLE_SYSTEM_SLIDER:
619 case ROLE_SYSTEM_SPINBUTTON: 619 case ROLE_SYSTEM_SPINBUTTON:
620 case ROLE_SYSTEM_SCROLLBAR: 620 case ROLE_SYSTEM_SCROLLBAR:
621 return true; 621 return true;
622 case ROLE_SYSTEM_SEPARATOR: 622 case ROLE_SYSTEM_SEPARATOR:
623 return owner()->HasState(ui::AX_STATE_FOCUSABLE); 623 return owner()->HasState(ui::AX_STATE_FOCUSABLE);
624 default: 624 default:
625 return false; 625 return false;
626 } 626 }
(...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3394 // 3394 //
3395 3395
3396 // static 3396 // static
3397 HRESULT WINAPI BrowserAccessibilityComWin::InternalQueryInterface( 3397 HRESULT WINAPI BrowserAccessibilityComWin::InternalQueryInterface(
3398 void* this_ptr, 3398 void* this_ptr,
3399 const _ATL_INTMAP_ENTRY* entries, 3399 const _ATL_INTMAP_ENTRY* entries,
3400 REFIID iid, 3400 REFIID iid,
3401 void** object) { 3401 void** object) {
3402 BrowserAccessibilityComWin* accessibility = 3402 BrowserAccessibilityComWin* accessibility =
3403 reinterpret_cast<BrowserAccessibilityComWin*>(this_ptr); 3403 reinterpret_cast<BrowserAccessibilityComWin*>(this_ptr);
3404 int32_t ia_role = accessibility->ia_role(); 3404 int32_t ia_role = accessibility->MSAARole();
3405 if (iid == IID_IAccessibleImage) { 3405 if (iid == IID_IAccessibleImage) {
3406 if (ia_role != ROLE_SYSTEM_GRAPHIC) { 3406 if (ia_role != ROLE_SYSTEM_GRAPHIC) {
3407 *object = NULL; 3407 *object = NULL;
3408 return E_NOINTERFACE; 3408 return E_NOINTERFACE;
3409 } 3409 }
3410 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { 3410 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) {
3411 if (ia_role != ROLE_SYSTEM_TABLE) { 3411 if (ia_role != ROLE_SYSTEM_TABLE) {
3412 *object = NULL; 3412 *object = NULL;
3413 return E_NOINTERFACE; 3413 return E_NOINTERFACE;
3414 } 3414 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 // Expose aria-colindex and aria-rowindex in a cell or row. 3653 // Expose aria-colindex and aria-rowindex in a cell or row.
3654 if (ui::IsCellOrTableHeaderRole(owner()->GetRole()) || 3654 if (ui::IsCellOrTableHeaderRole(owner()->GetRole()) ||
3655 owner()->GetRole() == ui::AX_ROLE_ROW) { 3655 owner()->GetRole() == ui::AX_ROLE_ROW) {
3656 if (owner()->GetRole() != ui::AX_ROLE_ROW) 3656 if (owner()->GetRole() != ui::AX_ROLE_ROW)
3657 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); 3657 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex");
3658 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); 3658 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex");
3659 } 3659 }
3660 3660
3661 // Expose row or column header sort direction. 3661 // Expose row or column header sort direction.
3662 int32_t sort_direction; 3662 int32_t sort_direction;
3663 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || 3663 if ((MSAARole() == ROLE_SYSTEM_COLUMNHEADER ||
3664 ia_role() == ROLE_SYSTEM_ROWHEADER) && 3664 MSAARole() == ROLE_SYSTEM_ROWHEADER) &&
3665 owner()->GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { 3665 owner()->GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) {
3666 switch (static_cast<ui::AXSortDirection>(sort_direction)) { 3666 switch (static_cast<ui::AXSortDirection>(sort_direction)) {
3667 case ui::AX_SORT_DIRECTION_NONE: 3667 case ui::AX_SORT_DIRECTION_NONE:
3668 break; 3668 break;
3669 case ui::AX_SORT_DIRECTION_UNSORTED: 3669 case ui::AX_SORT_DIRECTION_UNSORTED:
3670 win_attributes_->ia2_attributes.push_back(L"sort:none"); 3670 win_attributes_->ia2_attributes.push_back(L"sort:none");
3671 break; 3671 break;
3672 case ui::AX_SORT_DIRECTION_ASCENDING: 3672 case ui::AX_SORT_DIRECTION_ASCENDING:
3673 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); 3673 win_attributes_->ia2_attributes.push_back(L"sort:ascending");
3674 break; 3674 break;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 3733
3734 int error_message_id; 3734 int error_message_id;
3735 if (owner()->GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, &error_message_id)) 3735 if (owner()->GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, &error_message_id))
3736 AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id); 3736 AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id);
3737 3737
3738 UpdateRequiredAttributes(); 3738 UpdateRequiredAttributes();
3739 // If this is a web area for a presentational iframe, give it a role of 3739 // If this is a web area for a presentational iframe, give it a role of
3740 // something other than DOCUMENT so that the fact that it's a separate doc 3740 // something other than DOCUMENT so that the fact that it's a separate doc
3741 // is not exposed to AT. 3741 // is not exposed to AT.
3742 if (owner()->IsWebAreaForPresentationalIframe()) { 3742 if (owner()->IsWebAreaForPresentationalIframe()) {
3743 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING;
3744 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; 3743 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING;
3745 } 3744 }
3746 } 3745 }
3747 3746
3748 void BrowserAccessibilityComWin::UpdateStep2ComputeHypertext() { 3747 void BrowserAccessibilityComWin::UpdateStep2ComputeHypertext() {
3749 if (owner()->IsSimpleTextControl()) { 3748 if (owner()->IsSimpleTextControl()) {
3750 win_attributes_->hypertext = value(); 3749 win_attributes_->hypertext = value();
3751 return; 3750 return;
3752 } 3751 }
3753 3752
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4913 } 4912 }
4914 } 4913 }
4915 4914
4916 void BrowserAccessibilityComWin::FireNativeEvent(LONG win_event_type) const { 4915 void BrowserAccessibilityComWin::FireNativeEvent(LONG win_event_type) const {
4917 (new BrowserAccessibilityEventWin(BrowserAccessibilityEvent::FromTreeChange, 4916 (new BrowserAccessibilityEventWin(BrowserAccessibilityEvent::FromTreeChange,
4918 ui::AX_EVENT_NONE, win_event_type, owner())) 4917 ui::AX_EVENT_NONE, win_event_type, owner()))
4919 ->Fire(); 4918 ->Fire();
4920 } 4919 }
4921 4920
4922 void BrowserAccessibilityComWin::InitRoleAndState() { 4921 void BrowserAccessibilityComWin::InitRoleAndState() {
4923 int32_t ia_role = 0;
4924 base::string16 role_name;
4925 int32_t ia2_role = 0; 4922 int32_t ia2_role = 0;
4926 int32_t ia2_state = IA2_STATE_OPAQUE; 4923 int32_t ia2_state = IA2_STATE_OPAQUE;
4927 4924
4928 const auto checked_state = static_cast<ui::AXCheckedState>( 4925 const auto checked_state = static_cast<ui::AXCheckedState>(
4929 owner()->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); 4926 owner()->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE));
4930 if (checked_state) { 4927 if (checked_state) {
4931 ia2_state |= IA2_STATE_CHECKABLE; 4928 ia2_state |= IA2_STATE_CHECKABLE;
4932 } 4929 }
4933 4930
4934 if (owner()->HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && 4931 if (owner()->HasIntAttribute(ui::AX_ATTR_INVALID_STATE) &&
(...skipping 24 matching lines...) Expand all
4959 } 4956 }
4960 4957
4961 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) 4958 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty())
4962 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; 4959 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION;
4963 4960
4964 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) 4961 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL))
4965 ia2_state |= IA2_STATE_MODAL; 4962 ia2_state |= IA2_STATE_MODAL;
4966 4963
4967 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); 4964 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG);
4968 switch (owner()->GetRole()) { 4965 switch (owner()->GetRole()) {
4969 case ui::AX_ROLE_ALERT:
4970 ia_role = ROLE_SYSTEM_ALERT;
4971 break;
4972 case ui::AX_ROLE_ALERT_DIALOG:
4973 ia_role = ROLE_SYSTEM_DIALOG;
4974 break;
4975 case ui::AX_ROLE_ANCHOR:
4976 ia_role = ROLE_SYSTEM_LINK;
4977 break;
4978 case ui::AX_ROLE_APPLICATION:
4979 ia_role = ROLE_SYSTEM_APPLICATION;
4980 break;
4981 case ui::AX_ROLE_ARTICLE:
4982 ia_role = ROLE_SYSTEM_DOCUMENT;
4983 break;
4984 case ui::AX_ROLE_AUDIO:
4985 ia_role = ROLE_SYSTEM_GROUPING;
4986 break;
4987 case ui::AX_ROLE_BANNER: 4966 case ui::AX_ROLE_BANNER:
4988 ia_role = ROLE_SYSTEM_GROUPING;
4989 ia2_role = IA2_ROLE_HEADER; 4967 ia2_role = IA2_ROLE_HEADER;
4990 break; 4968 break;
4991 case ui::AX_ROLE_BLOCKQUOTE: 4969 case ui::AX_ROLE_BLOCKQUOTE:
4992 role_name = html_tag;
4993 ia2_role = IA2_ROLE_SECTION; 4970 ia2_role = IA2_ROLE_SECTION;
4994 break; 4971 break;
4995 case ui::AX_ROLE_BUSY_INDICATOR:
4996 ia_role = ROLE_SYSTEM_ANIMATION;
4997 break;
4998 case ui::AX_ROLE_BUTTON:
4999 ia_role = ROLE_SYSTEM_PUSHBUTTON;
5000 break;
5001 case ui::AX_ROLE_CANVAS: 4972 case ui::AX_ROLE_CANVAS:
5002 if (owner()->GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { 4973 if (owner()->GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
5003 role_name = L"canvas";
5004 ia2_role = IA2_ROLE_CANVAS; 4974 ia2_role = IA2_ROLE_CANVAS;
5005 } else {
5006 ia_role = ROLE_SYSTEM_GRAPHIC;
5007 } 4975 }
5008 break; 4976 break;
5009 case ui::AX_ROLE_CAPTION: 4977 case ui::AX_ROLE_CAPTION:
5010 ia_role = ROLE_SYSTEM_TEXT;
5011 ia2_role = IA2_ROLE_CAPTION; 4978 ia2_role = IA2_ROLE_CAPTION;
5012 break; 4979 break;
5013 case ui::AX_ROLE_CELL:
5014 ia_role = ROLE_SYSTEM_CELL;
5015 break;
5016 case ui::AX_ROLE_CHECK_BOX:
5017 ia_role = ROLE_SYSTEM_CHECKBUTTON;
5018 break;
5019 case ui::AX_ROLE_COLOR_WELL: 4980 case ui::AX_ROLE_COLOR_WELL:
5020 ia_role = ROLE_SYSTEM_TEXT;
5021 ia2_role = IA2_ROLE_COLOR_CHOOSER; 4981 ia2_role = IA2_ROLE_COLOR_CHOOSER;
5022 break; 4982 break;
5023 case ui::AX_ROLE_COLUMN:
5024 ia_role = ROLE_SYSTEM_COLUMN;
5025 break;
5026 case ui::AX_ROLE_COLUMN_HEADER:
5027 ia_role = ROLE_SYSTEM_COLUMNHEADER;
5028 break;
5029 case ui::AX_ROLE_COMBO_BOX:
5030 ia_role = ROLE_SYSTEM_COMBOBOX;
5031 break;
5032 case ui::AX_ROLE_COMPLEMENTARY: 4983 case ui::AX_ROLE_COMPLEMENTARY:
5033 ia_role = ROLE_SYSTEM_GROUPING;
5034 ia2_role = IA2_ROLE_NOTE; 4984 ia2_role = IA2_ROLE_NOTE;
5035 break; 4985 break;
5036 case ui::AX_ROLE_CONTENT_INFO: 4986 case ui::AX_ROLE_CONTENT_INFO:
5037 ia_role = ROLE_SYSTEM_TEXT;
5038 ia2_role = IA2_ROLE_PARAGRAPH; 4987 ia2_role = IA2_ROLE_PARAGRAPH;
5039 break; 4988 break;
5040 case ui::AX_ROLE_DATE: 4989 case ui::AX_ROLE_DATE:
5041 case ui::AX_ROLE_DATE_TIME: 4990 case ui::AX_ROLE_DATE_TIME:
5042 ia_role = ROLE_SYSTEM_DROPLIST;
5043 ia2_role = IA2_ROLE_DATE_EDITOR; 4991 ia2_role = IA2_ROLE_DATE_EDITOR;
5044 break; 4992 break;
5045 case ui::AX_ROLE_DEFINITION: 4993 case ui::AX_ROLE_DEFINITION:
5046 role_name = html_tag;
5047 ia2_role = IA2_ROLE_PARAGRAPH; 4994 ia2_role = IA2_ROLE_PARAGRAPH;
5048 break; 4995 break;
5049 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: 4996 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL:
5050 role_name = html_tag;
5051 ia_role = ROLE_SYSTEM_TEXT;
5052 ia2_role = IA2_ROLE_PARAGRAPH; 4997 ia2_role = IA2_ROLE_PARAGRAPH;
5053 break; 4998 break;
5054 case ui::AX_ROLE_DESCRIPTION_LIST:
5055 role_name = html_tag;
5056 ia_role = ROLE_SYSTEM_LIST;
5057 break;
5058 case ui::AX_ROLE_DESCRIPTION_LIST_TERM:
5059 ia_role = ROLE_SYSTEM_LISTITEM;
5060 break;
5061 case ui::AX_ROLE_DETAILS:
5062 role_name = html_tag;
5063 ia_role = ROLE_SYSTEM_GROUPING;
5064 break;
5065 case ui::AX_ROLE_DIALOG:
5066 ia_role = ROLE_SYSTEM_DIALOG;
5067 break;
5068 case ui::AX_ROLE_DISCLOSURE_TRIANGLE:
5069 ia_role = ROLE_SYSTEM_PUSHBUTTON;
5070 break;
5071 case ui::AX_ROLE_DOCUMENT:
5072 case ui::AX_ROLE_ROOT_WEB_AREA:
5073 case ui::AX_ROLE_WEB_AREA:
5074 ia_role = ROLE_SYSTEM_DOCUMENT;
5075 break;
5076 case ui::AX_ROLE_EMBEDDED_OBJECT: 4999 case ui::AX_ROLE_EMBEDDED_OBJECT:
5077 if (owner()->PlatformChildCount()) { 5000 if (!owner()->PlatformChildCount()) {
5078 // Windows screen readers assume that IA2_ROLE_EMBEDDED_OBJECT
5079 // doesn't have any children, but it may be something like a
5080 // browser plugin that has a document inside.
5081 ia_role = ROLE_SYSTEM_GROUPING;
5082 } else {
5083 ia_role = ROLE_SYSTEM_CLIENT;
5084 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; 5001 ia2_role = IA2_ROLE_EMBEDDED_OBJECT;
5085 } 5002 }
5086 break; 5003 break;
5087 case ui::AX_ROLE_FIGCAPTION: 5004 case ui::AX_ROLE_FIGCAPTION:
5088 role_name = html_tag;
5089 ia2_role = IA2_ROLE_CAPTION; 5005 ia2_role = IA2_ROLE_CAPTION;
5090 break; 5006 break;
5091 case ui::AX_ROLE_FIGURE:
5092 ia_role = ROLE_SYSTEM_GROUPING;
5093 break;
5094 case ui::AX_ROLE_FEED:
5095 ia_role = ROLE_SYSTEM_GROUPING;
5096 break;
5097 case ui::AX_ROLE_FORM: 5007 case ui::AX_ROLE_FORM:
5098 role_name = L"form";
5099 ia2_role = IA2_ROLE_FORM; 5008 ia2_role = IA2_ROLE_FORM;
5100 break; 5009 break;
5101 case ui::AX_ROLE_FOOTER: 5010 case ui::AX_ROLE_FOOTER:
5102 ia_role = ROLE_SYSTEM_GROUPING;
5103 ia2_role = IA2_ROLE_FOOTER; 5011 ia2_role = IA2_ROLE_FOOTER;
5104 break; 5012 break;
5105 case ui::AX_ROLE_GENERIC_CONTAINER: 5013 case ui::AX_ROLE_GENERIC_CONTAINER:
5106 ia_role = ROLE_SYSTEM_GROUPING;
5107 ia2_role = IA2_ROLE_SECTION; 5014 ia2_role = IA2_ROLE_SECTION;
5108 role_name = html_tag.empty() ? L"div" : html_tag;
5109 break;
5110 case ui::AX_ROLE_GRID:
5111 ia_role = ROLE_SYSTEM_TABLE;
5112 break;
5113 case ui::AX_ROLE_GROUP:
5114 ia_role = ROLE_SYSTEM_GROUPING;
5115 break; 5015 break;
5116 case ui::AX_ROLE_HEADING: 5016 case ui::AX_ROLE_HEADING:
5117 role_name = html_tag;
5118 if (html_tag.empty())
5119 ia_role = ROLE_SYSTEM_GROUPING;
5120 ia2_role = IA2_ROLE_HEADING; 5017 ia2_role = IA2_ROLE_HEADING;
5121 break; 5018 break;
5122 case ui::AX_ROLE_IFRAME: 5019 case ui::AX_ROLE_IFRAME:
5123 ia_role = ROLE_SYSTEM_DOCUMENT;
5124 ia2_role = IA2_ROLE_INTERNAL_FRAME; 5020 ia2_role = IA2_ROLE_INTERNAL_FRAME;
5125 break; 5021 break;
5126 case ui::AX_ROLE_IFRAME_PRESENTATIONAL:
5127 ia_role = ROLE_SYSTEM_GROUPING;
5128 break;
5129 case ui::AX_ROLE_IMAGE:
5130 ia_role = ROLE_SYSTEM_GRAPHIC;
5131 break;
5132 case ui::AX_ROLE_IMAGE_MAP: 5022 case ui::AX_ROLE_IMAGE_MAP:
5133 role_name = html_tag;
5134 ia2_role = IA2_ROLE_IMAGE_MAP; 5023 ia2_role = IA2_ROLE_IMAGE_MAP;
5135 break; 5024 break;
5136 case ui::AX_ROLE_IMAGE_MAP_LINK:
5137 ia_role = ROLE_SYSTEM_LINK;
5138 break;
5139 case ui::AX_ROLE_INPUT_TIME:
5140 ia_role = ROLE_SYSTEM_GROUPING;
5141 break;
5142 case ui::AX_ROLE_LABEL_TEXT: 5025 case ui::AX_ROLE_LABEL_TEXT:
5143 case ui::AX_ROLE_LEGEND: 5026 case ui::AX_ROLE_LEGEND:
5144 ia_role = ROLE_SYSTEM_TEXT;
5145 ia2_role = IA2_ROLE_LABEL; 5027 ia2_role = IA2_ROLE_LABEL;
5146 break; 5028 break;
5147 case ui::AX_ROLE_LINK:
5148 ia_role = ROLE_SYSTEM_LINK;
5149 break;
5150 case ui::AX_ROLE_LIST:
5151 ia_role = ROLE_SYSTEM_LIST;
5152 break;
5153 case ui::AX_ROLE_LIST_BOX:
5154 ia_role = ROLE_SYSTEM_LIST;
5155 break;
5156 case ui::AX_ROLE_LIST_BOX_OPTION:
5157 ia_role = ROLE_SYSTEM_LISTITEM;
5158 break;
5159 case ui::AX_ROLE_LIST_ITEM:
5160 ia_role = ROLE_SYSTEM_LISTITEM;
5161 break;
5162 case ui::AX_ROLE_MAIN: 5029 case ui::AX_ROLE_MAIN:
5163 ia_role = ROLE_SYSTEM_GROUPING;
5164 ia2_role = IA2_ROLE_PARAGRAPH; 5030 ia2_role = IA2_ROLE_PARAGRAPH;
5165 break; 5031 break;
5166 case ui::AX_ROLE_MARK: 5032 case ui::AX_ROLE_MARK:
5167 ia_role = ROLE_SYSTEM_TEXT;
5168 ia2_role = IA2_ROLE_TEXT_FRAME; 5033 ia2_role = IA2_ROLE_TEXT_FRAME;
5169 break; 5034 break;
5170 case ui::AX_ROLE_MARQUEE:
5171 ia_role = ROLE_SYSTEM_ANIMATION;
5172 break;
5173 case ui::AX_ROLE_MATH:
5174 ia_role = ROLE_SYSTEM_EQUATION;
5175 break;
5176 case ui::AX_ROLE_MENU:
5177 case ui::AX_ROLE_MENU_BUTTON:
5178 ia_role = ROLE_SYSTEM_MENUPOPUP;
5179 break;
5180 case ui::AX_ROLE_MENU_BAR:
5181 ia_role = ROLE_SYSTEM_MENUBAR;
5182 break;
5183 case ui::AX_ROLE_MENU_ITEM:
5184 ia_role = ROLE_SYSTEM_MENUITEM;
5185 break;
5186 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: 5035 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
5187 ia_role = ROLE_SYSTEM_MENUITEM;
5188 ia2_role = IA2_ROLE_CHECK_MENU_ITEM; 5036 ia2_role = IA2_ROLE_CHECK_MENU_ITEM;
5189 break; 5037 break;
5190 case ui::AX_ROLE_MENU_ITEM_RADIO: 5038 case ui::AX_ROLE_MENU_ITEM_RADIO:
5191 ia_role = ROLE_SYSTEM_MENUITEM;
5192 ia2_role = IA2_ROLE_RADIO_MENU_ITEM; 5039 ia2_role = IA2_ROLE_RADIO_MENU_ITEM;
5193 break; 5040 break;
5194 case ui::AX_ROLE_MENU_LIST_POPUP: 5041 case ui::AX_ROLE_MENU_LIST_POPUP:
5195 ia_role = ROLE_SYSTEM_LIST;
5196 ia2_state &= ~(IA2_STATE_EDITABLE); 5042 ia2_state &= ~(IA2_STATE_EDITABLE);
5197 break; 5043 break;
5198 case ui::AX_ROLE_MENU_LIST_OPTION: 5044 case ui::AX_ROLE_MENU_LIST_OPTION:
5199 ia_role = ROLE_SYSTEM_LISTITEM;
5200 ia2_state &= ~(IA2_STATE_EDITABLE); 5045 ia2_state &= ~(IA2_STATE_EDITABLE);
5201 break; 5046 break;
5202 case ui::AX_ROLE_METER:
5203 role_name = html_tag;
5204 ia_role = ROLE_SYSTEM_PROGRESSBAR;
5205 break;
5206 case ui::AX_ROLE_NAVIGATION: 5047 case ui::AX_ROLE_NAVIGATION:
5207 ia_role = ROLE_SYSTEM_GROUPING;
5208 ia2_role = IA2_ROLE_SECTION; 5048 ia2_role = IA2_ROLE_SECTION;
5209 break; 5049 break;
5210 case ui::AX_ROLE_NOTE: 5050 case ui::AX_ROLE_NOTE:
5211 ia_role = ROLE_SYSTEM_GROUPING;
5212 ia2_role = IA2_ROLE_NOTE; 5051 ia2_role = IA2_ROLE_NOTE;
5213 break; 5052 break;
5214 case ui::AX_ROLE_OUTLINE:
5215 ia_role = ROLE_SYSTEM_OUTLINE;
5216 break;
5217 case ui::AX_ROLE_PARAGRAPH: 5053 case ui::AX_ROLE_PARAGRAPH:
5218 role_name = L"P";
5219 ia2_role = IA2_ROLE_PARAGRAPH; 5054 ia2_role = IA2_ROLE_PARAGRAPH;
5220 break; 5055 break;
5221 case ui::AX_ROLE_POP_UP_BUTTON:
5222 if (html_tag == L"select") {
5223 ia_role = ROLE_SYSTEM_COMBOBOX;
5224 } else {
5225 ia_role = ROLE_SYSTEM_BUTTONMENU;
5226 }
5227 break;
5228 case ui::AX_ROLE_PRE: 5056 case ui::AX_ROLE_PRE:
5229 role_name = html_tag;
5230 ia_role = ROLE_SYSTEM_TEXT;
5231 ia2_role = IA2_ROLE_PARAGRAPH; 5057 ia2_role = IA2_ROLE_PARAGRAPH;
5232 break; 5058 break;
5233 case ui::AX_ROLE_PROGRESS_INDICATOR:
5234 ia_role = ROLE_SYSTEM_PROGRESSBAR;
5235 break;
5236 case ui::AX_ROLE_RADIO_BUTTON:
5237 ia_role = ROLE_SYSTEM_RADIOBUTTON;
5238 break;
5239 case ui::AX_ROLE_RADIO_GROUP:
5240 ia_role = ROLE_SYSTEM_GROUPING;
5241 break;
5242 case ui::AX_ROLE_REGION: 5059 case ui::AX_ROLE_REGION:
5243 if (html_tag == L"section") { 5060 if (html_tag == L"section") {
5244 ia_role = ROLE_SYSTEM_GROUPING;
5245 ia2_role = IA2_ROLE_SECTION; 5061 ia2_role = IA2_ROLE_SECTION;
5246 } else {
5247 ia_role = ROLE_SYSTEM_PANE;
5248 } 5062 }
5249 break; 5063 break;
5250 case ui::AX_ROLE_ROW: {
5251 // Role changes depending on whether row is inside a treegrid
5252 // https://www.w3.org/TR/core-aam-1.1/#role-map-row
5253 ia_role =
5254 IsInTreeGrid(owner()) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW;
5255 break;
5256 }
5257 case ui::AX_ROLE_ROW_HEADER:
5258 ia_role = ROLE_SYSTEM_ROWHEADER;
5259 break;
5260 case ui::AX_ROLE_RUBY: 5064 case ui::AX_ROLE_RUBY:
5261 ia_role = ROLE_SYSTEM_TEXT;
5262 ia2_role = IA2_ROLE_TEXT_FRAME; 5065 ia2_role = IA2_ROLE_TEXT_FRAME;
5263 break; 5066 break;
5264 case ui::AX_ROLE_RULER: 5067 case ui::AX_ROLE_RULER:
5265 ia_role = ROLE_SYSTEM_CLIENT;
5266 ia2_role = IA2_ROLE_RULER; 5068 ia2_role = IA2_ROLE_RULER;
5267 break; 5069 break;
5268 case ui::AX_ROLE_SCROLL_AREA: 5070 case ui::AX_ROLE_SCROLL_AREA:
5269 ia_role = ROLE_SYSTEM_CLIENT;
5270 ia2_role = IA2_ROLE_SCROLL_PANE; 5071 ia2_role = IA2_ROLE_SCROLL_PANE;
5271 ia2_state &= ~(IA2_STATE_EDITABLE); 5072 ia2_state &= ~(IA2_STATE_EDITABLE);
5272 break; 5073 break;
5273 case ui::AX_ROLE_SCROLL_BAR:
5274 ia_role = ROLE_SYSTEM_SCROLLBAR;
5275 break;
5276 case ui::AX_ROLE_SEARCH: 5074 case ui::AX_ROLE_SEARCH:
5277 ia_role = ROLE_SYSTEM_GROUPING;
5278 ia2_role = IA2_ROLE_SECTION; 5075 ia2_role = IA2_ROLE_SECTION;
5279 break; 5076 break;
5280 case ui::AX_ROLE_SLIDER:
5281 ia_role = ROLE_SYSTEM_SLIDER;
5282 break;
5283 case ui::AX_ROLE_SPIN_BUTTON:
5284 ia_role = ROLE_SYSTEM_SPINBUTTON;
5285 break;
5286 case ui::AX_ROLE_SPIN_BUTTON_PART:
5287 ia_role = ROLE_SYSTEM_PUSHBUTTON;
5288 break;
5289 case ui::AX_ROLE_ANNOTATION:
5290 case ui::AX_ROLE_LIST_MARKER:
5291 case ui::AX_ROLE_STATIC_TEXT:
5292 ia_role = ROLE_SYSTEM_STATICTEXT;
5293 break;
5294 case ui::AX_ROLE_STATUS:
5295 ia_role = ROLE_SYSTEM_STATUSBAR;
5296 break;
5297 case ui::AX_ROLE_SPLITTER:
5298 ia_role = ROLE_SYSTEM_SEPARATOR;
5299 break;
5300 case ui::AX_ROLE_SVG_ROOT:
5301 ia_role = ROLE_SYSTEM_GRAPHIC;
5302 break;
5303 case ui::AX_ROLE_SWITCH: 5077 case ui::AX_ROLE_SWITCH:
5304 role_name = L"switch";
5305 ia2_role = IA2_ROLE_TOGGLE_BUTTON; 5078 ia2_role = IA2_ROLE_TOGGLE_BUTTON;
5306 break; 5079 break;
5307 case ui::AX_ROLE_TAB:
5308 ia_role = ROLE_SYSTEM_PAGETAB;
5309 break;
5310 case ui::AX_ROLE_TABLE:
5311 ia_role = ROLE_SYSTEM_TABLE;
5312 break;
5313 case ui::AX_ROLE_TABLE_HEADER_CONTAINER: 5080 case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
5314 ia_role = ROLE_SYSTEM_GROUPING;
5315 ia2_role = IA2_ROLE_SECTION; 5081 ia2_role = IA2_ROLE_SECTION;
5316 break; 5082 break;
5317 case ui::AX_ROLE_TAB_LIST:
5318 ia_role = ROLE_SYSTEM_PAGETABLIST;
5319 break;
5320 case ui::AX_ROLE_TAB_PANEL:
5321 ia_role = ROLE_SYSTEM_PROPERTYPAGE;
5322 break;
5323 case ui::AX_ROLE_TERM:
5324 ia_role = ROLE_SYSTEM_LISTITEM;
5325 break;
5326 case ui::AX_ROLE_TOGGLE_BUTTON: 5083 case ui::AX_ROLE_TOGGLE_BUTTON:
5327 ia_role = ROLE_SYSTEM_PUSHBUTTON;
5328 ia2_role = IA2_ROLE_TOGGLE_BUTTON; 5084 ia2_role = IA2_ROLE_TOGGLE_BUTTON;
5329 break; 5085 break;
5330 case ui::AX_ROLE_TEXT_FIELD: 5086 case ui::AX_ROLE_TEXT_FIELD:
5331 case ui::AX_ROLE_SEARCH_BOX: 5087 case ui::AX_ROLE_SEARCH_BOX:
5332 ia_role = ROLE_SYSTEM_TEXT;
5333 ia2_state |= IA2_STATE_SELECTABLE_TEXT; 5088 ia2_state |= IA2_STATE_SELECTABLE_TEXT;
5334 break; 5089 break;
5335 case ui::AX_ROLE_ABBR: 5090 case ui::AX_ROLE_ABBR:
5336 case ui::AX_ROLE_TIME: 5091 case ui::AX_ROLE_TIME:
5337 role_name = html_tag;
5338 ia_role = ROLE_SYSTEM_TEXT;
5339 ia2_role = IA2_ROLE_TEXT_FRAME; 5092 ia2_role = IA2_ROLE_TEXT_FRAME;
5340 break; 5093 break;
5341 case ui::AX_ROLE_TIMER:
5342 ia_role = ROLE_SYSTEM_CLOCK;
5343 break;
5344 case ui::AX_ROLE_TOOLBAR:
5345 ia_role = ROLE_SYSTEM_TOOLBAR;
5346 break;
5347 case ui::AX_ROLE_TOOLTIP:
5348 ia_role = ROLE_SYSTEM_TOOLTIP;
5349 break;
5350 case ui::AX_ROLE_TREE:
5351 ia_role = ROLE_SYSTEM_OUTLINE;
5352 break;
5353 case ui::AX_ROLE_TREE_GRID:
5354 ia_role = ROLE_SYSTEM_OUTLINE;
5355 break;
5356 case ui::AX_ROLE_TREE_ITEM:
5357 ia_role = ROLE_SYSTEM_OUTLINEITEM;
5358 break;
5359 case ui::AX_ROLE_LINE_BREAK:
5360 ia_role = ROLE_SYSTEM_WHITESPACE;
5361 break;
5362 case ui::AX_ROLE_VIDEO:
5363 ia_role = ROLE_SYSTEM_GROUPING;
5364 break;
5365 case ui::AX_ROLE_WINDOW:
5366 ia_role = ROLE_SYSTEM_WINDOW;
5367 break;
5368
5369 // TODO(dmazzoni): figure out the proper MSAA role for all of these.
5370 case ui::AX_ROLE_DIRECTORY:
5371 case ui::AX_ROLE_IGNORED:
5372 case ui::AX_ROLE_LOG:
5373 case ui::AX_ROLE_NONE:
5374 case ui::AX_ROLE_PRESENTATIONAL:
5375 case ui::AX_ROLE_SLIDER_THUMB:
5376 default: 5094 default:
5377 ia_role = ROLE_SYSTEM_CLIENT;
5378 break; 5095 break;
5379 } 5096 }
5380 5097
5381 // The role should always be set. 5098 win_attributes_->ia_role = MSAARole();
5382 DCHECK(!role_name.empty() || ia_role); 5099 win_attributes_->ia_state = MSAAState();
5100 win_attributes_->role_name = base::UTF8ToUTF16(StringOverrideForMSAARole());
5383 5101
5384 // If we didn't explicitly set the IAccessible2 role, make it the same 5102 // If we didn't explicitly set the IAccessible2 role, make it the same
5385 // as the MSAA role. 5103 // as the MSAA role.
5386 if (!ia2_role) 5104 if (!ia2_role)
5387 ia2_role = ia_role; 5105 ia2_role = win_attributes_->ia_role;
5388 5106
5389 win_attributes_->ia_role = ia_role;
5390 win_attributes_->ia_state = MSAAState();
5391 win_attributes_->role_name = role_name;
5392 win_attributes_->ia2_role = ia2_role; 5107 win_attributes_->ia2_role = ia2_role;
5393 win_attributes_->ia2_state = ia2_state; 5108 win_attributes_->ia2_state = ia2_state;
5394 } 5109 }
5395 5110
5396 bool BrowserAccessibilityComWin::IsInTreeGrid(
5397 const BrowserAccessibility* item) {
5398 BrowserAccessibility* container = item->PlatformGetParent();
5399 if (container && container->GetRole() == ui::AX_ROLE_GROUP) {
5400 // If parent was a rowgroup, we need to look at the grandparent
5401 container = container->PlatformGetParent();
5402 }
5403
5404 if (!container) {
5405 return false;
5406 }
5407
5408 return container->GetRole() == ui::AX_ROLE_TREE_GRID;
5409 }
5410
5411 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( 5111 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin(
5412 BrowserAccessibility* obj) { 5112 BrowserAccessibility* obj) {
5413 if (!obj || !obj->IsNative()) 5113 if (!obj || !obj->IsNative())
5414 return nullptr; 5114 return nullptr;
5415 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); 5115 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM();
5416 return result; 5116 return result;
5417 } 5117 }
5418 5118
5419 } // namespace content 5119 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698