| 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 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2859 if (owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) | 2859 if (owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
| 2860 *node_name = SysAllocString(tag.c_str()); | 2860 *node_name = SysAllocString(tag.c_str()); |
| 2861 else | 2861 else |
| 2862 *node_name = nullptr; | 2862 *node_name = nullptr; |
| 2863 | 2863 |
| 2864 *name_space_id = 0; | 2864 *name_space_id = 0; |
| 2865 *node_value = SysAllocString(value().c_str()); | 2865 *node_value = SysAllocString(value().c_str()); |
| 2866 *num_children = owner()->PlatformChildCount(); | 2866 *num_children = owner()->PlatformChildCount(); |
| 2867 *unique_id = -owner()->unique_id(); | 2867 *unique_id = -owner()->unique_id(); |
| 2868 | 2868 |
| 2869 if (owner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 2869 if (owner()->IsDocument()) { |
| 2870 owner()->GetRole() == ui::AX_ROLE_WEB_AREA) { | |
| 2871 *node_type = NODETYPE_DOCUMENT; | 2870 *node_type = NODETYPE_DOCUMENT; |
| 2872 } else if (owner()->IsTextOnlyObject()) { | 2871 } else if (owner()->IsTextOnlyObject()) { |
| 2873 *node_type = NODETYPE_TEXT; | 2872 *node_type = NODETYPE_TEXT; |
| 2874 } else { | 2873 } else { |
| 2875 *node_type = NODETYPE_ELEMENT; | 2874 *node_type = NODETYPE_ELEMENT; |
| 2876 } | 2875 } |
| 2877 | 2876 |
| 2878 return S_OK; | 2877 return S_OK; |
| 2879 } | 2878 } |
| 2880 | 2879 |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3704 | 3703 |
| 3705 base::string16 value = owner()->GetValue(); | 3704 base::string16 value = owner()->GetValue(); |
| 3706 | 3705 |
| 3707 // Expose slider value. | 3706 // Expose slider value. |
| 3708 if (IsRangeValueSupported()) { | 3707 if (IsRangeValueSupported()) { |
| 3709 value = GetRangeValueText(); | 3708 value = GetRangeValueText(); |
| 3710 SanitizeStringAttributeForIA2(value, &value); | 3709 SanitizeStringAttributeForIA2(value, &value); |
| 3711 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value); | 3710 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value); |
| 3712 } else { | 3711 } else { |
| 3713 // On Windows, the value of a document should be its url. | 3712 // On Windows, the value of a document should be its url. |
| 3714 if (owner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3713 if (owner()->IsDocument()) { |
| 3715 owner()->GetRole() == ui::AX_ROLE_WEB_AREA) { | |
| 3716 value = base::UTF8ToUTF16(Manager()->GetTreeData().url); | 3714 value = base::UTF8ToUTF16(Manager()->GetTreeData().url); |
| 3717 } | 3715 } |
| 3718 // If this doesn't have a value and is linked then set its value to the url | 3716 // If this doesn't have a value and is linked then set its value to the url |
| 3719 // attribute. This allows screen readers to read an empty link's | 3717 // attribute. This allows screen readers to read an empty link's |
| 3720 // destination. | 3718 // destination. |
| 3721 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) | 3719 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) |
| 3722 value = owner()->GetString16Attribute(ui::AX_ATTR_URL); | 3720 value = owner()->GetString16Attribute(ui::AX_ATTR_URL); |
| 3723 } | 3721 } |
| 3724 | 3722 |
| 3725 win_attributes_->value = value; | 3723 win_attributes_->value = value; |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5005 // Expose whether or not the mouse is over an element, but suppress | 5003 // Expose whether or not the mouse is over an element, but suppress |
| 5006 // this for tests because it can make the test results flaky depending | 5004 // this for tests because it can make the test results flaky depending |
| 5007 // on the position of the mouse. | 5005 // on the position of the mouse. |
| 5008 BrowserAccessibilityStateImpl* accessibility_state = | 5006 BrowserAccessibilityStateImpl* accessibility_state = |
| 5009 BrowserAccessibilityStateImpl::GetInstance(); | 5007 BrowserAccessibilityStateImpl::GetInstance(); |
| 5010 if (!accessibility_state->disable_hot_tracking_for_testing()) { | 5008 if (!accessibility_state->disable_hot_tracking_for_testing()) { |
| 5011 if (owner()->HasState(ui::AX_STATE_HOVERED)) | 5009 if (owner()->HasState(ui::AX_STATE_HOVERED)) |
| 5012 ia_state |= STATE_SYSTEM_HOTTRACKED; | 5010 ia_state |= STATE_SYSTEM_HOTTRACKED; |
| 5013 } | 5011 } |
| 5014 | 5012 |
| 5015 if (owner()->HasState(ui::AX_STATE_EDITABLE)) | 5013 const bool is_editable = owner()->HasState(ui::AX_STATE_EDITABLE); |
| 5014 if (is_editable) |
| 5016 ia2_state |= IA2_STATE_EDITABLE; | 5015 ia2_state |= IA2_STATE_EDITABLE; |
| 5017 | 5016 |
| 5017 if (owner()->IsRichTextControl() || owner()->IsEditBox()) { |
| 5018 // Support multi/single line states if root editable or appropriate role. |
| 5019 // We support the edit box roles even if the area is not actually editable, |
| 5020 // because it is technically feasible for JS to implement the edit box |
| 5021 // by controlling selection. |
| 5022 if (owner()->HasState(ui::AX_STATE_MULTILINE)) { |
| 5023 ia2_state |= IA2_STATE_MULTI_LINE; |
| 5024 } else { |
| 5025 ia2_state |= IA2_STATE_SINGLE_LINE; |
| 5026 } |
| 5027 } |
| 5028 |
| 5018 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) | 5029 if (!owner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
| 5019 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; | 5030 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
| 5020 | 5031 |
| 5021 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) | 5032 if (owner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) |
| 5022 ia2_state |= IA2_STATE_MODAL; | 5033 ia2_state |= IA2_STATE_MODAL; |
| 5023 | 5034 |
| 5024 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); | 5035 base::string16 html_tag = owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| 5025 switch (owner()->GetRole()) { | 5036 switch (owner()->GetRole()) { |
| 5026 case ui::AX_ROLE_ALERT: | 5037 case ui::AX_ROLE_ALERT: |
| 5027 ia_role = ROLE_SYSTEM_ALERT; | 5038 ia_role = ROLE_SYSTEM_ALERT; |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5404 ia_role = ROLE_SYSTEM_LISTITEM; | 5415 ia_role = ROLE_SYSTEM_LISTITEM; |
| 5405 ia_state |= STATE_SYSTEM_READONLY; | 5416 ia_state |= STATE_SYSTEM_READONLY; |
| 5406 break; | 5417 break; |
| 5407 case ui::AX_ROLE_TOGGLE_BUTTON: | 5418 case ui::AX_ROLE_TOGGLE_BUTTON: |
| 5408 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5419 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5409 ia2_role = IA2_ROLE_TOGGLE_BUTTON; | 5420 ia2_role = IA2_ROLE_TOGGLE_BUTTON; |
| 5410 break; | 5421 break; |
| 5411 case ui::AX_ROLE_TEXT_FIELD: | 5422 case ui::AX_ROLE_TEXT_FIELD: |
| 5412 case ui::AX_ROLE_SEARCH_BOX: | 5423 case ui::AX_ROLE_SEARCH_BOX: |
| 5413 ia_role = ROLE_SYSTEM_TEXT; | 5424 ia_role = ROLE_SYSTEM_TEXT; |
| 5414 if (owner()->HasState(ui::AX_STATE_MULTILINE)) { | |
| 5415 ia2_state |= IA2_STATE_MULTI_LINE; | |
| 5416 } else { | |
| 5417 ia2_state |= IA2_STATE_SINGLE_LINE; | |
| 5418 } | |
| 5419 if (owner()->HasState(ui::AX_STATE_READ_ONLY)) | 5425 if (owner()->HasState(ui::AX_STATE_READ_ONLY)) |
| 5420 ia_state |= STATE_SYSTEM_READONLY; | 5426 ia_state |= STATE_SYSTEM_READONLY; |
| 5421 ia2_state |= IA2_STATE_SELECTABLE_TEXT; | 5427 ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
| 5422 break; | 5428 break; |
| 5423 case ui::AX_ROLE_ABBR: | 5429 case ui::AX_ROLE_ABBR: |
| 5424 case ui::AX_ROLE_TIME: | 5430 case ui::AX_ROLE_TIME: |
| 5425 role_name = html_tag; | 5431 role_name = html_tag; |
| 5426 ia_role = ROLE_SYSTEM_TEXT; | 5432 ia_role = ROLE_SYSTEM_TEXT; |
| 5427 ia2_role = IA2_ROLE_TEXT_FRAME; | 5433 ia2_role = IA2_ROLE_TEXT_FRAME; |
| 5428 break; | 5434 break; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5517 | 5523 |
| 5518 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 5524 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
| 5519 BrowserAccessibility* obj) { | 5525 BrowserAccessibility* obj) { |
| 5520 if (!obj || !obj->IsNative()) | 5526 if (!obj || !obj->IsNative()) |
| 5521 return nullptr; | 5527 return nullptr; |
| 5522 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 5528 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
| 5523 return result; | 5529 return result; |
| 5524 } | 5530 } |
| 5525 | 5531 |
| 5526 } // namespace content | 5532 } // namespace content |
| OLD | NEW |