OLD | NEW |
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 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2844 if (owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) | 2844 if (owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
2845 *node_name = SysAllocString(tag.c_str()); | 2845 *node_name = SysAllocString(tag.c_str()); |
2846 else | 2846 else |
2847 *node_name = nullptr; | 2847 *node_name = nullptr; |
2848 | 2848 |
2849 *name_space_id = 0; | 2849 *name_space_id = 0; |
2850 *node_value = SysAllocString(value().c_str()); | 2850 *node_value = SysAllocString(value().c_str()); |
2851 *num_children = owner()->PlatformChildCount(); | 2851 *num_children = owner()->PlatformChildCount(); |
2852 *unique_id = -owner()->unique_id(); | 2852 *unique_id = -owner()->unique_id(); |
2853 | 2853 |
2854 if (owner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 2854 if (owner()->IsDocument()) { |
2855 owner()->GetRole() == ui::AX_ROLE_WEB_AREA) { | |
2856 *node_type = NODETYPE_DOCUMENT; | 2855 *node_type = NODETYPE_DOCUMENT; |
2857 } else if (owner()->IsTextOnlyObject()) { | 2856 } else if (owner()->IsTextOnlyObject()) { |
2858 *node_type = NODETYPE_TEXT; | 2857 *node_type = NODETYPE_TEXT; |
2859 } else { | 2858 } else { |
2860 *node_type = NODETYPE_ELEMENT; | 2859 *node_type = NODETYPE_ELEMENT; |
2861 } | 2860 } |
2862 | 2861 |
2863 return S_OK; | 2862 return S_OK; |
2864 } | 2863 } |
2865 | 2864 |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3689 | 3688 |
3690 base::string16 value = owner()->GetValue(); | 3689 base::string16 value = owner()->GetValue(); |
3691 | 3690 |
3692 // Expose slider value. | 3691 // Expose slider value. |
3693 if (IsRangeValueSupported()) { | 3692 if (IsRangeValueSupported()) { |
3694 value = GetRangeValueText(); | 3693 value = GetRangeValueText(); |
3695 SanitizeStringAttributeForIA2(value, &value); | 3694 SanitizeStringAttributeForIA2(value, &value); |
3696 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value); | 3695 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value); |
3697 } else { | 3696 } else { |
3698 // On Windows, the value of a document should be its url. | 3697 // On Windows, the value of a document should be its url. |
3699 if (owner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3698 if (owner()->IsDocument()) { |
3700 owner()->GetRole() == ui::AX_ROLE_WEB_AREA) { | |
3701 value = base::UTF8ToUTF16(Manager()->GetTreeData().url); | 3699 value = base::UTF8ToUTF16(Manager()->GetTreeData().url); |
3702 } | 3700 } |
3703 // If this doesn't have a value and is linked then set its value to the url | 3701 // If this doesn't have a value and is linked then set its value to the url |
3704 // attribute. This allows screen readers to read an empty link's | 3702 // attribute. This allows screen readers to read an empty link's |
3705 // destination. | 3703 // destination. |
3706 if (value.empty() && (MSAAState() & STATE_SYSTEM_LINKED)) | 3704 if (value.empty() && (MSAAState() & STATE_SYSTEM_LINKED)) |
3707 value = owner()->GetString16Attribute(ui::AX_ATTR_URL); | 3705 value = owner()->GetString16Attribute(ui::AX_ATTR_URL); |
3708 } | 3706 } |
3709 | 3707 |
3710 win_attributes_->value = value; | 3708 win_attributes_->value = value; |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4937 owner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != | 4935 owner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != |
4938 ui::AX_INVALID_STATE_FALSE) | 4936 ui::AX_INVALID_STATE_FALSE) |
4939 ia2_state |= IA2_STATE_INVALID_ENTRY; | 4937 ia2_state |= IA2_STATE_INVALID_ENTRY; |
4940 if (owner()->HasState(ui::AX_STATE_REQUIRED)) | 4938 if (owner()->HasState(ui::AX_STATE_REQUIRED)) |
4941 ia2_state |= IA2_STATE_REQUIRED; | 4939 ia2_state |= IA2_STATE_REQUIRED; |
4942 if (owner()->HasState(ui::AX_STATE_VERTICAL)) | 4940 if (owner()->HasState(ui::AX_STATE_VERTICAL)) |
4943 ia2_state |= IA2_STATE_VERTICAL; | 4941 ia2_state |= IA2_STATE_VERTICAL; |
4944 if (owner()->HasState(ui::AX_STATE_HORIZONTAL)) | 4942 if (owner()->HasState(ui::AX_STATE_HORIZONTAL)) |
4945 ia2_state |= IA2_STATE_HORIZONTAL; | 4943 ia2_state |= IA2_STATE_HORIZONTAL; |
4946 | 4944 |
4947 if (owner()->HasState(ui::AX_STATE_EDITABLE)) | 4945 const bool is_editable = owner()->HasState(ui::AX_STATE_EDITABLE); |
| 4946 if (is_editable) |
4948 ia2_state |= IA2_STATE_EDITABLE; | 4947 ia2_state |= IA2_STATE_EDITABLE; |
4949 | 4948 |
| 4949 if (owner()->IsRichTextControl() || owner()->IsEditField()) { |
| 4950 // Support multi/single line states if root editable or appropriate role. |
| 4951 // We support the edit box roles even if the area is not actually editable, |
| 4952 // because it is technically feasible for JS to implement the edit box |
| 4953 // by controlling selection. |
| 4954 if (owner()->HasState(ui::AX_STATE_MULTILINE)) { |
| 4955 ia2_state |= IA2_STATE_MULTI_LINE; |
| 4956 } else { |
| 4957 ia2_state |= IA2_STATE_SINGLE_LINE; |
| 4958 } |
| 4959 } |
| 4960 |
4950 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) | 4961 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
4951 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; | 4962 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
4952 | 4963 |
4953 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) | 4964 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) |
4954 ia2_state |= IA2_STATE_MODAL; | 4965 ia2_state |= IA2_STATE_MODAL; |
4955 | 4966 |
4956 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); | 4967 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
4957 switch (owner()->GetRole()) { | 4968 switch (owner()->GetRole()) { |
4958 case ui::AX_ROLE_ALERT: | 4969 case ui::AX_ROLE_ALERT: |
4959 ia_role = ROLE_SYSTEM_ALERT; | 4970 ia_role = ROLE_SYSTEM_ALERT; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5312 case ui::AX_ROLE_TERM: | 5323 case ui::AX_ROLE_TERM: |
5313 ia_role = ROLE_SYSTEM_LISTITEM; | 5324 ia_role = ROLE_SYSTEM_LISTITEM; |
5314 break; | 5325 break; |
5315 case ui::AX_ROLE_TOGGLE_BUTTON: | 5326 case ui::AX_ROLE_TOGGLE_BUTTON: |
5316 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5327 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
5317 ia2_role = IA2_ROLE_TOGGLE_BUTTON; | 5328 ia2_role = IA2_ROLE_TOGGLE_BUTTON; |
5318 break; | 5329 break; |
5319 case ui::AX_ROLE_TEXT_FIELD: | 5330 case ui::AX_ROLE_TEXT_FIELD: |
5320 case ui::AX_ROLE_SEARCH_BOX: | 5331 case ui::AX_ROLE_SEARCH_BOX: |
5321 ia_role = ROLE_SYSTEM_TEXT; | 5332 ia_role = ROLE_SYSTEM_TEXT; |
5322 if (owner()->HasState(ui::AX_STATE_MULTILINE)) { | |
5323 ia2_state |= IA2_STATE_MULTI_LINE; | |
5324 } else { | |
5325 ia2_state |= IA2_STATE_SINGLE_LINE; | |
5326 } | |
5327 ia2_state |= IA2_STATE_SELECTABLE_TEXT; | 5333 ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
5328 break; | 5334 break; |
5329 case ui::AX_ROLE_ABBR: | 5335 case ui::AX_ROLE_ABBR: |
5330 case ui::AX_ROLE_TIME: | 5336 case ui::AX_ROLE_TIME: |
5331 role_name = html_tag; | 5337 role_name = html_tag; |
5332 ia_role = ROLE_SYSTEM_TEXT; | 5338 ia_role = ROLE_SYSTEM_TEXT; |
5333 ia2_role = IA2_ROLE_TEXT_FRAME; | 5339 ia2_role = IA2_ROLE_TEXT_FRAME; |
5334 break; | 5340 break; |
5335 case ui::AX_ROLE_TIMER: | 5341 case ui::AX_ROLE_TIMER: |
5336 ia_role = ROLE_SYSTEM_CLOCK; | 5342 ia_role = ROLE_SYSTEM_CLOCK; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5404 | 5410 |
5405 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 5411 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
5406 BrowserAccessibility* obj) { | 5412 BrowserAccessibility* obj) { |
5407 if (!obj || !obj->IsNative()) | 5413 if (!obj || !obj->IsNative()) |
5408 return nullptr; | 5414 return nullptr; |
5409 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 5415 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
5410 return result; | 5416 return result; |
5411 } | 5417 } |
5412 | 5418 |
5413 } // namespace content | 5419 } // namespace content |
OLD | NEW |