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

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

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

Powered by Google App Engine
This is Rietveld 408576698