Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ | 5 #ifndef UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
| 6 #define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ | 6 #define UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlcom.h> | 9 #include <atlcom.h> |
| 10 #include <oleacc.h> | 10 #include <oleacc.h> |
| 11 | 11 |
| 12 #include <UIAutomationCore.h> | 12 #include <UIAutomationCore.h> |
| 13 | 13 |
| 14 #include <set> | 14 #include <set> |
| 15 #include <vector> | |
| 15 | 16 |
| 16 #include "third_party/iaccessible2/ia2_api_all.h" | 17 #include "third_party/iaccessible2/ia2_api_all.h" |
| 17 #include "ui/accessibility/ax_view_state.h" | 18 #include "ui/accessibility/ax_view_state.h" |
| 18 #include "ui/views/accessibility/native_view_accessibility.h" | 19 #include "ui/views/accessibility/native_view_accessibility.h" |
| 19 #include "ui/views/controls/native/native_view_host.h" | 20 #include "ui/views/controls/native/native_view_host.h" |
| 20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| 23 enum TextBoundaryDirection; | 24 enum TextBoundaryDirection; |
| 24 enum TextBoundaryType; | 25 enum TextBoundaryType; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace views { | 28 namespace views { |
| 28 | 29 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 30 // | 31 // |
| 31 // NativeViewAccessibilityWin | 32 // NativeViewAccessibilityWin |
| 32 // | 33 // |
| 33 // Class implementing the MSAA IAccessible COM interface for a generic View, | 34 // Class implementing the MSAA IAccessible COM interface for a generic View, |
| 34 // providing accessibility to be used by screen readers and other assistive | 35 // providing accessibility to be used by screen readers and other assistive |
| 35 // technology (AT). | 36 // technology (AT). |
| 36 // | 37 // |
| 37 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
| 38 class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) | 39 class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) |
| 39 NativeViewAccessibilityWin | 40 NativeViewAccessibilityWin |
| 40 : public CComObjectRootEx<CComMultiThreadModel>, | 41 : public CComObjectRootEx<CComMultiThreadModel>, |
| 41 public IDispatchImpl<IAccessible2, &IID_IAccessible2, | 42 public IDispatchImpl<IAccessible2_2, &IID_IAccessible2_2, |
|
aboxhall
2014/05/07 15:26:30
Why all the _2s?
dmazzoni
2014/05/07 17:36:37
Believe it or not, that's what they call the exten
| |
| 42 &LIBID_IAccessible2Lib>, | 43 &LIBID_IAccessible2Lib>, |
| 43 public IAccessibleText, | 44 public IAccessibleText, |
| 44 public IServiceProvider, | 45 public IServiceProvider, |
| 45 public IAccessibleEx, | 46 public IAccessibleEx, |
| 46 public IRawElementProviderSimple, | 47 public IRawElementProviderSimple, |
| 47 public NativeViewAccessibility { | 48 public NativeViewAccessibility { |
| 48 public: | 49 public: |
| 49 BEGIN_COM_MAP(NativeViewAccessibilityWin) | 50 BEGIN_COM_MAP(NativeViewAccessibilityWin) |
| 50 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) | 51 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2_2) |
| 51 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) | 52 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2_2) |
| 52 COM_INTERFACE_ENTRY(IAccessible2) | 53 COM_INTERFACE_ENTRY(IAccessible2_2) |
| 53 COM_INTERFACE_ENTRY(IAccessibleText) | 54 COM_INTERFACE_ENTRY(IAccessibleText) |
| 54 COM_INTERFACE_ENTRY(IServiceProvider) | 55 COM_INTERFACE_ENTRY(IServiceProvider) |
| 55 COM_INTERFACE_ENTRY(IAccessibleEx) | 56 COM_INTERFACE_ENTRY(IAccessibleEx) |
| 56 COM_INTERFACE_ENTRY(IRawElementProviderSimple) | 57 COM_INTERFACE_ENTRY(IRawElementProviderSimple) |
| 57 END_COM_MAP() | 58 END_COM_MAP() |
| 58 | 59 |
| 59 virtual ~NativeViewAccessibilityWin(); | 60 virtual ~NativeViewAccessibilityWin(); |
| 60 | 61 |
| 61 // NativeViewAccessibility. | 62 // NativeViewAccessibility. |
| 62 virtual void NotifyAccessibilityEvent( | 63 virtual void NotifyAccessibilityEvent( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 // | 139 // |
| 139 | 140 |
| 140 STDMETHODIMP role(LONG* role); | 141 STDMETHODIMP role(LONG* role); |
| 141 | 142 |
| 142 STDMETHODIMP get_states(AccessibleStates* states); | 143 STDMETHODIMP get_states(AccessibleStates* states); |
| 143 | 144 |
| 144 STDMETHODIMP get_uniqueID(LONG* unique_id); | 145 STDMETHODIMP get_uniqueID(LONG* unique_id); |
| 145 | 146 |
| 146 STDMETHODIMP get_windowHandle(HWND* window_handle); | 147 STDMETHODIMP get_windowHandle(HWND* window_handle); |
| 147 | 148 |
| 149 STDMETHODIMP get_relationTargetsOfType(BSTR type, | |
| 150 long max_targets, | |
| 151 IUnknown ***targets, | |
| 152 long *n_targets); | |
| 153 | |
| 148 // | 154 // |
| 149 // IAccessible2 methods not implemented. | 155 // IAccessible2 methods not implemented. |
| 150 // | 156 // |
| 151 | 157 |
| 152 STDMETHODIMP get_attributes(BSTR* attributes) { | 158 STDMETHODIMP get_attributes(BSTR* attributes) { |
| 153 return E_NOTIMPL; | 159 return E_NOTIMPL; |
| 154 } | 160 } |
| 161 STDMETHODIMP get_attribute(BSTR name, VARIANT* attribute) { | |
| 162 return E_NOTIMPL; | |
| 163 } | |
| 155 STDMETHODIMP get_indexInParent(LONG* index_in_parent) { | 164 STDMETHODIMP get_indexInParent(LONG* index_in_parent) { |
| 156 return E_NOTIMPL; | 165 return E_NOTIMPL; |
| 157 } | 166 } |
| 158 STDMETHODIMP get_extendedRole(BSTR* extended_role) { | 167 STDMETHODIMP get_extendedRole(BSTR* extended_role) { |
| 159 return E_NOTIMPL; | 168 return E_NOTIMPL; |
| 160 } | 169 } |
| 161 STDMETHODIMP get_nRelations(LONG* n_relations) { | 170 STDMETHODIMP get_nRelations(LONG* n_relations) { |
| 162 return E_NOTIMPL; | 171 return E_NOTIMPL; |
| 163 } | 172 } |
| 164 STDMETHODIMP get_relation(LONG relation_index, | 173 STDMETHODIMP get_relation(LONG relation_index, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 } | 207 } |
| 199 STDMETHODIMP get_localizedExtendedStates( | 208 STDMETHODIMP get_localizedExtendedStates( |
| 200 LONG max_localized_extended_states, | 209 LONG max_localized_extended_states, |
| 201 BSTR** localized_extended_states, | 210 BSTR** localized_extended_states, |
| 202 LONG* n_localized_extended_states) { | 211 LONG* n_localized_extended_states) { |
| 203 return E_NOTIMPL; | 212 return E_NOTIMPL; |
| 204 } | 213 } |
| 205 STDMETHODIMP get_locale(IA2Locale* locale) { | 214 STDMETHODIMP get_locale(IA2Locale* locale) { |
| 206 return E_NOTIMPL; | 215 return E_NOTIMPL; |
| 207 } | 216 } |
| 217 STDMETHODIMP get_accessibleWithCaret(IUnknown** accessible, | |
| 218 long* caret_offset) { | |
| 219 return E_NOTIMPL; | |
| 220 } | |
| 208 | 221 |
| 209 // | 222 // |
| 210 // IAccessibleText methods. | 223 // IAccessibleText methods. |
| 211 // | 224 // |
| 212 | 225 |
| 213 STDMETHODIMP get_nCharacters(LONG* n_characters); | 226 STDMETHODIMP get_nCharacters(LONG* n_characters); |
| 214 | 227 |
| 215 STDMETHODIMP get_caretOffset(LONG* offset); | 228 STDMETHODIMP get_caretOffset(LONG* offset); |
| 216 | 229 |
| 217 STDMETHODIMP get_nSelections(LONG* n_selections); | 230 STDMETHODIMP get_nSelections(LONG* n_selections); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 LONG FindBoundary(const base::string16& text, | 402 LONG FindBoundary(const base::string16& text, |
| 390 IA2TextBoundaryType ia2_boundary, | 403 IA2TextBoundaryType ia2_boundary, |
| 391 LONG start_offset, | 404 LONG start_offset, |
| 392 ui::TextBoundaryDirection direction); | 405 ui::TextBoundaryDirection direction); |
| 393 | 406 |
| 394 // Populates the given vector with all widgets that are either a child | 407 // Populates the given vector with all widgets that are either a child |
| 395 // or are owned by this view's widget, and who are not contained in a | 408 // or are owned by this view's widget, and who are not contained in a |
| 396 // NativeViewHost. | 409 // NativeViewHost. |
| 397 void PopulateChildWidgetVector(std::vector<Widget*>* child_widgets); | 410 void PopulateChildWidgetVector(std::vector<Widget*>* child_widgets); |
| 398 | 411 |
| 412 // Adds this view to alert_target_view_storage_ids_. | |
| 413 void AddAlertTarget(); | |
| 414 | |
| 415 // Remove this view from alert_target_view_storage_ids_. | |
|
aboxhall
2014/05/07 15:26:30
Nit: Removes
dmazzoni
2014/05/07 17:36:37
Done.
| |
| 416 void RemoveAlertTarget(); | |
| 417 | |
| 399 // Give CComObject access to the class constructor. | 418 // Give CComObject access to the class constructor. |
| 400 template <class Base> friend class CComObject; | 419 template <class Base> friend class CComObject; |
| 401 | 420 |
| 402 // Member View needed for view-specific calls. | 421 // Member View needed for view-specific calls. |
| 403 View* view_; | 422 View* view_; |
| 404 | 423 |
| 405 // A unique id for each object, needed for IAccessible2. | 424 // A unique id for each object, needed for IAccessible2. |
| 406 long unique_id_; | 425 long unique_id_; |
| 407 | 426 |
| 408 // Next unique id to assign. | 427 // Next unique id to assign. |
| 409 static long next_unique_id_; | 428 static long next_unique_id_; |
| 410 | 429 |
| 411 // Circular queue size. | 430 // Circular queue size. |
| 412 static const int kMaxViewStorageIds = 20; | 431 static const int kMaxViewStorageIds = 20; |
| 413 | 432 |
| 414 // Circular queue of view storage ids corresponding to child ids | 433 // Circular queue of view storage ids corresponding to child ids |
| 415 // used to post notifications using NotifyWinEvent. | 434 // used to post notifications using NotifyWinEvent. |
| 416 static int view_storage_ids_[kMaxViewStorageIds]; | 435 static int view_storage_ids_[kMaxViewStorageIds]; |
| 417 | 436 |
| 418 // Next index into |view_storage_ids_| to use. | 437 // Next index into |view_storage_ids_| to use. |
| 419 static int next_view_storage_id_index_; | 438 static int next_view_storage_id_index_; |
| 420 | 439 |
| 440 // A vector of view storage ids of views that have been the target of | |
| 441 // an alert event, in order to provide an api to quickly identify all | |
| 442 // open alerts. | |
| 443 static std::vector<int> alert_target_view_storage_ids_; | |
| 444 | |
| 421 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin); | 445 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin); |
| 422 }; | 446 }; |
| 423 | 447 |
| 424 } // namespace views | 448 } // namespace views |
| 425 | 449 |
| 426 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ | 450 #endif // UI_VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
| OLD | NEW |