| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 if (!instance_active()) | 490 if (!instance_active()) |
| 491 return E_FAIL; | 491 return E_FAIL; |
| 492 | 492 |
| 493 if (!disp_parent) | 493 if (!disp_parent) |
| 494 return E_INVALIDARG; | 494 return E_INVALIDARG; |
| 495 | 495 |
| 496 IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin(); | 496 IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin(); |
| 497 if (parent_obj == NULL) { | 497 if (parent_obj == NULL) { |
| 498 // This happens if we're the root of the tree; | 498 // This happens if we're the root of the tree; |
| 499 // return the IAccessible for the window. | 499 // return the IAccessible for the window. |
| 500 parent_obj = | 500 if (manager()->delegate()) |
| 501 manager()->ToBrowserAccessibilityManagerWin()->parent_iaccessible(); | 501 parent_obj = manager()->delegate()->GetParentIAccessible(); |
| 502 // |parent| can only be NULL if the manager was created before the parent | 502 // |parent| can only be NULL if the manager was created before the parent |
| 503 // IAccessible was known and it wasn't subsequently set before a client | 503 // IAccessible was known and it wasn't subsequently set before a client |
| 504 // requested it. This has been fixed. |parent| may also be NULL during | 504 // requested it. This has been fixed. |parent| may also be NULL during |
| 505 // destruction. Possible cases where this could occur include tabs being | 505 // destruction. Possible cases where this could occur include tabs being |
| 506 // dragged to a new window, etc. | 506 // dragged to a new window, etc. |
| 507 if (!parent_obj) { | 507 if (!parent_obj) { |
| 508 DVLOG(1) << "In Function: " | 508 DVLOG(1) << "In Function: " |
| 509 << __FUNCTION__ | 509 << __FUNCTION__ |
| 510 << ". Parent IAccessible interface is NULL. Returning failure"; | 510 << ". Parent IAccessible interface is NULL. Returning failure"; |
| 511 return E_FAIL; | 511 return E_FAIL; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 return S_OK; | 731 return S_OK; |
| 732 } | 732 } |
| 733 | 733 |
| 734 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { | 734 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { |
| 735 if (!instance_active()) | 735 if (!instance_active()) |
| 736 return E_FAIL; | 736 return E_FAIL; |
| 737 | 737 |
| 738 if (!window_handle) | 738 if (!window_handle) |
| 739 return E_INVALIDARG; | 739 return E_INVALIDARG; |
| 740 | 740 |
| 741 *window_handle = manager()->ToBrowserAccessibilityManagerWin()->parent_hwnd(); | 741 if (!manager()->delegate()) |
| 742 return E_FAIL; |
| 743 |
| 744 *window_handle = manager()->delegate()->GetAccessibleParentHWND(); |
| 742 return S_OK; | 745 return S_OK; |
| 743 } | 746 } |
| 744 | 747 |
| 745 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { | 748 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { |
| 746 if (!instance_active()) | 749 if (!instance_active()) |
| 747 return E_FAIL; | 750 return E_FAIL; |
| 748 | 751 |
| 749 if (!index_in_parent) | 752 if (!index_in_parent) |
| 750 return E_INVALIDARG; | 753 return E_INVALIDARG; |
| 751 | 754 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 enum IA2CoordinateType coordinate_type, | 986 enum IA2CoordinateType coordinate_type, |
| 984 LONG* x, | 987 LONG* x, |
| 985 LONG* y) { | 988 LONG* y) { |
| 986 if (!instance_active()) | 989 if (!instance_active()) |
| 987 return E_FAIL; | 990 return E_FAIL; |
| 988 | 991 |
| 989 if (!x || !y) | 992 if (!x || !y) |
| 990 return E_INVALIDARG; | 993 return E_INVALIDARG; |
| 991 | 994 |
| 992 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 995 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 993 HWND parent_hwnd = | 996 if (!manager()->delegate()) |
| 994 manager()->ToBrowserAccessibilityManagerWin()->parent_hwnd(); | 997 return E_FAIL; |
| 998 HWND parent_hwnd = manager()->delegate()->GetAccessibleParentHWND(); |
| 995 POINT top_left = {0, 0}; | 999 POINT top_left = {0, 0}; |
| 996 ::ClientToScreen(parent_hwnd, &top_left); | 1000 ::ClientToScreen(parent_hwnd, &top_left); |
| 997 *x = GetLocation().x() + top_left.x; | 1001 *x = GetLocation().x() + top_left.x; |
| 998 *y = GetLocation().y() + top_left.y; | 1002 *y = GetLocation().y() + top_left.y; |
| 999 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1003 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 1000 *x = GetLocation().x(); | 1004 *x = GetLocation().x(); |
| 1001 *y = GetLocation().y(); | 1005 *y = GetLocation().y(); |
| 1002 if (GetParent()) { | 1006 if (GetParent()) { |
| 1003 *x -= GetParent()->GetLocation().x(); | 1007 *x -= GetParent()->GetLocation().x(); |
| 1004 *y -= GetParent()->GetLocation().y(); | 1008 *y -= GetParent()->GetLocation().y(); |
| (...skipping 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3784 // The role should always be set. | 3788 // The role should always be set. |
| 3785 DCHECK(!role_name_.empty() || ia_role_); | 3789 DCHECK(!role_name_.empty() || ia_role_); |
| 3786 | 3790 |
| 3787 // If we didn't explicitly set the IAccessible2 role, make it the same | 3791 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 3788 // as the MSAA role. | 3792 // as the MSAA role. |
| 3789 if (!ia2_role_) | 3793 if (!ia2_role_) |
| 3790 ia2_role_ = ia_role_; | 3794 ia2_role_ = ia_role_; |
| 3791 } | 3795 } |
| 3792 | 3796 |
| 3793 } // namespace content | 3797 } // namespace content |
| OLD | NEW |