OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ | 5 #ifndef VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
6 #define VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ | 6 #define VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <atlbase.h> | 9 #include <atlbase.h> |
10 #include <atlcom.h> | 10 #include <atlcom.h> |
11 | 11 |
12 #include <oleacc.h> | 12 #include <oleacc.h> |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "third_party/iaccessible2/ia2_api_all.h" |
15 #include "ui/base/accessibility/accessible_view_state.h" | 16 #include "ui/base/accessibility/accessible_view_state.h" |
16 #include "views/controls/native/native_view_host.h" | 17 #include "views/controls/native/native_view_host.h" |
17 #include "views/view.h" | 18 #include "views/view.h" |
18 | 19 |
19 // Note: do not put NativeViewAccessibilityWin in the namespace "views"; | 20 // Note: do not put NativeViewAccessibilityWin in the namespace "views"; |
20 // Visual Studio 2005 does not allow an ATL::CComObject symbol in a namespace. | 21 // Visual Studio 2005 does not allow an ATL::CComObject symbol in a namespace. |
21 | 22 |
22 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
23 // | 24 // |
24 // NativeViewAccessibilityWin | 25 // NativeViewAccessibilityWin |
25 // | 26 // |
26 // Class implementing the MSAA IAccessible COM interface for a generic View, | 27 // Class implementing the MSAA IAccessible COM interface for a generic View, |
27 // providing accessibility to be used by screen readers and other assistive | 28 // providing accessibility to be used by screen readers and other assistive |
28 // technology (AT). | 29 // technology (AT). |
29 // | 30 // |
30 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
31 class ATL_NO_VTABLE NativeViewAccessibilityWin | 32 class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) |
| 33 NativeViewAccessibilityWin |
32 : public CComObjectRootEx<CComMultiThreadModel>, | 34 : public CComObjectRootEx<CComMultiThreadModel>, |
33 public IDispatchImpl<IAccessible, &IID_IAccessible, &LIBID_Accessibility> { | 35 public IDispatchImpl<IAccessible2, &IID_IAccessible2, |
| 36 &LIBID_IAccessible2Lib>, |
| 37 public IAccessibleText, |
| 38 public IServiceProvider { |
34 public: | 39 public: |
35 BEGIN_COM_MAP(NativeViewAccessibilityWin) | 40 BEGIN_COM_MAP(NativeViewAccessibilityWin) |
36 COM_INTERFACE_ENTRY2(IDispatch, IAccessible) | 41 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) |
37 COM_INTERFACE_ENTRY(IAccessible) | 42 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) |
| 43 COM_INTERFACE_ENTRY(IAccessible2) |
| 44 COM_INTERFACE_ENTRY(IAccessibleText) |
| 45 COM_INTERFACE_ENTRY(IServiceProvider) |
38 END_COM_MAP() | 46 END_COM_MAP() |
39 | 47 |
40 // Create method for view accessibility. | 48 // Create method for view accessibility. |
41 static scoped_refptr<NativeViewAccessibilityWin> Create(views::View* view); | 49 static scoped_refptr<NativeViewAccessibilityWin> Create(views::View* view); |
42 | 50 |
43 virtual ~NativeViewAccessibilityWin(); | 51 virtual ~NativeViewAccessibilityWin(); |
44 | 52 |
45 void set_view(views::View* view) { view_ = view; } | 53 void set_view(views::View* view) { view_ = view; } |
46 | 54 |
47 // Supported IAccessible methods. | 55 // Supported IAccessible methods. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Help functions not supported. | 112 // Help functions not supported. |
105 STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* help); | 113 STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* help); |
106 STDMETHODIMP get_accHelpTopic(BSTR* help_file, | 114 STDMETHODIMP get_accHelpTopic(BSTR* help_file, |
107 VARIANT var_id, | 115 VARIANT var_id, |
108 LONG* topic_id); | 116 LONG* topic_id); |
109 | 117 |
110 // Deprecated functions, not implemented here. | 118 // Deprecated functions, not implemented here. |
111 STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name); | 119 STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name); |
112 STDMETHODIMP put_accValue(VARIANT var_id, BSTR put_val); | 120 STDMETHODIMP put_accValue(VARIANT var_id, BSTR put_val); |
113 | 121 |
| 122 // |
| 123 // IAccessible2 |
| 124 // |
| 125 |
| 126 STDMETHODIMP role(LONG* role); |
| 127 |
| 128 STDMETHODIMP get_states(AccessibleStates* states); |
| 129 |
| 130 STDMETHODIMP get_uniqueID(LONG* unique_id); |
| 131 |
| 132 STDMETHODIMP get_windowHandle(HWND* window_handle); |
| 133 |
| 134 // |
| 135 // IAccessible2 methods not implemented. |
| 136 // |
| 137 |
| 138 STDMETHODIMP get_attributes(BSTR* attributes) { |
| 139 return E_NOTIMPL; |
| 140 } |
| 141 STDMETHODIMP get_indexInParent(LONG* index_in_parent) { |
| 142 return E_NOTIMPL; |
| 143 } |
| 144 STDMETHODIMP get_extendedRole(BSTR* extended_role) { |
| 145 return E_NOTIMPL; |
| 146 } |
| 147 STDMETHODIMP get_nRelations(LONG* n_relations) { |
| 148 return E_NOTIMPL; |
| 149 } |
| 150 STDMETHODIMP get_relation(LONG relation_index, |
| 151 IAccessibleRelation** relation) { |
| 152 return E_NOTIMPL; |
| 153 } |
| 154 STDMETHODIMP get_relations(LONG max_relations, |
| 155 IAccessibleRelation** relations, |
| 156 LONG* n_relations) { |
| 157 return E_NOTIMPL; |
| 158 } |
| 159 STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) { |
| 160 return E_NOTIMPL; |
| 161 } |
| 162 STDMETHODIMP scrollToPoint( |
| 163 enum IA2CoordinateType coordinate_type, |
| 164 LONG x, |
| 165 LONG y) { |
| 166 return E_NOTIMPL; |
| 167 } |
| 168 STDMETHODIMP get_groupPosition(LONG* group_level, |
| 169 LONG* similar_items_in_group, |
| 170 LONG* position_in_group) { |
| 171 return E_NOTIMPL; |
| 172 } |
| 173 STDMETHODIMP get_localizedExtendedRole( |
| 174 BSTR* localized_extended_role) { |
| 175 return E_NOTIMPL; |
| 176 } |
| 177 STDMETHODIMP get_nExtendedStates(LONG* n_extended_states) { |
| 178 return E_NOTIMPL; |
| 179 } |
| 180 STDMETHODIMP get_extendedStates(LONG max_extended_states, |
| 181 BSTR** extended_states, |
| 182 LONG* n_extended_states) { |
| 183 return E_NOTIMPL; |
| 184 } |
| 185 STDMETHODIMP get_localizedExtendedStates( |
| 186 LONG max_localized_extended_states, |
| 187 BSTR** localized_extended_states, |
| 188 LONG* n_localized_extended_states) { |
| 189 return E_NOTIMPL; |
| 190 } |
| 191 STDMETHODIMP get_locale(IA2Locale* locale) { |
| 192 return E_NOTIMPL; |
| 193 } |
| 194 |
| 195 // |
| 196 // IAccessibleText methods. |
| 197 // |
| 198 |
| 199 STDMETHODIMP get_nCharacters(LONG* n_characters); |
| 200 |
| 201 STDMETHODIMP get_caretOffset(LONG* offset); |
| 202 |
| 203 STDMETHODIMP get_nSelections(LONG* n_selections); |
| 204 |
| 205 STDMETHODIMP get_selection(LONG selection_index, |
| 206 LONG* start_offset, |
| 207 LONG* end_offset); |
| 208 |
| 209 STDMETHODIMP get_text(LONG start_offset, LONG end_offset, BSTR* text); |
| 210 |
| 211 STDMETHODIMP get_offsetAtPoint(LONG x, LONG y, |
| 212 enum IA2CoordinateType coord_type, |
| 213 LONG* offset); |
| 214 |
| 215 // |
| 216 // IAccessibleText methods not implemented. |
| 217 // |
| 218 |
| 219 STDMETHODIMP get_textAtOffset(LONG offset, |
| 220 enum IA2TextBoundaryType boundary_type, |
| 221 LONG* start_offset, LONG* end_offset, |
| 222 BSTR* text) { |
| 223 return E_NOTIMPL; |
| 224 } |
| 225 STDMETHODIMP get_textBeforeOffset(LONG offset, |
| 226 enum IA2TextBoundaryType boundary_type, |
| 227 LONG* start_offset, LONG* end_offset, |
| 228 BSTR* text) { |
| 229 return E_NOTIMPL; |
| 230 } |
| 231 STDMETHODIMP get_textAfterOffset(LONG offset, |
| 232 enum IA2TextBoundaryType boundary_type, |
| 233 LONG* start_offset, LONG* end_offset, |
| 234 BSTR* text) { |
| 235 return E_NOTIMPL; |
| 236 } |
| 237 STDMETHODIMP get_newText(IA2TextSegment* new_text) { |
| 238 return E_NOTIMPL; |
| 239 } |
| 240 STDMETHODIMP get_oldText(IA2TextSegment* old_text) { |
| 241 return E_NOTIMPL; |
| 242 } |
| 243 STDMETHODIMP addSelection(LONG start_offset, LONG end_offset) { |
| 244 return E_NOTIMPL; |
| 245 } |
| 246 STDMETHODIMP get_attributes(LONG offset, |
| 247 LONG* start_offset, |
| 248 LONG* end_offset, |
| 249 BSTR* text_attributes) { |
| 250 return E_NOTIMPL; |
| 251 } |
| 252 STDMETHODIMP get_characterExtents(LONG offset, |
| 253 enum IA2CoordinateType coord_type, |
| 254 LONG* x, LONG* y, |
| 255 LONG* width, LONG* height) { |
| 256 return E_NOTIMPL; |
| 257 } |
| 258 STDMETHODIMP removeSelection(LONG selection_index) { |
| 259 return E_NOTIMPL; |
| 260 } |
| 261 STDMETHODIMP setCaretOffset(LONG offset) { |
| 262 return E_NOTIMPL; |
| 263 } |
| 264 STDMETHODIMP setSelection(LONG selection_index, |
| 265 LONG start_offset, |
| 266 LONG end_offset) { |
| 267 return E_NOTIMPL; |
| 268 } |
| 269 STDMETHODIMP scrollSubstringTo(LONG start_index, |
| 270 LONG end_index, |
| 271 enum IA2ScrollType scroll_type) { |
| 272 return E_NOTIMPL; |
| 273 } |
| 274 STDMETHODIMP scrollSubstringToPoint(LONG start_index, |
| 275 LONG end_index, |
| 276 enum IA2CoordinateType coordinate_type, |
| 277 LONG x, LONG y) { |
| 278 return E_NOTIMPL; |
| 279 } |
| 280 |
| 281 // |
| 282 // IServiceProvider methods. |
| 283 // |
| 284 |
| 285 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object); |
| 286 |
114 // Returns a conversion from the event (as defined in accessibility_types.h) | 287 // Returns a conversion from the event (as defined in accessibility_types.h) |
115 // to an MSAA event. | 288 // to an MSAA event. |
116 static int32 MSAAEvent(ui::AccessibilityTypes::Event event); | 289 static int32 MSAAEvent(ui::AccessibilityTypes::Event event); |
117 | 290 |
118 // Returns a conversion from the Role (as defined in accessibility_types.h) | 291 // Returns a conversion from the Role (as defined in accessibility_types.h) |
119 // to an MSAA role. | 292 // to an MSAA role. |
120 static int32 MSAARole(ui::AccessibilityTypes::Role role); | 293 static int32 MSAARole(ui::AccessibilityTypes::Role role); |
121 | 294 |
122 // Returns a conversion from the State (as defined in accessibility_types.h) | 295 // Returns a conversion from the State (as defined in accessibility_types.h) |
123 // to MSAA states set. | 296 // to MSAA states set. |
(...skipping 13 matching lines...) Expand all Loading... |
137 int start_id, | 310 int start_id, |
138 int lower_bound, | 311 int lower_bound, |
139 int upper_bound) const; | 312 int upper_bound) const; |
140 | 313 |
141 // Determines if the child id variant is valid. | 314 // Determines if the child id variant is valid. |
142 bool IsValidId(const VARIANT& child) const; | 315 bool IsValidId(const VARIANT& child) const; |
143 | 316 |
144 // Helper function which sets applicable states of view. | 317 // Helper function which sets applicable states of view. |
145 void SetState(VARIANT* msaa_state, views::View* view); | 318 void SetState(VARIANT* msaa_state, views::View* view); |
146 | 319 |
| 320 // Return the text to use for IAccessibleText. |
| 321 string16 TextForIAccessibleText(); |
| 322 |
147 // Give CComObject access to the class constructor. | 323 // Give CComObject access to the class constructor. |
148 template <class Base> friend class CComObject; | 324 template <class Base> friend class CComObject; |
149 | 325 |
150 // Member View needed for view-specific calls. | 326 // Member View needed for view-specific calls. |
151 views::View* view_; | 327 views::View* view_; |
152 | 328 |
| 329 // A unique id for each object, needed for IAccessible2. |
| 330 long unique_id_; |
| 331 |
| 332 // Next unique id to assign. |
| 333 static long next_unique_id_; |
| 334 |
153 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin); | 335 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin); |
154 }; | 336 }; |
155 | 337 |
156 #endif // VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ | 338 #endif // VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_ |
OLD | NEW |