| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/accessibility/view_accessibility.h" | 5 #include "views/accessibility/view_accessibility.h" |
| 6 | 6 |
| 7 #include "views/accessibility/view_accessibility_wrapper.h" | 7 #include "views/accessibility/view_accessibility_wrapper.h" |
| 8 #include "views/widget/widget.h" | 8 #include "views/widget/widget.h" |
| 9 #include "views/widget/widget_win.h" | 9 #include "views/widget/widget_win.h" |
| 10 | 10 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 if (!view_) { | 284 if (!view_) { |
| 285 return E_FAIL; | 285 return E_FAIL; |
| 286 } | 286 } |
| 287 | 287 |
| 288 views::View* child_view = NULL; | 288 views::View* child_view = NULL; |
| 289 | 289 |
| 290 // Check to see if child is out-of-bounds. | 290 // Check to see if child is out-of-bounds. |
| 291 if (IsValidChild((var_child.lVal - 1), view_)) { | 291 if (IsValidChild((var_child.lVal - 1), view_)) { |
| 292 child_view = view_->GetChildViewAt(var_child.lVal - 1); | 292 child_view = view_->GetChildViewAt(var_child.lVal - 1); |
| 293 |
| 294 // Parents handle leaf IAccessible's. |
| 295 if (child_view && child_view->GetChildViewCount() == 0) |
| 296 return S_FALSE; |
| 293 } else { | 297 } else { |
| 294 // Child is located elsewhere in the hierarchy, get ID and adjust for MSAA. | 298 // Child is located elsewhere in this view's subtree. |
| 295 child_view = view_->GetViewByID(static_cast<int>(var_child.lVal)); | 299 // Positive child id's are 1-based indexes so you can iterate over all |
| 300 // children, and negative values are direct references to objects. |
| 301 // Note that we return full IAccessible's for leafs that have |
| 302 // negative child id's. |
| 303 if (var_child.lVal > 0) { |
| 304 child_view = view_->GetViewByID(static_cast<int>(var_child.lVal)); |
| 305 } else { |
| 306 // Retrieve it from our cache of views that have fired events. |
| 307 views::WidgetWin* view_widget = |
| 308 static_cast<views::WidgetWin*>(view_->GetWidget()); |
| 309 child_view = view_widget->GetAccessibilityViewEventAt(var_child.lVal); |
| 310 } |
| 296 } | 311 } |
| 297 | 312 |
| 298 if (!child_view) { | 313 if (!child_view) { |
| 299 // No child found. | 314 // No child found. |
| 300 *disp_child = NULL; | 315 *disp_child = NULL; |
| 301 return E_FAIL; | 316 return E_FAIL; |
| 302 } | 317 } |
| 303 | 318 |
| 304 // First, check to see if the child is a native view. | 319 // First, check to see if the child is a native view. |
| 305 if (child_view->GetClassName() == views::NativeViewHost::kViewClassName) { | 320 if (child_view->GetClassName() == views::NativeViewHost::kViewClassName) { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 if (V_VT(&var_id) == VT_BSTR) { | 764 if (V_VT(&var_id) == VT_BSTR) { |
| 750 if (!lstrcmpi(var_id.bstrVal, kViewsUninitializeAccessibilityInstance)) { | 765 if (!lstrcmpi(var_id.bstrVal, kViewsUninitializeAccessibilityInstance)) { |
| 751 view_ = NULL; | 766 view_ = NULL; |
| 752 return S_OK; | 767 return S_OK; |
| 753 } | 768 } |
| 754 } | 769 } |
| 755 // Deprecated. | 770 // Deprecated. |
| 756 return E_NOTIMPL; | 771 return E_NOTIMPL; |
| 757 } | 772 } |
| 758 | 773 |
| 774 int32 ViewAccessibility::MSAAEvent(AccessibilityTypes::Event event) { |
| 775 switch (event) { |
| 776 case AccessibilityTypes::EVENT_FOCUS: |
| 777 return EVENT_OBJECT_FOCUS; |
| 778 case AccessibilityTypes::EVENT_MENUSTART: |
| 779 return EVENT_SYSTEM_MENUSTART; |
| 780 case AccessibilityTypes::EVENT_MENUEND: |
| 781 return EVENT_SYSTEM_MENUEND; |
| 782 case AccessibilityTypes::EVENT_MENUPOPUPSTART: |
| 783 return EVENT_SYSTEM_MENUPOPUPSTART; |
| 784 case AccessibilityTypes::EVENT_MENUPOPUPEND: |
| 785 return EVENT_SYSTEM_MENUPOPUPEND; |
| 786 default: |
| 787 // Not supported or invalid event. |
| 788 NOTREACHED(); |
| 789 return -1; |
| 790 } |
| 791 } |
| 792 |
| 759 int32 ViewAccessibility::MSAARole(AccessibilityTypes::Role role) { | 793 int32 ViewAccessibility::MSAARole(AccessibilityTypes::Role role) { |
| 760 switch (role) { | 794 switch (role) { |
| 761 case AccessibilityTypes::ROLE_APPLICATION: | 795 case AccessibilityTypes::ROLE_APPLICATION: |
| 762 return ROLE_SYSTEM_APPLICATION; | 796 return ROLE_SYSTEM_APPLICATION; |
| 763 case AccessibilityTypes::ROLE_BUTTONDROPDOWN: | 797 case AccessibilityTypes::ROLE_BUTTONDROPDOWN: |
| 764 return ROLE_SYSTEM_BUTTONDROPDOWN; | 798 return ROLE_SYSTEM_BUTTONDROPDOWN; |
| 765 case AccessibilityTypes::ROLE_BUTTONMENU: | 799 case AccessibilityTypes::ROLE_BUTTONMENU: |
| 766 return ROLE_SYSTEM_BUTTONMENU; | 800 return ROLE_SYSTEM_BUTTONMENU; |
| 767 case AccessibilityTypes::ROLE_CHECKBUTTON: | 801 case AccessibilityTypes::ROLE_CHECKBUTTON: |
| 768 return ROLE_SYSTEM_CHECKBUTTON; | 802 return ROLE_SYSTEM_CHECKBUTTON; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 HWND native_view_window , IDispatch** disp_child) { | 884 HWND native_view_window , IDispatch** disp_child) { |
| 851 if (IsWindow(native_view_window)) { | 885 if (IsWindow(native_view_window)) { |
| 852 LRESULT ret = SendMessage(native_view_window, WM_GETOBJECT, 0, | 886 LRESULT ret = SendMessage(native_view_window, WM_GETOBJECT, 0, |
| 853 OBJID_CLIENT); | 887 OBJID_CLIENT); |
| 854 return ObjectFromLresult(ret, IID_IDispatch, 0, | 888 return ObjectFromLresult(ret, IID_IDispatch, 0, |
| 855 reinterpret_cast<void**>(disp_child)); | 889 reinterpret_cast<void**>(disp_child)); |
| 856 } | 890 } |
| 857 | 891 |
| 858 return E_FAIL; | 892 return E_FAIL; |
| 859 } | 893 } |
| OLD | NEW |