summaryrefslogtreecommitdiffstats
path: root/views/accessibility
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 22:25:25 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-13 22:25:25 +0000
commitce3c9bf8016bf2fd11bd41e388764d9f4724e5ef (patch)
treed0e046745460465d1d06ca28e60fc6cf90ef37f1 /views/accessibility
parent69e7ecec96febc8fb52c87206028f2ee2cc2b2e8 (diff)
downloadchromium_src-ce3c9bf8016bf2fd11bd41e388764d9f4724e5ef.zip
chromium_src-ce3c9bf8016bf2fd11bd41e388764d9f4724e5ef.tar.gz
chromium_src-ce3c9bf8016bf2fd11bd41e388764d9f4724e5ef.tar.bz2
Make the web content accessibility tree a descendant of the main window's
accessibility tree again, which makes it possible to debug Chrome accessibility on Windows using tools like AccExplorer32 or AccProbe. This change refactors the code that retrieves the Windows IAccessible interface from a View that wraps a native HWND. The previous code was brittle, using ViewProps and hardcoded View classname tests. This change moves that logic directly to the classes that wrap native views. BUG=54220 BUG=85673 TEST=Updated AccessibilityWinBrowserTest.ContainsRendererAccessibilityTree Review URL: http://codereview.chromium.org/6995126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/accessibility')
-rw-r--r--views/accessibility/native_view_accessibility_win.cc68
-rw-r--r--views/accessibility/native_view_accessibility_win.h14
2 files changed, 6 insertions, 76 deletions
diff --git a/views/accessibility/native_view_accessibility_win.cc b/views/accessibility/native_view_accessibility_win.cc
index 6796afe..e36c406 100644
--- a/views/accessibility/native_view_accessibility_win.cc
+++ b/views/accessibility/native_view_accessibility_win.cc
@@ -28,33 +28,6 @@ scoped_refptr<NativeViewAccessibilityWin> NativeViewAccessibilityWin::Create(
return scoped_refptr<NativeViewAccessibilityWin>(instance);
}
-// static
-IAccessible* NativeViewAccessibilityWin::GetAccessibleForView(
- views::View* view) {
- IAccessible* accessible = NULL;
-
- // First, check to see if the view is a native view.
- if (view->GetClassName() == views::NativeViewHost::kViewClassName) {
- views::NativeViewHost* native_host =
- static_cast<views::NativeViewHost*>(view);
- if (GetNativeIAccessibleInterface(native_host, &accessible) == S_OK)
- return accessible;
- }
-
- // Next, see if the view is a widget container.
- if (view->GetChildWidget()) {
- views::NativeWidgetWin* native_widget =
- reinterpret_cast<views::NativeWidgetWin*>(view->GetChildWidget());
- if (GetNativeIAccessibleInterface(
- native_widget->GetNativeView(), &accessible) == S_OK) {
- return accessible;
- }
- }
-
- // Finally, use our NativeViewAccessibilityWin implementation.
- return view->GetNativeViewAccessibilityWin();
-}
-
NativeViewAccessibilityWin::NativeViewAccessibilityWin() : view_(NULL) {
}
@@ -86,7 +59,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accHitTest(
child->lVal = CHILDID_SELF;
} else {
child->vt = VT_DISPATCH;
- child->pdispVal = GetAccessibleForView(view);
+ child->pdispVal = view->GetNativeViewAccessible();
child->pdispVal->AddRef();
}
return S_OK;
@@ -156,7 +129,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate(
views::View* child = view_->GetChildViewAt(child_id);
end->vt = VT_DISPATCH;
- end->pdispVal = GetAccessibleForView(child);
+ end->pdispVal = child->GetNativeViewAccessible();
end->pdispVal->AddRef();
return S_OK;
}
@@ -190,7 +163,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate(
}
views::View* child = parent->GetChildViewAt(view_index);
- end->pdispVal = GetAccessibleForView(child);
+ end->pdispVal = child->GetNativeViewAccessible();
end->vt = VT_DISPATCH;
end->pdispVal->AddRef();
return S_OK;
@@ -270,7 +243,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child,
return E_FAIL;
}
- *disp_child = GetAccessibleForView(child_view);
+ *disp_child = child_view->GetNativeViewAccessible();
(*disp_child)->AddRef();
return S_OK;
}
@@ -344,7 +317,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accFocus(VARIANT* focus_child) {
focus_child->lVal = CHILDID_SELF;
} else if (focus && view_->Contains(focus)) {
// Return the child object that has the keyboard focus.
- focus_child->pdispVal = GetAccessibleForView(focus);
+ focus_child->pdispVal = focus->GetNativeViewAccessible();
focus_child->pdispVal->AddRef();
return S_OK;
} else {
@@ -432,7 +405,7 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accParent(
return S_OK;
}
- *disp_parent = GetAccessibleForView(parent_view);
+ *disp_parent = parent_view->GetNativeViewAccessible();
(*disp_parent)->AddRef();
return S_OK;
}
@@ -724,32 +697,3 @@ int32 NativeViewAccessibilityWin::MSAAState(AccessibilityTypes::State state) {
msaa_state |= STATE_SYSTEM_UNAVAILABLE;
return msaa_state;
}
-
-// static
-HRESULT NativeViewAccessibilityWin::GetNativeIAccessibleInterface(
- views::NativeViewHost* native_host, IAccessible** accessible) {
- if (!native_host || !accessible)
- return E_INVALIDARG;
-
- HWND native_view_window = static_cast<HWND>(
- ui::ViewProp::GetValue(native_host->native_view(),
- views::kViewsNativeHostPropForAccessibility));
- if (!IsWindow(native_view_window)) {
- native_view_window = native_host->native_view();
- }
-
- return GetNativeIAccessibleInterface(native_view_window, accessible);
-}
-
-// static
-HRESULT NativeViewAccessibilityWin::GetNativeIAccessibleInterface(
- HWND native_view_window , IAccessible** accessible) {
- if (IsWindow(native_view_window)) {
- LRESULT ret = SendMessage(native_view_window, WM_GETOBJECT, 0,
- OBJID_CLIENT);
- return ObjectFromLresult(ret, IID_IDispatch, 0,
- reinterpret_cast<void**>(accessible));
- }
-
- return E_FAIL;
-}
diff --git a/views/accessibility/native_view_accessibility_win.h b/views/accessibility/native_view_accessibility_win.h
index 89708ab..2736160 100644
--- a/views/accessibility/native_view_accessibility_win.h
+++ b/views/accessibility/native_view_accessibility_win.h
@@ -16,11 +16,8 @@
#include "views/controls/native/native_view_host.h"
#include "views/view.h"
-namespace views {
-extern const char kViewsNativeHostPropForAccessibility[];
// Note: do not put NativeViewAccessibilityWin in the namespace "views";
// Visual Studio 2005 does not allow an ATL::CComObject symbol in a namespace.
-}
////////////////////////////////////////////////////////////////////////////////
//
@@ -43,9 +40,6 @@ class ATL_NO_VTABLE NativeViewAccessibilityWin
// Create method for view accessibility.
static scoped_refptr<NativeViewAccessibilityWin> Create(views::View* view);
- // Returns the IAccessible interface for a view.
- static IAccessible* GetAccessibleForView(views::View* view);
-
virtual ~NativeViewAccessibilityWin();
void set_view(views::View* view) { view_ = view; }
@@ -150,14 +144,6 @@ class ATL_NO_VTABLE NativeViewAccessibilityWin
// Helper function which sets applicable states of view.
void SetState(VARIANT* msaa_state, views::View* view);
- // Returns the IAccessible interface for a native view if applicable.
- // Returns S_OK on success.
- static HRESULT GetNativeIAccessibleInterface(
- views::NativeViewHost* native_host, IAccessible** accessible);
-
- static HRESULT GetNativeIAccessibleInterface(
- HWND native_view_window, IAccessible** accessible);
-
// Give CComObject access to the class constructor.
template <class Base> friend class CComObject;