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_
11 #include <UIAutomationCore.h>
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"
24 enum TextBoundaryDirection
;
25 enum TextBoundaryType
;
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
,
59 public IRawElementProviderSimple
{
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
)
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
virtual ~BrowserAccessibilityWin();
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_
; }
101 // BrowserAccessibility methods.
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
;
111 // IAccessible methods.
114 // Performs the default action on a given object.
115 CONTENT_EXPORT STDMETHODIMP
accDoDefaultAction(VARIANT var_id
) override
;
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
;
121 // Retrieves the specified object's current screen location.
122 CONTENT_EXPORT STDMETHODIMP
accLocation(LONG
* x_left
,
126 VARIANT var_id
) override
;
128 // Traverses to another UI element and retrieves the object.
129 CONTENT_EXPORT STDMETHODIMP
130 accNavigate(LONG nav_dir
, VARIANT start
, VARIANT
* end
) override
;
132 // Retrieves an IDispatch interface pointer for the specified child.
133 CONTENT_EXPORT STDMETHODIMP
134 get_accChild(VARIANT var_child
, IDispatch
** disp_child
) override
;
136 // Retrieves the number of accessible children.
137 CONTENT_EXPORT STDMETHODIMP
get_accChildCount(LONG
* child_count
) override
;
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
;
143 // Retrieves the object's description.
144 CONTENT_EXPORT STDMETHODIMP
145 get_accDescription(VARIANT var_id
, BSTR
* desc
) override
;
147 // Retrieves the object that has the keyboard focus.
148 CONTENT_EXPORT STDMETHODIMP
get_accFocus(VARIANT
* focus_child
) override
;
150 // Retrieves the help information associated with the object.
151 CONTENT_EXPORT STDMETHODIMP
get_accHelp(VARIANT var_id
, BSTR
* heflp
) override
;
153 // Retrieves the specified object's shortcut.
154 CONTENT_EXPORT STDMETHODIMP
155 get_accKeyboardShortcut(VARIANT var_id
, BSTR
* access_key
) override
;
157 // Retrieves the name of the specified object.
158 CONTENT_EXPORT STDMETHODIMP
get_accName(VARIANT var_id
, BSTR
* name
) override
;
160 // Retrieves the IDispatch interface of the object's parent.
161 CONTENT_EXPORT STDMETHODIMP
get_accParent(IDispatch
** disp_parent
) override
;
163 // Retrieves information describing the role of the specified object.
164 CONTENT_EXPORT STDMETHODIMP
165 get_accRole(VARIANT var_id
, VARIANT
* role
) override
;
167 // Retrieves the current state of the specified object.
168 CONTENT_EXPORT STDMETHODIMP
169 get_accState(VARIANT var_id
, VARIANT
* state
) override
;
171 // Returns the value associated with the object.
172 CONTENT_EXPORT STDMETHODIMP
173 get_accValue(VARIANT var_id
, BSTR
* value
) override
;
175 // Make an object take focus or extend the selection.
176 CONTENT_EXPORT STDMETHODIMP
177 accSelect(LONG flags_sel
, VARIANT var_id
) override
;
179 CONTENT_EXPORT STDMETHODIMP
180 get_accHelpTopic(BSTR
* help_file
, VARIANT var_id
, LONG
* topic_id
) override
;
182 CONTENT_EXPORT STDMETHODIMP
get_accSelection(VARIANT
* selected
) override
;
184 // Deprecated methods, not implemented.
185 CONTENT_EXPORT STDMETHODIMP
186 put_accName(VARIANT var_id
, BSTR put_name
) override
{
189 CONTENT_EXPORT STDMETHODIMP
190 put_accValue(VARIANT var_id
, BSTR put_val
) override
{
195 // IAccessible2 methods.
198 // Returns role from a longer list of possible roles.
199 CONTENT_EXPORT STDMETHODIMP
role(LONG
* role
) override
;
201 // Returns the state bitmask from a larger set of possible states.
202 CONTENT_EXPORT STDMETHODIMP
get_states(AccessibleStates
* states
) override
;
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
;
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
;
212 // Get the window handle of the enclosing window.
213 CONTENT_EXPORT STDMETHODIMP
get_windowHandle(HWND
* window_handle
) override
;
215 // Get this object's index in its parent object.
216 CONTENT_EXPORT STDMETHODIMP
get_indexInParent(LONG
* index_in_parent
) override
;
218 CONTENT_EXPORT STDMETHODIMP
get_nRelations(LONG
* n_relations
) override
;
220 CONTENT_EXPORT STDMETHODIMP
221 get_relation(LONG relation_index
, IAccessibleRelation
** relation
) override
;
223 CONTENT_EXPORT STDMETHODIMP
get_relations(LONG max_relations
,
224 IAccessibleRelation
** relations
,
225 LONG
* n_relations
) override
;
227 CONTENT_EXPORT STDMETHODIMP
scrollTo(enum IA2ScrollType scroll_type
) override
;
229 CONTENT_EXPORT STDMETHODIMP
230 scrollToPoint(enum IA2CoordinateType coordinate_type
,
234 CONTENT_EXPORT STDMETHODIMP
235 get_groupPosition(LONG
* group_level
,
236 LONG
* similar_items_in_group
,
237 LONG
* position_in_group
) override
;
240 // IAccessibleEx methods not implemented.
242 CONTENT_EXPORT STDMETHODIMP
get_extendedRole(BSTR
* extended_role
) override
{
245 CONTENT_EXPORT STDMETHODIMP
246 get_localizedExtendedRole(BSTR
* localized_extended_role
) override
{
249 CONTENT_EXPORT STDMETHODIMP
250 get_nExtendedStates(LONG
* n_extended_states
) override
{
253 CONTENT_EXPORT STDMETHODIMP
254 get_extendedStates(LONG max_extended_states
,
255 BSTR
** extended_states
,
256 LONG
* n_extended_states
) override
{
259 CONTENT_EXPORT STDMETHODIMP
260 get_localizedExtendedStates(LONG max_localized_extended_states
,
261 BSTR
** localized_extended_states
,
262 LONG
* n_localized_extended_states
) override
{
265 CONTENT_EXPORT STDMETHODIMP
get_locale(IA2Locale
* locale
) override
{
270 // IAccessibleApplication methods.
272 CONTENT_EXPORT STDMETHODIMP
get_appName(BSTR
* app_name
) override
;
274 CONTENT_EXPORT STDMETHODIMP
get_appVersion(BSTR
* app_version
) override
;
276 CONTENT_EXPORT STDMETHODIMP
get_toolkitName(BSTR
* toolkit_name
) override
;
278 CONTENT_EXPORT STDMETHODIMP
279 get_toolkitVersion(BSTR
* toolkit_version
) override
;
282 // IAccessibleImage methods.
284 CONTENT_EXPORT STDMETHODIMP
get_description(BSTR
* description
) override
;
286 CONTENT_EXPORT STDMETHODIMP
287 get_imagePosition(enum IA2CoordinateType coordinate_type
,
291 CONTENT_EXPORT STDMETHODIMP
get_imageSize(LONG
* height
, LONG
* width
) override
;
294 // IAccessibleTable methods.
297 // get_description - also used by IAccessibleImage
299 CONTENT_EXPORT STDMETHODIMP
300 get_accessibleAt(long row
, long column
, IUnknown
** accessible
) override
;
302 CONTENT_EXPORT STDMETHODIMP
get_caption(IUnknown
** accessible
) override
;
304 CONTENT_EXPORT STDMETHODIMP
305 get_childIndex(long row_index
, long column_index
, long* cell_index
) override
;
307 CONTENT_EXPORT STDMETHODIMP
308 get_columnDescription(long column
, BSTR
* description
) override
;
310 CONTENT_EXPORT STDMETHODIMP
311 get_columnExtentAt(long row
, long column
, long* n_columns_spanned
) override
;
313 CONTENT_EXPORT STDMETHODIMP
314 get_columnHeader(IAccessibleTable
** accessible_table
,
315 long* starting_row_index
) override
;
317 CONTENT_EXPORT STDMETHODIMP
318 get_columnIndex(long cell_index
, long* column_index
) override
;
320 CONTENT_EXPORT STDMETHODIMP
get_nColumns(long* column_count
) override
;
322 CONTENT_EXPORT STDMETHODIMP
get_nRows(long* row_count
) override
;
324 CONTENT_EXPORT STDMETHODIMP
get_nSelectedChildren(long* cell_count
) override
;
326 CONTENT_EXPORT STDMETHODIMP
get_nSelectedColumns(long* column_count
) override
;
328 CONTENT_EXPORT STDMETHODIMP
get_nSelectedRows(long* row_count
) override
;
330 CONTENT_EXPORT STDMETHODIMP
331 get_rowDescription(long row
, BSTR
* description
) override
;
333 CONTENT_EXPORT STDMETHODIMP
334 get_rowExtentAt(long row
, long column
, long* n_rows_spanned
) override
;
336 CONTENT_EXPORT STDMETHODIMP
337 get_rowHeader(IAccessibleTable
** accessible_table
,
338 long* starting_column_index
) override
;
340 CONTENT_EXPORT STDMETHODIMP
341 get_rowIndex(long cell_index
, long* row_index
) override
;
343 CONTENT_EXPORT STDMETHODIMP
get_selectedChildren(long max_children
,
345 long* n_children
) override
;
347 CONTENT_EXPORT STDMETHODIMP
get_selectedColumns(long max_columns
,
349 long* n_columns
) override
;
351 CONTENT_EXPORT STDMETHODIMP
352 get_selectedRows(long max_rows
, long** rows
, long* n_rows
) override
;
354 CONTENT_EXPORT STDMETHODIMP
get_summary(IUnknown
** accessible
) override
;
356 CONTENT_EXPORT STDMETHODIMP
357 get_isColumnSelected(long column
, boolean
* is_selected
) override
;
359 CONTENT_EXPORT STDMETHODIMP
360 get_isRowSelected(long row
, boolean
* is_selected
) override
;
362 CONTENT_EXPORT STDMETHODIMP
363 get_isSelected(long row
, long column
, boolean
* is_selected
) override
;
365 CONTENT_EXPORT STDMETHODIMP
366 get_rowColumnExtentsAtIndex(long index
,
370 long* column_extents
,
371 boolean
* is_selected
) override
;
373 CONTENT_EXPORT STDMETHODIMP
selectRow(long row
) override
{ return E_NOTIMPL
; }
375 CONTENT_EXPORT STDMETHODIMP
selectColumn(long column
) override
{
379 CONTENT_EXPORT STDMETHODIMP
unselectRow(long row
) override
{
383 CONTENT_EXPORT STDMETHODIMP
unselectColumn(long column
) override
{
387 CONTENT_EXPORT STDMETHODIMP
388 get_modelChange(IA2TableModelChange
* model_change
) override
{
393 // IAccessibleTable2 methods.
395 // (Most of these are duplicates of IAccessibleTable methods, only the
396 // unique ones are included here.)
399 CONTENT_EXPORT STDMETHODIMP
400 get_cellAt(long row
, long column
, IUnknown
** cell
) override
;
402 CONTENT_EXPORT STDMETHODIMP
get_nSelectedCells(long* cell_count
) override
;
404 CONTENT_EXPORT STDMETHODIMP
405 get_selectedCells(IUnknown
*** cells
, long* n_selected_cells
) override
;
407 CONTENT_EXPORT STDMETHODIMP
408 get_selectedColumns(long** columns
, long* n_columns
) override
;
410 CONTENT_EXPORT STDMETHODIMP
411 get_selectedRows(long** rows
, long* n_rows
) override
;
414 // IAccessibleTableCell methods.
417 CONTENT_EXPORT STDMETHODIMP
418 get_columnExtent(long* n_columns_spanned
) override
;
420 CONTENT_EXPORT STDMETHODIMP
421 get_columnHeaderCells(IUnknown
*** cell_accessibles
,
422 long* n_column_header_cells
) override
;
424 CONTENT_EXPORT STDMETHODIMP
get_columnIndex(long* column_index
) override
;
426 CONTENT_EXPORT STDMETHODIMP
get_rowExtent(long* n_rows_spanned
) override
;
428 CONTENT_EXPORT STDMETHODIMP
429 get_rowHeaderCells(IUnknown
*** cell_accessibles
,
430 long* n_row_header_cells
) override
;
432 CONTENT_EXPORT STDMETHODIMP
get_rowIndex(long* row_index
) override
;
434 CONTENT_EXPORT STDMETHODIMP
get_isSelected(boolean
* is_selected
) override
;
436 CONTENT_EXPORT STDMETHODIMP
437 get_rowColumnExtents(long* row
,
440 long* column_extents
,
441 boolean
* is_selected
) override
;
443 CONTENT_EXPORT STDMETHODIMP
get_table(IUnknown
** table
) override
;
446 // IAccessibleText methods.
449 CONTENT_EXPORT STDMETHODIMP
get_nCharacters(LONG
* n_characters
) override
;
451 CONTENT_EXPORT STDMETHODIMP
get_caretOffset(LONG
* offset
) override
;
453 CONTENT_EXPORT STDMETHODIMP
454 get_characterExtents(LONG offset
,
455 enum IA2CoordinateType coord_type
,
459 LONG
* out_height
) override
;
461 CONTENT_EXPORT STDMETHODIMP
get_nSelections(LONG
* n_selections
) override
;
463 CONTENT_EXPORT STDMETHODIMP
get_selection(LONG selection_index
,
465 LONG
* end_offset
) override
;
467 CONTENT_EXPORT STDMETHODIMP
468 get_text(LONG start_offset
, LONG end_offset
, BSTR
* text
) override
;
470 CONTENT_EXPORT STDMETHODIMP
471 get_textAtOffset(LONG offset
,
472 enum IA2TextBoundaryType boundary_type
,
475 BSTR
* text
) override
;
477 CONTENT_EXPORT STDMETHODIMP
478 get_textBeforeOffset(LONG offset
,
479 enum IA2TextBoundaryType boundary_type
,
482 BSTR
* text
) override
;
484 CONTENT_EXPORT STDMETHODIMP
485 get_textAfterOffset(LONG offset
,
486 enum IA2TextBoundaryType boundary_type
,
489 BSTR
* text
) override
;
491 CONTENT_EXPORT STDMETHODIMP
get_newText(IA2TextSegment
* new_text
) override
;
493 CONTENT_EXPORT STDMETHODIMP
get_oldText(IA2TextSegment
* old_text
) override
;
495 CONTENT_EXPORT STDMETHODIMP
496 get_offsetAtPoint(LONG x
,
498 enum IA2CoordinateType coord_type
,
499 LONG
* offset
) override
;
501 CONTENT_EXPORT STDMETHODIMP
502 scrollSubstringTo(LONG start_index
,
504 enum IA2ScrollType scroll_type
) override
;
506 CONTENT_EXPORT STDMETHODIMP
507 scrollSubstringToPoint(LONG start_index
,
509 enum IA2CoordinateType coordinate_type
,
513 CONTENT_EXPORT STDMETHODIMP
514 addSelection(LONG start_offset
, LONG end_offset
) override
;
516 CONTENT_EXPORT STDMETHODIMP
removeSelection(LONG selection_index
) override
;
518 CONTENT_EXPORT STDMETHODIMP
setCaretOffset(LONG offset
) override
;
520 CONTENT_EXPORT STDMETHODIMP
setSelection(LONG selection_index
,
522 LONG end_offset
) override
;
524 // IAccessibleText methods not implemented.
525 CONTENT_EXPORT STDMETHODIMP
get_attributes(LONG offset
,
528 BSTR
* text_attributes
) override
{
533 // IAccessibleHypertext methods.
536 CONTENT_EXPORT STDMETHODIMP
get_nHyperlinks(long* hyperlink_count
) override
;
538 CONTENT_EXPORT STDMETHODIMP
539 get_hyperlink(long index
, IAccessibleHyperlink
** hyperlink
) override
;
541 CONTENT_EXPORT STDMETHODIMP
542 get_hyperlinkIndex(long char_index
, long* hyperlink_index
) override
;
544 // IAccessibleHyperlink not implemented.
545 CONTENT_EXPORT STDMETHODIMP
get_anchor(long index
, VARIANT
* anchor
) override
{
548 CONTENT_EXPORT STDMETHODIMP
549 get_anchorTarget(long index
, VARIANT
* anchor_target
) override
{
552 CONTENT_EXPORT STDMETHODIMP
get_startIndex(long* index
) override
{
555 CONTENT_EXPORT STDMETHODIMP
get_endIndex(long* index
) override
{
558 CONTENT_EXPORT STDMETHODIMP
get_valid(boolean
* valid
) override
{
562 // IAccessibleAction not implemented.
563 CONTENT_EXPORT STDMETHODIMP
nActions(long* n_actions
) override
{
566 CONTENT_EXPORT STDMETHODIMP
doAction(long action_index
) override
{
569 CONTENT_EXPORT STDMETHODIMP
570 get_description(long action_index
, BSTR
* description
) override
{
573 CONTENT_EXPORT STDMETHODIMP
get_keyBinding(long action_index
,
576 long* n_bindings
) override
{
579 CONTENT_EXPORT STDMETHODIMP
get_name(long action_index
, BSTR
* name
) override
{
582 CONTENT_EXPORT STDMETHODIMP
583 get_localizedName(long action_index
, BSTR
* localized_name
) override
{
588 // IAccessibleValue methods.
591 CONTENT_EXPORT STDMETHODIMP
get_currentValue(VARIANT
* value
) override
;
593 CONTENT_EXPORT STDMETHODIMP
get_minimumValue(VARIANT
* value
) override
;
595 CONTENT_EXPORT STDMETHODIMP
get_maximumValue(VARIANT
* value
) override
;
597 CONTENT_EXPORT STDMETHODIMP
setCurrentValue(VARIANT new_value
) override
;
600 // ISimpleDOMDocument methods.
603 CONTENT_EXPORT STDMETHODIMP
get_URL(BSTR
* url
) override
;
605 CONTENT_EXPORT STDMETHODIMP
get_title(BSTR
* title
) override
;
607 CONTENT_EXPORT STDMETHODIMP
get_mimeType(BSTR
* mime_type
) override
;
609 CONTENT_EXPORT STDMETHODIMP
get_docType(BSTR
* doc_type
) override
;
611 CONTENT_EXPORT STDMETHODIMP
612 get_nameSpaceURIForID(short name_space_id
, BSTR
* name_space_uri
) override
{
615 CONTENT_EXPORT STDMETHODIMP
616 put_alternateViewMediaTypes(BSTR
* comma_separated_media_types
) override
{
621 // ISimpleDOMNode methods.
624 CONTENT_EXPORT STDMETHODIMP
get_nodeInfo(BSTR
* node_name
,
625 short* name_space_id
,
627 unsigned int* num_children
,
628 unsigned int* unique_id
,
629 unsigned short* node_type
) override
;
631 CONTENT_EXPORT STDMETHODIMP
632 get_attributes(unsigned short max_attribs
,
634 short* name_space_id
,
636 unsigned short* num_attribs
) override
;
638 CONTENT_EXPORT STDMETHODIMP
639 get_attributesForNames(unsigned short num_attribs
,
641 short* name_space_id
,
642 BSTR
* attrib_values
) override
;
644 CONTENT_EXPORT STDMETHODIMP
645 get_computedStyle(unsigned short max_style_properties
,
646 boolean use_alternate_view
,
647 BSTR
* style_properties
,
649 unsigned short* num_style_properties
) override
;
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
;
657 CONTENT_EXPORT STDMETHODIMP
scrollTo(boolean placeTopLeft
) override
;
659 CONTENT_EXPORT STDMETHODIMP
get_parentNode(ISimpleDOMNode
** node
) override
;
661 CONTENT_EXPORT STDMETHODIMP
get_firstChild(ISimpleDOMNode
** node
) override
;
663 CONTENT_EXPORT STDMETHODIMP
get_lastChild(ISimpleDOMNode
** node
) override
;
665 CONTENT_EXPORT STDMETHODIMP
666 get_previousSibling(ISimpleDOMNode
** node
) override
;
668 CONTENT_EXPORT STDMETHODIMP
get_nextSibling(ISimpleDOMNode
** node
) override
;
670 CONTENT_EXPORT STDMETHODIMP
671 get_childAt(unsigned int child_index
, ISimpleDOMNode
** node
) override
;
673 CONTENT_EXPORT STDMETHODIMP
get_innerHTML(BSTR
* innerHTML
) override
{
677 CONTENT_EXPORT STDMETHODIMP
678 get_localInterface(void** local_interface
) override
{
682 CONTENT_EXPORT STDMETHODIMP
get_language(BSTR
* language
) override
{
687 // ISimpleDOMText methods.
690 CONTENT_EXPORT STDMETHODIMP
get_domText(BSTR
* dom_text
) override
;
692 CONTENT_EXPORT STDMETHODIMP
693 get_clippedSubstringBounds(unsigned int start_index
,
694 unsigned int end_index
,
698 int* out_height
) override
;
700 CONTENT_EXPORT STDMETHODIMP
701 get_unclippedSubstringBounds(unsigned int start_index
,
702 unsigned int end_index
,
706 int* out_height
) override
;
708 CONTENT_EXPORT STDMETHODIMP
709 scrollToSubstring(unsigned int start_index
, unsigned int end_index
) override
;
711 CONTENT_EXPORT STDMETHODIMP
get_fontFamily(BSTR
* font_family
) override
{
716 // IServiceProvider methods.
719 CONTENT_EXPORT STDMETHODIMP
720 QueryService(REFGUID guidService
, REFIID riid
, void** object
) override
;
722 // IAccessibleEx methods not implemented.
723 CONTENT_EXPORT STDMETHODIMP
724 GetObjectForChild(long child_id
, IAccessibleEx
** ret
) override
{
728 CONTENT_EXPORT STDMETHODIMP
729 GetIAccessiblePair(IAccessible
** acc
, long* child_id
) override
{
733 CONTENT_EXPORT STDMETHODIMP
GetRuntimeId(SAFEARRAY
** runtime_id
) override
{
737 CONTENT_EXPORT STDMETHODIMP
738 ConvertReturnedElement(IRawElementProviderSimple
* element
,
739 IAccessibleEx
** acc
) override
{
744 // IRawElementProviderSimple methods.
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
;
754 // IRawElementProviderSimple methods not implemented
756 CONTENT_EXPORT STDMETHODIMP
757 get_ProviderOptions(enum ProviderOptions
* ret
) override
{
761 CONTENT_EXPORT STDMETHODIMP
762 get_HostRawElementProvider(IRawElementProviderSimple
** provider
) override
{
767 // CComObjectRootEx methods.
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
,
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_
;
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();
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
);
800 // Initialize the role and state metadata from the role enum and state
801 // bitmasks defined in ui::AXNodeData.
802 void InitRoleAndState();
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
,
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
);
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
);
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
);
826 // Get the value text, which might come from the floating-point
827 // value for some roles.
828 base::string16
GetValueText();
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();
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
);
838 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
839 ui::TextBoundaryType
IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type
);
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
,
847 ui::TextBoundaryDirection direction
);
849 // Return a pointer to the object corresponding to the given id,
850 // does not make a new reference.
851 BrowserAccessibilityWin
* GetFromID(int32 id
);
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.
858 // IAccessible role and state.
861 base::string16 role_name_
;
863 // IAccessible2 role and state.
867 // IAccessible2 attributes.
868 std::vector
<base::string16
> ia2_attributes_
;
870 // True in Initialize when the object is first created, and false
874 // The previous text, before the last update to this object.
875 base::string16 previous_text_
;
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_
;
882 // The previous state, used to see if there was a state change.
885 // Relationships between this node and other nodes.
886 std::vector
<BrowserAccessibilityRelation
*> relations_
;
888 // The text of this node including embedded hyperlink characters.
889 base::string16 hypertext_
;
891 // Maps the |hypertext_| embedded character offset to an index in
893 std::map
<int32
, int32
> hyperlink_offset_to_index_
;
895 // Collection of non-static text child indicies, each of which corresponds to
897 std::vector
<int32
> hyperlinks_
;
899 // The previous scroll position, so we can tell if this object scrolled.
900 int previous_scroll_x_
;
901 int previous_scroll_y_
;
903 // The next unique id to use.
904 static LONG next_unique_id_win_
;
906 // Give BrowserAccessibility::Create access to our constructor.
907 friend class BrowserAccessibility
;
908 friend class BrowserAccessibilityRelation
;
910 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin
);
913 } // namespace content
915 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_