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