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