| Index: views/accessibility/view_accessibility.cc
|
| ===================================================================
|
| --- views/accessibility/view_accessibility.cc (revision 28536)
|
| +++ views/accessibility/view_accessibility.cc (working copy)
|
| @@ -7,6 +7,13 @@
|
| #include "views/accessibility/view_accessibility_wrapper.h"
|
| #include "views/widget/widget.h"
|
|
|
| +const wchar_t kViewsUninitializeAccessibilityInstance[] =
|
| + L"Views_Uninitialize_AccessibilityInstance";
|
| +
|
| +const wchar_t kViewsNativeHostPropForAccessibility[] =
|
| + L"Views_NativeViewHostHWNDForAccessibility";
|
| +
|
| +
|
| HRESULT ViewAccessibility::Initialize(views::View* view) {
|
| if (!view) {
|
| return E_INVALIDARG;
|
| @@ -23,6 +30,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| gfx::Point pt(x_left, y_top);
|
| views::View::ConvertPointToView(NULL, view_, &pt);
|
|
|
| @@ -82,6 +93,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| gfx::Rect view_bounds;
|
| // Retrieving the parent View to be used for converting from view-to-screen
|
| // coordinates.
|
| @@ -126,6 +141,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| switch (nav_dir) {
|
| case NAVDIR_FIRSTCHILD:
|
| case NAVDIR_LASTCHILD: {
|
| @@ -181,7 +200,7 @@
|
| // Check navigation bounds, adjusting for View child indexing (MSAA
|
| // child indexing starts with 1, whereas View indexing starts with 0).
|
| if (!IsValidNav(nav_dir, view_index, -1,
|
| - parent->GetChildViewCount())) {
|
| + parent->GetChildViewCount() - 1)) {
|
| // Navigation attempted to go out-of-bounds.
|
| end->vt = VT_EMPTY;
|
| return S_FALSE;
|
| @@ -261,6 +280,10 @@
|
| return S_OK;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| views::View* child_view = NULL;
|
| bool get_iaccessible = false;
|
|
|
| @@ -293,6 +316,12 @@
|
| return E_NOINTERFACE;
|
| }
|
| } 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;
|
| @@ -304,6 +333,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| *child_count = view_->GetChildViewCount();
|
| return S_OK;
|
| }
|
| @@ -314,6 +347,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| std::wstring temp_action;
|
|
|
| if (var_id.lVal == CHILDID_SELF) {
|
| @@ -363,6 +400,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| if (view_->GetChildViewCount() == 0 && view_->HasFocus()) {
|
| // Parent view has focus.
|
| focus_child->vt = VT_I4;
|
| @@ -401,6 +442,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| std::wstring temp_key;
|
|
|
| if (var_id.lVal == CHILDID_SELF) {
|
| @@ -426,6 +471,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| std::wstring temp_name;
|
|
|
| if (var_id.lVal == CHILDID_SELF) {
|
| @@ -454,6 +503,10 @@
|
| return E_INVALIDARG;
|
| }
|
|
|
| + if (!view_) {
|
| + return E_FAIL;
|
| + }
|
| +
|
| views::View* parent_view = view_->GetParent();
|
|
|
| if (!parent_view) {
|
| @@ -705,6 +758,32 @@
|
| }
|
|
|
| STDMETHODIMP ViewAccessibility::put_accValue(VARIANT var_id, BSTR put_val) {
|
| + if (V_VT(&var_id) == VT_BSTR) {
|
| + if (!lstrcmpi(var_id.bstrVal, kViewsUninitializeAccessibilityInstance)) {
|
| + view_ = NULL;
|
| + return S_OK;
|
| + }
|
| + }
|
| // Deprecated.
|
| return E_NOTIMPL;
|
| }
|
| +
|
| +HRESULT ViewAccessibility::GetNativeIAccessibleInterface(
|
| + views::NativeViewHost* native_host, IDispatch** disp_child) {
|
| + if (!native_host || !disp_child) {
|
| + return E_INVALIDARG;
|
| + }
|
| +
|
| + HWND render_view_window =
|
| + static_cast<HWND>(GetProp(native_host->native_view(),
|
| + kViewsNativeHostPropForAccessibility));
|
| +
|
| + if (IsWindow(render_view_window)) {
|
| + LRESULT ret = SendMessage(render_view_window, WM_GETOBJECT, 0,
|
| + OBJID_CLIENT);
|
| + return ObjectFromLresult(ret, IID_IDispatch, 0,
|
| + reinterpret_cast<void**>(disp_child));
|
| + }
|
| +
|
| + return E_FAIL;
|
| +}
|
|
|