Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: views/accessibility/native_view_accessibility_win.h

Issue 8533010: views: Move accessibility/ directory to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/accessibility/OWNERS ('k') | views/accessibility/native_view_accessibility_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_
6 #define VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_
7 #pragma once
8
9 #include <atlbase.h>
10 #include <atlcom.h>
11
12 #include <oleacc.h>
13
14 #include "base/memory/scoped_ptr.h"
15 #include "third_party/iaccessible2/ia2_api_all.h"
16 #include "ui/base/accessibility/accessible_view_state.h"
17 #include "views/controls/native/native_view_host.h"
18 #include "views/view.h"
19
20 namespace ui {
21 enum TextBoundaryDirection;
22 enum TextBoundaryType;
23 }
24
25 // Note: do not put NativeViewAccessibilityWin in the namespace "views";
26 // Visual Studio 2005 does not allow an ATL::CComObject symbol in a namespace.
27
28 ////////////////////////////////////////////////////////////////////////////////
29 //
30 // NativeViewAccessibilityWin
31 //
32 // Class implementing the MSAA IAccessible COM interface for a generic View,
33 // providing accessibility to be used by screen readers and other assistive
34 // technology (AT).
35 //
36 ////////////////////////////////////////////////////////////////////////////////
37 class __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
38 NativeViewAccessibilityWin
39 : public CComObjectRootEx<CComMultiThreadModel>,
40 public IDispatchImpl<IAccessible2, &IID_IAccessible2,
41 &LIBID_IAccessible2Lib>,
42 public IAccessibleText,
43 public IServiceProvider {
44 public:
45 BEGIN_COM_MAP(NativeViewAccessibilityWin)
46 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2)
47 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2)
48 COM_INTERFACE_ENTRY(IAccessible2)
49 COM_INTERFACE_ENTRY(IAccessibleText)
50 COM_INTERFACE_ENTRY(IServiceProvider)
51 END_COM_MAP()
52
53 // Create method for view accessibility.
54 static scoped_refptr<NativeViewAccessibilityWin> Create(views::View* view);
55
56 virtual ~NativeViewAccessibilityWin();
57
58 void set_view(views::View* view) { view_ = view; }
59
60 // Supported IAccessible methods.
61
62 // Retrieves the child element or child object at a given point on the screen.
63 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child);
64
65 // Performs the object's default action.
66 STDMETHODIMP accDoDefaultAction(VARIANT var_id);
67
68 // Retrieves the specified object's current screen location.
69 STDMETHODIMP accLocation(LONG* x_left,
70 LONG* y_top,
71 LONG* width,
72 LONG* height,
73 VARIANT var_id);
74
75 // Traverses to another UI element and retrieves the object.
76 STDMETHODIMP accNavigate(LONG nav_dir, VARIANT start, VARIANT* end);
77
78 // Retrieves an IDispatch interface pointer for the specified child.
79 STDMETHODIMP get_accChild(VARIANT var_child, IDispatch** disp_child);
80
81 // Retrieves the number of accessible children.
82 STDMETHODIMP get_accChildCount(LONG* child_count);
83
84 // Retrieves a string that describes the object's default action.
85 STDMETHODIMP get_accDefaultAction(VARIANT var_id, BSTR* default_action);
86
87 // Retrieves the tooltip description.
88 STDMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc);
89
90 // Retrieves the object that has the keyboard focus.
91 STDMETHODIMP get_accFocus(VARIANT* focus_child);
92
93 // Retrieves the specified object's shortcut.
94 STDMETHODIMP get_accKeyboardShortcut(VARIANT var_id, BSTR* access_key);
95
96 // Retrieves the name of the specified object.
97 STDMETHODIMP get_accName(VARIANT var_id, BSTR* name);
98
99 // Retrieves the IDispatch interface of the object's parent.
100 STDMETHODIMP get_accParent(IDispatch** disp_parent);
101
102 // Retrieves information describing the role of the specified object.
103 STDMETHODIMP get_accRole(VARIANT var_id, VARIANT* role);
104
105 // Retrieves the current state of the specified object.
106 STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state);
107
108 // Retrieves the current value associated with the specified object.
109 STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value);
110
111 // Non-supported IAccessible methods.
112
113 // Selections not applicable to views.
114 STDMETHODIMP get_accSelection(VARIANT* selected);
115 STDMETHODIMP accSelect(LONG flags_sel, VARIANT var_id);
116
117 // Help functions not supported.
118 STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* help);
119 STDMETHODIMP get_accHelpTopic(BSTR* help_file,
120 VARIANT var_id,
121 LONG* topic_id);
122
123 // Deprecated functions, not implemented here.
124 STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name);
125 STDMETHODIMP put_accValue(VARIANT var_id, BSTR put_val);
126
127 //
128 // IAccessible2
129 //
130
131 STDMETHODIMP role(LONG* role);
132
133 STDMETHODIMP get_states(AccessibleStates* states);
134
135 STDMETHODIMP get_uniqueID(LONG* unique_id);
136
137 STDMETHODIMP get_windowHandle(HWND* window_handle);
138
139 //
140 // IAccessible2 methods not implemented.
141 //
142
143 STDMETHODIMP get_attributes(BSTR* attributes) {
144 return E_NOTIMPL;
145 }
146 STDMETHODIMP get_indexInParent(LONG* index_in_parent) {
147 return E_NOTIMPL;
148 }
149 STDMETHODIMP get_extendedRole(BSTR* extended_role) {
150 return E_NOTIMPL;
151 }
152 STDMETHODIMP get_nRelations(LONG* n_relations) {
153 return E_NOTIMPL;
154 }
155 STDMETHODIMP get_relation(LONG relation_index,
156 IAccessibleRelation** relation) {
157 return E_NOTIMPL;
158 }
159 STDMETHODIMP get_relations(LONG max_relations,
160 IAccessibleRelation** relations,
161 LONG* n_relations) {
162 return E_NOTIMPL;
163 }
164 STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) {
165 return E_NOTIMPL;
166 }
167 STDMETHODIMP scrollToPoint(
168 enum IA2CoordinateType coordinate_type,
169 LONG x,
170 LONG y) {
171 return E_NOTIMPL;
172 }
173 STDMETHODIMP get_groupPosition(LONG* group_level,
174 LONG* similar_items_in_group,
175 LONG* position_in_group) {
176 return E_NOTIMPL;
177 }
178 STDMETHODIMP get_localizedExtendedRole(
179 BSTR* localized_extended_role) {
180 return E_NOTIMPL;
181 }
182 STDMETHODIMP get_nExtendedStates(LONG* n_extended_states) {
183 return E_NOTIMPL;
184 }
185 STDMETHODIMP get_extendedStates(LONG max_extended_states,
186 BSTR** extended_states,
187 LONG* n_extended_states) {
188 return E_NOTIMPL;
189 }
190 STDMETHODIMP get_localizedExtendedStates(
191 LONG max_localized_extended_states,
192 BSTR** localized_extended_states,
193 LONG* n_localized_extended_states) {
194 return E_NOTIMPL;
195 }
196 STDMETHODIMP get_locale(IA2Locale* locale) {
197 return E_NOTIMPL;
198 }
199
200 //
201 // IAccessibleText methods.
202 //
203
204 STDMETHODIMP get_nCharacters(LONG* n_characters);
205
206 STDMETHODIMP get_caretOffset(LONG* offset);
207
208 STDMETHODIMP get_nSelections(LONG* n_selections);
209
210 STDMETHODIMP get_selection(LONG selection_index,
211 LONG* start_offset,
212 LONG* end_offset);
213
214 STDMETHODIMP get_text(LONG start_offset, LONG end_offset, BSTR* text);
215
216 STDMETHODIMP get_textAtOffset(LONG offset,
217 enum IA2TextBoundaryType boundary_type,
218 LONG* start_offset, LONG* end_offset,
219 BSTR* text);
220
221 STDMETHODIMP get_textBeforeOffset(LONG offset,
222 enum IA2TextBoundaryType boundary_type,
223 LONG* start_offset, LONG* end_offset,
224 BSTR* text);
225
226 STDMETHODIMP get_textAfterOffset(LONG offset,
227 enum IA2TextBoundaryType boundary_type,
228 LONG* start_offset, LONG* end_offset,
229 BSTR* text);
230
231 STDMETHODIMP get_offsetAtPoint(LONG x, LONG y,
232 enum IA2CoordinateType coord_type,
233 LONG* offset);
234
235 //
236 // IAccessibleText methods not implemented.
237 //
238
239 STDMETHODIMP get_newText(IA2TextSegment* new_text) {
240 return E_NOTIMPL;
241 }
242 STDMETHODIMP get_oldText(IA2TextSegment* old_text) {
243 return E_NOTIMPL;
244 }
245 STDMETHODIMP addSelection(LONG start_offset, LONG end_offset) {
246 return E_NOTIMPL;
247 }
248 STDMETHODIMP get_attributes(LONG offset,
249 LONG* start_offset,
250 LONG* end_offset,
251 BSTR* text_attributes) {
252 return E_NOTIMPL;
253 }
254 STDMETHODIMP get_characterExtents(LONG offset,
255 enum IA2CoordinateType coord_type,
256 LONG* x, LONG* y,
257 LONG* width, LONG* height) {
258 return E_NOTIMPL;
259 }
260 STDMETHODIMP removeSelection(LONG selection_index) {
261 return E_NOTIMPL;
262 }
263 STDMETHODIMP setCaretOffset(LONG offset) {
264 return E_NOTIMPL;
265 }
266 STDMETHODIMP setSelection(LONG selection_index,
267 LONG start_offset,
268 LONG end_offset) {
269 return E_NOTIMPL;
270 }
271 STDMETHODIMP scrollSubstringTo(LONG start_index,
272 LONG end_index,
273 enum IA2ScrollType scroll_type) {
274 return E_NOTIMPL;
275 }
276 STDMETHODIMP scrollSubstringToPoint(LONG start_index,
277 LONG end_index,
278 enum IA2CoordinateType coordinate_type,
279 LONG x, LONG y) {
280 return E_NOTIMPL;
281 }
282
283 //
284 // IServiceProvider methods.
285 //
286
287 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object);
288
289 // Returns a conversion from the event (as defined in accessibility_types.h)
290 // to an MSAA event.
291 static int32 MSAAEvent(ui::AccessibilityTypes::Event event);
292
293 // Returns a conversion from the Role (as defined in accessibility_types.h)
294 // to an MSAA role.
295 static int32 MSAARole(ui::AccessibilityTypes::Role role);
296
297 // Returns a conversion from the State (as defined in accessibility_types.h)
298 // to MSAA states set.
299 static int32 MSAAState(ui::AccessibilityTypes::State state);
300
301 private:
302 NativeViewAccessibilityWin();
303
304 // Determines navigation direction for accNavigate, based on left, up and
305 // previous being mapped all to previous and right, down, next being mapped
306 // to next. Returns true if navigation direction is next, false otherwise.
307 bool IsNavDirNext(int nav_dir) const;
308
309 // Determines if the navigation target is within the allowed bounds. Returns
310 // true if it is, false otherwise.
311 bool IsValidNav(int nav_dir,
312 int start_id,
313 int lower_bound,
314 int upper_bound) const;
315
316 // Determines if the child id variant is valid.
317 bool IsValidId(const VARIANT& child) const;
318
319 // Helper function which sets applicable states of view.
320 void SetState(VARIANT* msaa_state, views::View* view);
321
322 // Return the text to use for IAccessibleText.
323 string16 TextForIAccessibleText();
324
325 // If offset is a member of IA2TextSpecialOffsets this function updates the
326 // value of offset and returns, otherwise offset remains unchanged.
327 void HandleSpecialTextOffset(const string16& text, LONG* offset);
328
329 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
330 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
331
332 // Search forwards (direction == 1) or backwards (direction == -1)
333 // from the given offset until the given boundary is found, and
334 // return the offset of that boundary.
335 LONG FindBoundary(const string16& text,
336 IA2TextBoundaryType ia2_boundary,
337 LONG start_offset,
338 ui::TextBoundaryDirection direction);
339
340 // Give CComObject access to the class constructor.
341 template <class Base> friend class CComObject;
342
343 // Member View needed for view-specific calls.
344 views::View* view_;
345
346 // A unique id for each object, needed for IAccessible2.
347 long unique_id_;
348
349 // Next unique id to assign.
350 static long next_unique_id_;
351
352 DISALLOW_COPY_AND_ASSIGN(NativeViewAccessibilityWin);
353 };
354
355 #endif // VIEWS_ACCESSIBILITY_NATIVE_VIEW_ACCESSIBILITY_WIN_H_
OLDNEW
« no previous file with comments | « views/accessibility/OWNERS ('k') | views/accessibility/native_view_accessibility_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698