Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / content / browser / accessibility / browser_accessibility_win.h
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_
7
8 #include <atlbase.h>
9 #include <atlcom.h>
10 #include <oleacc.h>
11 #include <UIAutomationCore.h>
12
13 #include <vector>
14
15 #include "base/compiler_specific.h"
16 #include "content/browser/accessibility/browser_accessibility.h"
17 #include "content/common/content_export.h"
18 #include "third_party/iaccessible2/ia2_api_all.h"
19 #include "third_party/isimpledom/ISimpleDOMDocument.h"
20 #include "third_party/isimpledom/ISimpleDOMNode.h"
21 #include "third_party/isimpledom/ISimpleDOMText.h"
22
23 namespace ui {
24 enum TextBoundaryDirection;
25 enum TextBoundaryType;
26 }
27
28 namespace content {
29 class BrowserAccessibilityRelation;
30
31 ////////////////////////////////////////////////////////////////////////////////
32 //
33 // BrowserAccessibilityWin
34 //
35 // Class implementing the windows accessible interface for the Browser-Renderer
36 // communication of accessibility information, providing accessibility
37 // to be used by screen readers and other assistive technology (AT).
38 //
39 ////////////////////////////////////////////////////////////////////////////////
40 class __declspec(uuid("562072fe-3390-43b1-9e2c-dd4118f5ac79"))
41 BrowserAccessibilityWin
42     : public BrowserAccessibility,
43       public CComObjectRootEx<CComMultiThreadModel>,
44       public IDispatchImpl<IAccessible2, &IID_IAccessible2,
45                            &LIBID_IAccessible2Lib>,
46       public IAccessibleApplication,
47       public IAccessibleHyperlink,
48       public IAccessibleHypertext,
49       public IAccessibleImage,
50       public IAccessibleTable,
51       public IAccessibleTable2,
52       public IAccessibleTableCell,
53       public IAccessibleValue,
54       public IServiceProvider,
55       public ISimpleDOMDocument,
56       public ISimpleDOMNode,
57       public ISimpleDOMText,
58       public IAccessibleEx,
59       public IRawElementProviderSimple {
60  public:
61   BEGIN_COM_MAP(BrowserAccessibilityWin)
62     COM_INTERFACE_ENTRY2(IDispatch, IAccessible2)
63     COM_INTERFACE_ENTRY(IAccessible)
64     COM_INTERFACE_ENTRY(IAccessible2)
65     COM_INTERFACE_ENTRY(IAccessibleApplication)
66     COM_INTERFACE_ENTRY(IAccessibleEx)
67     COM_INTERFACE_ENTRY(IAccessibleHyperlink)
68     COM_INTERFACE_ENTRY(IAccessibleHypertext)
69     COM_INTERFACE_ENTRY(IAccessibleImage)
70     COM_INTERFACE_ENTRY(IAccessibleTable)
71     COM_INTERFACE_ENTRY(IAccessibleTable2)
72     COM_INTERFACE_ENTRY(IAccessibleTableCell)
73     COM_INTERFACE_ENTRY(IAccessibleText)
74     COM_INTERFACE_ENTRY(IAccessibleValue)
75     COM_INTERFACE_ENTRY(IRawElementProviderSimple)
76     COM_INTERFACE_ENTRY(IServiceProvider)
77     COM_INTERFACE_ENTRY(ISimpleDOMDocument)
78     COM_INTERFACE_ENTRY(ISimpleDOMNode)
79     COM_INTERFACE_ENTRY(ISimpleDOMText)
80   END_COM_MAP()
81
82   // Represents a non-static text node in IAccessibleHypertext. This character
83   // is embedded in the response to IAccessibleText::get_text, indicating the
84   // position where a non-static text child object appears.
85   CONTENT_EXPORT static const base::char16 kEmbeddedCharacter[];
86
87   // Mappings from roles and states to human readable strings. Initialize
88   // with |InitializeStringMaps|.
89   static std::map<int32, base::string16> role_string_map;
90   static std::map<int32, base::string16> state_string_map;
91
92   CONTENT_EXPORT BrowserAccessibilityWin();
93
94   CONTENT_EXPORT virtual ~BrowserAccessibilityWin();
95
96   // The Windows-specific unique ID, used as the child ID for MSAA methods
97   // like NotifyWinEvent, and as the unique ID for IAccessible2 and ISimpleDOM.
98   LONG unique_id_win() const { return unique_id_win_; }
99
100   //
101   // BrowserAccessibility methods.
102   //
103   CONTENT_EXPORT virtual void OnDataChanged() override;
104   CONTENT_EXPORT virtual void OnUpdateFinished() override;
105   CONTENT_EXPORT virtual void NativeAddReference() override;
106   CONTENT_EXPORT virtual void NativeReleaseReference() override;
107   CONTENT_EXPORT virtual bool IsNative() const override;
108   CONTENT_EXPORT virtual void OnLocationChanged() override;
109
110   //
111   // IAccessible methods.
112   //
113
114   // Performs the default action on a given object.
115   CONTENT_EXPORT STDMETHODIMP accDoDefaultAction(VARIANT var_id) override;
116
117   // Retrieves the child element or child object at a given point on the screen.
118   CONTENT_EXPORT STDMETHODIMP
119   accHitTest(LONG x_left, LONG y_top, VARIANT* child) override;
120
121   // Retrieves the specified object's current screen location.
122   CONTENT_EXPORT STDMETHODIMP accLocation(LONG* x_left,
123                                           LONG* y_top,
124                                           LONG* width,
125                                           LONG* height,
126                                           VARIANT var_id) override;
127
128   // Traverses to another UI element and retrieves the object.
129   CONTENT_EXPORT STDMETHODIMP
130   accNavigate(LONG nav_dir, VARIANT start, VARIANT* end) override;
131
132   // Retrieves an IDispatch interface pointer for the specified child.
133   CONTENT_EXPORT STDMETHODIMP
134   get_accChild(VARIANT var_child, IDispatch** disp_child) override;
135
136   // Retrieves the number of accessible children.
137   CONTENT_EXPORT STDMETHODIMP get_accChildCount(LONG* child_count) override;
138
139   // Retrieves a string that describes the object's default action.
140   CONTENT_EXPORT STDMETHODIMP
141   get_accDefaultAction(VARIANT var_id, BSTR* default_action) override;
142
143   // Retrieves the object's description.
144   CONTENT_EXPORT STDMETHODIMP
145   get_accDescription(VARIANT var_id, BSTR* desc) override;
146
147   // Retrieves the object that has the keyboard focus.
148   CONTENT_EXPORT STDMETHODIMP get_accFocus(VARIANT* focus_child) override;
149
150   // Retrieves the help information associated with the object.
151   CONTENT_EXPORT STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* heflp) override;
152
153   // Retrieves the specified object's shortcut.
154   CONTENT_EXPORT STDMETHODIMP
155   get_accKeyboardShortcut(VARIANT var_id, BSTR* access_key) override;
156
157   // Retrieves the name of the specified object.
158   CONTENT_EXPORT STDMETHODIMP get_accName(VARIANT var_id, BSTR* name) override;
159
160   // Retrieves the IDispatch interface of the object's parent.
161   CONTENT_EXPORT STDMETHODIMP get_accParent(IDispatch** disp_parent) override;
162
163   // Retrieves information describing the role of the specified object.
164   CONTENT_EXPORT STDMETHODIMP
165   get_accRole(VARIANT var_id, VARIANT* role) override;
166
167   // Retrieves the current state of the specified object.
168   CONTENT_EXPORT STDMETHODIMP
169   get_accState(VARIANT var_id, VARIANT* state) override;
170
171   // Returns the value associated with the object.
172   CONTENT_EXPORT STDMETHODIMP
173   get_accValue(VARIANT var_id, BSTR* value) override;
174
175   // Make an object take focus or extend the selection.
176   CONTENT_EXPORT STDMETHODIMP
177   accSelect(LONG flags_sel, VARIANT var_id) override;
178
179   CONTENT_EXPORT STDMETHODIMP
180   get_accHelpTopic(BSTR* help_file, VARIANT var_id, LONG* topic_id) override;
181
182   CONTENT_EXPORT STDMETHODIMP get_accSelection(VARIANT* selected) override;
183
184   // Deprecated methods, not implemented.
185   CONTENT_EXPORT STDMETHODIMP
186   put_accName(VARIANT var_id, BSTR put_name) override {
187     return E_NOTIMPL;
188   }
189   CONTENT_EXPORT STDMETHODIMP
190   put_accValue(VARIANT var_id, BSTR put_val) override {
191     return E_NOTIMPL;
192   }
193
194   //
195   // IAccessible2 methods.
196   //
197
198   // Returns role from a longer list of possible roles.
199   CONTENT_EXPORT STDMETHODIMP role(LONG* role) override;
200
201   // Returns the state bitmask from a larger set of possible states.
202   CONTENT_EXPORT STDMETHODIMP get_states(AccessibleStates* states) override;
203
204   // Returns the attributes specific to this IAccessible2 object,
205   // such as a cell's formula.
206   CONTENT_EXPORT STDMETHODIMP get_attributes(BSTR* attributes) override;
207
208   // Get the unique ID of this object so that the client knows if it's
209   // been encountered previously.
210   CONTENT_EXPORT STDMETHODIMP get_uniqueID(LONG* unique_id) override;
211
212   // Get the window handle of the enclosing window.
213   CONTENT_EXPORT STDMETHODIMP get_windowHandle(HWND* window_handle) override;
214
215   // Get this object's index in its parent object.
216   CONTENT_EXPORT STDMETHODIMP get_indexInParent(LONG* index_in_parent) override;
217
218   CONTENT_EXPORT STDMETHODIMP get_nRelations(LONG* n_relations) override;
219
220   CONTENT_EXPORT STDMETHODIMP
221   get_relation(LONG relation_index, IAccessibleRelation** relation) override;
222
223   CONTENT_EXPORT STDMETHODIMP get_relations(LONG max_relations,
224                                             IAccessibleRelation** relations,
225                                             LONG* n_relations) override;
226
227   CONTENT_EXPORT STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override;
228
229   CONTENT_EXPORT STDMETHODIMP
230   scrollToPoint(enum IA2CoordinateType coordinate_type,
231                 LONG x,
232                 LONG y) override;
233
234   CONTENT_EXPORT STDMETHODIMP
235   get_groupPosition(LONG* group_level,
236                     LONG* similar_items_in_group,
237                     LONG* position_in_group) override;
238
239   //
240   // IAccessibleEx methods not implemented.
241   //
242   CONTENT_EXPORT STDMETHODIMP get_extendedRole(BSTR* extended_role) override {
243     return E_NOTIMPL;
244   }
245   CONTENT_EXPORT STDMETHODIMP
246   get_localizedExtendedRole(BSTR* localized_extended_role) override {
247     return E_NOTIMPL;
248   }
249   CONTENT_EXPORT STDMETHODIMP
250   get_nExtendedStates(LONG* n_extended_states) override {
251     return E_NOTIMPL;
252   }
253   CONTENT_EXPORT STDMETHODIMP
254   get_extendedStates(LONG max_extended_states,
255                      BSTR** extended_states,
256                      LONG* n_extended_states) override {
257     return E_NOTIMPL;
258   }
259   CONTENT_EXPORT STDMETHODIMP
260   get_localizedExtendedStates(LONG max_localized_extended_states,
261                               BSTR** localized_extended_states,
262                               LONG* n_localized_extended_states) override {
263     return E_NOTIMPL;
264   }
265   CONTENT_EXPORT STDMETHODIMP get_locale(IA2Locale* locale) override {
266     return E_NOTIMPL;
267   }
268
269   //
270   // IAccessibleApplication methods.
271   //
272   CONTENT_EXPORT STDMETHODIMP get_appName(BSTR* app_name) override;
273
274   CONTENT_EXPORT STDMETHODIMP get_appVersion(BSTR* app_version) override;
275
276   CONTENT_EXPORT STDMETHODIMP get_toolkitName(BSTR* toolkit_name) override;
277
278   CONTENT_EXPORT STDMETHODIMP
279   get_toolkitVersion(BSTR* toolkit_version) override;
280
281   //
282   // IAccessibleImage methods.
283   //
284   CONTENT_EXPORT STDMETHODIMP get_description(BSTR* description) override;
285
286   CONTENT_EXPORT STDMETHODIMP
287   get_imagePosition(enum IA2CoordinateType coordinate_type,
288                     LONG* x,
289                     LONG* y) override;
290
291   CONTENT_EXPORT STDMETHODIMP get_imageSize(LONG* height, LONG* width) override;
292
293   //
294   // IAccessibleTable methods.
295   //
296
297   // get_description - also used by IAccessibleImage
298
299   CONTENT_EXPORT STDMETHODIMP
300   get_accessibleAt(long row, long column, IUnknown** accessible) override;
301
302   CONTENT_EXPORT STDMETHODIMP get_caption(IUnknown** accessible) override;
303
304   CONTENT_EXPORT STDMETHODIMP
305   get_childIndex(long row_index, long column_index, long* cell_index) override;
306
307   CONTENT_EXPORT STDMETHODIMP
308   get_columnDescription(long column, BSTR* description) override;
309
310   CONTENT_EXPORT STDMETHODIMP
311   get_columnExtentAt(long row, long column, long* n_columns_spanned) override;
312
313   CONTENT_EXPORT STDMETHODIMP
314   get_columnHeader(IAccessibleTable** accessible_table,
315                    long* starting_row_index) override;
316
317   CONTENT_EXPORT STDMETHODIMP
318   get_columnIndex(long cell_index, long* column_index) override;
319
320   CONTENT_EXPORT STDMETHODIMP get_nColumns(long* column_count) override;
321
322   CONTENT_EXPORT STDMETHODIMP get_nRows(long* row_count) override;
323
324   CONTENT_EXPORT STDMETHODIMP get_nSelectedChildren(long* cell_count) override;
325
326   CONTENT_EXPORT STDMETHODIMP get_nSelectedColumns(long* column_count) override;
327
328   CONTENT_EXPORT STDMETHODIMP get_nSelectedRows(long* row_count) override;
329
330   CONTENT_EXPORT STDMETHODIMP
331   get_rowDescription(long row, BSTR* description) override;
332
333   CONTENT_EXPORT STDMETHODIMP
334   get_rowExtentAt(long row, long column, long* n_rows_spanned) override;
335
336   CONTENT_EXPORT STDMETHODIMP
337   get_rowHeader(IAccessibleTable** accessible_table,
338                 long* starting_column_index) override;
339
340   CONTENT_EXPORT STDMETHODIMP
341   get_rowIndex(long cell_index, long* row_index) override;
342
343   CONTENT_EXPORT STDMETHODIMP get_selectedChildren(long max_children,
344                                                    long** children,
345                                                    long* n_children) override;
346
347   CONTENT_EXPORT STDMETHODIMP get_selectedColumns(long max_columns,
348                                                   long** columns,
349                                                   long* n_columns) override;
350
351   CONTENT_EXPORT STDMETHODIMP
352   get_selectedRows(long max_rows, long** rows, long* n_rows) override;
353
354   CONTENT_EXPORT STDMETHODIMP get_summary(IUnknown** accessible) override;
355
356   CONTENT_EXPORT STDMETHODIMP
357   get_isColumnSelected(long column, boolean* is_selected) override;
358
359   CONTENT_EXPORT STDMETHODIMP
360   get_isRowSelected(long row, boolean* is_selected) override;
361
362   CONTENT_EXPORT STDMETHODIMP
363   get_isSelected(long row, long column, boolean* is_selected) override;
364
365   CONTENT_EXPORT STDMETHODIMP
366   get_rowColumnExtentsAtIndex(long index,
367                               long* row,
368                               long* column,
369                               long* row_extents,
370                               long* column_extents,
371                               boolean* is_selected) override;
372
373   CONTENT_EXPORT STDMETHODIMP selectRow(long row) override { return E_NOTIMPL; }
374
375   CONTENT_EXPORT STDMETHODIMP selectColumn(long column) override {
376     return E_NOTIMPL;
377   }
378
379   CONTENT_EXPORT STDMETHODIMP unselectRow(long row) override {
380     return E_NOTIMPL;
381   }
382
383   CONTENT_EXPORT STDMETHODIMP unselectColumn(long column) override {
384     return E_NOTIMPL;
385   }
386
387   CONTENT_EXPORT STDMETHODIMP
388   get_modelChange(IA2TableModelChange* model_change) override {
389     return E_NOTIMPL;
390   }
391
392   //
393   // IAccessibleTable2 methods.
394   //
395   // (Most of these are duplicates of IAccessibleTable methods, only the
396   // unique ones are included here.)
397   //
398
399   CONTENT_EXPORT STDMETHODIMP
400   get_cellAt(long row, long column, IUnknown** cell) override;
401
402   CONTENT_EXPORT STDMETHODIMP get_nSelectedCells(long* cell_count) override;
403
404   CONTENT_EXPORT STDMETHODIMP
405   get_selectedCells(IUnknown*** cells, long* n_selected_cells) override;
406
407   CONTENT_EXPORT STDMETHODIMP
408   get_selectedColumns(long** columns, long* n_columns) override;
409
410   CONTENT_EXPORT STDMETHODIMP
411   get_selectedRows(long** rows, long* n_rows) override;
412
413   //
414   // IAccessibleTableCell methods.
415   //
416
417   CONTENT_EXPORT STDMETHODIMP
418   get_columnExtent(long* n_columns_spanned) override;
419
420   CONTENT_EXPORT STDMETHODIMP
421   get_columnHeaderCells(IUnknown*** cell_accessibles,
422                         long* n_column_header_cells) override;
423
424   CONTENT_EXPORT STDMETHODIMP get_columnIndex(long* column_index) override;
425
426   CONTENT_EXPORT STDMETHODIMP get_rowExtent(long* n_rows_spanned) override;
427
428   CONTENT_EXPORT STDMETHODIMP
429   get_rowHeaderCells(IUnknown*** cell_accessibles,
430                      long* n_row_header_cells) override;
431
432   CONTENT_EXPORT STDMETHODIMP get_rowIndex(long* row_index) override;
433
434   CONTENT_EXPORT STDMETHODIMP get_isSelected(boolean* is_selected) override;
435
436   CONTENT_EXPORT STDMETHODIMP
437   get_rowColumnExtents(long* row,
438                        long* column,
439                        long* row_extents,
440                        long* column_extents,
441                        boolean* is_selected) override;
442
443   CONTENT_EXPORT STDMETHODIMP get_table(IUnknown** table) override;
444
445   //
446   // IAccessibleText methods.
447   //
448
449   CONTENT_EXPORT STDMETHODIMP get_nCharacters(LONG* n_characters) override;
450
451   CONTENT_EXPORT STDMETHODIMP get_caretOffset(LONG* offset) override;
452
453   CONTENT_EXPORT STDMETHODIMP
454   get_characterExtents(LONG offset,
455                        enum IA2CoordinateType coord_type,
456                        LONG* out_x,
457                        LONG* out_y,
458                        LONG* out_width,
459                        LONG* out_height) override;
460
461   CONTENT_EXPORT STDMETHODIMP get_nSelections(LONG* n_selections) override;
462
463   CONTENT_EXPORT STDMETHODIMP get_selection(LONG selection_index,
464                                             LONG* start_offset,
465                                             LONG* end_offset) override;
466
467   CONTENT_EXPORT STDMETHODIMP
468   get_text(LONG start_offset, LONG end_offset, BSTR* text) override;
469
470   CONTENT_EXPORT STDMETHODIMP
471   get_textAtOffset(LONG offset,
472                    enum IA2TextBoundaryType boundary_type,
473                    LONG* start_offset,
474                    LONG* end_offset,
475                    BSTR* text) override;
476
477   CONTENT_EXPORT STDMETHODIMP
478   get_textBeforeOffset(LONG offset,
479                        enum IA2TextBoundaryType boundary_type,
480                        LONG* start_offset,
481                        LONG* end_offset,
482                        BSTR* text) override;
483
484   CONTENT_EXPORT STDMETHODIMP
485   get_textAfterOffset(LONG offset,
486                       enum IA2TextBoundaryType boundary_type,
487                       LONG* start_offset,
488                       LONG* end_offset,
489                       BSTR* text) override;
490
491   CONTENT_EXPORT STDMETHODIMP get_newText(IA2TextSegment* new_text) override;
492
493   CONTENT_EXPORT STDMETHODIMP get_oldText(IA2TextSegment* old_text) override;
494
495   CONTENT_EXPORT STDMETHODIMP
496   get_offsetAtPoint(LONG x,
497                     LONG y,
498                     enum IA2CoordinateType coord_type,
499                     LONG* offset) override;
500
501   CONTENT_EXPORT STDMETHODIMP
502   scrollSubstringTo(LONG start_index,
503                     LONG end_index,
504                     enum IA2ScrollType scroll_type) override;
505
506   CONTENT_EXPORT STDMETHODIMP
507   scrollSubstringToPoint(LONG start_index,
508                          LONG end_index,
509                          enum IA2CoordinateType coordinate_type,
510                          LONG x,
511                          LONG y) override;
512
513   CONTENT_EXPORT STDMETHODIMP
514   addSelection(LONG start_offset, LONG end_offset) override;
515
516   CONTENT_EXPORT STDMETHODIMP removeSelection(LONG selection_index) override;
517
518   CONTENT_EXPORT STDMETHODIMP setCaretOffset(LONG offset) override;
519
520   CONTENT_EXPORT STDMETHODIMP setSelection(LONG selection_index,
521                                            LONG start_offset,
522                                            LONG end_offset) override;
523
524   // IAccessibleText methods not implemented.
525   CONTENT_EXPORT STDMETHODIMP get_attributes(LONG offset,
526                                              LONG* start_offset,
527                                              LONG* end_offset,
528                                              BSTR* text_attributes) override {
529     return E_NOTIMPL;
530   }
531
532   //
533   // IAccessibleHypertext methods.
534   //
535
536   CONTENT_EXPORT STDMETHODIMP get_nHyperlinks(long* hyperlink_count) override;
537
538   CONTENT_EXPORT STDMETHODIMP
539   get_hyperlink(long index, IAccessibleHyperlink** hyperlink) override;
540
541   CONTENT_EXPORT STDMETHODIMP
542   get_hyperlinkIndex(long char_index, long* hyperlink_index) override;
543
544   // IAccessibleHyperlink not implemented.
545   CONTENT_EXPORT STDMETHODIMP get_anchor(long index, VARIANT* anchor) override {
546     return E_NOTIMPL;
547   }
548   CONTENT_EXPORT STDMETHODIMP
549   get_anchorTarget(long index, VARIANT* anchor_target) override {
550     return E_NOTIMPL;
551   }
552   CONTENT_EXPORT STDMETHODIMP get_startIndex(long* index) override {
553     return E_NOTIMPL;
554   }
555   CONTENT_EXPORT STDMETHODIMP get_endIndex(long* index) override {
556     return E_NOTIMPL;
557   }
558   CONTENT_EXPORT STDMETHODIMP get_valid(boolean* valid) override {
559     return E_NOTIMPL;
560   }
561
562   // IAccessibleAction not implemented.
563   CONTENT_EXPORT STDMETHODIMP nActions(long* n_actions) override {
564     return E_NOTIMPL;
565   }
566   CONTENT_EXPORT STDMETHODIMP doAction(long action_index) override {
567     return E_NOTIMPL;
568   }
569   CONTENT_EXPORT STDMETHODIMP
570   get_description(long action_index, BSTR* description) override {
571     return E_NOTIMPL;
572   }
573   CONTENT_EXPORT STDMETHODIMP get_keyBinding(long action_index,
574                                              long n_max_bindings,
575                                              BSTR** key_bindings,
576                                              long* n_bindings) override {
577     return E_NOTIMPL;
578   }
579   CONTENT_EXPORT STDMETHODIMP get_name(long action_index, BSTR* name) override {
580     return E_NOTIMPL;
581   }
582   CONTENT_EXPORT STDMETHODIMP
583   get_localizedName(long action_index, BSTR* localized_name) override {
584     return E_NOTIMPL;
585   }
586
587   //
588   // IAccessibleValue methods.
589   //
590
591   CONTENT_EXPORT STDMETHODIMP get_currentValue(VARIANT* value) override;
592
593   CONTENT_EXPORT STDMETHODIMP get_minimumValue(VARIANT* value) override;
594
595   CONTENT_EXPORT STDMETHODIMP get_maximumValue(VARIANT* value) override;
596
597   CONTENT_EXPORT STDMETHODIMP setCurrentValue(VARIANT new_value) override;
598
599   //
600   // ISimpleDOMDocument methods.
601   //
602
603   CONTENT_EXPORT STDMETHODIMP get_URL(BSTR* url) override;
604
605   CONTENT_EXPORT STDMETHODIMP get_title(BSTR* title) override;
606
607   CONTENT_EXPORT STDMETHODIMP get_mimeType(BSTR* mime_type) override;
608
609   CONTENT_EXPORT STDMETHODIMP get_docType(BSTR* doc_type) override;
610
611   CONTENT_EXPORT STDMETHODIMP
612   get_nameSpaceURIForID(short name_space_id, BSTR* name_space_uri) override {
613     return E_NOTIMPL;
614   }
615   CONTENT_EXPORT STDMETHODIMP
616   put_alternateViewMediaTypes(BSTR* comma_separated_media_types) override {
617     return E_NOTIMPL;
618   }
619
620   //
621   // ISimpleDOMNode methods.
622   //
623
624   CONTENT_EXPORT STDMETHODIMP get_nodeInfo(BSTR* node_name,
625                                            short* name_space_id,
626                                            BSTR* node_value,
627                                            unsigned int* num_children,
628                                            unsigned int* unique_id,
629                                            unsigned short* node_type) override;
630
631   CONTENT_EXPORT STDMETHODIMP
632   get_attributes(unsigned short max_attribs,
633                  BSTR* attrib_names,
634                  short* name_space_id,
635                  BSTR* attrib_values,
636                  unsigned short* num_attribs) override;
637
638   CONTENT_EXPORT STDMETHODIMP
639   get_attributesForNames(unsigned short num_attribs,
640                          BSTR* attrib_names,
641                          short* name_space_id,
642                          BSTR* attrib_values) override;
643
644   CONTENT_EXPORT STDMETHODIMP
645   get_computedStyle(unsigned short max_style_properties,
646                     boolean use_alternate_view,
647                     BSTR* style_properties,
648                     BSTR* style_values,
649                     unsigned short* num_style_properties) override;
650
651   CONTENT_EXPORT STDMETHODIMP
652   get_computedStyleForProperties(unsigned short num_style_properties,
653                                  boolean use_alternate_view,
654                                  BSTR* style_properties,
655                                  BSTR* style_values) override;
656
657   CONTENT_EXPORT STDMETHODIMP scrollTo(boolean placeTopLeft) override;
658
659   CONTENT_EXPORT STDMETHODIMP get_parentNode(ISimpleDOMNode** node) override;
660
661   CONTENT_EXPORT STDMETHODIMP get_firstChild(ISimpleDOMNode** node) override;
662
663   CONTENT_EXPORT STDMETHODIMP get_lastChild(ISimpleDOMNode** node) override;
664
665   CONTENT_EXPORT STDMETHODIMP
666   get_previousSibling(ISimpleDOMNode** node) override;
667
668   CONTENT_EXPORT STDMETHODIMP get_nextSibling(ISimpleDOMNode** node) override;
669
670   CONTENT_EXPORT STDMETHODIMP
671   get_childAt(unsigned int child_index, ISimpleDOMNode** node) override;
672
673   CONTENT_EXPORT STDMETHODIMP get_innerHTML(BSTR* innerHTML) override {
674     return E_NOTIMPL;
675   }
676
677   CONTENT_EXPORT STDMETHODIMP
678   get_localInterface(void** local_interface) override {
679     return E_NOTIMPL;
680   }
681
682   CONTENT_EXPORT STDMETHODIMP get_language(BSTR* language) override {
683     return E_NOTIMPL;
684   }
685
686   //
687   // ISimpleDOMText methods.
688   //
689
690   CONTENT_EXPORT STDMETHODIMP get_domText(BSTR* dom_text) override;
691
692   CONTENT_EXPORT STDMETHODIMP
693   get_clippedSubstringBounds(unsigned int start_index,
694                              unsigned int end_index,
695                              int* out_x,
696                              int* out_y,
697                              int* out_width,
698                              int* out_height) override;
699
700   CONTENT_EXPORT STDMETHODIMP
701   get_unclippedSubstringBounds(unsigned int start_index,
702                                unsigned int end_index,
703                                int* out_x,
704                                int* out_y,
705                                int* out_width,
706                                int* out_height) override;
707
708   CONTENT_EXPORT STDMETHODIMP
709   scrollToSubstring(unsigned int start_index, unsigned int end_index) override;
710
711   CONTENT_EXPORT STDMETHODIMP get_fontFamily(BSTR* font_family) override {
712     return E_NOTIMPL;
713   }
714
715   //
716   // IServiceProvider methods.
717   //
718
719   CONTENT_EXPORT STDMETHODIMP
720   QueryService(REFGUID guidService, REFIID riid, void** object) override;
721
722   // IAccessibleEx methods not implemented.
723   CONTENT_EXPORT STDMETHODIMP
724   GetObjectForChild(long child_id, IAccessibleEx** ret) override {
725     return E_NOTIMPL;
726   }
727
728   CONTENT_EXPORT STDMETHODIMP
729   GetIAccessiblePair(IAccessible** acc, long* child_id) override {
730     return E_NOTIMPL;
731   }
732
733   CONTENT_EXPORT STDMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) override {
734     return E_NOTIMPL;
735   }
736
737   CONTENT_EXPORT STDMETHODIMP
738   ConvertReturnedElement(IRawElementProviderSimple* element,
739                          IAccessibleEx** acc) override {
740     return E_NOTIMPL;
741   }
742
743   //
744   // IRawElementProviderSimple methods.
745   //
746   // The GetPatternProvider/GetPropertyValue methods need to be implemented for
747   // the on-screen keyboard to show up in Windows 8 metro.
748   CONTENT_EXPORT STDMETHODIMP
749   GetPatternProvider(PATTERNID id, IUnknown** provider) override;
750   CONTENT_EXPORT STDMETHODIMP
751   GetPropertyValue(PROPERTYID id, VARIANT* ret) override;
752
753   //
754   // IRawElementProviderSimple methods not implemented
755   //
756   CONTENT_EXPORT STDMETHODIMP
757   get_ProviderOptions(enum ProviderOptions* ret) override {
758     return E_NOTIMPL;
759   }
760
761   CONTENT_EXPORT STDMETHODIMP
762   get_HostRawElementProvider(IRawElementProviderSimple** provider) override {
763     return E_NOTIMPL;
764   }
765
766   //
767   // CComObjectRootEx methods.
768   //
769
770   // Called by BEGIN_COM_MAP() / END_COM_MAP().
771   static CONTENT_EXPORT HRESULT WINAPI
772   InternalQueryInterface(void* this_ptr,
773                          const _ATL_INTMAP_ENTRY* entries,
774                          REFIID iid,
775                          void** object);
776
777   // Accessors.
778   int32 ia_role() const { return ia_role_; }
779   int32 ia_state() const { return ia_state_; }
780   const base::string16& role_name() const { return role_name_; }
781   int32 ia2_role() const { return ia2_role_; }
782   int32 ia2_state() const { return ia2_state_; }
783   const std::vector<base::string16>& ia2_attributes() const {
784     return ia2_attributes_;
785   }
786
787  private:
788   // Add one to the reference count and return the same object. Always
789   // use this method when returning a BrowserAccessibilityWin object as
790   // an output parameter to a COM interface, never use it otherwise.
791   BrowserAccessibilityWin* NewReference();
792
793   // Many MSAA methods take a var_id parameter indicating that the operation
794   // should be performed on a particular child ID, rather than this object.
795   // This method tries to figure out the target object from |var_id| and
796   // returns a pointer to the target object if it exists, otherwise NULL.
797   // Does not return a new reference.
798   BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id);
799
800   // Initialize the role and state metadata from the role enum and state
801   // bitmasks defined in ui::AXNodeData.
802   void InitRoleAndState();
803
804   // Retrieve the value of an attribute from the string attribute map and
805   // if found and nonempty, allocate a new BSTR (with SysAllocString)
806   // and return S_OK. If not found or empty, return S_FALSE.
807   HRESULT GetStringAttributeAsBstr(
808       ui::AXStringAttribute attribute,
809       BSTR* value_bstr);
810
811   // If the string attribute |attribute| is present, add its value as an
812   // IAccessible2 attribute with the name |ia2_attr|.
813   void StringAttributeToIA2(ui::AXStringAttribute attribute,
814                             const char* ia2_attr);
815
816   // If the bool attribute |attribute| is present, add its value as an
817   // IAccessible2 attribute with the name |ia2_attr|.
818   void BoolAttributeToIA2(ui::AXBoolAttribute attribute,
819                           const char* ia2_attr);
820
821   // If the int attribute |attribute| is present, add its value as an
822   // IAccessible2 attribute with the name |ia2_attr|.
823   void IntAttributeToIA2(ui::AXIntAttribute attribute,
824                          const char* ia2_attr);
825
826   // Get the value text, which might come from the floating-point
827   // value for some roles.
828   base::string16 GetValueText();
829
830   // Get the text of this node for the purposes of IAccessibleText - it may
831   // be the name, it may be the value, etc. depending on the role.
832   base::string16 TextForIAccessibleText();
833
834   // If offset is a member of IA2TextSpecialOffsets this function updates the
835   // value of offset and returns, otherwise offset remains unchanged.
836   void HandleSpecialTextOffset(const base::string16& text, LONG* offset);
837
838   // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
839   ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
840
841   // Search forwards (direction == 1) or backwards (direction == -1)
842   // from the given offset until the given boundary is found, and
843   // return the offset of that boundary.
844   LONG FindBoundary(const base::string16& text,
845                     IA2TextBoundaryType ia2_boundary,
846                     LONG start_offset,
847                     ui::TextBoundaryDirection direction);
848
849   // Return a pointer to the object corresponding to the given id,
850   // does not make a new reference.
851   BrowserAccessibilityWin* GetFromID(int32 id);
852
853   // Windows-specific unique ID (unique within the browser process),
854   // used for get_accChild, NotifyWinEvent, and as the unique ID for
855   // IAccessible2 and ISimpleDOM.
856   LONG unique_id_win_;
857
858   // IAccessible role and state.
859   int32 ia_role_;
860   int32 ia_state_;
861   base::string16 role_name_;
862
863   // IAccessible2 role and state.
864   int32 ia2_role_;
865   int32 ia2_state_;
866
867   // IAccessible2 attributes.
868   std::vector<base::string16> ia2_attributes_;
869
870   // True in Initialize when the object is first created, and false
871   // subsequent times.
872   bool first_time_;
873
874   // The previous text, before the last update to this object.
875   base::string16 previous_text_;
876
877   // The old text to return in IAccessibleText::get_oldText - this is like
878   // previous_text_ except that it's NOT updated when the object
879   // is initialized again but the text doesn't change.
880   base::string16 old_text_;
881
882   // The previous state, used to see if there was a state change.
883   int32 old_ia_state_;
884
885   // Relationships between this node and other nodes.
886   std::vector<BrowserAccessibilityRelation*> relations_;
887
888   // The text of this node including embedded hyperlink characters.
889   base::string16 hypertext_;
890
891   // Maps the |hypertext_| embedded character offset to an index in
892   // |hyperlinks_|.
893   std::map<int32, int32> hyperlink_offset_to_index_;
894
895   // Collection of non-static text child indicies, each of which corresponds to
896   // a hyperlink.
897   std::vector<int32> hyperlinks_;
898
899   // The previous scroll position, so we can tell if this object scrolled.
900   int previous_scroll_x_;
901   int previous_scroll_y_;
902
903   // The next unique id to use.
904   static LONG next_unique_id_win_;
905
906   // Give BrowserAccessibility::Create access to our constructor.
907   friend class BrowserAccessibility;
908   friend class BrowserAccessibilityRelation;
909
910   DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin);
911 };
912
913 }  // namespace content
914
915 #endif  // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_