diff options
author | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-27 23:00:03 +0000 |
---|---|---|
committer | ctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-27 23:00:03 +0000 |
commit | b82a049e6ffc65c14daf1c2c8bee6390cb7fe1fa (patch) | |
tree | 21f95e3df23460ae77342f865a24178d0cadba89 /views/accessibility | |
parent | 6f496b2703a7ccb7bba1dbb14a2b9c00f02a853e (diff) | |
download | chromium_src-b82a049e6ffc65c14daf1c2c8bee6390cb7fe1fa.zip chromium_src-b82a049e6ffc65c14daf1c2c8bee6390cb7fe1fa.tar.gz chromium_src-b82a049e6ffc65c14daf1c2c8bee6390cb7fe1fa.tar.bz2 |
Initial work to fix the IAccessible tree in circumstances where there is a widget not at the root of the UI heirarchy. Also contains misc fixes for setting correct name/role for controls found in the Options dialog.
BUG=9621
TEST=none
Review URL: http://codereview.chromium.org/2174002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/accessibility')
-rw-r--r-- | views/accessibility/view_accessibility.cc | 59 | ||||
-rw-r--r-- | views/accessibility/view_accessibility.h | 3 |
2 files changed, 37 insertions, 25 deletions
diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc index c440e53..67aaaf2 100644 --- a/views/accessibility/view_accessibility.cc +++ b/views/accessibility/view_accessibility.cc @@ -6,6 +6,7 @@ #include "views/accessibility/view_accessibility_wrapper.h" #include "views/widget/widget.h" +#include "views/widget/widget_win.h" const wchar_t kViewsUninitializeAccessibilityInstance[] = L"Views_Uninitialize_AccessibilityInstance"; @@ -285,7 +286,6 @@ STDMETHODIMP ViewAccessibility::get_accChild(VARIANT var_child, } views::View* child_view = NULL; - bool get_iaccessible = false; // Check to see if child is out-of-bounds. if (IsValidChild((var_child.lVal - 1), view_)) { @@ -293,7 +293,6 @@ STDMETHODIMP ViewAccessibility::get_accChild(VARIANT var_child, } else { // Child is located elsewhere in the hierarchy, get ID and adjust for MSAA. child_view = view_->GetViewByID(static_cast<int>(var_child.lVal)); - get_iaccessible = true; } if (!child_view) { @@ -302,29 +301,35 @@ STDMETHODIMP ViewAccessibility::get_accChild(VARIANT var_child, return E_FAIL; } - if (get_iaccessible || child_view->GetChildViewCount() != 0) { - // Retrieve the IUnknown interface for the requested child view, and - // assign the IDispatch returned. - if ((GetViewAccessibilityWrapper(child_view))-> - GetInstance(IID_IAccessible, - reinterpret_cast<void**>(disp_child)) == S_OK) { - // Increment the reference count for the retrieved interface. - (*disp_child)->AddRef(); + // First, check to see if the child is a native view. + if (child_view->GetClassName() == views::NativeViewHost::kViewClassName) { + views::NativeViewHost* native_host = + static_cast<views::NativeViewHost*>(child_view); + if (GetNativeIAccessibleInterface(native_host, disp_child) == S_OK) + return S_OK; + } + + // Next, see if the child view is a widget container. + if (child_view->child_widget()) { + views::WidgetWin* native_widget = + reinterpret_cast<views::WidgetWin*>(child_view->child_widget()); + if (GetNativeIAccessibleInterface( + native_widget->GetNativeView(), disp_child) == S_OK) { return S_OK; - } else { - // No interface, return failure. - return E_NOINTERFACE; } + } + + // Finally, try our ViewAccessibility implementation. + // Retrieve the IUnknown interface for the requested child view, and + // assign the IDispatch returned. + HRESULT hr = GetViewAccessibilityWrapper(child_view)-> + GetInstance(IID_IAccessible, reinterpret_cast<void**>(disp_child)); + if (hr == S_OK) { + // Increment the reference count for the retrieved interface. + (*disp_child)->AddRef(); + return S_OK; } else { - if (child_view->GetClassName() == views::NativeViewHost::kViewClassName) { - views::NativeViewHost* native_host = - static_cast<views::NativeViewHost*>(child_view); - if (GetNativeIAccessibleInterface(native_host, disp_child) == S_OK) - return S_OK; - } - // When at a leaf, children are handled by the parent object. - *disp_child = NULL; - return S_FALSE; + return E_NOINTERFACE; } } @@ -697,9 +702,8 @@ void ViewAccessibility::SetState(VARIANT* msaa_state, views::View* view) { // Add on any view-specific states. AccessibilityTypes::State state; - view->GetAccessibleState(&state); - - msaa_state->lVal |= MSAAState(state); + if (view->GetAccessibleState(&state)) + msaa_state->lVal |= MSAAState(state); } // IAccessible functions not supported. @@ -839,6 +843,11 @@ HRESULT ViewAccessibility::GetNativeIAccessibleInterface( native_view_window = native_host->native_view(); } + return GetNativeIAccessibleInterface(native_view_window, disp_child); +} + +HRESULT ViewAccessibility::GetNativeIAccessibleInterface( + HWND native_view_window , IDispatch** disp_child) { if (IsWindow(native_view_window)) { LRESULT ret = SendMessage(native_view_window, WM_GETOBJECT, 0, OBJID_CLIENT); diff --git a/views/accessibility/view_accessibility.h b/views/accessibility/view_accessibility.h index 0224dfa07..d2472fb 100644 --- a/views/accessibility/view_accessibility.h +++ b/views/accessibility/view_accessibility.h @@ -141,6 +141,9 @@ class ATL_NO_VTABLE ViewAccessibility HRESULT GetNativeIAccessibleInterface(views::NativeViewHost* native_host, IDispatch** disp_child); + HRESULT GetNativeIAccessibleInterface(HWND native_view_window, + IDispatch** disp_child); + // Member View needed for view-specific calls. views::View* view_; |