OLD | NEW |
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 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 CComObject<BrowserAccessibilityRelation>* relation; | 3398 CComObject<BrowserAccessibilityRelation>* relation; |
3399 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( | 3399 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( |
3400 &relation); | 3400 &relation); |
3401 DCHECK(SUCCEEDED(hr)); | 3401 DCHECK(SUCCEEDED(hr)); |
3402 relation->AddRef(); | 3402 relation->AddRef(); |
3403 relation->Initialize(this, IA2_RELATION_LABELLED_BY); | 3403 relation->Initialize(this, IA2_RELATION_LABELLED_BY); |
3404 relation->AddTarget(title_elem_id); | 3404 relation->AddTarget(title_elem_id); |
3405 relations_.push_back(relation); | 3405 relations_.push_back(relation); |
3406 } | 3406 } |
3407 | 3407 |
3408 // Expose slider value. | 3408 UpdateRequiredAttributes(); |
3409 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || | |
3410 ia_role() == ROLE_SYSTEM_SCROLLBAR || | |
3411 ia_role() == ROLE_SYSTEM_SLIDER) { | |
3412 base::string16 value_text = GetValueText(); | |
3413 SanitizeStringAttributeForIA2(value_text, &value_text); | |
3414 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); | |
3415 } | |
3416 | |
3417 // Expose dropeffect attribute. | |
3418 base::string16 drop_effect; | |
3419 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { | |
3420 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); | |
3421 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); | |
3422 } | |
3423 | |
3424 // Expose grabbed attribute. | |
3425 base::string16 grabbed; | |
3426 if (GetHtmlAttribute("aria-grabbed", &grabbed)) { | |
3427 SanitizeStringAttributeForIA2(grabbed, &grabbed); | |
3428 win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); | |
3429 } | |
3430 | |
3431 // Expose datetime attribute. | |
3432 base::string16 datetime; | |
3433 if (GetRole() == ui::AX_ROLE_TIME && | |
3434 GetHtmlAttribute("datetime", &datetime)) { | |
3435 SanitizeStringAttributeForIA2(datetime, &datetime); | |
3436 win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); | |
3437 } | |
3438 | |
3439 // Expose input-text type attribute. | |
3440 base::string16 type; | |
3441 if (GetRole() == ui::AX_ROLE_TEXT_FIELD && GetHtmlAttribute("type", &type)) { | |
3442 SanitizeStringAttributeForIA2(type, &type); | |
3443 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); | |
3444 } | |
3445 | |
3446 // If this is a web area for a presentational iframe, give it a role of | 3409 // If this is a web area for a presentational iframe, give it a role of |
3447 // something other than DOCUMENT so that the fact that it's a separate doc | 3410 // something other than DOCUMENT so that the fact that it's a separate doc |
3448 // is not exposed to AT. | 3411 // is not exposed to AT. |
3449 if (IsWebAreaForPresentationalIframe()) { | 3412 if (IsWebAreaForPresentationalIframe()) { |
3450 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; | 3413 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
3451 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; | 3414 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
3452 } | 3415 } |
3453 } | 3416 } |
3454 | 3417 |
3455 void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { | 3418 void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4092 } | 4055 } |
4093 | 4056 |
4094 if (role == ui::AX_ROLE_MENU_LIST_OPTION && | 4057 if (role == ui::AX_ROLE_MENU_LIST_OPTION && |
4095 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { | 4058 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { |
4096 return true; | 4059 return true; |
4097 } | 4060 } |
4098 | 4061 |
4099 return false; | 4062 return false; |
4100 } | 4063 } |
4101 | 4064 |
| 4065 void BrowserAccessibilityWin::UpdateRequiredAttributes() { |
| 4066 // Expose slider value. |
| 4067 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 4068 ia_role() == ROLE_SYSTEM_SCROLLBAR || |
| 4069 ia_role() == ROLE_SYSTEM_SLIDER) { |
| 4070 base::string16 value_text = GetValueText(); |
| 4071 SanitizeStringAttributeForIA2(value_text, &value_text); |
| 4072 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); |
| 4073 } |
| 4074 |
| 4075 // Expose dropeffect attribute. |
| 4076 base::string16 drop_effect; |
| 4077 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
| 4078 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); |
| 4079 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); |
| 4080 } |
| 4081 |
| 4082 // Expose grabbed attribute. |
| 4083 base::string16 grabbed; |
| 4084 if (GetHtmlAttribute("aria-grabbed", &grabbed)) { |
| 4085 SanitizeStringAttributeForIA2(grabbed, &grabbed); |
| 4086 win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); |
| 4087 } |
| 4088 |
| 4089 // Expose class attribute. |
| 4090 base::string16 class_attr; |
| 4091 if (GetHtmlAttribute("class", &class_attr)) { |
| 4092 SanitizeStringAttributeForIA2(class_attr, &class_attr); |
| 4093 win_attributes_->ia2_attributes.push_back(L"class:" + class_attr); |
| 4094 } |
| 4095 |
| 4096 // Expose datetime attribute. |
| 4097 base::string16 datetime; |
| 4098 if (GetRole() == ui::AX_ROLE_TIME && |
| 4099 GetHtmlAttribute("datetime", &datetime)) { |
| 4100 SanitizeStringAttributeForIA2(datetime, &datetime); |
| 4101 win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); |
| 4102 } |
| 4103 |
| 4104 // Expose id attribute. |
| 4105 base::string16 id; |
| 4106 if (GetHtmlAttribute("id", &id)) { |
| 4107 SanitizeStringAttributeForIA2(id, &id); |
| 4108 win_attributes_->ia2_attributes.push_back(L"id:" + id); |
| 4109 } |
| 4110 |
| 4111 // Expose src attribute. |
| 4112 base::string16 src; |
| 4113 if (GetRole() == ui::AX_ROLE_IMAGE && GetHtmlAttribute("src", &src)) { |
| 4114 SanitizeStringAttributeForIA2(src, &src); |
| 4115 win_attributes_->ia2_attributes.push_back(L"src:" + src); |
| 4116 } |
| 4117 |
| 4118 // Expose input-text type attribute. |
| 4119 base::string16 type; |
| 4120 base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| 4121 if (GetRole() == ui::AX_ROLE_TEXT_FIELD && html_tag == L"input" && |
| 4122 GetHtmlAttribute("type", &type)) { |
| 4123 SanitizeStringAttributeForIA2(type, &type); |
| 4124 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); |
| 4125 } |
| 4126 } |
| 4127 |
4102 void BrowserAccessibilityWin::InitRoleAndState() { | 4128 void BrowserAccessibilityWin::InitRoleAndState() { |
4103 int32 ia_role = 0; | 4129 int32 ia_role = 0; |
4104 int32 ia_state = 0; | 4130 int32 ia_state = 0; |
4105 base::string16 role_name; | 4131 base::string16 role_name; |
4106 int32 ia2_role = 0; | 4132 int32 ia2_role = 0; |
4107 int32 ia2_state = IA2_STATE_OPAQUE; | 4133 int32 ia2_state = IA2_STATE_OPAQUE; |
4108 | 4134 |
4109 if (HasState(ui::AX_STATE_BUSY)) | 4135 if (HasState(ui::AX_STATE_BUSY)) |
4110 ia_state |= STATE_SYSTEM_BUSY; | 4136 ia_state |= STATE_SYSTEM_BUSY; |
4111 if (HasState(ui::AX_STATE_CHECKED)) | 4137 if (HasState(ui::AX_STATE_CHECKED)) |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4648 ia2_role = ia_role; | 4674 ia2_role = ia_role; |
4649 | 4675 |
4650 win_attributes_->ia_role = ia_role; | 4676 win_attributes_->ia_role = ia_role; |
4651 win_attributes_->ia_state = ia_state; | 4677 win_attributes_->ia_state = ia_state; |
4652 win_attributes_->role_name = role_name; | 4678 win_attributes_->role_name = role_name; |
4653 win_attributes_->ia2_role = ia2_role; | 4679 win_attributes_->ia2_role = ia2_role; |
4654 win_attributes_->ia2_state = ia2_state; | 4680 win_attributes_->ia2_state = ia2_state; |
4655 } | 4681 } |
4656 | 4682 |
4657 } // namespace content | 4683 } // namespace content |
OLD | NEW |