diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-06 09:12:21 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-06 09:12:21 +0000 |
commit | 3fe2d9e6b0319e972b72beb5082d5486f7cb26d0 (patch) | |
tree | b879ece463c5de34a90c53b4f1d5af4f23544fe0 /ui | |
parent | 3bc8e9fc0d76910b4550e9109a5a30f51f98d9c9 (diff) | |
download | chromium_src-3fe2d9e6b0319e972b72beb5082d5486f7cb26d0.zip chromium_src-3fe2d9e6b0319e972b72beb5082d5486f7cb26d0.tar.gz chromium_src-3fe2d9e6b0319e972b72beb5082d5486f7cb26d0.tar.bz2 |
Implement Windows accessibility for Aura.
Windows accessibility requires posting notifications
on an HWND, then listening for messages on that HWND
and routing them back to the appropriate child object.
Before, that code was implemented in NativeWidgetWin
because a NativeWidget corresponded to an HWND.
Now with Aura, a Widget doesn't necessarily have an
HWND, so there's now a new class,
NativeWidgetAccessibilityWin, that's a companion to
NativeViewAccessibilityWin and handles this abstraction.
Refactored some code so that we don't need screen
reader detection or dynamic HWND annotation (in
methods like SetAccessibilityRole, etc.) anymore.
Tested with Windows screen readers. Web content is
still not accessible in Aura, that will be the next
changelist. Win 8 in Metro mode is not accessible yet,
that's going to require further changes.
BUG=175156
Review URL: https://chromiumcodereview.appspot.com/12335075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186382 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
31 files changed, 240 insertions, 466 deletions
diff --git a/ui/views/accessibility/native_view_accessibility.cc b/ui/views/accessibility/native_view_accessibility.cc new file mode 100644 index 0000000..f295c6d --- /dev/null +++ b/ui/views/accessibility/native_view_accessibility.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/accessibility/native_view_accessibility.h" + +namespace views { + +#if !defined(OS_WIN) +// static +NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { + return NULL; +} +#endif + +NativeViewAccessibility::NativeViewAccessibility() { +} + +NativeViewAccessibility::~NativeViewAccessibility() { +} + +gfx::NativeViewAccessible NativeViewAccessibility::GetNativeObject() { + return NULL; +} + +void NativeViewAccessibility::Destroy() { + delete this; +} + +} // namespace views diff --git a/ui/views/accessibility/native_view_accessibility.h b/ui/views/accessibility/native_view_accessibility.h new file mode 100644 index 0000000..add7f97 --- /dev/null +++ b/ui/views/accessibility/native_view_accessibility.h @@ -0,0 +1,38 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ +#define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ + +#include "ui/base/accessibility/accessibility_types.h" +#include "ui/gfx/native_widget_types.h" + +namespace views { + +class View; + +class NativeViewAccessibility { + public: + static NativeViewAccessibility* Create(View* view); + + virtual void NotifyAccessibilityEvent( + ui::AccessibilityTypes::Event event_type) {} + + virtual gfx::NativeViewAccessible GetNativeObject(); + + // Call Destroy rather than deleting this, because the subclass may + // use reference counting. + virtual void Destroy(); + + protected: + NativeViewAccessibility(); + virtual ~NativeViewAccessibility(); + + private: + DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibility); +}; + +} // namespace views + +#endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_H_ diff --git a/ui/views/accessibility/native_view_accessibility_win.cc b/ui/views/accessibility/native_view_accessibility_win.cc index 551dcd1..05ed729 100644 --- a/ui/views/accessibility/native_view_accessibility_win.cc +++ b/ui/views/accessibility/native_view_accessibility_win.cc @@ -4,9 +4,8 @@ #include "ui/views/accessibility/native_view_accessibility_win.h" -#include <atlbase.h> -#include <atlcom.h> #include <UIAutomationClient.h> +#include <oleacc.h> #include <vector> @@ -14,21 +13,24 @@ #include "third_party/iaccessible2/ia2_api_all.h" #include "ui/base/accessibility/accessible_text_utils.h" #include "ui/base/accessibility/accessible_view_state.h" -#include "ui/base/view_prop.h" #include "ui/base/win/accessibility_misc_utils.h" #include "ui/base/win/atl_module.h" #include "ui/views/controls/button/custom_button.h" -#include "ui/views/widget/native_widget_win.h" -#include "ui/views/widget/widget.h" +#include "ui/views/focus/focus_manager.h" +#include "ui/views/focus/view_storage.h" +#include "ui/views/win/hwnd_util.h" using ui::AccessibilityTypes; +namespace views { + // static long NativeViewAccessibilityWin::next_unique_id_ = 1; +int NativeViewAccessibilityWin::view_storage_ids_[kMaxViewStorageIds] = {0}; +int NativeViewAccessibilityWin::next_view_storage_id_index_ = 0; // static -scoped_refptr<NativeViewAccessibilityWin> NativeViewAccessibilityWin::Create( - views::View* view) { +NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { // Make sure ATL is initialized in this module. ui::win::CreateATLModuleIfNeeded(); @@ -37,7 +39,8 @@ scoped_refptr<NativeViewAccessibilityWin> NativeViewAccessibilityWin::Create( &instance); DCHECK(SUCCEEDED(hr)); instance->set_view(view); - return scoped_refptr<NativeViewAccessibilityWin>(instance); + instance->AddRef(); + return instance; } NativeViewAccessibilityWin::NativeViewAccessibilityWin() @@ -48,6 +51,40 @@ NativeViewAccessibilityWin::NativeViewAccessibilityWin() NativeViewAccessibilityWin::~NativeViewAccessibilityWin() { } +void NativeViewAccessibilityWin::NotifyAccessibilityEvent( + ui::AccessibilityTypes::Event event_type) { + if (!view_) + return; + + ViewStorage* view_storage = ViewStorage::GetInstance(); + HWND hwnd = HWNDForView(view_); + int view_storage_id = view_storage_ids_[next_view_storage_id_index_]; + if (view_storage_id == 0) { + view_storage_id = view_storage->CreateStorageID(); + view_storage_ids_[next_view_storage_id_index_] = view_storage_id; + } else { + view_storage->RemoveView(view_storage_id); + } + view_storage->StoreView(view_storage_id, view_); + + // Positive child ids are used for enumerating direct children, + // negative child ids can be used as unique ids to refer to a specific + // descendants. Make index into view_storage_ids_ into a negative child id. + int child_id = -1 - next_view_storage_id_index_; + ::NotifyWinEvent(MSAAEvent(event_type), hwnd, OBJID_CLIENT, child_id); + next_view_storage_id_index_ = + (next_view_storage_id_index_ + 1) % kMaxViewStorageIds; +} + +gfx::NativeViewAccessible NativeViewAccessibilityWin::GetNativeObject() { + return this; +} + +void NativeViewAccessibilityWin::Destroy() { + view_ = NULL; + Release(); +} + // TODO(ctguil): Handle case where child View is not contained by parent. STDMETHODIMP NativeViewAccessibilityWin::accHitTest( LONG x_left, LONG y_top, VARIANT* child) { @@ -58,7 +95,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accHitTest( return E_FAIL; gfx::Point point(x_left, y_top); - views::View::ConvertPointToTarget(NULL, view_, &point); + View::ConvertPointToTarget(NULL, view_, &point); if (!view_->HitTestPoint(point)) { // If containing parent is not hit, return with failure. @@ -66,7 +103,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accHitTest( return S_FALSE; } - views::View* view = view_->GetEventHandlerForPoint(point); + View* view = view_->GetEventHandlerForPoint(point); if (view == view_) { // No child hit, return parent id. child->vt = VT_I4; @@ -100,7 +137,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accLocation( *width = view_->width(); *height = view_->height(); gfx::Point topleft(view_->bounds().origin()); - views::View::ConvertPointToScreen( + View::ConvertPointToScreen( view_->parent() ? view_->parent() : view_, &topleft); *x_left = topleft.x(); *y_top = topleft.y(); @@ -134,7 +171,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate( if (nav_dir == NAVDIR_LASTCHILD) child_id = view_->child_count() - 1; - views::View* child = view_->child_at(child_id); + View* child = view_->child_at(child_id); end->vt = VT_DISPATCH; end->pdispVal = child->GetNativeViewAccessible(); end->pdispVal->AddRef(); @@ -147,7 +184,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate( case NAVDIR_DOWN: case NAVDIR_NEXT: { // Retrieve parent to access view index and perform bounds checking. - views::View* parent = view_->parent(); + View* parent = view_->parent(); if (!parent) { return E_FAIL; } @@ -169,7 +206,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate( } } - views::View* child = parent->child_at(view_index); + View* child = parent->child_at(view_index); end->pdispVal = child->GetNativeViewAccessible(); end->vt = VT_DISPATCH; end->pdispVal->AddRef(); @@ -212,7 +249,7 @@ STDMETHODIMP NativeViewAccessibilityWin::accNavigate( } STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child, - IDispatch** disp_child) { + IDispatch** disp_child) { if (var_child.vt != VT_I4 || !disp_child) return E_INVALIDARG; @@ -226,22 +263,24 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accChild(VARIANT var_child, return S_OK; } - views::View* child_view = NULL; + View* child_view = NULL; if (child_id > 0) { + // Positive child ids are a 1-based child index, used by clients + // that want to enumerate all immediate children. int child_id_as_index = child_id - 1; - if (child_id_as_index < view_->child_count()) { - // Note: child_id is a one based index when indexing children. + if (child_id_as_index < view_->child_count()) child_view = view_->child_at(child_id_as_index); - } else { - // Attempt to retrieve a child view with the specified id. - child_view = view_->GetViewByID(child_id); - } } else { - // Negative values are used for events fired using the view's - // NativeWidgetWin. - views::NativeWidgetWin* widget = static_cast<views::NativeWidgetWin*>( - view_->GetWidget()->native_widget()); - child_view = widget->GetAccessibilityViewEventAt(child_id); + // Negative child ids can be used to map to any descendant; + // we map child ids to a view storage id that can refer to a + // specific view (if that view still exists). + int view_storage_id_index = -(child_id + 1); + if (view_storage_id_index >= 0 && + view_storage_id_index < kMaxViewStorageIds) { + int view_storage_id = view_storage_ids_[view_storage_id_index]; + ViewStorage* view_storage = ViewStorage::GetInstance(); + child_view = view_storage->RetrieveView(view_storage_id); + } } if (!child_view) { @@ -314,8 +353,8 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accFocus(VARIANT* focus_child) { if (!view_) return E_FAIL; - views::FocusManager* focus_manager = view_->GetFocusManager(); - views::View* focus = focus_manager ? focus_manager->GetFocusedView() : NULL; + FocusManager* focus_manager = view_->GetFocusManager(); + View* focus = focus_manager ? focus_manager->GetFocusedView() : NULL; if (focus == view_) { // This view has focus. focus_child->vt = VT_I4; @@ -385,30 +424,17 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accParent( if (!view_) return E_FAIL; - views::View* parent_view = view_->parent(); + *disp_parent = NULL; + View* parent_view = view_->parent(); if (!parent_view) { - // This function can get called during teardown of WidetWin so we - // should bail out if we fail to get the HWND. - if (!view_->GetWidget() || !view_->GetWidget()->GetNativeView()) { - *disp_parent = NULL; + HWND hwnd = HWNDForView(view_); + if (!hwnd) return S_FALSE; - } - - // For a View that has no parent (e.g. root), point the accessible parent - // to the default implementation, to interface with Windows' hierarchy - // and to support calls from e.g. WindowFromAccessibleObject. - HRESULT hr = - ::AccessibleObjectFromWindow(view_->GetWidget()->GetNativeView(), - OBJID_WINDOW, IID_IAccessible, - reinterpret_cast<void**>(disp_parent)); - if (!SUCCEEDED(hr)) { - *disp_parent = NULL; - return S_FALSE; - } - - return S_OK; + return ::AccessibleObjectFromWindow( + hwnd, OBJID_WINDOW, IID_IAccessible, + reinterpret_cast<void**>(disp_parent)); } *disp_parent = parent_view->GetNativeViewAccessible(); @@ -580,8 +606,8 @@ STDMETHODIMP NativeViewAccessibilityWin::get_windowHandle(HWND* window_handle) { if (!window_handle) return E_INVALIDARG; - *window_handle = view_->GetWidget()->GetNativeView(); - return S_OK; + *window_handle = HWNDForView(view_); + return *window_handle ? S_OK : S_FALSE; } // @@ -829,7 +855,7 @@ STDMETHODIMP NativeViewAccessibilityWin::GetPatternProvider( } STDMETHODIMP NativeViewAccessibilityWin::GetPropertyValue(PROPERTYID id, - VARIANT* ret) { + VARIANT* ret) { DVLOG(1) << "In Function: " << __FUNCTION__ << " for property id: " @@ -1023,7 +1049,7 @@ bool NativeViewAccessibilityWin::IsValidId(const VARIANT& child) const { } void NativeViewAccessibilityWin::SetState( - VARIANT* msaa_state, views::View* view) { + VARIANT* msaa_state, View* view) { // Ensure the output param is initialized to zero. msaa_state->lVal = 0; @@ -1037,8 +1063,8 @@ void NativeViewAccessibilityWin::SetState( msaa_state->lVal |= STATE_SYSTEM_UNAVAILABLE; if (!view->visible()) msaa_state->lVal |= STATE_SYSTEM_INVISIBLE; - if (view->GetClassName() == views::CustomButton::kViewClassName) { - views::CustomButton* button = static_cast<views::CustomButton*>(view); + if (view->GetClassName() == CustomButton::kViewClassName) { + CustomButton* button = static_cast<CustomButton*>(view); if (button->IsHotTracked()) msaa_state->lVal |= STATE_SYSTEM_HOTTRACKED; } @@ -1095,3 +1121,5 @@ LONG NativeViewAccessibilityWin::FindBoundary( return ui::FindAccessibleTextBoundary( text, line_breaks, boundary, start_offset, direction); } + +} // namespace views diff --git a/ui/views/accessibility/native_view_accessibility_win.h b/ui/views/accessibility/native_view_accessibility_win.h index dbe51d3..8e80c27 100644 --- a/ui/views/accessibility/native_view_accessibility_win.h +++ b/ui/views/accessibility/native_view_accessibility_win.h @@ -7,13 +7,15 @@ #include <atlbase.h> #include <atlcom.h> - #include <oleacc.h> + #include <UIAutomationCore.h> -#include "base/memory/ref_counted.h" +#include <vector> + #include "third_party/iaccessible2/ia2_api_all.h" #include "ui/base/accessibility/accessible_view_state.h" +#include "ui/views/accessibility/native_view_accessibility.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/view.h" @@ -22,8 +24,7 @@ enum TextBoundaryDirection; enum TextBoundaryType; } -// Note: do not put NativeViewAccessibilityWin in the namespace "views"; -// Visual Studio 2005 does not allow an ATL::CComObject symbol in a namespace. +namespace views { //////////////////////////////////////////////////////////////////////////////// // @@ -42,7 +43,8 @@ NativeViewAccessibilityWin public IAccessibleText, public IServiceProvider, public IAccessibleEx, - public IRawElementProviderSimple { + public IRawElementProviderSimple, + public NativeViewAccessibility { public: BEGIN_COM_MAP(NativeViewAccessibilityWin) COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) @@ -54,11 +56,14 @@ NativeViewAccessibilityWin COM_INTERFACE_ENTRY(IRawElementProviderSimple) END_COM_MAP() - // Create method for view accessibility. - static scoped_refptr<NativeViewAccessibilityWin> Create(views::View* view); - virtual ~NativeViewAccessibilityWin(); + // NativeViewAccessibility. + virtual void NotifyAccessibilityEvent( + ui::AccessibilityTypes::Event event_type) OVERRIDE; + virtual gfx::NativeViewAccessible GetNativeObject() OVERRIDE; + virtual void Destroy() OVERRIDE; + void set_view(views::View* view) { view_ = view; } // Supported IAccessible methods. @@ -330,6 +335,8 @@ NativeViewAccessibilityWin return E_NOTIMPL; } + // Static methods + // Returns a conversion from the event (as defined in accessibility_types.h) // to an MSAA event. static int32 MSAAEvent(ui::AccessibilityTypes::Event event); @@ -361,7 +368,7 @@ NativeViewAccessibilityWin bool IsValidId(const VARIANT& child) const; // Helper function which sets applicable states of view. - void SetState(VARIANT* msaa_state, views::View* view); + void SetState(VARIANT* msaa_state, View* view); // Return the text to use for IAccessibleText. string16 TextForIAccessibleText(); @@ -385,7 +392,7 @@ NativeViewAccessibilityWin template <class Base> friend class CComObject; // Member View needed for view-specific calls. - views::View* view_; + View* view_; // A unique id for each object, needed for IAccessible2. long unique_id_; @@ -393,7 +400,19 @@ NativeViewAccessibilityWin // Next unique id to assign. static long next_unique_id_; + // Circular queue size. + static const int kMaxViewStorageIds = 20; + + // Circular queue of view storage ids corresponding to child ids + // used to post notifications using NotifyWinEvent. + static int view_storage_ids_[kMaxViewStorageIds]; + + // Next index into |view_storage_ids_| to use. + static int next_view_storage_id_index_; + DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin); }; +} // namespace views + #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ diff --git a/ui/views/view.cc b/ui/views/view.cc index 65290b7..d88c2bc 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -32,6 +32,7 @@ #include "ui/gfx/skia_util.h" #include "ui/gfx/transform.h" #include "ui/native_theme/native_theme.h" +#include "ui/views/accessibility/native_view_accessibility.h" #include "ui/views/background.h" #include "ui/views/context_menu_controller.h" #include "ui/views/drag_controller.h" @@ -44,7 +45,6 @@ #if defined(OS_WIN) #include "base/win/scoped_gdi_object.h" -#include "ui/views/accessibility/native_view_accessibility_win.h" #endif namespace { @@ -187,7 +187,8 @@ View::View() context_menu_controller_(NULL), drag_controller_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(post_dispatch_handler_( - new internal::PostEventDispatchHandler(this))) { + new internal::PostEventDispatchHandler(this))), + native_view_accessibility_(NULL) { AddPostTargetHandler(post_dispatch_handler_.get()); } @@ -201,10 +202,10 @@ View::~View() { delete *i; } -#if defined(OS_WIN) - if (native_view_accessibility_win_.get()) - native_view_accessibility_win_->set_view(NULL); -#endif + // Release ownership of the native accessibility object, but it's + // reference-counted on some platforms, so it may not be deleted right away. + if (native_view_accessibility_) + native_view_accessibility_->Destroy(); } // Tree operations ------------------------------------------------------------- @@ -1177,6 +1178,30 @@ bool View::ExceededDragThreshold(const gfx::Vector2d& delta) { abs(delta.y()) > GetVerticalDragThreshold()); } +// Accessibility---------------------------------------------------------------- + +gfx::NativeViewAccessible View::GetNativeViewAccessible() { + if (!native_view_accessibility_) + native_view_accessibility_ = NativeViewAccessibility::Create(this); + if (native_view_accessibility_) + return native_view_accessibility_->GetNativeObject(); + return NULL; +} + +void View::NotifyAccessibilityEvent( + ui::AccessibilityTypes::Event event_type, + bool send_native_event) { + if (ViewsDelegate::views_delegate) + ViewsDelegate::views_delegate->NotifyAccessibilityEvent(this, event_type); + + if (send_native_event) { + if (!native_view_accessibility_) + native_view_accessibility_ = NativeViewAccessibility::Create(this); + if (native_view_accessibility_) + native_view_accessibility_->NotifyAccessibilityEvent(event_type); + } +} + // Scrolling ------------------------------------------------------------------- void View::ScrollRectToVisible(const gfx::Rect& rect) { @@ -1442,8 +1467,7 @@ void View::OnFocus() { // TODO(beng): Investigate whether it's possible for us to move this to // Focus(). // Notify assistive technologies of the focus change. - GetWidget()->NotifyAccessibilityEvent( - this, ui::AccessibilityTypes::EVENT_FOCUS, true); + NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true); } void View::OnBlur() { diff --git a/ui/views/view.h b/ui/views/view.h index 6d466b3..dbc74b6 100644 --- a/ui/views/view.h +++ b/ui/views/view.h @@ -17,6 +17,7 @@ #include "base/memory/scoped_ptr.h" #include "build/build_config.h" #include "ui/base/accelerators/accelerator.h" +#include "ui/base/accessibility/accessibility_types.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/os_exchange_data.h" #include "ui/base/events/event.h" @@ -53,11 +54,6 @@ class Texture; class ThemeProvider; } -#if defined(OS_WIN) -class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) -NativeViewAccessibilityWin; -#endif - namespace views { class Background; @@ -69,6 +65,7 @@ class FocusManager; class FocusTraversable; class InputMethod; class LayoutManager; +class NativeViewAccessibility; class ScrollView; class Widget; @@ -871,6 +868,15 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Returns an instance of the native accessibility interface for this view. virtual gfx::NativeViewAccessible GetNativeViewAccessible(); + // Notifies assistive technology that an accessibility event has + // occurred on this view, such as when the view is focused or when its + // value changes. Pass true for |send_native_event| except for rare + // cases where the view is a native control that's already sending a + // native accessibility event and the duplicate event would cause + // problems. + void NotifyAccessibilityEvent(ui::AccessibilityTypes::Event event_type, + bool send_native_event); + // Scrolling ----------------------------------------------------------------- // TODO(beng): Figure out if this can live somewhere other than View, i.e. // closer to ScrollView. @@ -1486,11 +1492,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Accessibility ------------------------------------------------------------- - // The Windows-specific accessibility implementation for this view. -#if defined(OS_WIN) - base::win::ScopedComPtr<NativeViewAccessibilityWin> - native_view_accessibility_win_; -#endif + // Belongs to this view, but it's reference-counted on some platforms + // so we can't use a scoped_ptr. It's dereferenced in the destructor. + NativeViewAccessibility* native_view_accessibility_; DISALLOW_COPY_AND_ASSIGN(View); }; diff --git a/ui/views/view_aura.cc b/ui/views/view_aura.cc index 6045b91..006f1da 100644 --- a/ui/views/view_aura.cc +++ b/ui/views/view_aura.cc @@ -18,10 +18,6 @@ const int kDefaultVerticalDragThreshold = 8; namespace views { -gfx::NativeViewAccessible View::GetNativeViewAccessible() { - return NULL; -} - int View::GetHorizontalDragThreshold() { // TODO(jennyz): This value may need to be adjusted for different platforms // and for different display density. diff --git a/ui/views/view_win.cc b/ui/views/view_win.cc index 472fbcd..183a775 100644 --- a/ui/views/view_win.cc +++ b/ui/views/view_win.cc @@ -9,16 +9,8 @@ #include <initguid.h> #include <oleacc.h> -#include "ui/views/accessibility/native_view_accessibility_win.h" - namespace views { -gfx::NativeViewAccessible View::GetNativeViewAccessible() { - if (!native_view_accessibility_win_.get()) - native_view_accessibility_win_ = NativeViewAccessibilityWin::Create(this); - return native_view_accessibility_win_.get(); -} - int View::GetHorizontalDragThreshold() { static int threshold = -1; if (threshold == -1) diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 208baa5..afb320d 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -39,6 +39,8 @@ ], 'sources': [ # All .cc, .h under views, except unittests + 'accessibility/native_view_accessibility.cc', + 'accessibility/native_view_accessibility.h', 'accessibility/native_view_accessibility_win.cc', 'accessibility/native_view_accessibility_win.h', 'accessible_pane_view.cc', @@ -499,6 +501,8 @@ ['include', 'controls/menu/menu_config_win.cc'], ['include', 'controls/menu/menu_item_view_win.cc'], ['include', 'controls/menu/menu_separator_win.cc'], + ['include', 'accessibility/native_view_accessibility_win.cc'], + ['include', 'accessibility/native_view_accessibility_win.h'], ], }], ['use_aura==1 and OS=="linux" and chromeos==0', { diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index f5aa215..75eceb5 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -310,15 +310,6 @@ TooltipManager* DesktopNativeWidgetAura::GetTooltipManager() const { return tooltip_manager_.get(); } -bool DesktopNativeWidgetAura::IsScreenReaderActive() const { - return false; -} - -void DesktopNativeWidgetAura::SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) { -} - void DesktopNativeWidgetAura::SetCapture() { window_->SetCapture(); // aura::Window doesn't implicitly update capture on the RootWindowHost, so @@ -367,17 +358,6 @@ void DesktopNativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) { } -void DesktopNativeWidgetAura::SetAccessibleName(const string16& name) { -} - -void DesktopNativeWidgetAura::SetAccessibleRole( - ui::AccessibilityTypes::Role role) { -} - -void DesktopNativeWidgetAura::SetAccessibleState( - ui::AccessibilityTypes::State state) { -} - void DesktopNativeWidgetAura::InitModalType(ui::ModalType modal_type) { // 99% of the time, we should not be asked to create a // DesktopNativeWidgetAura that is modal. The case where this breaks down is @@ -509,10 +489,6 @@ void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) { desktop_root_window_host_->FlashFrame(flash_frame); } -bool DesktopNativeWidgetAura::IsAccessibleWidget() const { - return false; -} - void DesktopNativeWidgetAura::RunShellDrag( View* view, const ui::OSExchangeData& data, diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index 3320c49..f358b58 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -84,10 +84,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; virtual TooltipManager* GetTooltipManager() const OVERRIDE; - virtual bool IsScreenReaderActive() const OVERRIDE; - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) OVERRIDE; virtual void SetCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE; virtual bool HasCapture() const OVERRIDE; @@ -100,9 +96,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura virtual void SetWindowTitle(const string16& title) OVERRIDE; virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; @@ -135,7 +128,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura virtual void SetOpacity(unsigned char opacity) OVERRIDE; virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; virtual void FlashFrame(bool flash_frame) OVERRIDE; - virtual bool IsAccessibleWidget() const OVERRIDE; virtual void RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host.h b/ui/views/widget/desktop_aura/desktop_root_window_host.h index 0dee5690..e52b66f 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host.h @@ -104,10 +104,6 @@ class VIEWS_EXPORT DesktopRootWindowHost { virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) = 0; - virtual void SetAccessibleName(const string16& name) = 0; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0; - virtual void InitModalType(ui::ModalType modal_type) = 0; virtual void FlashFrame(bool flash_frame) = 0; diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc index 1a117b8..335c3c3 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.cc @@ -615,23 +615,6 @@ void DesktopRootWindowHostLinux::SetWindowIcons( NOTIMPLEMENTED(); } -void DesktopRootWindowHostLinux::SetAccessibleName(const string16& name) { - // TODO(erg): - NOTIMPLEMENTED(); -} - -void DesktopRootWindowHostLinux::SetAccessibleRole( - ui::AccessibilityTypes::Role role) { - // TODO(erg): - NOTIMPLEMENTED(); -} - -void DesktopRootWindowHostLinux::SetAccessibleState( - ui::AccessibilityTypes::State state) { - // TODO(erg): - NOTIMPLEMENTED(); -} - void DesktopRootWindowHostLinux::InitModalType(ui::ModalType modal_type) { // TODO(erg): NOTIMPLEMENTED(); diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h index be31a5a..2806fcb 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_linux.h @@ -134,9 +134,6 @@ class VIEWS_EXPORT DesktopRootWindowHostLinux virtual void SetOpacity(unsigned char opacity) OVERRIDE; virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual void FlashFrame(bool flash_frame) OVERRIDE; virtual void OnNativeWidgetFocus() OVERRIDE; diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index 6c5c0b6..ec09a85 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -328,20 +328,6 @@ void DesktopRootWindowHostWin::SetWindowIcons( message_handler_->SetWindowIcons(window_icon, app_icon); } -void DesktopRootWindowHostWin::SetAccessibleName(const string16& name) { - message_handler_->SetAccessibleName(name); -} - -void DesktopRootWindowHostWin::SetAccessibleRole( - ui::AccessibilityTypes::Role role) { - message_handler_->SetAccessibleRole(role); -} - -void DesktopRootWindowHostWin::SetAccessibleState( - ui::AccessibilityTypes::State state) { - message_handler_->SetAccessibleState(state); -} - void DesktopRootWindowHostWin::InitModalType(ui::ModalType modal_type) { message_handler_->InitModalType(modal_type); } @@ -741,9 +727,6 @@ void DesktopRootWindowHostWin::HandlePaint(gfx::Canvas* canvas) { root_window_host_delegate_->OnHostPaint(); } -void DesktopRootWindowHostWin::HandleScreenReaderDetected() { -} - bool DesktopRootWindowHostWin::HandleTooltipNotify(int w_param, NMHDR* l_param, LRESULT* l_result) { diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h index df72607..43e5753 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h @@ -89,9 +89,6 @@ class VIEWS_EXPORT DesktopRootWindowHostWin virtual void SetOpacity(unsigned char opacity) OVERRIDE; virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual void FlashFrame(bool flash_frame) OVERRIDE; virtual void OnNativeWidgetFocus() OVERRIDE; @@ -187,7 +184,6 @@ class VIEWS_EXPORT DesktopRootWindowHostWin HKL input_language_id) OVERRIDE; virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE; virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE; - virtual void HandleScreenReaderDetected() OVERRIDE; virtual bool HandleTooltipNotify(int w_param, NMHDR* l_param, LRESULT* l_result) OVERRIDE; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index e2e723d..86c1d1d 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -244,19 +244,6 @@ TooltipManager* NativeWidgetAura::GetTooltipManager() const { return tooltip_manager_.get(); } -bool NativeWidgetAura::IsScreenReaderActive() const { - // http://crbug.com/102570 - // NOTIMPLEMENTED(); - return false; -} - -void NativeWidgetAura::SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) { - // http://crbug.com/102570 - // NOTIMPLEMENTED(); -} - void NativeWidgetAura::SetCapture() { window_->SetCapture(); } @@ -344,21 +331,6 @@ void NativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon, // Aura doesn't have window icons. } -void NativeWidgetAura::SetAccessibleName(const string16& name) { - // http://crbug.com/102570 - // NOTIMPLEMENTED(); -} - -void NativeWidgetAura::SetAccessibleRole(ui::AccessibilityTypes::Role role) { - // http://crbug.com/102570 - // NOTIMPLEMENTED(); -} - -void NativeWidgetAura::SetAccessibleState(ui::AccessibilityTypes::State state) { - // http://crbug.com/102570 - // NOTIMPLEMENTED(); -} - void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { if (modal_type != ui::MODAL_TYPE_NONE) window_->SetProperty(aura::client::kModalKey, modal_type); @@ -561,12 +533,6 @@ void NativeWidgetAura::FlashFrame(bool flash) { window_->SetProperty(aura::client::kDrawAttentionKey, flash); } -bool NativeWidgetAura::IsAccessibleWidget() const { - // http://crbug.com/102570 - // NOTIMPLEMENTED(); - return false; -} - void NativeWidgetAura::RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 31078b7..c799111 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -63,10 +63,6 @@ class VIEWS_EXPORT NativeWidgetAura virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; virtual TooltipManager* GetTooltipManager() const OVERRIDE; - virtual bool IsScreenReaderActive() const OVERRIDE; - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) OVERRIDE; virtual void SetCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE; virtual bool HasCapture() const OVERRIDE; @@ -79,9 +75,6 @@ class VIEWS_EXPORT NativeWidgetAura virtual void SetWindowTitle(const string16& title) OVERRIDE; virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; @@ -114,7 +107,6 @@ class VIEWS_EXPORT NativeWidgetAura virtual void SetOpacity(unsigned char opacity) OVERRIDE; virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; virtual void FlashFrame(bool flash_frame) OVERRIDE; - virtual bool IsAccessibleWidget() const OVERRIDE; virtual void RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h index df2d23d..9d43c78 100644 --- a/ui/views/widget/native_widget_private.h +++ b/ui/views/widget/native_widget_private.h @@ -115,14 +115,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { // to update tooltips. virtual TooltipManager* GetTooltipManager() const = 0; - // Returns true if a system screen reader is active for the NativeWidget. - virtual bool IsScreenReaderActive() const = 0; - - // Notify native Accessibility clients of an event. - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) = 0; - // Sets or releases event capturing for this native widget. virtual void SetCapture() = 0; virtual void ReleaseCapture() = 0; @@ -158,11 +150,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) = 0; - // Update native accessibility properties on the native window. - virtual void SetAccessibleName(const string16& name) = 0; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0; - // Initializes the modal type of the window to |modal_type|. Called from // NativeWidgetDelegate::OnNativeWidgetCreated() before the widget is // initially parented. @@ -201,7 +188,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { virtual void SetOpacity(unsigned char opacity) = 0; virtual void SetUseDragFrame(bool use_drag_frame) = 0; virtual void FlashFrame(bool flash) = 0; - virtual bool IsAccessibleWidget() const = 0; virtual void RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 7e5d940..403ee91 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -32,7 +32,6 @@ #include "ui/gfx/path.h" #include "ui/gfx/screen.h" #include "ui/native_theme/native_theme.h" -#include "ui/views/accessibility/native_view_accessibility_win.h" #include "ui/views/controls/native_control_win.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/drag_utils.h" @@ -77,17 +76,12 @@ const int kDragFrameWindowAlpha = 200; } // namespace -// static -bool NativeWidgetWin::screen_reader_active_ = false; - //////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, public: NativeWidgetWin::NativeWidgetWin(internal::NativeWidgetDelegate* delegate) : delegate_(delegate), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), - accessibility_view_events_index_(-1), - accessibility_view_events_(kMaxAccessibilityViewEvents), has_non_client_view_(false), ALLOW_THIS_IN_INITIALIZER_LIST( message_handler_(new HWNDMessageHandler(this))) { @@ -114,31 +108,6 @@ void NativeWidgetWin::Show(int show_state) { message_handler_->Show(show_state); } -View* NativeWidgetWin::GetAccessibilityViewEventAt(int id) { - // Convert from MSAA child id. - id = -(id + 1); - DCHECK(id >= 0 && id < kMaxAccessibilityViewEvents); - return accessibility_view_events_[id]; -} - -int NativeWidgetWin::AddAccessibilityViewEvent(View* view) { - accessibility_view_events_index_ = - (accessibility_view_events_index_ + 1) % kMaxAccessibilityViewEvents; - accessibility_view_events_[accessibility_view_events_index_] = view; - - // Convert to MSAA child id. - return -(accessibility_view_events_index_ + 1); -} - -void NativeWidgetWin::ClearAccessibilityViewEvent(View* view) { - for (std::vector<View*>::iterator it = accessibility_view_events_.begin(); - it != accessibility_view_events_.end(); - ++it) { - if (*it == view) - *it = NULL; - } -} - //////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, NativeWidget implementation: @@ -197,8 +166,6 @@ gfx::Vector2d NativeWidgetWin::CalculateOffsetToAncestorWithLayer( void NativeWidgetWin::ViewRemoved(View* view) { if (drop_target_.get()) drop_target_->ResetTargetViewIfEquals(view); - - ClearAccessibilityViewEvent(view); } void NativeWidgetWin::SetNativeWindowProperty(const char* name, void* value) { @@ -222,17 +189,6 @@ TooltipManager* NativeWidgetWin::GetTooltipManager() const { return tooltip_manager_.get(); } -bool NativeWidgetWin::IsScreenReaderActive() const { - return screen_reader_active_; -} - -void NativeWidgetWin::SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) { - message_handler_->SendNativeAccessibilityEvent( - AddAccessibilityViewEvent(view), event_type); -} - void NativeWidgetWin::SetCapture() { message_handler_->SetCapture(); } @@ -273,18 +229,6 @@ void NativeWidgetWin::SetWindowIcons(const gfx::ImageSkia& window_icon, message_handler_->SetWindowIcons(window_icon, app_icon); } -void NativeWidgetWin::SetAccessibleName(const string16& name) { - message_handler_->SetAccessibleName(name); -} - -void NativeWidgetWin::SetAccessibleRole(ui::AccessibilityTypes::Role role) { - message_handler_->SetAccessibleRole(role); -} - -void NativeWidgetWin::SetAccessibleState(ui::AccessibilityTypes::State state) { - message_handler_->SetAccessibleState(state); -} - void NativeWidgetWin::InitModalType(ui::ModalType modal_type) { message_handler_->InitModalType(modal_type); } @@ -440,10 +384,6 @@ void NativeWidgetWin::FlashFrame(bool flash) { message_handler_->FlashFrame(flash); } -bool NativeWidgetWin::IsAccessibleWidget() const { - return screen_reader_active_; -} - void NativeWidgetWin::RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, @@ -506,10 +446,6 @@ void NativeWidgetWin::OnFinalMessage(HWND window) { //////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, protected: -void NativeWidgetWin::OnScreenReaderDetected() { - screen_reader_active_ = true; -} - HWNDMessageHandler* NativeWidgetWin::GetMessageHandler() { return message_handler_.get(); } @@ -823,11 +759,6 @@ void NativeWidgetWin::HandlePaint(gfx::Canvas* canvas) { delegate_->OnNativeWidgetPaint(canvas); } -void NativeWidgetWin::HandleScreenReaderDetected() { - // TODO(beng): just consolidate this with OnScreenReaderDetected. - OnScreenReaderDetected(); -} - bool NativeWidgetWin::HandleTooltipNotify(int w_param, NMHDR* l_param, LRESULT* l_result) { diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index 006a249a..61db5b2 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -59,22 +59,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, // Show the window with the specified show command. void Show(int show_state); - // Obtain the view event with the given MSAA child id. Used in - // NativeViewAccessibilityWin::get_accChild to support requests for - // children of windowless controls. May return NULL - // (see ViewHierarchyChanged). - View* GetAccessibilityViewEventAt(int id); - - // Add a view that has recently fired an accessibility event. Returns a MSAA - // child id which is generated by: -(index of view in vector + 1) which - // guarantees a negative child id. This distinguishes the view from - // positive MSAA child id's which are direct leaf children of views that have - // associated hWnd's (e.g. NativeWidgetWin). - int AddAccessibilityViewEvent(View* view); - - // Clear a view that has recently been removed on a hierarchy change. - void ClearAccessibilityViewEvent(View* view); - // Places the window in a pseudo-fullscreen mode where it looks and acts as // like a fullscreen window except that it remains within the boundaries // of the metro snap divider. @@ -101,10 +85,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; virtual TooltipManager* GetTooltipManager() const OVERRIDE; - virtual bool IsScreenReaderActive() const OVERRIDE; - virtual void SendNativeAccessibilityEvent( - View* view, - ui::AccessibilityTypes::Event event_type) OVERRIDE; virtual void SetCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE; virtual bool HasCapture() const OVERRIDE; @@ -117,9 +97,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, virtual void SetWindowTitle(const string16& title) OVERRIDE; virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) OVERRIDE; - virtual void SetAccessibleName(const string16& name) OVERRIDE; - virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; - virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; @@ -152,7 +129,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, virtual void SetOpacity(unsigned char opacity) OVERRIDE; virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; virtual void FlashFrame(bool flash) OVERRIDE; - virtual bool IsAccessibleWidget() const OVERRIDE; virtual void RunShellDrag(View* view, const ui::OSExchangeData& data, const gfx::Point& location, @@ -175,9 +151,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, // behavior. virtual void OnFinalMessage(HWND window); - // Called when a MSAA screen reader client is detected. - virtual void OnScreenReaderDetected(); - HWNDMessageHandler* GetMessageHandler(); // Overridden from HWNDMessageHandlerDelegate: @@ -241,7 +214,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, HKL input_language_id) OVERRIDE; virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE; virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE; - virtual void HandleScreenReaderDetected() OVERRIDE; virtual bool HandleTooltipNotify(int w_param, NMHDR* l_param, LRESULT* l_result) OVERRIDE; @@ -276,23 +248,6 @@ class VIEWS_EXPORT NativeWidgetWin : public internal::NativeWidgetPrivate, // See class documentation for Widget in widget.h for a note about ownership. Widget::InitParams::Ownership ownership_; - // Instance of accessibility information and handling for MSAA root - base::win::ScopedComPtr<IAccessible> accessibility_root_; - - // Value determines whether the Widget is customized for accessibility. - static bool screen_reader_active_; - - // The maximum number of view events in our vector below. - static const int kMaxAccessibilityViewEvents = 20; - - // A vector used to access views for which we have sent notifications to - // accessibility clients. It is used as a circular queue. - std::vector<View*> accessibility_view_events_; - - // The current position of the view events vector. When incrementing, - // we always mod this value with the max view events above . - int accessibility_view_events_index_; - ViewProps props_; // The window styles before we modified them for the drag frame appearance. diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index 7d717a8..1092f2d 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -17,6 +17,7 @@ #include "ui/views/focus/view_storage.h" #include "ui/views/layout/fill_layout.h" #include "ui/views/widget/widget.h" +#include "ui/views/widget/widget_delegate.h" namespace views { namespace internal { @@ -596,7 +597,8 @@ void RootView::SetMouseHandler(View* new_mh) { } void RootView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_APPLICATION; + state->name = widget_->widget_delegate()->GetAccessibleWindowTitle(); + state->role = widget_->widget_delegate()->GetAccessibleWindowRole(); } void RootView::ReorderChildLayers(ui::Layer* parent_layer) { diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index abc31ed..65c65da 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -688,10 +688,6 @@ bool Widget::IsVisible() const { return native_widget_->IsVisible(); } -bool Widget::IsAccessibleWidget() const { - return native_widget_->IsAccessibleWidget(); -} - ui::ThemeProvider* Widget::GetThemeProvider() const { const Widget* root_widget = GetTopLevelWidget(); if (root_widget && root_widget != this) { @@ -782,12 +778,7 @@ void Widget::UpdateWindowTitle() { // Update the native frame's text. We do this regardless of whether or not // the native frame is being used, since this also updates the taskbar, etc. - string16 window_title; - if (native_widget_->IsScreenReaderActive()) { - window_title = widget_delegate_->GetAccessibleWindowTitle(); - } else { - window_title = widget_delegate_->GetWindowTitle(); - } + string16 window_title = widget_delegate_->GetWindowTitle(); base::i18n::AdjustStringForLocaleDirection(&window_title); native_widget_->SetWindowTitle(window_title); non_client_view_->UpdateWindowTitle(); @@ -897,12 +888,9 @@ void Widget::NotifyAccessibilityEvent( View* view, ui::AccessibilityTypes::Event event_type, bool send_native_event) { - // Send the notification to the delegate. - if (ViewsDelegate::views_delegate) - ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type); - - if (send_native_event) - native_widget_->SendNativeAccessibilityEvent(view, event_type); + // TODO(dmazzoni): get rid of this method and have clients just use + // View::NotifyAccessibilityEvent directly. + view->NotifyAccessibilityEvent(event_type, send_native_event); } const NativeWidget* Widget::native_widget() const { @@ -1017,11 +1005,6 @@ void Widget::OnNativeWidgetCreated() { if (is_top_level()) focus_manager_.reset(FocusManagerFactory::Create(this)); - native_widget_->SetAccessibleRole( - widget_delegate_->GetAccessibleWindowRole()); - native_widget_->SetAccessibleState( - widget_delegate_->GetAccessibleWindowState()); - native_widget_->InitModalType(widget_delegate_->GetModalType()); FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetCreated(this)); diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index f68481a..2d6e6aaf 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -461,9 +461,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Returns whether the Widget is visible to the user. virtual bool IsVisible() const; - // Returns whether the Widget is customized for accessibility. - bool IsAccessibleWidget() const; - // Returns the ThemeProvider that provides theme resources for this Widget. virtual ui::ThemeProvider* GetThemeProvider() const; diff --git a/ui/views/widget/widget_delegate.cc b/ui/views/widget/widget_delegate.cc index cb7b469d..f463e00 100644 --- a/ui/views/widget/widget_delegate.cc +++ b/ui/views/widget/widget_delegate.cc @@ -61,10 +61,6 @@ ui::AccessibilityTypes::Role WidgetDelegate::GetAccessibleWindowRole() const { return ui::AccessibilityTypes::ROLE_WINDOW; } -ui::AccessibilityTypes::State WidgetDelegate::GetAccessibleWindowState() const { - return 0; -} - string16 WidgetDelegate::GetAccessibleWindowTitle() const { return GetWindowTitle(); } diff --git a/ui/views/widget/widget_delegate.h b/ui/views/widget/widget_delegate.h index f7b5ffc..6106e2d 100644 --- a/ui/views/widget/widget_delegate.h +++ b/ui/views/widget/widget_delegate.h @@ -61,8 +61,6 @@ class VIEWS_EXPORT WidgetDelegate { virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const; - virtual ui::AccessibilityTypes::State GetAccessibleWindowState() const; - // Returns the title to be read with screen readers. virtual string16 GetAccessibleWindowTitle() const; diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index e2c27fb..d1760ab 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -288,10 +288,6 @@ bool ProcessChildWindowMessage(UINT message, #endif -// A custom MSAA object id used to determine if a screen reader is actively -// listening for MSAA events. -const int kCustomObjectID = 1; - // The thickness of an auto-hide taskbar in pixels. const int kAutoHideTaskbarThicknessPx = 2; @@ -737,71 +733,6 @@ void HWNDMessageHandler::SetVisibilityChangedAnimationsEnabled(bool enabled) { void HWNDMessageHandler::SetTitle(const string16& title) { SetWindowText(hwnd(), title.c_str()); - SetAccessibleName(title); -} - -void HWNDMessageHandler::SetAccessibleName(const string16& name) { - // TODO(beng): figure out vis-a-vis aura. -#if !defined(USE_AURA) - base::win::ScopedComPtr<IAccPropServices> pAccPropServices; - HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, - IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); - if (SUCCEEDED(hr)) - hr = pAccPropServices->SetHwndPropStr(hwnd(), OBJID_CLIENT, CHILDID_SELF, - PROPID_ACC_NAME, name.c_str()); -#endif -} - -void HWNDMessageHandler::SetAccessibleRole(ui::AccessibilityTypes::Role role) { - // TODO(beng): figure out vis-a-vis aura. -#if !defined(USE_AURA) - base::win::ScopedComPtr<IAccPropServices> pAccPropServices; - HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, - IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); - if (SUCCEEDED(hr)) { - VARIANT var; - if (role) { - var.vt = VT_I4; - var.lVal = NativeViewAccessibilityWin::MSAARole(role); - hr = pAccPropServices->SetHwndProp(hwnd(), OBJID_CLIENT, CHILDID_SELF, - PROPID_ACC_ROLE, var); - } - } -#endif -} - -void HWNDMessageHandler::SetAccessibleState( - ui::AccessibilityTypes::State state) { - // TODO(beng): figure out vis-a-vis aura. -#if !defined(USE_AURA) - base::win::ScopedComPtr<IAccPropServices> pAccPropServices; - HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, - IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices)); - if (SUCCEEDED(hr)) { - VARIANT var; - if (state) { - var.vt = VT_I4; - var.lVal = NativeViewAccessibilityWin::MSAAState(state); - hr = pAccPropServices->SetHwndProp(hwnd(), OBJID_CLIENT, CHILDID_SELF, - PROPID_ACC_STATE, var); - } - } -#endif -} - -void HWNDMessageHandler::SendNativeAccessibilityEvent( - int id, - ui::AccessibilityTypes::Event event_type) { - // TODO(beng): figure out vis-a-vis aura. -#if !defined(USE_AURA) - // Now call the Windows-specific method to notify MSAA clients of this - // event. The widget gives us a temporary unique child ID to associate - // with this view so that clients can call get_accChild in - // NativeViewAccessibilityWin to retrieve the IAccessible associated - // with this view. - ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type), hwnd(), - OBJID_CLIENT, id); -#endif } void HWNDMessageHandler::SetCursor(HCURSOR cursor) { @@ -1285,9 +1216,6 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) { fullscreen_handler_->set_hwnd(hwnd()); - // Attempt to detect screen readers by sending an event with our custom id. - NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kCustomObjectID, CHILDID_SELF); - // This message initializes the window so that focus border are shown for // windows. SendMessage(hwnd(), @@ -1414,15 +1342,6 @@ LRESULT HWNDMessageHandler::OnGetObject(UINT message, static_cast<IAccessible*>(root.Detach())); } - if (kCustomObjectID == l_param) { - // An MSAA client requested our custom id. Assume that we have detected an - // active windows screen reader. - delegate_->HandleScreenReaderDetected(); - - // Return with failure. - return static_cast<LRESULT>(0L); - } - return reference_result; } diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h index 3654b93..e455baa 100644 --- a/ui/views/win/hwnd_message_handler.h +++ b/ui/views/win/hwnd_message_handler.h @@ -124,12 +124,6 @@ class VIEWS_EXPORT HWNDMessageHandler : public ui::WindowImpl, void SetTitle(const string16& title); - void SetAccessibleName(const string16& name); - void SetAccessibleRole(ui::AccessibilityTypes::Role role); - void SetAccessibleState(ui::AccessibilityTypes::State state); - void SendNativeAccessibilityEvent(int id, - ui::AccessibilityTypes::Event event_type); - void SetCursor(HCURSOR cursor); void FrameTypeChanged(); diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h index ac7c865..73e2142 100644 --- a/ui/views/win/hwnd_message_handler_delegate.h +++ b/ui/views/win/hwnd_message_handler_delegate.h @@ -198,9 +198,6 @@ class VIEWS_EXPORT HWNDMessageHandlerDelegate { // Called to compel the delegate to paint using the software path. virtual void HandlePaint(gfx::Canvas* canvas) = 0; - // Called when we have detected a screen reader. - virtual void HandleScreenReaderDetected() = 0; - // Called to forward a WM_NOTIFY message to the tooltip manager. virtual bool HandleTooltipNotify(int w_param, NMHDR* l_param, diff --git a/ui/views/window/dialog_delegate.h b/ui/views/window/dialog_delegate.h index 682e9f3..ff7b031 100644 --- a/ui/views/window/dialog_delegate.h +++ b/ui/views/window/dialog_delegate.h @@ -98,7 +98,7 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate { DialogClientView* GetDialogClientView(); protected: - // Overridden from WindowDelegate: + // Overridden from WidgetDelegate: virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE; }; diff --git a/ui/views/window/non_client_view.cc b/ui/views/window/non_client_view.cc index 5dcfdd5..5cc5881 100644 --- a/ui/views/window/non_client_view.cc +++ b/ui/views/window/non_client_view.cc @@ -161,7 +161,7 @@ void NonClientView::ViewHierarchyChanged(bool is_add, View* parent, } void NonClientView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_WINDOW; + state->role = ui::AccessibilityTypes::ROLE_CLIENT; state->name = accessible_name_; } @@ -271,7 +271,7 @@ void NonClientFrameView::ShouldPaintAsActiveChanged() { } void NonClientFrameView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_WINDOW; + state->role = ui::AccessibilityTypes::ROLE_CLIENT; } std::string NonClientFrameView::GetClassName() const { |