| 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 "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 return S_OK; | 351 return S_OK; |
| 352 } | 352 } |
| 353 | 353 |
| 354 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { | 354 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { |
| 355 if (!instance_active_) | 355 if (!instance_active_) |
| 356 return E_FAIL; | 356 return E_FAIL; |
| 357 | 357 |
| 358 if (!child_count) | 358 if (!child_count) |
| 359 return E_INVALIDARG; | 359 return E_INVALIDARG; |
| 360 | 360 |
| 361 *child_count = children_.size(); | 361 *child_count = PlatformChildCount(); |
| 362 |
| 362 return S_OK; | 363 return S_OK; |
| 363 } | 364 } |
| 364 | 365 |
| 365 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, | 366 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, |
| 366 BSTR* def_action) { | 367 BSTR* def_action) { |
| 367 if (!instance_active_) | 368 if (!instance_active_) |
| 368 return E_FAIL; | 369 return E_FAIL; |
| 369 | 370 |
| 370 if (!def_action) | 371 if (!def_action) |
| 371 return E_INVALIDARG; | 372 return E_INVALIDARG; |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 if (!instance_active_) | 869 if (!instance_active_) |
| 869 return E_FAIL; | 870 return E_FAIL; |
| 870 | 871 |
| 871 if (!group_level || !similar_items_in_group || !position_in_group) | 872 if (!group_level || !similar_items_in_group || !position_in_group) |
| 872 return E_INVALIDARG; | 873 return E_INVALIDARG; |
| 873 | 874 |
| 874 if (role_ == WebKit::WebAXRoleListBoxOption && | 875 if (role_ == WebKit::WebAXRoleListBoxOption && |
| 875 parent_ && | 876 parent_ && |
| 876 parent_->role() == WebKit::WebAXRoleListBox) { | 877 parent_->role() == WebKit::WebAXRoleListBox) { |
| 877 *group_level = 0; | 878 *group_level = 0; |
| 878 *similar_items_in_group = parent_->child_count(); | 879 *similar_items_in_group = parent_->PlatformChildCount(); |
| 879 *position_in_group = index_in_parent_ + 1; | 880 *position_in_group = index_in_parent_ + 1; |
| 880 return S_OK; | 881 return S_OK; |
| 881 } | 882 } |
| 882 | 883 |
| 883 return E_NOTIMPL; | 884 return E_NOTIMPL; |
| 884 } | 885 } |
| 885 | 886 |
| 886 // | 887 // |
| 887 // IAccessibleApplication methods. | 888 // IAccessibleApplication methods. |
| 888 // | 889 // |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 | 2612 |
| 2612 STDMETHODIMP BrowserAccessibilityWin::get_childAt( | 2613 STDMETHODIMP BrowserAccessibilityWin::get_childAt( |
| 2613 unsigned int child_index, | 2614 unsigned int child_index, |
| 2614 ISimpleDOMNode** node) { | 2615 ISimpleDOMNode** node) { |
| 2615 if (!instance_active_) | 2616 if (!instance_active_) |
| 2616 return E_FAIL; | 2617 return E_FAIL; |
| 2617 | 2618 |
| 2618 if (!node) | 2619 if (!node) |
| 2619 return E_INVALIDARG; | 2620 return E_INVALIDARG; |
| 2620 | 2621 |
| 2621 if (child_index < children_.size()) { | 2622 BrowserAccessibility* child = PlatformGetChild(child_index); |
| 2623 if (!child) { |
| 2622 *node = NULL; | 2624 *node = NULL; |
| 2623 return S_FALSE; | 2625 return S_FALSE; |
| 2624 } | 2626 } |
| 2625 | 2627 |
| 2626 *node = children_[child_index]->ToBrowserAccessibilityWin()->NewReference(); | 2628 *node = child->ToBrowserAccessibilityWin()->NewReference(); |
| 2627 return S_OK; | 2629 return S_OK; |
| 2628 } | 2630 } |
| 2629 | 2631 |
| 2630 // | 2632 // |
| 2631 // ISimpleDOMText methods. | 2633 // ISimpleDOMText methods. |
| 2632 // | 2634 // |
| 2633 | 2635 |
| 2634 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { | 2636 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { |
| 2635 if (!instance_active_) | 2637 if (!instance_active_) |
| 2636 return E_FAIL; | 2638 return E_FAIL; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 StringAttributeToIA2(AccessibilityNodeData::ATTR_ROLE, "xml-roles"); | 2798 StringAttributeToIA2(AccessibilityNodeData::ATTR_ROLE, "xml-roles"); |
| 2797 | 2799 |
| 2798 // Expose "level" attribute for headings, trees, etc. | 2800 // Expose "level" attribute for headings, trees, etc. |
| 2799 IntAttributeToIA2(AccessibilityNodeData::ATTR_HIERARCHICAL_LEVEL, "level"); | 2801 IntAttributeToIA2(AccessibilityNodeData::ATTR_HIERARCHICAL_LEVEL, "level"); |
| 2800 | 2802 |
| 2801 // Expose the set size and position in set for listbox options. | 2803 // Expose the set size and position in set for listbox options. |
| 2802 if (role_ == WebKit::WebAXRoleListBoxOption && | 2804 if (role_ == WebKit::WebAXRoleListBoxOption && |
| 2803 parent_ && | 2805 parent_ && |
| 2804 parent_->role() == WebKit::WebAXRoleListBox) { | 2806 parent_->role() == WebKit::WebAXRoleListBox) { |
| 2805 ia2_attributes_.push_back( | 2807 ia2_attributes_.push_back( |
| 2806 L"setsize:" + base::IntToString16(parent_->child_count())); | 2808 L"setsize:" + base::IntToString16(parent_->PlatformChildCount())); |
| 2807 ia2_attributes_.push_back( | 2809 ia2_attributes_.push_back( |
| 2808 L"setsize:" + base::IntToString16(index_in_parent_ + 1)); | 2810 L"setsize:" + base::IntToString16(index_in_parent_ + 1)); |
| 2809 } | 2811 } |
| 2810 | 2812 |
| 2811 if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || | 2813 if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || |
| 2812 ia_role_ == ROLE_SYSTEM_RADIOBUTTON || | 2814 ia_role_ == ROLE_SYSTEM_RADIOBUTTON || |
| 2813 ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) { | 2815 ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) { |
| 2814 ia2_attributes_.push_back(L"checkable:true"); | 2816 ia2_attributes_.push_back(L"checkable:true"); |
| 2815 } | 2817 } |
| 2816 | 2818 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 } | 2965 } |
| 2964 } | 2966 } |
| 2965 | 2967 |
| 2966 void BrowserAccessibilityWin::PostInitialize() { | 2968 void BrowserAccessibilityWin::PostInitialize() { |
| 2967 BrowserAccessibility::PostInitialize(); | 2969 BrowserAccessibility::PostInitialize(); |
| 2968 | 2970 |
| 2969 // Construct the hypertext for this node. | 2971 // Construct the hypertext for this node. |
| 2970 hyperlink_offset_to_index_.clear(); | 2972 hyperlink_offset_to_index_.clear(); |
| 2971 hyperlinks_.clear(); | 2973 hyperlinks_.clear(); |
| 2972 hypertext_.clear(); | 2974 hypertext_.clear(); |
| 2973 for (unsigned int i = 0; i < children().size(); ++i) { | 2975 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { |
| 2974 BrowserAccessibility* child = children()[i]; | 2976 BrowserAccessibility* child = PlatformGetChild(i); |
| 2975 if (child->role() == WebKit::WebAXRoleStaticText) { | 2977 if (child->role() == WebKit::WebAXRoleStaticText) { |
| 2976 hypertext_ += UTF8ToUTF16(child->name()); | 2978 hypertext_ += UTF8ToUTF16(child->name()); |
| 2977 } else { | 2979 } else { |
| 2978 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); | 2980 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); |
| 2979 hypertext_ += kEmbeddedCharacter; | 2981 hypertext_ += kEmbeddedCharacter; |
| 2980 hyperlinks_.push_back(i); | 2982 hyperlinks_.push_back(i); |
| 2981 } | 2983 } |
| 2982 } | 2984 } |
| 2983 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); | 2985 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); |
| 2984 | 2986 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 | 3060 |
| 3059 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( | 3061 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( |
| 3060 const VARIANT& var_id) { | 3062 const VARIANT& var_id) { |
| 3061 if (var_id.vt != VT_I4) | 3063 if (var_id.vt != VT_I4) |
| 3062 return NULL; | 3064 return NULL; |
| 3063 | 3065 |
| 3064 LONG child_id = var_id.lVal; | 3066 LONG child_id = var_id.lVal; |
| 3065 if (child_id == CHILDID_SELF) | 3067 if (child_id == CHILDID_SELF) |
| 3066 return this; | 3068 return this; |
| 3067 | 3069 |
| 3068 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) | 3070 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) |
| 3069 return children_[child_id - 1]->ToBrowserAccessibilityWin(); | 3071 return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin(); |
| 3070 | 3072 |
| 3071 return manager_->ToBrowserAccessibilityManagerWin()-> | 3073 return manager_->ToBrowserAccessibilityManagerWin()-> |
| 3072 GetFromUniqueIdWin(child_id); | 3074 GetFromUniqueIdWin(child_id); |
| 3073 } | 3075 } |
| 3074 | 3076 |
| 3075 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( | 3077 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( |
| 3076 AccessibilityNodeData::StringAttribute attribute, | 3078 AccessibilityNodeData::StringAttribute attribute, |
| 3077 BSTR* value_bstr) { | 3079 BSTR* value_bstr) { |
| 3078 string16 str; | 3080 string16 str; |
| 3079 | 3081 |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3661 // The role should always be set. | 3663 // The role should always be set. |
| 3662 DCHECK(!role_name_.empty() || ia_role_); | 3664 DCHECK(!role_name_.empty() || ia_role_); |
| 3663 | 3665 |
| 3664 // If we didn't explicitly set the IAccessible2 role, make it the same | 3666 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 3665 // as the MSAA role. | 3667 // as the MSAA role. |
| 3666 if (!ia2_role_) | 3668 if (!ia2_role_) |
| 3667 ia2_role_ = ia_role_; | 3669 ia2_role_ = ia_role_; |
| 3668 } | 3670 } |
| 3669 | 3671 |
| 3670 } // namespace content | 3672 } // namespace content |
| OLD | NEW |