Index: ui/accessibility/platform/ax_platform_node_win.h |
diff --git a/ui/views/accessibility/native_view_accessibility_win.h b/ui/accessibility/platform/ax_platform_node_win.h |
similarity index 57% |
copy from ui/views/accessibility/native_view_accessibility_win.h |
copy to ui/accessibility/platform/ax_platform_node_win.h |
index e34bdc33c31070478323b873ceadf72b69afc5f4..36217904b49a4a2ce169a865183699245cfbc94a 100644 |
--- a/ui/views/accessibility/native_view_accessibility_win.h |
+++ b/ui/accessibility/platform/ax_platform_node_win.h |
@@ -1,141 +1,117 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2015 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_WIN_H_ |
-#define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
+#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_ |
+#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_ |
#include <atlbase.h> |
#include <atlcom.h> |
#include <oleacc.h> |
-#include <UIAutomationCore.h> |
- |
-#include <set> |
-#include <vector> |
- |
#include "third_party/iaccessible2/ia2_api_all.h" |
-#include "ui/accessibility/ax_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" |
+#include "ui/accessibility/platform/ax_platform_node_base.h" |
namespace ui { |
-enum TextBoundaryDirection; |
-enum TextBoundaryType; |
-} |
- |
-namespace views { |
- |
-//////////////////////////////////////////////////////////////////////////////// |
-// |
-// NativeViewAccessibilityWin |
-// |
-// Class implementing the MSAA IAccessible COM interface for a generic View, |
-// providing accessibility to be used by screen readers and other assistive |
-// technology (AT). |
-// |
-//////////////////////////////////////////////////////////////////////////////// |
+ |
class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) |
-NativeViewAccessibilityWin |
- : public CComObjectRootEx<CComMultiThreadModel>, |
- public IDispatchImpl<IAccessible2_2, &IID_IAccessible2_2, |
- &LIBID_IAccessible2Lib>, |
+AXPlatformNodeWin |
+: public CComObjectRootEx<CComMultiThreadModel>, |
+ public IDispatchImpl<IAccessible2_2, &IID_IAccessible2, |
+ &LIBID_IAccessible2Lib>, |
public IAccessibleText, |
public IServiceProvider, |
- public IAccessibleEx, |
- public IRawElementProviderSimple, |
- public NativeViewAccessibility { |
+ public AXPlatformNodeBase { |
public: |
- BEGIN_COM_MAP(NativeViewAccessibilityWin) |
+ BEGIN_COM_MAP(AXPlatformNodeWin) |
COM_INTERFACE_ENTRY2(IDispatch, IAccessible2_2) |
+ COM_INTERFACE_ENTRY(AXPlatformNodeWin) |
COM_INTERFACE_ENTRY(IAccessible) |
COM_INTERFACE_ENTRY(IAccessible2) |
COM_INTERFACE_ENTRY(IAccessible2_2) |
- COM_INTERFACE_ENTRY(IAccessibleEx) |
COM_INTERFACE_ENTRY(IAccessibleText) |
- COM_INTERFACE_ENTRY(IRawElementProviderSimple) |
COM_INTERFACE_ENTRY(IServiceProvider) |
END_COM_MAP() |
- virtual ~NativeViewAccessibilityWin(); |
+ virtual ~AXPlatformNodeWin(); |
- // NativeViewAccessibility. |
- void NotifyAccessibilityEvent(ui::AXEvent event_type) override; |
- gfx::NativeViewAccessible GetNativeObject() override; |
+ // AXPlatformNode overrides. |
void Destroy() override; |
+ gfx::NativeViewAccessible GetNativeViewAccessible() override; |
+ void NotifyAccessibilityEvent(ui::AXEvent event_type) override; |
+ |
+ // AXPlatformNodeBase overrides. |
+ int GetIndexInParent() override; |
- // Supported IAccessible methods. |
+ // |
+ // IAccessible methods. |
+ // |
// Retrieves the child element or child object at a given point on the screen. |
- STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child) override; |
+ virtual STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); |
// Performs the object's default action. |
- STDMETHODIMP accDoDefaultAction(VARIANT var_id) override; |
+ STDMETHODIMP accDoDefaultAction(VARIANT var_id); |
// Retrieves the specified object's current screen location. |
STDMETHODIMP accLocation(LONG* x_left, |
LONG* y_top, |
LONG* width, |
LONG* height, |
- VARIANT var_id) override; |
+ VARIANT var_id); |
// Traverses to another UI element and retrieves the object. |
- STDMETHODIMP accNavigate(LONG nav_dir, VARIANT start, VARIANT* end) override; |
+ STDMETHODIMP accNavigate(LONG nav_dir, VARIANT start, VARIANT* end); |
// Retrieves an IDispatch interface pointer for the specified child. |
- STDMETHODIMP get_accChild(VARIANT var_child, IDispatch** disp_child) override; |
+ virtual STDMETHODIMP get_accChild(VARIANT var_child, IDispatch** disp_child); |
// Retrieves the number of accessible children. |
- STDMETHODIMP get_accChildCount(LONG* child_count) override; |
+ virtual STDMETHODIMP get_accChildCount(LONG* child_count); |
// Retrieves a string that describes the object's default action. |
- STDMETHODIMP get_accDefaultAction(VARIANT var_id, |
- BSTR* default_action) override; |
+ STDMETHODIMP get_accDefaultAction(VARIANT var_id, BSTR* default_action); |
// Retrieves the tooltip description. |
- STDMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc) override; |
+ STDMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc); |
// Retrieves the object that has the keyboard focus. |
- STDMETHODIMP get_accFocus(VARIANT* focus_child) override; |
+ STDMETHODIMP get_accFocus(VARIANT* focus_child); |
// Retrieves the specified object's shortcut. |
- STDMETHODIMP get_accKeyboardShortcut(VARIANT var_id, |
- BSTR* access_key) override; |
+ STDMETHODIMP get_accKeyboardShortcut(VARIANT var_id, BSTR* access_key); |
// Retrieves the name of the specified object. |
- STDMETHODIMP get_accName(VARIANT var_id, BSTR* name) override; |
+ STDMETHODIMP get_accName(VARIANT var_id, BSTR* name); |
// Retrieves the IDispatch interface of the object's parent. |
- STDMETHODIMP get_accParent(IDispatch** disp_parent) override; |
+ STDMETHODIMP get_accParent(IDispatch** disp_parent); |
// Retrieves information describing the role of the specified object. |
- STDMETHODIMP get_accRole(VARIANT var_id, VARIANT* role) override; |
+ STDMETHODIMP get_accRole(VARIANT var_id, VARIANT* role); |
// Retrieves the current state of the specified object. |
- STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state) override; |
+ STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state); |
+ |
+ // Gets the help string for the specified object. |
+ STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* help); |
// Retrieve or set the string value associated with the specified object. |
// Setting the value is not typically used by screen readers, but it's |
// used frequently by automation software. |
- STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value) override; |
- STDMETHODIMP put_accValue(VARIANT var_id, BSTR new_value) override; |
+ STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value); |
+ STDMETHODIMP put_accValue(VARIANT var_id, BSTR new_value); |
- // Selections not applicable to views. |
- STDMETHODIMP get_accSelection(VARIANT* selected) override; |
- STDMETHODIMP accSelect(LONG flags_sel, VARIANT var_id) override; |
- |
- // Help functions not supported. |
- STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* help) override; |
+ // IAccessible methods not implemented. |
+ STDMETHODIMP get_accSelection(VARIANT* selected); |
+ STDMETHODIMP accSelect(LONG flags_sel, VARIANT var_id); |
STDMETHODIMP get_accHelpTopic(BSTR* help_file, |
VARIANT var_id, |
- LONG* topic_id) override; |
- |
- // Deprecated functions, not implemented here. |
- STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name) override; |
+ LONG* topic_id); |
+ STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name); |
// |
- // IAccessible2 |
+ // IAccessible2 methods. |
// |
STDMETHODIMP role(LONG* role) override; |
@@ -307,85 +283,23 @@ NativeViewAccessibilityWin |
// IServiceProvider methods. |
// |
- STDMETHODIMP QueryService(REFGUID guidService, |
- REFIID riid, |
- void** object) override; |
- |
- // |
- // IAccessibleEx methods not implemented. |
- // |
- STDMETHODIMP GetObjectForChild(long child_id, IAccessibleEx** ret) override { |
- return E_NOTIMPL; |
- } |
- |
- STDMETHODIMP GetIAccessiblePair(IAccessible** acc, long* child_id) override { |
- return E_NOTIMPL; |
- } |
- |
- STDMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) override { |
- return E_NOTIMPL; |
- } |
- |
- STDMETHODIMP ConvertReturnedElement(IRawElementProviderSimple* element, |
- IAccessibleEx** acc) override { |
- return E_NOTIMPL; |
- } |
- |
- // |
- // IRawElementProviderSimple methods. |
- // |
- // The GetPatternProvider/GetPropertyValue methods need to be implemented for |
- // the on-screen keyboard to show up in Windows 8 metro. |
- STDMETHODIMP GetPatternProvider(PATTERNID id, IUnknown** provider) override; |
- STDMETHODIMP GetPropertyValue(PROPERTYID id, VARIANT* ret) override; |
- |
- // |
- // IRawElementProviderSimple methods not implemented. |
- // |
- STDMETHODIMP get_ProviderOptions(enum ProviderOptions* ret) override { |
- return E_NOTIMPL; |
- } |
- |
- STDMETHODIMP get_HostRawElementProvider( |
- IRawElementProviderSimple** provider) override { |
- return E_NOTIMPL; |
- } |
- |
- // Static methods |
- |
- // Returns a conversion from the event (as defined in ax_enums.idl) |
- // to an MSAA event. |
- static int32 MSAAEvent(ui::AXEvent event); |
- |
- // Returns a conversion from the Role (as defined in ax_enums.idl) |
- // to an MSAA role. |
- static int32 MSAARole(ui::AXRole role); |
- |
- // Returns a conversion from the State (as defined in ax_enums.idl) |
- // to MSAA states set. |
- static int32 MSAAState(const ui::AXViewState& state); |
+ STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object); |
protected: |
- NativeViewAccessibilityWin(); |
+ AXPlatformNodeWin(); |
private: |
- // Determines navigation direction for accNavigate, based on left, up and |
- // previous being mapped all to previous and right, down, next being mapped |
- // to next. Returns true if navigation direction is next, false otherwise. |
- bool IsNavDirNext(int nav_dir) const; |
- |
- // Determines if the navigation target is within the allowed bounds. Returns |
- // true if it is, false otherwise. |
- bool IsValidNav(int nav_dir, |
- int start_id, |
- int lower_bound, |
- int upper_bound) const; |
- |
- // Determines if the child id variant is valid. |
bool IsValidId(const VARIANT& child) const; |
+ int MSAARole(); |
+ int MSAAState(); |
+ int MSAAEvent(ui::AXEvent event); |
- // Helper function which sets applicable states of view. |
- void SetState(VARIANT* msaa_state, View* view); |
+ HRESULT GetStringAttributeAsBstr( |
+ ui::AXStringAttribute attribute, |
+ BSTR* value_bstr) const; |
+ |
+ void AddAlertTarget(); |
+ void RemoveAlertTarget(); |
// Return the text to use for IAccessibleText. |
base::string16 TextForIAccessibleText(); |
@@ -405,44 +319,17 @@ NativeViewAccessibilityWin |
LONG start_offset, |
ui::TextBoundaryDirection direction); |
- // Populates the given vector with all widgets that are either a child |
- // or are owned by this view's widget, and who are not contained in a |
- // NativeViewHost. |
- void PopulateChildWidgetVector(std::vector<Widget*>* child_widgets); |
- |
- // Adds this view to alert_target_view_storage_ids_. |
- void AddAlertTarget(); |
- |
- // Removes this view from alert_target_view_storage_ids_. |
- void RemoveAlertTarget(); |
- |
- // Give CComObject access to the class constructor. |
- template <class Base> friend class CComObject; |
- |
- // A unique id for each object, needed for IAccessible2. |
- long unique_id_; |
- |
- // 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_; |
- |
- // A vector of view storage ids of views that have been the target of |
- // an alert event, in order to provide an api to quickly identify all |
- // open alerts. |
- static std::vector<int> alert_target_view_storage_ids_; |
- |
- DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin); |
+ // A windows-specific unique ID for this object. It's returned in |
+ // IAccessible2::get_uniqueID, but more importantly it's used for |
+ // firing events. On Windows, we fire events on the nearest parent HWND |
+ // and pass the unique ID as the child id parameter. When the client |
+ // wants to retrieve the object the event was fired on, it calls |
+ // get_accChild and passes the child ID. We use negative IDs for the unique |
+ // ID so we can distinguish a request for an arbitrary child from a request |
+ // for an immediate child of an object by its 0-based index. |
+ LONG unique_id_win_; |
}; |
-} // namespace views |
+} // namespace ui |
-#endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
+#endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_ |