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_
; }
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
virtual void OnSubtreeWillBeDeleted() override
;
112 CONTENT_EXPORT
virtual void NativeAddReference() override
;
113 CONTENT_EXPORT
virtual void NativeReleaseReference() override
;
114 CONTENT_EXPORT
virtual bool IsNative() const override
;
115 CONTENT_EXPORT
virtual 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
,
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
{
196 CONTENT_EXPORT STDMETHODIMP
197 put_accValue(VARIANT var_id
, BSTR put_val
) override
{
202 // IAccessible2 methods.
205 // Returns role from a longer list of possible roles.
206 CONTENT_EXPORT STDMETHODIMP
role(LONG
* role
) override
;
208 // Returns the state bitmask from a larger set of possible states.
209 CONTENT_EXPORT STDMETHODIMP
get_states(AccessibleStates
* states
) override
;
211 // Returns the attributes specific to this IAccessible2 object,
212 // such as a cell's formula.
213 CONTENT_EXPORT STDMETHODIMP
get_attributes(BSTR
* attributes
) override
;
215 // Get the unique ID of this object so that the client knows if it's
216 // been encountered previously.
217 CONTENT_EXPORT STDMETHODIMP
get_uniqueID(LONG
* unique_id
) override
;
219 // Get the window handle of the enclosing window.
220 CONTENT_EXPORT STDMETHODIMP
get_windowHandle(HWND
* window_handle
) override
;
222 // Get this object's index in its parent object.
223 CONTENT_EXPORT STDMETHODIMP
get_indexInParent(LONG
* index_in_parent
) override
;
225 CONTENT_EXPORT STDMETHODIMP
get_nRelations(LONG
* n_relations
) override
;
227 CONTENT_EXPORT STDMETHODIMP
228 get_relation(LONG relation_index
, IAccessibleRelation
** relation
) override
;
230 CONTENT_EXPORT STDMETHODIMP
get_relations(LONG max_relations
,
231 IAccessibleRelation
** relations
,
232 LONG
* n_relations
) override
;
234 CONTENT_EXPORT STDMETHODIMP
scrollTo(enum IA2ScrollType scroll_type
) override
;
236 CONTENT_EXPORT STDMETHODIMP
237 scrollToPoint(enum IA2CoordinateType coordinate_type
,
241 CONTENT_EXPORT STDMETHODIMP
242 get_groupPosition(LONG
* group_level
,
243 LONG
* similar_items_in_group
,
244 LONG
* position_in_group
) override
;
247 // IAccessibleEx methods not implemented.
249 CONTENT_EXPORT STDMETHODIMP
get_extendedRole(BSTR
* extended_role
) override
{
252 CONTENT_EXPORT STDMETHODIMP
253 get_localizedExtendedRole(BSTR
* localized_extended_role
) override
{
256 CONTENT_EXPORT STDMETHODIMP
257 get_nExtendedStates(LONG
* n_extended_states
) override
{
260 CONTENT_EXPORT STDMETHODIMP
261 get_extendedStates(LONG max_extended_states
,
262 BSTR
** extended_states
,
263 LONG
* n_extended_states
) override
{
266 CONTENT_EXPORT STDMETHODIMP
267 get_localizedExtendedStates(LONG max_localized_extended_states
,
268 BSTR
** localized_extended_states
,
269 LONG
* n_localized_extended_states
) override
{
272 CONTENT_EXPORT STDMETHODIMP
get_locale(IA2Locale
* locale
) override
{
277 // IAccessibleApplication methods.
279 CONTENT_EXPORT STDMETHODIMP
get_appName(BSTR
* app_name
) override
;
281 CONTENT_EXPORT STDMETHODIMP
get_appVersion(BSTR
* app_version
) override
;
283 CONTENT_EXPORT STDMETHODIMP
get_toolkitName(BSTR
* toolkit_name
) override
;
285 CONTENT_EXPORT STDMETHODIMP
286 get_toolkitVersion(BSTR
* toolkit_version
) override
;
289 // IAccessibleImage methods.
291 CONTENT_EXPORT STDMETHODIMP
get_description(BSTR
* description
) override
;
293 CONTENT_EXPORT STDMETHODIMP
294 get_imagePosition(enum IA2CoordinateType coordinate_type
,
298 CONTENT_EXPORT STDMETHODIMP
get_imageSize(LONG
* height
, LONG
* width
) override
;
301 // IAccessibleTable methods.
304 // get_description - also used by IAccessibleImage
306 CONTENT_EXPORT STDMETHODIMP
307 get_accessibleAt(long row
, long column
, IUnknown
** accessible
) override
;
309 CONTENT_EXPORT STDMETHODIMP
get_caption(IUnknown
** accessible
) override
;
311 CONTENT_EXPORT STDMETHODIMP
312 get_childIndex(long row_index
, long column_index
, long* cell_index
) override
;
314 CONTENT_EXPORT STDMETHODIMP
315 get_columnDescription(long column
, BSTR
* description
) override
;
317 CONTENT_EXPORT STDMETHODIMP
318 get_columnExtentAt(long row
, long column
, long* n_columns_spanned
) override
;
320 CONTENT_EXPORT STDMETHODIMP
321 get_columnHeader(IAccessibleTable
** accessible_table
,
322 long* starting_row_index
) override
;
324 CONTENT_EXPORT STDMETHODIMP
325 get_columnIndex(long cell_index
, long* column_index
) override
;
327 CONTENT_EXPORT STDMETHODIMP
get_nColumns(long* column_count
) override
;
329 CONTENT_EXPORT STDMETHODIMP
get_nRows(long* row_count
) override
;
331 CONTENT_EXPORT STDMETHODIMP
get_nSelectedChildren(long* cell_count
) override
;
333 CONTENT_EXPORT STDMETHODIMP
get_nSelectedColumns(long* column_count
) override
;
335 CONTENT_EXPORT STDMETHODIMP
get_nSelectedRows(long* row_count
) override
;
337 CONTENT_EXPORT STDMETHODIMP
338 get_rowDescription(long row
, BSTR
* description
) override
;
340 CONTENT_EXPORT STDMETHODIMP
341 get_rowExtentAt(long row
, long column
, long* n_rows_spanned
) override
;
343 CONTENT_EXPORT STDMETHODIMP
344 get_rowHeader(IAccessibleTable
** accessible_table
,
345 long* starting_column_index
) override
;
347 CONTENT_EXPORT STDMETHODIMP
348 get_rowIndex(long cell_index
, long* row_index
) override
;
350 CONTENT_EXPORT STDMETHODIMP
get_selectedChildren(long max_children
,
352 long* n_children
) override
;
354 CONTENT_EXPORT STDMETHODIMP
get_selectedColumns(long max_columns
,
356 long* n_columns
) override
;
358 CONTENT_EXPORT STDMETHODIMP
359 get_selectedRows(long max_rows
, long** rows
, long* n_rows
) override
;
361 CONTENT_EXPORT STDMETHODIMP
get_summary(IUnknown
** accessible
) override
;
363 CONTENT_EXPORT STDMETHODIMP
364 get_isColumnSelected(long column
, boolean
* is_selected
) override
;
366 CONTENT_EXPORT STDMETHODIMP
367 get_isRowSelected(long row
, boolean
* is_selected
) override
;
369 CONTENT_EXPORT STDMETHODIMP
370 get_isSelected(long row
, long column
, boolean
* is_selected
) override
;
372 CONTENT_EXPORT STDMETHODIMP
373 get_rowColumnExtentsAtIndex(long index
,
377 long* column_extents
,
378 boolean
* is_selected
) override
;
380 CONTENT_EXPORT STDMETHODIMP
selectRow(long row
) override
{ return E_NOTIMPL
; }
382 CONTENT_EXPORT STDMETHODIMP
selectColumn(long column
) override
{
386 CONTENT_EXPORT STDMETHODIMP
unselectRow(long row
) override
{
390 CONTENT_EXPORT STDMETHODIMP
unselectColumn(long column
) override
{
394 CONTENT_EXPORT STDMETHODIMP
395 get_modelChange(IA2TableModelChange
* model_change
) override
{
400 // IAccessibleTable2 methods.
402 // (Most of these are duplicates of IAccessibleTable methods, only the
403 // unique ones are included here.)
406 CONTENT_EXPORT STDMETHODIMP
407 get_cellAt(long row
, long column
, IUnknown
** cell
) override
;
409 CONTENT_EXPORT STDMETHODIMP
get_nSelectedCells(long* cell_count
) override
;
411 CONTENT_EXPORT STDMETHODIMP
412 get_selectedCells(IUnknown
*** cells
, long* n_selected_cells
) override
;
414 CONTENT_EXPORT STDMETHODIMP
415 get_selectedColumns(long** columns
, long* n_columns
) override
;
417 CONTENT_EXPORT STDMETHODIMP
418 get_selectedRows(long** rows
, long* n_rows
) override
;
421 // IAccessibleTableCell methods.
424 CONTENT_EXPORT STDMETHODIMP
425 get_columnExtent(long* n_columns_spanned
) override
;
427 CONTENT_EXPORT STDMETHODIMP
428 get_columnHeaderCells(IUnknown
*** cell_accessibles
,
429 long* n_column_header_cells
) override
;
431 CONTENT_EXPORT STDMETHODIMP
get_columnIndex(long* column_index
) override
;
433 CONTENT_EXPORT STDMETHODIMP
get_rowExtent(long* n_rows_spanned
) override
;
435 CONTENT_EXPORT STDMETHODIMP
436 get_rowHeaderCells(IUnknown
*** cell_accessibles
,
437 long* n_row_header_cells
) override
;
439 CONTENT_EXPORT STDMETHODIMP
get_rowIndex(long* row_index
) override
;
441 CONTENT_EXPORT STDMETHODIMP
get_isSelected(boolean
* is_selected
) override
;
443 CONTENT_EXPORT STDMETHODIMP
444 get_rowColumnExtents(long* row
,
447 long* column_extents
,
448 boolean
* is_selected
) override
;
450 CONTENT_EXPORT STDMETHODIMP
get_table(IUnknown
** table
) override
;
453 // IAccessibleText methods.
456 CONTENT_EXPORT STDMETHODIMP
get_nCharacters(LONG
* n_characters
) override
;
458 CONTENT_EXPORT STDMETHODIMP
get_caretOffset(LONG
* offset
) override
;
460 CONTENT_EXPORT STDMETHODIMP
461 get_characterExtents(LONG offset
,
462 enum IA2CoordinateType coord_type
,
466 LONG
* out_height
) override
;
468 CONTENT_EXPORT STDMETHODIMP
get_nSelections(LONG
* n_selections
) override
;
470 CONTENT_EXPORT STDMETHODIMP
get_selection(LONG selection_index
,
472 LONG
* end_offset
) override
;
474 CONTENT_EXPORT STDMETHODIMP
475 get_text(LONG start_offset
, LONG end_offset
, BSTR
* text
) override
;
477 CONTENT_EXPORT STDMETHODIMP
478 get_textAtOffset(LONG offset
,
479 enum IA2TextBoundaryType boundary_type
,
482 BSTR
* text
) override
;
484 CONTENT_EXPORT STDMETHODIMP
485 get_textBeforeOffset(LONG offset
,
486 enum IA2TextBoundaryType boundary_type
,
489 BSTR
* text
) override
;
491 CONTENT_EXPORT STDMETHODIMP
492 get_textAfterOffset(LONG offset
,
493 enum IA2TextBoundaryType boundary_type
,
496 BSTR
* text
) override
;
498 CONTENT_EXPORT STDMETHODIMP
get_newText(IA2TextSegment
* new_text
) override
;
500 CONTENT_EXPORT STDMETHODIMP
get_oldText(IA2TextSegment
* old_text
) override
;
502 CONTENT_EXPORT STDMETHODIMP
503 get_offsetAtPoint(LONG x
,
505 enum IA2CoordinateType coord_type
,
506 LONG
* offset
) override
;
508 CONTENT_EXPORT STDMETHODIMP
509 scrollSubstringTo(LONG start_index
,
511 enum IA2ScrollType scroll_type
) override
;
513 CONTENT_EXPORT STDMETHODIMP
514 scrollSubstringToPoint(LONG start_index
,
516 enum IA2CoordinateType coordinate_type
,
520 CONTENT_EXPORT STDMETHODIMP
521 addSelection(LONG start_offset
, LONG end_offset
) override
;
523 CONTENT_EXPORT STDMETHODIMP
removeSelection(LONG selection_index
) override
;
525 CONTENT_EXPORT STDMETHODIMP
setCaretOffset(LONG offset
) override
;
527 CONTENT_EXPORT STDMETHODIMP
setSelection(LONG selection_index
,
529 LONG end_offset
) override
;
531 // IAccessibleText methods not implemented.
532 CONTENT_EXPORT STDMETHODIMP
get_attributes(LONG offset
,
535 BSTR
* text_attributes
) override
{
540 // IAccessibleHypertext methods.
543 CONTENT_EXPORT STDMETHODIMP
get_nHyperlinks(long* hyperlink_count
) override
;
545 CONTENT_EXPORT STDMETHODIMP
546 get_hyperlink(long index
, IAccessibleHyperlink
** hyperlink
) override
;
548 CONTENT_EXPORT STDMETHODIMP
549 get_hyperlinkIndex(long char_index
, long* hyperlink_index
) override
;
551 // IAccessibleHyperlink not implemented.
552 CONTENT_EXPORT STDMETHODIMP
get_anchor(long index
, VARIANT
* anchor
) override
{
555 CONTENT_EXPORT STDMETHODIMP
556 get_anchorTarget(long index
, VARIANT
* anchor_target
) override
{
559 CONTENT_EXPORT STDMETHODIMP
get_startIndex(long* index
) override
{
562 CONTENT_EXPORT STDMETHODIMP
get_endIndex(long* index
) override
{
565 CONTENT_EXPORT STDMETHODIMP
get_valid(boolean
* valid
) override
{
569 // IAccessibleAction not implemented.
570 CONTENT_EXPORT STDMETHODIMP
nActions(long* n_actions
) override
{
573 CONTENT_EXPORT STDMETHODIMP
doAction(long action_index
) override
{
576 CONTENT_EXPORT STDMETHODIMP
577 get_description(long action_index
, BSTR
* description
) override
{
580 CONTENT_EXPORT STDMETHODIMP
get_keyBinding(long action_index
,
583 long* n_bindings
) override
{
586 CONTENT_EXPORT STDMETHODIMP
get_name(long action_index
, BSTR
* name
) override
{
589 CONTENT_EXPORT STDMETHODIMP
590 get_localizedName(long action_index
, BSTR
* localized_name
) override
{
595 // IAccessibleValue methods.
598 CONTENT_EXPORT STDMETHODIMP
get_currentValue(VARIANT
* value
) override
;
600 CONTENT_EXPORT STDMETHODIMP
get_minimumValue(VARIANT
* value
) override
;
602 CONTENT_EXPORT STDMETHODIMP
get_maximumValue(VARIANT
* value
) override
;
604 CONTENT_EXPORT STDMETHODIMP
setCurrentValue(VARIANT new_value
) override
;
607 // ISimpleDOMDocument methods.
610 CONTENT_EXPORT STDMETHODIMP
get_URL(BSTR
* url
) override
;
612 CONTENT_EXPORT STDMETHODIMP
get_title(BSTR
* title
) override
;
614 CONTENT_EXPORT STDMETHODIMP
get_mimeType(BSTR
* mime_type
) override
;
616 CONTENT_EXPORT STDMETHODIMP
get_docType(BSTR
* doc_type
) override
;
618 CONTENT_EXPORT STDMETHODIMP
619 get_nameSpaceURIForID(short name_space_id
, BSTR
* name_space_uri
) override
{
622 CONTENT_EXPORT STDMETHODIMP
623 put_alternateViewMediaTypes(BSTR
* comma_separated_media_types
) override
{
628 // ISimpleDOMNode methods.
631 CONTENT_EXPORT STDMETHODIMP
get_nodeInfo(BSTR
* node_name
,
632 short* name_space_id
,
634 unsigned int* num_children
,
635 unsigned int* unique_id
,
636 unsigned short* node_type
) override
;
638 CONTENT_EXPORT STDMETHODIMP
639 get_attributes(unsigned short max_attribs
,
641 short* name_space_id
,
643 unsigned short* num_attribs
) override
;
645 CONTENT_EXPORT STDMETHODIMP
646 get_attributesForNames(unsigned short num_attribs
,
648 short* name_space_id
,
649 BSTR
* attrib_values
) override
;
651 CONTENT_EXPORT STDMETHODIMP
652 get_computedStyle(unsigned short max_style_properties
,
653 boolean use_alternate_view
,
654 BSTR
* style_properties
,
656 unsigned short* num_style_properties
) override
;
658 CONTENT_EXPORT STDMETHODIMP
659 get_computedStyleForProperties(unsigned short num_style_properties
,
660 boolean use_alternate_view
,
661 BSTR
* style_properties
,
662 BSTR
* style_values
) override
;
664 CONTENT_EXPORT STDMETHODIMP
scrollTo(boolean placeTopLeft
) override
;
666 CONTENT_EXPORT STDMETHODIMP
get_parentNode(ISimpleDOMNode
** node
) override
;
668 CONTENT_EXPORT STDMETHODIMP
get_firstChild(ISimpleDOMNode
** node
) override
;
670 CONTENT_EXPORT STDMETHODIMP
get_lastChild(ISimpleDOMNode
** node
) override
;
672 CONTENT_EXPORT STDMETHODIMP
673 get_previousSibling(ISimpleDOMNode
** node
) override
;
675 CONTENT_EXPORT STDMETHODIMP
get_nextSibling(ISimpleDOMNode
** node
) override
;
677 CONTENT_EXPORT STDMETHODIMP
678 get_childAt(unsigned int child_index
, ISimpleDOMNode
** node
) override
;
680 CONTENT_EXPORT STDMETHODIMP
get_innerHTML(BSTR
* innerHTML
) override
{
684 CONTENT_EXPORT STDMETHODIMP
685 get_localInterface(void** local_interface
) override
{
689 CONTENT_EXPORT STDMETHODIMP
get_language(BSTR
* language
) override
{
694 // ISimpleDOMText methods.
697 CONTENT_EXPORT STDMETHODIMP
get_domText(BSTR
* dom_text
) override
;
699 CONTENT_EXPORT STDMETHODIMP
700 get_clippedSubstringBounds(unsigned int start_index
,
701 unsigned int end_index
,
705 int* out_height
) override
;
707 CONTENT_EXPORT STDMETHODIMP
708 get_unclippedSubstringBounds(unsigned int start_index
,
709 unsigned int end_index
,
713 int* out_height
) override
;
715 CONTENT_EXPORT STDMETHODIMP
716 scrollToSubstring(unsigned int start_index
, unsigned int end_index
) override
;
718 CONTENT_EXPORT STDMETHODIMP
get_fontFamily(BSTR
* font_family
) override
{
723 // IServiceProvider methods.
726 CONTENT_EXPORT STDMETHODIMP
727 QueryService(REFGUID guidService
, REFIID riid
, void** object
) override
;
729 // IAccessibleEx methods not implemented.
730 CONTENT_EXPORT STDMETHODIMP
731 GetObjectForChild(long child_id
, IAccessibleEx
** ret
) override
{
735 CONTENT_EXPORT STDMETHODIMP
736 GetIAccessiblePair(IAccessible
** acc
, long* child_id
) override
{
740 CONTENT_EXPORT STDMETHODIMP
GetRuntimeId(SAFEARRAY
** runtime_id
) override
{
744 CONTENT_EXPORT STDMETHODIMP
745 ConvertReturnedElement(IRawElementProviderSimple
* element
,
746 IAccessibleEx
** acc
) override
{
751 // IRawElementProviderSimple methods.
753 // The GetPatternProvider/GetPropertyValue methods need to be implemented for
754 // the on-screen keyboard to show up in Windows 8 metro.
755 CONTENT_EXPORT STDMETHODIMP
756 GetPatternProvider(PATTERNID id
, IUnknown
** provider
) override
;
757 CONTENT_EXPORT STDMETHODIMP
758 GetPropertyValue(PROPERTYID id
, VARIANT
* ret
) override
;
761 // IRawElementProviderSimple methods not implemented
763 CONTENT_EXPORT STDMETHODIMP
764 get_ProviderOptions(enum ProviderOptions
* ret
) override
{
768 CONTENT_EXPORT STDMETHODIMP
769 get_HostRawElementProvider(IRawElementProviderSimple
** provider
) override
{
774 // CComObjectRootEx methods.
777 // Called by BEGIN_COM_MAP() / END_COM_MAP().
778 static CONTENT_EXPORT HRESULT WINAPI
779 InternalQueryInterface(void* this_ptr
,
780 const _ATL_INTMAP_ENTRY
* entries
,
785 int32
ia_role() const { return win_attributes_
->ia_role
; }
786 int32
ia_state() const { return win_attributes_
->ia_state
; }
787 const base::string16
& role_name() const { return win_attributes_
->role_name
; }
788 int32
ia2_role() const { return win_attributes_
->ia2_role
; }
789 int32
ia2_state() const { return win_attributes_
->ia2_state
; }
790 const std::vector
<base::string16
>& ia2_attributes() const {
791 return win_attributes_
->ia2_attributes
;
793 base::string16
name() const { return win_attributes_
->name
; }
794 base::string16
description() const { return win_attributes_
->description
; }
795 base::string16
help() const { return win_attributes_
->help
; }
796 base::string16
value() const { return win_attributes_
->value
; }
797 base::string16
hypertext() const { return win_attributes_
->hypertext
; }
798 std::map
<int32
, int32
>& hyperlink_offset_to_index() const {
799 return win_attributes_
->hyperlink_offset_to_index
;
801 std::vector
<int32
>& hyperlinks() const { return win_attributes_
->hyperlinks
; }
804 // Add one to the reference count and return the same object. Always
805 // use this method when returning a BrowserAccessibilityWin object as
806 // an output parameter to a COM interface, never use it otherwise.
807 BrowserAccessibilityWin
* NewReference();
809 // Many MSAA methods take a var_id parameter indicating that the operation
810 // should be performed on a particular child ID, rather than this object.
811 // This method tries to figure out the target object from |var_id| and
812 // returns a pointer to the target object if it exists, otherwise NULL.
813 // Does not return a new reference.
814 BrowserAccessibilityWin
* GetTargetFromChildID(const VARIANT
& var_id
);
816 // Initialize the role and state metadata from the role enum and state
817 // bitmasks defined in ui::AXNodeData.
818 void InitRoleAndState();
820 // Retrieve the value of an attribute from the string attribute map and
821 // if found and nonempty, allocate a new BSTR (with SysAllocString)
822 // and return S_OK. If not found or empty, return S_FALSE.
823 HRESULT
GetStringAttributeAsBstr(
824 ui::AXStringAttribute attribute
,
827 // If the string attribute |attribute| is present, add its value as an
828 // IAccessible2 attribute with the name |ia2_attr|.
829 void StringAttributeToIA2(ui::AXStringAttribute attribute
,
830 const char* ia2_attr
);
832 // If the bool attribute |attribute| is present, add its value as an
833 // IAccessible2 attribute with the name |ia2_attr|.
834 void BoolAttributeToIA2(ui::AXBoolAttribute attribute
,
835 const char* ia2_attr
);
837 // If the int attribute |attribute| is present, add its value as an
838 // IAccessible2 attribute with the name |ia2_attr|.
839 void IntAttributeToIA2(ui::AXIntAttribute attribute
,
840 const char* ia2_attr
);
842 // Append the accessible name from this node and its children.
843 base::string16
GetNameRecursive() const;
845 // Get the value text, which might come from the floating-point
846 // value for some roles.
847 base::string16
GetValueText();
849 // Get the text of this node for the purposes of IAccessibleText - it may
850 // be the name, it may be the value, etc. depending on the role.
851 base::string16
TextForIAccessibleText();
853 bool IsSameHypertextCharacter(size_t old_char_index
, size_t new_char_index
);
854 void ComputeHypertextRemovedAndInserted(
855 int* start
, int* old_len
, int* new_len
);
857 // If offset is a member of IA2TextSpecialOffsets this function updates the
858 // value of offset and returns, otherwise offset remains unchanged.
859 void HandleSpecialTextOffset(const base::string16
& text
, LONG
* offset
);
861 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
862 ui::TextBoundaryType
IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type
);
864 // Search forwards (direction == 1) or backwards (direction == -1)
865 // from the given offset until the given boundary is found, and
866 // return the offset of that boundary.
867 LONG
FindBoundary(const base::string16
& text
,
868 IA2TextBoundaryType ia2_boundary
,
870 ui::TextBoundaryDirection direction
);
872 // Return a pointer to the object corresponding to the given id,
873 // does not make a new reference.
874 BrowserAccessibilityWin
* GetFromID(int32 id
);
876 // Windows-specific unique ID (unique within the browser process),
877 // used for get_accChild, NotifyWinEvent, and as the unique ID for
878 // IAccessible2 and ISimpleDOM.
881 struct WinAttributes
{
884 // IAccessible role and state.
887 base::string16 role_name
;
889 // IAccessible name, description, help, value.
891 base::string16 description
;
893 base::string16 value
;
895 // IAccessible2 role and state.
899 // IAccessible2 attributes.
900 std::vector
<base::string16
> ia2_attributes
;
903 base::string16 hypertext
;
905 // Maps the |hypertext_| embedded character offset to an index in
907 std::map
<int32
, int32
> hyperlink_offset_to_index
;
909 // The id of a BrowserAccessibilityWin for each hyperlink.
910 std::vector
<int32
> hyperlinks
;
913 scoped_ptr
<WinAttributes
> win_attributes_
;
915 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or
916 // IA2_EVENT_TEXT_INSERTED event.
917 scoped_ptr
<WinAttributes
> old_win_attributes_
;
919 // Relationships between this node and other nodes.
920 std::vector
<BrowserAccessibilityRelation
*> relations_
;
922 // The previous scroll position, so we can tell if this object scrolled.
923 int previous_scroll_x_
;
924 int previous_scroll_y_
;
926 // The next unique id to use.
927 static LONG next_unique_id_win_
;
929 // Give BrowserAccessibility::Create access to our constructor.
930 friend class BrowserAccessibility
;
931 friend class BrowserAccessibilityRelation
;
933 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin
);
936 } // namespace content
938 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_