Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / browser / accessibility / browser_accessibility_win.h
blob1cd7b3c2c29391a61d2a82b5b338c4c9fe41ac96
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.
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_
8 #include <atlbase.h>
9 #include <atlcom.h>
10 #include <oleacc.h>
11 #include <UIAutomationCore.h>
13 #include <vector>
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"
23 namespace ui {
24 enum TextBoundaryDirection;
25 enum TextBoundaryType;
28 namespace content {
29 class BrowserAccessibilityRelation;
31 ////////////////////////////////////////////////////////////////////////////////
33 // BrowserAccessibilityWin
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).
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()
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;
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;
92 CONTENT_EXPORT BrowserAccessibilityWin();
94 CONTENT_EXPORT ~BrowserAccessibilityWin() override;
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_; }
100 // Called after an atomic tree update completes. See
101 // BrowserAccessibilityManagerWin::OnAtomicUpdateFinished for more
102 // details on what these do.
103 CONTENT_EXPORT void UpdateStep1ComputeWinAttributes();
104 CONTENT_EXPORT void UpdateStep2ComputeHypertext();
105 CONTENT_EXPORT void UpdateStep3FireEvents(bool is_subtree_creation);
106 CONTENT_EXPORT void UpdateStep4DeleteOldWinAttributes();
109 // BrowserAccessibility methods.
111 CONTENT_EXPORT void OnSubtreeWillBeDeleted() override;
112 CONTENT_EXPORT void NativeAddReference() override;
113 CONTENT_EXPORT void NativeReleaseReference() override;
114 CONTENT_EXPORT bool IsNative() const override;
115 CONTENT_EXPORT void OnLocationChanged() override;
118 // IAccessible methods.
121 // Performs the default action on a given object.
122 CONTENT_EXPORT STDMETHODIMP accDoDefaultAction(VARIANT var_id) override;
124 // Retrieves the child element or child object at a given point on the screen.
125 CONTENT_EXPORT STDMETHODIMP
126 accHitTest(LONG x_left, LONG y_top, VARIANT* child) override;
128 // Retrieves the specified object's current screen location.
129 CONTENT_EXPORT STDMETHODIMP accLocation(LONG* x_left,
130 LONG* y_top,
131 LONG* width,
132 LONG* height,
133 VARIANT var_id) override;
135 // Traverses to another UI element and retrieves the object.
136 CONTENT_EXPORT STDMETHODIMP
137 accNavigate(LONG nav_dir, VARIANT start, VARIANT* end) override;
139 // Retrieves an IDispatch interface pointer for the specified child.
140 CONTENT_EXPORT STDMETHODIMP
141 get_accChild(VARIANT var_child, IDispatch** disp_child) override;
143 // Retrieves the number of accessible children.
144 CONTENT_EXPORT STDMETHODIMP get_accChildCount(LONG* child_count) override;
146 // Retrieves a string that describes the object's default action.
147 CONTENT_EXPORT STDMETHODIMP
148 get_accDefaultAction(VARIANT var_id, BSTR* default_action) override;
150 // Retrieves the object's description.
151 CONTENT_EXPORT STDMETHODIMP
152 get_accDescription(VARIANT var_id, BSTR* desc) override;
154 // Retrieves the object that has the keyboard focus.
155 CONTENT_EXPORT STDMETHODIMP get_accFocus(VARIANT* focus_child) override;
157 // Retrieves the help information associated with the object.
158 CONTENT_EXPORT STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* heflp) override;
160 // Retrieves the specified object's shortcut.
161 CONTENT_EXPORT STDMETHODIMP
162 get_accKeyboardShortcut(VARIANT var_id, BSTR* access_key) override;
164 // Retrieves the name of the specified object.
165 CONTENT_EXPORT STDMETHODIMP get_accName(VARIANT var_id, BSTR* name) override;
167 // Retrieves the IDispatch interface of the object's parent.
168 CONTENT_EXPORT STDMETHODIMP get_accParent(IDispatch** disp_parent) override;
170 // Retrieves information describing the role of the specified object.
171 CONTENT_EXPORT STDMETHODIMP
172 get_accRole(VARIANT var_id, VARIANT* role) override;
174 // Retrieves the current state of the specified object.
175 CONTENT_EXPORT STDMETHODIMP
176 get_accState(VARIANT var_id, VARIANT* state) override;
178 // Returns the value associated with the object.
179 CONTENT_EXPORT STDMETHODIMP
180 get_accValue(VARIANT var_id, BSTR* value) override;
182 // Make an object take focus or extend the selection.
183 CONTENT_EXPORT STDMETHODIMP
184 accSelect(LONG flags_sel, VARIANT var_id) override;
186 CONTENT_EXPORT STDMETHODIMP
187 get_accHelpTopic(BSTR* help_file, VARIANT var_id, LONG* topic_id) override;
189 CONTENT_EXPORT STDMETHODIMP get_accSelection(VARIANT* selected) override;
191 // Deprecated methods, not implemented.
192 CONTENT_EXPORT STDMETHODIMP
193 put_accName(VARIANT var_id, BSTR put_name) override;
194 CONTENT_EXPORT STDMETHODIMP
195 put_accValue(VARIANT var_id, BSTR put_val) override;
198 // IAccessible2 methods.
201 // Returns role from a longer list of possible roles.
202 CONTENT_EXPORT STDMETHODIMP role(LONG* role) override;
204 // Returns the state bitmask from a larger set of possible states.
205 CONTENT_EXPORT STDMETHODIMP get_states(AccessibleStates* states) override;
207 // Returns the attributes specific to this IAccessible2 object,
208 // such as a cell's formula.
209 CONTENT_EXPORT STDMETHODIMP get_attributes(BSTR* attributes) override;
211 // Get the unique ID of this object so that the client knows if it's
212 // been encountered previously.
213 CONTENT_EXPORT STDMETHODIMP get_uniqueID(LONG* unique_id) override;
215 // Get the window handle of the enclosing window.
216 CONTENT_EXPORT STDMETHODIMP get_windowHandle(HWND* window_handle) override;
218 // Get this object's index in its parent object.
219 CONTENT_EXPORT STDMETHODIMP get_indexInParent(LONG* index_in_parent) override;
221 CONTENT_EXPORT STDMETHODIMP get_nRelations(LONG* n_relations) override;
223 CONTENT_EXPORT STDMETHODIMP
224 get_relation(LONG relation_index, IAccessibleRelation** relation) override;
226 CONTENT_EXPORT STDMETHODIMP get_relations(LONG max_relations,
227 IAccessibleRelation** relations,
228 LONG* n_relations) override;
230 CONTENT_EXPORT STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override;
232 CONTENT_EXPORT STDMETHODIMP
233 scrollToPoint(enum IA2CoordinateType coordinate_type,
234 LONG x,
235 LONG y) override;
237 CONTENT_EXPORT STDMETHODIMP
238 get_groupPosition(LONG* group_level,
239 LONG* similar_items_in_group,
240 LONG* position_in_group) override;
243 // IAccessibleEx methods not implemented.
245 CONTENT_EXPORT STDMETHODIMP get_extendedRole(BSTR* extended_role) override;
246 CONTENT_EXPORT STDMETHODIMP
247 get_localizedExtendedRole(BSTR* localized_extended_role) override;
248 CONTENT_EXPORT STDMETHODIMP
249 get_nExtendedStates(LONG* n_extended_states) override;
250 CONTENT_EXPORT STDMETHODIMP
251 get_extendedStates(LONG max_extended_states,
252 BSTR** extended_states,
253 LONG* n_extended_states) override;
254 CONTENT_EXPORT STDMETHODIMP
255 get_localizedExtendedStates(LONG max_localized_extended_states,
256 BSTR** localized_extended_states,
257 LONG* n_localized_extended_states) override;
258 CONTENT_EXPORT STDMETHODIMP get_locale(IA2Locale* locale) override;
261 // IAccessibleApplication methods.
263 CONTENT_EXPORT STDMETHODIMP get_appName(BSTR* app_name) override;
265 CONTENT_EXPORT STDMETHODIMP get_appVersion(BSTR* app_version) override;
267 CONTENT_EXPORT STDMETHODIMP get_toolkitName(BSTR* toolkit_name) override;
269 CONTENT_EXPORT STDMETHODIMP
270 get_toolkitVersion(BSTR* toolkit_version) override;
273 // IAccessibleImage methods.
275 CONTENT_EXPORT STDMETHODIMP get_description(BSTR* description) override;
277 CONTENT_EXPORT STDMETHODIMP
278 get_imagePosition(enum IA2CoordinateType coordinate_type,
279 LONG* x,
280 LONG* y) override;
282 CONTENT_EXPORT STDMETHODIMP get_imageSize(LONG* height, LONG* width) override;
285 // IAccessibleTable methods.
288 // get_description - also used by IAccessibleImage
290 CONTENT_EXPORT STDMETHODIMP
291 get_accessibleAt(long row, long column, IUnknown** accessible) override;
293 CONTENT_EXPORT STDMETHODIMP get_caption(IUnknown** accessible) override;
295 CONTENT_EXPORT STDMETHODIMP
296 get_childIndex(long row_index, long column_index, long* cell_index) override;
298 CONTENT_EXPORT STDMETHODIMP
299 get_columnDescription(long column, BSTR* description) override;
301 CONTENT_EXPORT STDMETHODIMP
302 get_columnExtentAt(long row, long column, long* n_columns_spanned) override;
304 CONTENT_EXPORT STDMETHODIMP
305 get_columnHeader(IAccessibleTable** accessible_table,
306 long* starting_row_index) override;
308 CONTENT_EXPORT STDMETHODIMP
309 get_columnIndex(long cell_index, long* column_index) override;
311 CONTENT_EXPORT STDMETHODIMP get_nColumns(long* column_count) override;
313 CONTENT_EXPORT STDMETHODIMP get_nRows(long* row_count) override;
315 CONTENT_EXPORT STDMETHODIMP get_nSelectedChildren(long* cell_count) override;
317 CONTENT_EXPORT STDMETHODIMP get_nSelectedColumns(long* column_count) override;
319 CONTENT_EXPORT STDMETHODIMP get_nSelectedRows(long* row_count) override;
321 CONTENT_EXPORT STDMETHODIMP
322 get_rowDescription(long row, BSTR* description) override;
324 CONTENT_EXPORT STDMETHODIMP
325 get_rowExtentAt(long row, long column, long* n_rows_spanned) override;
327 CONTENT_EXPORT STDMETHODIMP
328 get_rowHeader(IAccessibleTable** accessible_table,
329 long* starting_column_index) override;
331 CONTENT_EXPORT STDMETHODIMP
332 get_rowIndex(long cell_index, long* row_index) override;
334 CONTENT_EXPORT STDMETHODIMP get_selectedChildren(long max_children,
335 long** children,
336 long* n_children) override;
338 CONTENT_EXPORT STDMETHODIMP get_selectedColumns(long max_columns,
339 long** columns,
340 long* n_columns) override;
342 CONTENT_EXPORT STDMETHODIMP
343 get_selectedRows(long max_rows, long** rows, long* n_rows) override;
345 CONTENT_EXPORT STDMETHODIMP get_summary(IUnknown** accessible) override;
347 CONTENT_EXPORT STDMETHODIMP
348 get_isColumnSelected(long column, boolean* is_selected) override;
350 CONTENT_EXPORT STDMETHODIMP
351 get_isRowSelected(long row, boolean* is_selected) override;
353 CONTENT_EXPORT STDMETHODIMP
354 get_isSelected(long row, long column, boolean* is_selected) override;
356 CONTENT_EXPORT STDMETHODIMP
357 get_rowColumnExtentsAtIndex(long index,
358 long* row,
359 long* column,
360 long* row_extents,
361 long* column_extents,
362 boolean* is_selected) override;
364 CONTENT_EXPORT STDMETHODIMP selectRow(long row) override;
366 CONTENT_EXPORT STDMETHODIMP selectColumn(long column) override;
368 CONTENT_EXPORT STDMETHODIMP unselectRow(long row) override;
370 CONTENT_EXPORT STDMETHODIMP unselectColumn(long column) override;
372 CONTENT_EXPORT STDMETHODIMP
373 get_modelChange(IA2TableModelChange* model_change) override;
376 // IAccessibleTable2 methods.
378 // (Most of these are duplicates of IAccessibleTable methods, only the
379 // unique ones are included here.)
382 CONTENT_EXPORT STDMETHODIMP
383 get_cellAt(long row, long column, IUnknown** cell) override;
385 CONTENT_EXPORT STDMETHODIMP get_nSelectedCells(long* cell_count) override;
387 CONTENT_EXPORT STDMETHODIMP
388 get_selectedCells(IUnknown*** cells, long* n_selected_cells) override;
390 CONTENT_EXPORT STDMETHODIMP
391 get_selectedColumns(long** columns, long* n_columns) override;
393 CONTENT_EXPORT STDMETHODIMP
394 get_selectedRows(long** rows, long* n_rows) override;
397 // IAccessibleTableCell methods.
400 CONTENT_EXPORT STDMETHODIMP
401 get_columnExtent(long* n_columns_spanned) override;
403 CONTENT_EXPORT STDMETHODIMP
404 get_columnHeaderCells(IUnknown*** cell_accessibles,
405 long* n_column_header_cells) override;
407 CONTENT_EXPORT STDMETHODIMP get_columnIndex(long* column_index) override;
409 CONTENT_EXPORT STDMETHODIMP get_rowExtent(long* n_rows_spanned) override;
411 CONTENT_EXPORT STDMETHODIMP
412 get_rowHeaderCells(IUnknown*** cell_accessibles,
413 long* n_row_header_cells) override;
415 CONTENT_EXPORT STDMETHODIMP get_rowIndex(long* row_index) override;
417 CONTENT_EXPORT STDMETHODIMP get_isSelected(boolean* is_selected) override;
419 CONTENT_EXPORT STDMETHODIMP
420 get_rowColumnExtents(long* row,
421 long* column,
422 long* row_extents,
423 long* column_extents,
424 boolean* is_selected) override;
426 CONTENT_EXPORT STDMETHODIMP get_table(IUnknown** table) override;
429 // IAccessibleText methods.
432 CONTENT_EXPORT STDMETHODIMP get_nCharacters(LONG* n_characters) override;
434 CONTENT_EXPORT STDMETHODIMP get_caretOffset(LONG* offset) override;
436 CONTENT_EXPORT STDMETHODIMP
437 get_characterExtents(LONG offset,
438 enum IA2CoordinateType coord_type,
439 LONG* out_x,
440 LONG* out_y,
441 LONG* out_width,
442 LONG* out_height) override;
444 CONTENT_EXPORT STDMETHODIMP get_nSelections(LONG* n_selections) override;
446 CONTENT_EXPORT STDMETHODIMP get_selection(LONG selection_index,
447 LONG* start_offset,
448 LONG* end_offset) override;
450 CONTENT_EXPORT STDMETHODIMP
451 get_text(LONG start_offset, LONG end_offset, BSTR* text) override;
453 CONTENT_EXPORT STDMETHODIMP
454 get_textAtOffset(LONG offset,
455 enum IA2TextBoundaryType boundary_type,
456 LONG* start_offset,
457 LONG* end_offset,
458 BSTR* text) override;
460 CONTENT_EXPORT STDMETHODIMP
461 get_textBeforeOffset(LONG offset,
462 enum IA2TextBoundaryType boundary_type,
463 LONG* start_offset,
464 LONG* end_offset,
465 BSTR* text) override;
467 CONTENT_EXPORT STDMETHODIMP
468 get_textAfterOffset(LONG offset,
469 enum IA2TextBoundaryType boundary_type,
470 LONG* start_offset,
471 LONG* end_offset,
472 BSTR* text) override;
474 CONTENT_EXPORT STDMETHODIMP get_newText(IA2TextSegment* new_text) override;
476 CONTENT_EXPORT STDMETHODIMP get_oldText(IA2TextSegment* old_text) override;
478 CONTENT_EXPORT STDMETHODIMP
479 get_offsetAtPoint(LONG x,
480 LONG y,
481 enum IA2CoordinateType coord_type,
482 LONG* offset) override;
484 CONTENT_EXPORT STDMETHODIMP
485 scrollSubstringTo(LONG start_index,
486 LONG end_index,
487 enum IA2ScrollType scroll_type) override;
489 CONTENT_EXPORT STDMETHODIMP
490 scrollSubstringToPoint(LONG start_index,
491 LONG end_index,
492 enum IA2CoordinateType coordinate_type,
493 LONG x,
494 LONG y) override;
496 CONTENT_EXPORT STDMETHODIMP
497 addSelection(LONG start_offset, LONG end_offset) override;
499 CONTENT_EXPORT STDMETHODIMP removeSelection(LONG selection_index) override;
501 CONTENT_EXPORT STDMETHODIMP setCaretOffset(LONG offset) override;
503 CONTENT_EXPORT STDMETHODIMP setSelection(LONG selection_index,
504 LONG start_offset,
505 LONG end_offset) override;
507 // IAccessibleText methods not implemented.
508 CONTENT_EXPORT STDMETHODIMP get_attributes(LONG offset,
509 LONG* start_offset,
510 LONG* end_offset,
511 BSTR* text_attributes) override;
514 // IAccessibleHypertext methods.
517 CONTENT_EXPORT STDMETHODIMP get_nHyperlinks(long* hyperlink_count) override;
519 CONTENT_EXPORT STDMETHODIMP
520 get_hyperlink(long index, IAccessibleHyperlink** hyperlink) override;
522 CONTENT_EXPORT STDMETHODIMP
523 get_hyperlinkIndex(long char_index, long* hyperlink_index) override;
525 // IAccessibleHyperlink not implemented.
526 CONTENT_EXPORT STDMETHODIMP get_anchor(long index, VARIANT* anchor) override;
527 CONTENT_EXPORT STDMETHODIMP
528 get_anchorTarget(long index, VARIANT* anchor_target) override;
529 CONTENT_EXPORT STDMETHODIMP get_startIndex(long* index) override;
530 CONTENT_EXPORT STDMETHODIMP get_endIndex(long* index) override;
531 CONTENT_EXPORT STDMETHODIMP get_valid(boolean* valid) override;
533 // IAccessibleAction not implemented.
534 CONTENT_EXPORT STDMETHODIMP nActions(long* n_actions) override;
535 CONTENT_EXPORT STDMETHODIMP doAction(long action_index) override;
536 CONTENT_EXPORT STDMETHODIMP
537 get_description(long action_index, BSTR* description) override;
538 CONTENT_EXPORT STDMETHODIMP get_keyBinding(long action_index,
539 long n_max_bindings,
540 BSTR** key_bindings,
541 long* n_bindings) override;
542 CONTENT_EXPORT STDMETHODIMP get_name(long action_index, BSTR* name) override;
543 CONTENT_EXPORT STDMETHODIMP
544 get_localizedName(long action_index, BSTR* localized_name) override;
547 // IAccessibleValue methods.
550 CONTENT_EXPORT STDMETHODIMP get_currentValue(VARIANT* value) override;
552 CONTENT_EXPORT STDMETHODIMP get_minimumValue(VARIANT* value) override;
554 CONTENT_EXPORT STDMETHODIMP get_maximumValue(VARIANT* value) override;
556 CONTENT_EXPORT STDMETHODIMP setCurrentValue(VARIANT new_value) override;
559 // ISimpleDOMDocument methods.
562 CONTENT_EXPORT STDMETHODIMP get_URL(BSTR* url) override;
564 CONTENT_EXPORT STDMETHODIMP get_title(BSTR* title) override;
566 CONTENT_EXPORT STDMETHODIMP get_mimeType(BSTR* mime_type) override;
568 CONTENT_EXPORT STDMETHODIMP get_docType(BSTR* doc_type) override;
570 CONTENT_EXPORT STDMETHODIMP
571 get_nameSpaceURIForID(short name_space_id, BSTR* name_space_uri) override;
572 CONTENT_EXPORT STDMETHODIMP
573 put_alternateViewMediaTypes(BSTR* comma_separated_media_types) override;
576 // ISimpleDOMNode methods.
579 CONTENT_EXPORT STDMETHODIMP get_nodeInfo(BSTR* node_name,
580 short* name_space_id,
581 BSTR* node_value,
582 unsigned int* num_children,
583 unsigned int* unique_id,
584 unsigned short* node_type) override;
586 CONTENT_EXPORT STDMETHODIMP
587 get_attributes(unsigned short max_attribs,
588 BSTR* attrib_names,
589 short* name_space_id,
590 BSTR* attrib_values,
591 unsigned short* num_attribs) override;
593 CONTENT_EXPORT STDMETHODIMP
594 get_attributesForNames(unsigned short num_attribs,
595 BSTR* attrib_names,
596 short* name_space_id,
597 BSTR* attrib_values) override;
599 CONTENT_EXPORT STDMETHODIMP
600 get_computedStyle(unsigned short max_style_properties,
601 boolean use_alternate_view,
602 BSTR* style_properties,
603 BSTR* style_values,
604 unsigned short* num_style_properties) override;
606 CONTENT_EXPORT STDMETHODIMP
607 get_computedStyleForProperties(unsigned short num_style_properties,
608 boolean use_alternate_view,
609 BSTR* style_properties,
610 BSTR* style_values) override;
612 CONTENT_EXPORT STDMETHODIMP scrollTo(boolean placeTopLeft) override;
614 CONTENT_EXPORT STDMETHODIMP get_parentNode(ISimpleDOMNode** node) override;
616 CONTENT_EXPORT STDMETHODIMP get_firstChild(ISimpleDOMNode** node) override;
618 CONTENT_EXPORT STDMETHODIMP get_lastChild(ISimpleDOMNode** node) override;
620 CONTENT_EXPORT STDMETHODIMP
621 get_previousSibling(ISimpleDOMNode** node) override;
623 CONTENT_EXPORT STDMETHODIMP get_nextSibling(ISimpleDOMNode** node) override;
625 CONTENT_EXPORT STDMETHODIMP
626 get_childAt(unsigned int child_index, ISimpleDOMNode** node) override;
628 CONTENT_EXPORT STDMETHODIMP get_innerHTML(BSTR* innerHTML) override;
630 CONTENT_EXPORT STDMETHODIMP
631 get_localInterface(void** local_interface) override;
633 CONTENT_EXPORT STDMETHODIMP get_language(BSTR* language) override;
636 // ISimpleDOMText methods.
639 CONTENT_EXPORT STDMETHODIMP get_domText(BSTR* dom_text) override;
641 CONTENT_EXPORT STDMETHODIMP
642 get_clippedSubstringBounds(unsigned int start_index,
643 unsigned int end_index,
644 int* out_x,
645 int* out_y,
646 int* out_width,
647 int* out_height) override;
649 CONTENT_EXPORT STDMETHODIMP
650 get_unclippedSubstringBounds(unsigned int start_index,
651 unsigned int end_index,
652 int* out_x,
653 int* out_y,
654 int* out_width,
655 int* out_height) override;
657 CONTENT_EXPORT STDMETHODIMP
658 scrollToSubstring(unsigned int start_index, unsigned int end_index) override;
660 CONTENT_EXPORT STDMETHODIMP get_fontFamily(BSTR* font_family) override;
663 // IServiceProvider methods.
666 CONTENT_EXPORT STDMETHODIMP
667 QueryService(REFGUID guidService, REFIID riid, void** object) override;
669 // IAccessibleEx methods not implemented.
670 CONTENT_EXPORT STDMETHODIMP
671 GetObjectForChild(long child_id, IAccessibleEx** ret) override;
673 CONTENT_EXPORT STDMETHODIMP
674 GetIAccessiblePair(IAccessible** acc, long* child_id) override;
676 CONTENT_EXPORT STDMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) override;
678 CONTENT_EXPORT STDMETHODIMP
679 ConvertReturnedElement(IRawElementProviderSimple* element,
680 IAccessibleEx** acc) override;
683 // IRawElementProviderSimple methods.
685 // The GetPatternProvider/GetPropertyValue methods need to be implemented for
686 // the on-screen keyboard to show up in Windows 8 metro.
687 CONTENT_EXPORT STDMETHODIMP
688 GetPatternProvider(PATTERNID id, IUnknown** provider) override;
689 CONTENT_EXPORT STDMETHODIMP
690 GetPropertyValue(PROPERTYID id, VARIANT* ret) override;
693 // IRawElementProviderSimple methods not implemented
695 CONTENT_EXPORT STDMETHODIMP
696 get_ProviderOptions(enum ProviderOptions* ret) override;
697 CONTENT_EXPORT STDMETHODIMP
698 get_HostRawElementProvider(IRawElementProviderSimple** provider) override;
701 // CComObjectRootEx methods.
704 // Called by BEGIN_COM_MAP() / END_COM_MAP().
705 static CONTENT_EXPORT HRESULT WINAPI
706 InternalQueryInterface(void* this_ptr,
707 const _ATL_INTMAP_ENTRY* entries,
708 REFIID iid,
709 void** object);
711 // Accessors.
712 int32 ia_role() const { return win_attributes_->ia_role; }
713 int32 ia_state() const { return win_attributes_->ia_state; }
714 const base::string16& role_name() const { return win_attributes_->role_name; }
715 int32 ia2_role() const { return win_attributes_->ia2_role; }
716 int32 ia2_state() const { return win_attributes_->ia2_state; }
717 const std::vector<base::string16>& ia2_attributes() const {
718 return win_attributes_->ia2_attributes;
720 base::string16 name() const { return win_attributes_->name; }
721 base::string16 description() const { return win_attributes_->description; }
722 base::string16 help() const { return win_attributes_->help; }
723 base::string16 value() const { return win_attributes_->value; }
724 base::string16 hypertext() const { return win_attributes_->hypertext; }
725 std::map<int32, int32>& hyperlink_offset_to_index() const {
726 return win_attributes_->hyperlink_offset_to_index;
728 std::vector<int32>& hyperlinks() const { return win_attributes_->hyperlinks; }
730 private:
731 // Add one to the reference count and return the same object. Always
732 // use this method when returning a BrowserAccessibilityWin object as
733 // an output parameter to a COM interface, never use it otherwise.
734 BrowserAccessibilityWin* NewReference();
736 // Many MSAA methods take a var_id parameter indicating that the operation
737 // should be performed on a particular child ID, rather than this object.
738 // This method tries to figure out the target object from |var_id| and
739 // returns a pointer to the target object if it exists, otherwise NULL.
740 // Does not return a new reference.
741 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id);
743 // Initialize the role and state metadata from the role enum and state
744 // bitmasks defined in ui::AXNodeData.
745 void InitRoleAndState();
747 // Retrieve the value of an attribute from the string attribute map and
748 // if found and nonempty, allocate a new BSTR (with SysAllocString)
749 // and return S_OK. If not found or empty, return S_FALSE.
750 HRESULT GetStringAttributeAsBstr(
751 ui::AXStringAttribute attribute,
752 BSTR* value_bstr);
754 // If the string attribute |attribute| is present, add its value as an
755 // IAccessible2 attribute with the name |ia2_attr|.
756 void StringAttributeToIA2(ui::AXStringAttribute attribute,
757 const char* ia2_attr);
759 // If the bool attribute |attribute| is present, add its value as an
760 // IAccessible2 attribute with the name |ia2_attr|.
761 void BoolAttributeToIA2(ui::AXBoolAttribute attribute,
762 const char* ia2_attr);
764 // If the int attribute |attribute| is present, add its value as an
765 // IAccessible2 attribute with the name |ia2_attr|.
766 void IntAttributeToIA2(ui::AXIntAttribute attribute,
767 const char* ia2_attr);
769 // Append the accessible name from this node and its children.
770 base::string16 GetNameRecursive() const;
772 // Get the value text, which might come from the floating-point
773 // value for some roles.
774 base::string16 GetValueText();
776 // Get the text of this node for the purposes of IAccessibleText - it may
777 // be the name, it may be the value, etc. depending on the role.
778 base::string16 TextForIAccessibleText();
780 bool IsSameHypertextCharacter(size_t old_char_index, size_t new_char_index);
781 void ComputeHypertextRemovedAndInserted(
782 int* start, int* old_len, int* new_len);
784 // If offset is a member of IA2TextSpecialOffsets this function updates the
785 // value of offset and returns, otherwise offset remains unchanged.
786 void HandleSpecialTextOffset(const base::string16& text, LONG* offset);
788 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
789 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
791 // Search forwards (direction == 1) or backwards (direction == -1)
792 // from the given offset until the given boundary is found, and
793 // return the offset of that boundary.
794 LONG FindBoundary(const base::string16& text,
795 IA2TextBoundaryType ia2_boundary,
796 LONG start_offset,
797 ui::TextBoundaryDirection direction);
799 // Return a pointer to the object corresponding to the given id,
800 // does not make a new reference.
801 BrowserAccessibilityWin* GetFromID(int32 id);
803 // Returns true if this is a list box option with a parent of type list box,
804 // or a menu list option with a parent of type menu list popup.
805 bool IsListBoxOptionOrMenuListOption();
807 // Windows-specific unique ID (unique within the browser process),
808 // used for get_accChild, NotifyWinEvent, and as the unique ID for
809 // IAccessible2 and ISimpleDOM.
810 LONG unique_id_win_;
812 struct WinAttributes {
813 WinAttributes();
814 ~WinAttributes();
816 // IAccessible role and state.
817 int32 ia_role;
818 int32 ia_state;
819 base::string16 role_name;
821 // IAccessible name, description, help, value.
822 base::string16 name;
823 base::string16 description;
824 base::string16 help;
825 base::string16 value;
827 // IAccessible2 role and state.
828 int32 ia2_role;
829 int32 ia2_state;
831 // IAccessible2 attributes.
832 std::vector<base::string16> ia2_attributes;
834 // Hypertext.
835 base::string16 hypertext;
837 // Maps the |hypertext_| embedded character offset to an index in
838 // |hyperlinks_|.
839 std::map<int32, int32> hyperlink_offset_to_index;
841 // The id of a BrowserAccessibilityWin for each hyperlink.
842 std::vector<int32> hyperlinks;
845 scoped_ptr<WinAttributes> win_attributes_;
847 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or
848 // IA2_EVENT_TEXT_INSERTED event.
849 scoped_ptr<WinAttributes> old_win_attributes_;
851 // Relationships between this node and other nodes.
852 std::vector<BrowserAccessibilityRelation*> relations_;
854 // The previous scroll position, so we can tell if this object scrolled.
855 int previous_scroll_x_;
856 int previous_scroll_y_;
858 // The next unique id to use.
859 static LONG next_unique_id_win_;
861 // Give BrowserAccessibility::Create access to our constructor.
862 friend class BrowserAccessibility;
863 friend class BrowserAccessibilityRelation;
865 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin);
868 } // namespace content
870 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_