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_ENTRY2(IAccessible, IAccessible2)
64 COM_INTERFACE_ENTRY2(IAccessibleText, IAccessibleHypertext)
65 COM_INTERFACE_ENTRY(IAccessible2)
66 COM_INTERFACE_ENTRY(IAccessibleApplication)
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(IAccessibleValue)
74 COM_INTERFACE_ENTRY(IServiceProvider)
75 COM_INTERFACE_ENTRY(ISimpleDOMDocument)
76 COM_INTERFACE_ENTRY(ISimpleDOMNode)
77 COM_INTERFACE_ENTRY(ISimpleDOMText)
78 COM_INTERFACE_ENTRY(IAccessibleEx)
79 COM_INTERFACE_ENTRY(IRawElementProviderSimple)
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 char16 kEmbeddedCharacter[];
87 // Mappings from roles and states to human readable strings. Initialize
88 // with |InitializeStringMaps|.
89 static std::map<int32, string16> role_string_map;
90 static std::map<int32, 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 PreInitialize() OVERRIDE;
104 CONTENT_EXPORT virtual void PostInitialize() 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 SetLocation(const gfx::Rect& new_location)
112 // IAccessible methods.
115 // Performs the default action on a given object.
116 CONTENT_EXPORT STDMETHODIMP accDoDefaultAction(VARIANT var_id);
118 // Retrieves the child element or child object at a given point on the screen.
119 CONTENT_EXPORT STDMETHODIMP accHitTest(LONG x_left, LONG y_top,
122 // Retrieves the specified object's current screen location.
123 CONTENT_EXPORT STDMETHODIMP accLocation(LONG* x_left,
129 // Traverses to another UI element and retrieves the object.
130 CONTENT_EXPORT STDMETHODIMP accNavigate(LONG nav_dir, VARIANT start,
133 // Retrieves an IDispatch interface pointer for the specified child.
134 CONTENT_EXPORT STDMETHODIMP get_accChild(VARIANT var_child,
135 IDispatch** disp_child);
137 // Retrieves the number of accessible children.
138 CONTENT_EXPORT STDMETHODIMP get_accChildCount(LONG* child_count);
140 // Retrieves a string that describes the object's default action.
141 CONTENT_EXPORT STDMETHODIMP get_accDefaultAction(VARIANT var_id,
142 BSTR* default_action);
144 // Retrieves the object's description.
145 CONTENT_EXPORT STDMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc);
147 // Retrieves the object that has the keyboard focus.
148 CONTENT_EXPORT STDMETHODIMP get_accFocus(VARIANT* focus_child);
150 // Retrieves the help information associated with the object.
151 CONTENT_EXPORT STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* heflp);
153 // Retrieves the specified object's shortcut.
154 CONTENT_EXPORT STDMETHODIMP get_accKeyboardShortcut(VARIANT var_id,
157 // Retrieves the name of the specified object.
158 CONTENT_EXPORT STDMETHODIMP get_accName(VARIANT var_id, BSTR* name);
160 // Retrieves the IDispatch interface of the object's parent.
161 CONTENT_EXPORT STDMETHODIMP get_accParent(IDispatch** disp_parent);
163 // Retrieves information describing the role of the specified object.
164 CONTENT_EXPORT STDMETHODIMP get_accRole(VARIANT var_id, VARIANT* role);
166 // Retrieves the current state of the specified object.
167 CONTENT_EXPORT STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state);
169 // Returns the value associated with the object.
170 CONTENT_EXPORT STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value);
172 // Make an object take focus or extend the selection.
173 CONTENT_EXPORT STDMETHODIMP accSelect(LONG flags_sel, VARIANT var_id);
175 CONTENT_EXPORT STDMETHODIMP get_accHelpTopic(BSTR* help_file,
179 CONTENT_EXPORT STDMETHODIMP get_accSelection(VARIANT* selected);
181 // Deprecated methods, not implemented.
182 CONTENT_EXPORT STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name) {
185 CONTENT_EXPORT STDMETHODIMP put_accValue(VARIANT var_id, BSTR put_val) {
190 // IAccessible2 methods.
193 // Returns role from a longer list of possible roles.
194 CONTENT_EXPORT STDMETHODIMP role(LONG* role);
196 // Returns the state bitmask from a larger set of possible states.
197 CONTENT_EXPORT STDMETHODIMP get_states(AccessibleStates* states);
199 // Returns the attributes specific to this IAccessible2 object,
200 // such as a cell's formula.
201 CONTENT_EXPORT STDMETHODIMP get_attributes(BSTR* attributes);
203 // Get the unique ID of this object so that the client knows if it's
204 // been encountered previously.
205 CONTENT_EXPORT STDMETHODIMP get_uniqueID(LONG* unique_id);
207 // Get the window handle of the enclosing window.
208 CONTENT_EXPORT STDMETHODIMP get_windowHandle(HWND* window_handle);
210 // Get this object's index in its parent object.
211 CONTENT_EXPORT STDMETHODIMP get_indexInParent(LONG* index_in_parent);
213 CONTENT_EXPORT STDMETHODIMP get_nRelations(LONG* n_relations);
215 CONTENT_EXPORT STDMETHODIMP get_relation(LONG relation_index,
216 IAccessibleRelation** relation);
218 CONTENT_EXPORT STDMETHODIMP get_relations(LONG max_relations,
219 IAccessibleRelation** relations,
222 CONTENT_EXPORT STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type);
224 CONTENT_EXPORT STDMETHODIMP scrollToPoint(
225 enum IA2CoordinateType coordinate_type,
229 CONTENT_EXPORT STDMETHODIMP get_groupPosition(LONG* group_level,
230 LONG* similar_items_in_group,
231 LONG* position_in_group);
234 // IAccessibleEx methods not implemented.
236 CONTENT_EXPORT STDMETHODIMP get_extendedRole(BSTR* extended_role) {
239 CONTENT_EXPORT STDMETHODIMP get_localizedExtendedRole(
240 BSTR* localized_extended_role) {
243 CONTENT_EXPORT STDMETHODIMP get_nExtendedStates(LONG* n_extended_states) {
246 CONTENT_EXPORT STDMETHODIMP get_extendedStates(LONG max_extended_states,
247 BSTR** extended_states,
248 LONG* n_extended_states) {
251 CONTENT_EXPORT STDMETHODIMP get_localizedExtendedStates(
252 LONG max_localized_extended_states,
253 BSTR** localized_extended_states,
254 LONG* n_localized_extended_states) {
257 CONTENT_EXPORT STDMETHODIMP get_locale(IA2Locale* locale) {
262 // IAccessibleApplication methods.
264 CONTENT_EXPORT STDMETHODIMP get_appName(BSTR* app_name);
266 CONTENT_EXPORT STDMETHODIMP get_appVersion(BSTR* app_version);
268 CONTENT_EXPORT STDMETHODIMP get_toolkitName(BSTR* toolkit_name);
270 CONTENT_EXPORT STDMETHODIMP get_toolkitVersion(BSTR* toolkit_version);
273 // IAccessibleImage methods.
275 CONTENT_EXPORT STDMETHODIMP get_description(BSTR* description);
277 CONTENT_EXPORT STDMETHODIMP get_imagePosition(
278 enum IA2CoordinateType coordinate_type,
282 CONTENT_EXPORT STDMETHODIMP get_imageSize(LONG* height, LONG* width);
285 // IAccessibleTable methods.
288 // get_description - also used by IAccessibleImage
290 CONTENT_EXPORT STDMETHODIMP get_accessibleAt(long row,
292 IUnknown** accessible);
294 CONTENT_EXPORT STDMETHODIMP get_caption(IUnknown** accessible);
296 CONTENT_EXPORT STDMETHODIMP get_childIndex(long row_index,
300 CONTENT_EXPORT STDMETHODIMP get_columnDescription(long column,
303 CONTENT_EXPORT STDMETHODIMP get_columnExtentAt(long row,
305 long* n_columns_spanned);
307 CONTENT_EXPORT STDMETHODIMP get_columnHeader(
308 IAccessibleTable** accessible_table,
309 long* starting_row_index);
311 CONTENT_EXPORT STDMETHODIMP get_columnIndex(long cell_index,
314 CONTENT_EXPORT STDMETHODIMP get_nColumns(long* column_count);
316 CONTENT_EXPORT STDMETHODIMP get_nRows(long* row_count);
318 CONTENT_EXPORT STDMETHODIMP get_nSelectedChildren(long* cell_count);
320 CONTENT_EXPORT STDMETHODIMP get_nSelectedColumns(long* column_count);
322 CONTENT_EXPORT STDMETHODIMP get_nSelectedRows(long *row_count);
324 CONTENT_EXPORT STDMETHODIMP get_rowDescription(long row,
327 CONTENT_EXPORT STDMETHODIMP get_rowExtentAt(long row,
329 long* n_rows_spanned);
331 CONTENT_EXPORT STDMETHODIMP get_rowHeader(IAccessibleTable** accessible_table,
332 long* starting_column_index);
334 CONTENT_EXPORT STDMETHODIMP get_rowIndex(long cell_index,
337 CONTENT_EXPORT STDMETHODIMP get_selectedChildren(long max_children,
341 CONTENT_EXPORT STDMETHODIMP get_selectedColumns(long max_columns,
345 CONTENT_EXPORT STDMETHODIMP get_selectedRows(long max_rows,
349 CONTENT_EXPORT STDMETHODIMP get_summary(IUnknown** accessible);
351 CONTENT_EXPORT STDMETHODIMP get_isColumnSelected(long column,
352 boolean* is_selected);
354 CONTENT_EXPORT STDMETHODIMP get_isRowSelected(long row,
355 boolean* is_selected);
357 CONTENT_EXPORT STDMETHODIMP get_isSelected(long row,
359 boolean* is_selected);
361 CONTENT_EXPORT STDMETHODIMP get_rowColumnExtentsAtIndex(long index,
365 long* column_extents,
366 boolean* is_selected);
368 CONTENT_EXPORT STDMETHODIMP selectRow(long row) {
372 CONTENT_EXPORT STDMETHODIMP selectColumn(long column) {
376 CONTENT_EXPORT STDMETHODIMP unselectRow(long row) {
380 CONTENT_EXPORT STDMETHODIMP unselectColumn(long column) {
384 CONTENT_EXPORT STDMETHODIMP get_modelChange(
385 IA2TableModelChange* model_change) {
390 // IAccessibleTable2 methods.
392 // (Most of these are duplicates of IAccessibleTable methods, only the
393 // unique ones are included here.)
396 CONTENT_EXPORT STDMETHODIMP get_cellAt(long row,
400 CONTENT_EXPORT STDMETHODIMP get_nSelectedCells(long* cell_count);
402 CONTENT_EXPORT STDMETHODIMP get_selectedCells(IUnknown*** cells,
403 long* n_selected_cells);
405 CONTENT_EXPORT STDMETHODIMP get_selectedColumns(long** columns,
408 CONTENT_EXPORT STDMETHODIMP get_selectedRows(long** rows,
412 // IAccessibleTableCell methods.
415 CONTENT_EXPORT STDMETHODIMP get_columnExtent(long* n_columns_spanned);
417 CONTENT_EXPORT STDMETHODIMP get_columnHeaderCells(
418 IUnknown*** cell_accessibles,
419 long* n_column_header_cells);
421 CONTENT_EXPORT STDMETHODIMP get_columnIndex(long* column_index);
423 CONTENT_EXPORT STDMETHODIMP get_rowExtent(long* n_rows_spanned);
425 CONTENT_EXPORT STDMETHODIMP get_rowHeaderCells(IUnknown*** cell_accessibles,
426 long* n_row_header_cells);
428 CONTENT_EXPORT STDMETHODIMP get_rowIndex(long* row_index);
430 CONTENT_EXPORT STDMETHODIMP get_isSelected(boolean* is_selected);
432 CONTENT_EXPORT STDMETHODIMP get_rowColumnExtents(long* row,
435 long* column_extents,
436 boolean* is_selected);
438 CONTENT_EXPORT STDMETHODIMP get_table(IUnknown** table);
441 // IAccessibleText methods.
444 CONTENT_EXPORT STDMETHODIMP get_nCharacters(LONG* n_characters);
446 CONTENT_EXPORT STDMETHODIMP get_caretOffset(LONG* offset);
448 CONTENT_EXPORT STDMETHODIMP get_nSelections(LONG* n_selections);
450 CONTENT_EXPORT STDMETHODIMP get_selection(LONG selection_index,
454 CONTENT_EXPORT STDMETHODIMP get_text(LONG start_offset,
458 CONTENT_EXPORT STDMETHODIMP get_textAtOffset(
460 enum IA2TextBoundaryType boundary_type,
465 CONTENT_EXPORT STDMETHODIMP get_textBeforeOffset(
467 enum IA2TextBoundaryType boundary_type,
472 CONTENT_EXPORT STDMETHODIMP get_textAfterOffset(
474 enum IA2TextBoundaryType boundary_type,
479 CONTENT_EXPORT STDMETHODIMP get_newText(IA2TextSegment* new_text);
481 CONTENT_EXPORT STDMETHODIMP get_oldText(IA2TextSegment* old_text);
483 CONTENT_EXPORT STDMETHODIMP get_offsetAtPoint(
486 enum IA2CoordinateType coord_type,
489 CONTENT_EXPORT STDMETHODIMP scrollSubstringTo(
492 enum IA2ScrollType scroll_type);
494 CONTENT_EXPORT STDMETHODIMP scrollSubstringToPoint(
497 enum IA2CoordinateType coordinate_type,
500 CONTENT_EXPORT STDMETHODIMP addSelection(LONG start_offset, LONG end_offset);
502 CONTENT_EXPORT STDMETHODIMP removeSelection(LONG selection_index);
504 CONTENT_EXPORT STDMETHODIMP setCaretOffset(LONG offset);
506 CONTENT_EXPORT STDMETHODIMP setSelection(LONG selection_index,
510 // IAccessibleText methods not implemented.
511 CONTENT_EXPORT STDMETHODIMP get_attributes(LONG offset, LONG* start_offset,
513 BSTR* text_attributes) {
516 CONTENT_EXPORT STDMETHODIMP get_characterExtents(LONG offset,
517 enum IA2CoordinateType coord_type,
526 // IAccessibleHypertext methods.
529 CONTENT_EXPORT STDMETHODIMP get_nHyperlinks(long* hyperlink_count);
531 CONTENT_EXPORT STDMETHODIMP get_hyperlink(long index,
532 IAccessibleHyperlink** hyperlink);
534 CONTENT_EXPORT STDMETHODIMP get_hyperlinkIndex(long char_index,
535 long* hyperlink_index);
537 // IAccessibleHyperlink not implemented.
538 CONTENT_EXPORT STDMETHODIMP get_anchor(long index, VARIANT* anchor) {
541 CONTENT_EXPORT STDMETHODIMP get_anchorTarget(long index,
542 VARIANT* anchor_target) {
545 CONTENT_EXPORT STDMETHODIMP get_startIndex( long* index) {
548 CONTENT_EXPORT STDMETHODIMP get_endIndex( long* index) {
551 CONTENT_EXPORT STDMETHODIMP get_valid(boolean* valid) {
555 // IAccessibleAction not implemented.
556 CONTENT_EXPORT STDMETHODIMP nActions(long* n_actions) {
559 CONTENT_EXPORT STDMETHODIMP doAction(long action_index) {
562 CONTENT_EXPORT STDMETHODIMP get_description(long action_index,
566 CONTENT_EXPORT STDMETHODIMP get_keyBinding(long action_index,
572 CONTENT_EXPORT STDMETHODIMP get_name(long action_index, BSTR* name) {
575 CONTENT_EXPORT STDMETHODIMP get_localizedName(long action_index,
576 BSTR* localized_name) {
581 // IAccessibleValue methods.
584 CONTENT_EXPORT STDMETHODIMP get_currentValue(VARIANT* value);
586 CONTENT_EXPORT STDMETHODIMP get_minimumValue(VARIANT* value);
588 CONTENT_EXPORT STDMETHODIMP get_maximumValue(VARIANT* value);
590 CONTENT_EXPORT STDMETHODIMP setCurrentValue(VARIANT new_value);
593 // ISimpleDOMDocument methods.
596 CONTENT_EXPORT STDMETHODIMP get_URL(BSTR* url);
598 CONTENT_EXPORT STDMETHODIMP get_title(BSTR* title);
600 CONTENT_EXPORT STDMETHODIMP get_mimeType(BSTR* mime_type);
602 CONTENT_EXPORT STDMETHODIMP get_docType(BSTR* doc_type);
604 CONTENT_EXPORT STDMETHODIMP get_nameSpaceURIForID(short name_space_id,
605 BSTR* name_space_uri) {
608 CONTENT_EXPORT STDMETHODIMP put_alternateViewMediaTypes(
609 BSTR* comma_separated_media_types) {
614 // ISimpleDOMNode methods.
617 CONTENT_EXPORT STDMETHODIMP get_nodeInfo(BSTR* node_name,
618 short* name_space_id,
620 unsigned int* num_children,
621 unsigned int* unique_id,
622 unsigned short* node_type);
624 CONTENT_EXPORT STDMETHODIMP get_attributes(unsigned short max_attribs,
626 short* name_space_id,
628 unsigned short* num_attribs);
630 CONTENT_EXPORT STDMETHODIMP get_attributesForNames(
631 unsigned short num_attribs,
633 short* name_space_id,
634 BSTR* attrib_values);
636 CONTENT_EXPORT STDMETHODIMP get_computedStyle(
637 unsigned short max_style_properties,
638 boolean use_alternate_view,
639 BSTR *style_properties,
641 unsigned short *num_style_properties);
643 CONTENT_EXPORT STDMETHODIMP get_computedStyleForProperties(
644 unsigned short num_style_properties,
645 boolean use_alternate_view,
646 BSTR* style_properties,
649 CONTENT_EXPORT STDMETHODIMP scrollTo(boolean placeTopLeft);
651 CONTENT_EXPORT STDMETHODIMP get_parentNode(ISimpleDOMNode** node);
653 CONTENT_EXPORT STDMETHODIMP get_firstChild(ISimpleDOMNode** node);
655 CONTENT_EXPORT STDMETHODIMP get_lastChild(ISimpleDOMNode** node);
657 CONTENT_EXPORT STDMETHODIMP get_previousSibling(ISimpleDOMNode** node);
659 CONTENT_EXPORT STDMETHODIMP get_nextSibling(ISimpleDOMNode** node);
661 CONTENT_EXPORT STDMETHODIMP get_childAt(unsigned int child_index,
662 ISimpleDOMNode** node);
664 CONTENT_EXPORT STDMETHODIMP get_innerHTML(BSTR* innerHTML) {
668 CONTENT_EXPORT STDMETHODIMP get_localInterface(void** local_interface) {
672 CONTENT_EXPORT STDMETHODIMP get_language(BSTR* language) {
677 // ISimpleDOMText methods.
680 CONTENT_EXPORT STDMETHODIMP get_domText(BSTR* dom_text);
682 CONTENT_EXPORT STDMETHODIMP get_clippedSubstringBounds(
683 unsigned int start_index,
684 unsigned int end_index,
692 CONTENT_EXPORT STDMETHODIMP get_unclippedSubstringBounds(
693 unsigned int start_index,
694 unsigned int end_index,
702 CONTENT_EXPORT STDMETHODIMP scrollToSubstring(unsigned int start_index,
703 unsigned int end_index) {
707 CONTENT_EXPORT STDMETHODIMP get_fontFamily(BSTR *font_family) {
712 // IServiceProvider methods.
715 CONTENT_EXPORT STDMETHODIMP QueryService(REFGUID guidService,
719 // IAccessibleEx methods not implemented.
720 CONTENT_EXPORT STDMETHODIMP GetObjectForChild(long child_id,
721 IAccessibleEx** ret) {
725 CONTENT_EXPORT STDMETHODIMP GetIAccessiblePair(IAccessible** acc,
730 CONTENT_EXPORT STDMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) {
734 CONTENT_EXPORT STDMETHODIMP ConvertReturnedElement(
735 IRawElementProviderSimple* element,
736 IAccessibleEx** acc) {
741 // IRawElementProviderSimple methods.
743 // The GetPatternProvider/GetPropertyValue methods need to be implemented for
744 // the on-screen keyboard to show up in Windows 8 metro.
745 CONTENT_EXPORT STDMETHODIMP GetPatternProvider(PATTERNID id,
746 IUnknown** provider);
747 CONTENT_EXPORT STDMETHODIMP GetPropertyValue(PROPERTYID id, VARIANT* ret);
750 // IRawElementProviderSimple methods not implemented
752 CONTENT_EXPORT STDMETHODIMP get_ProviderOptions(enum ProviderOptions* ret) {
756 CONTENT_EXPORT STDMETHODIMP get_HostRawElementProvider(
757 IRawElementProviderSimple** provider) {
762 // CComObjectRootEx methods.
765 CONTENT_EXPORT HRESULT WINAPI InternalQueryInterface(
767 const _ATL_INTMAP_ENTRY* entries,
772 int32 ia_role() const { return ia_role_; }
773 int32 ia_state() const { return ia_state_; }
774 const string16& role_name() const { return role_name_; }
775 int32 ia2_role() const { return ia2_role_; }
776 int32 ia2_state() const { return ia2_state_; }
777 const std::vector<string16>& ia2_attributes() const {
778 return ia2_attributes_;
782 // Add one to the reference count and return the same object. Always
783 // use this method when returning a BrowserAccessibilityWin object as
784 // an output parameter to a COM interface, never use it otherwise.
785 BrowserAccessibilityWin* NewReference();
787 // Many MSAA methods take a var_id parameter indicating that the operation
788 // should be performed on a particular child ID, rather than this object.
789 // This method tries to figure out the target object from |var_id| and
790 // returns a pointer to the target object if it exists, otherwise NULL.
791 // Does not return a new reference.
792 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id);
794 // Initialize the role and state metadata from the role enum and state
795 // bitmasks defined in AccessibilityNodeData.
796 void InitRoleAndState();
798 // Retrieve the value of an attribute from the string attribute map and
799 // if found and nonempty, allocate a new BSTR (with SysAllocString)
800 // and return S_OK. If not found or empty, return S_FALSE.
801 HRESULT GetStringAttributeAsBstr(
802 AccessibilityNodeData::StringAttribute attribute,
805 // If the string attribute |attribute| is present, add its value as an
806 // IAccessible2 attribute with the name |ia2_attr|.
807 void StringAttributeToIA2(AccessibilityNodeData::StringAttribute attribute,
808 const char* ia2_attr);
810 // If the bool attribute |attribute| is present, add its value as an
811 // IAccessible2 attribute with the name |ia2_attr|.
812 void BoolAttributeToIA2(AccessibilityNodeData::BoolAttribute attribute,
813 const char* ia2_attr);
815 // If the int attribute |attribute| is present, add its value as an
816 // IAccessible2 attribute with the name |ia2_attr|.
817 void IntAttributeToIA2(AccessibilityNodeData::IntAttribute attribute,
818 const char* ia2_attr);
820 // Get the value text, which might come from the floating-point
821 // value for some roles.
822 string16 GetValueText();
824 // Get the text of this node for the purposes of IAccessibleText - it may
825 // be the name, it may be the value, etc. depending on the role.
826 string16 TextForIAccessibleText();
828 // If offset is a member of IA2TextSpecialOffsets this function updates the
829 // value of offset and returns, otherwise offset remains unchanged.
830 void HandleSpecialTextOffset(const string16& text, LONG* offset);
832 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
833 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
835 // Search forwards (direction == 1) or backwards (direction == -1)
836 // from the given offset until the given boundary is found, and
837 // return the offset of that boundary.
838 LONG FindBoundary(const string16& text,
839 IA2TextBoundaryType ia2_boundary,
841 ui::TextBoundaryDirection direction);
843 // Return a pointer to the object corresponding to the given renderer_id,
844 // does not make a new reference.
845 BrowserAccessibilityWin* GetFromRendererID(int32 renderer_id);
847 // Windows-specific unique ID (unique within the browser process),
848 // used for get_accChild, NotifyWinEvent, and as the unique ID for
849 // IAccessible2 and ISimpleDOM.
852 // IAccessible role and state.
857 // IAccessible2 role and state.
861 // IAccessible2 attributes.
862 std::vector<string16> ia2_attributes_;
864 // True in Initialize when the object is first created, and false
868 // The previous text, before the last update to this object.
869 string16 previous_text_;
871 // The old text to return in IAccessibleText::get_oldText - this is like
872 // previous_text_ except that it's NOT updated when the object
873 // is initialized again but the text doesn't change.
876 // The previous state, used to see if there was a state change.
879 // Relationships between this node and other nodes.
880 std::vector<BrowserAccessibilityRelation*> relations_;
882 // The text of this node including embedded hyperlink characters.
885 // Maps the |hypertext_| embedded character offset to an index in
887 std::map<int32, int32> hyperlink_offset_to_index_;
889 // Collection of non-static text child indicies, each of which corresponds to
891 std::vector<int32> hyperlinks_;
893 // The next unique id to use.
894 static LONG next_unique_id_win_;
896 // Give BrowserAccessibility::Create access to our constructor.
897 friend class BrowserAccessibility;
898 friend class BrowserAccessibilityRelation;
900 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin);
903 } // namespace content
905 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_