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. 4 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ 7 8 #include <atlbase.h> 9 #include <atlcom.h> 10 #include <oleacc.h> 11 #include <UIAutomationCore.h> 12 13 #include <vector> 14 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" 22 23 namespace ui { 24 enum TextBoundaryDirection; 25 enum TextBoundaryType; 26 } 27 28 namespace content { 29 class BrowserAccessibilityRelation; 30 31 //////////////////////////////////////////////////////////////////////////////// 32 // 33 // BrowserAccessibilityWin 34 // 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). 38 // 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() 81 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[]; 86 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; 91 92 CONTENT_EXPORT BrowserAccessibilityWin(); 93 94 CONTENT_EXPORT virtual ~BrowserAccessibilityWin(); 95 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_; } 99 100 // 101 // BrowserAccessibility methods. 102 // 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) 109 OVERRIDE; 110 111 // 112 // IAccessible methods. 113 // 114 115 // Performs the default action on a given object. 116 CONTENT_EXPORT STDMETHODIMP accDoDefaultAction(VARIANT var_id); 117 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, 120 VARIANT* child); 121 122 // Retrieves the specified object's current screen location. 123 CONTENT_EXPORT STDMETHODIMP accLocation(LONG* x_left, 124 LONG* y_top, 125 LONG* width, 126 LONG* height, 127 VARIANT var_id); 128 129 // Traverses to another UI element and retrieves the object. 130 CONTENT_EXPORT STDMETHODIMP accNavigate(LONG nav_dir, VARIANT start, 131 VARIANT* end); 132 133 // Retrieves an IDispatch interface pointer for the specified child. 134 CONTENT_EXPORT STDMETHODIMP get_accChild(VARIANT var_child, 135 IDispatch** disp_child); 136 137 // Retrieves the number of accessible children. 138 CONTENT_EXPORT STDMETHODIMP get_accChildCount(LONG* child_count); 139 140 // Retrieves a string that describes the object's default action. 141 CONTENT_EXPORT STDMETHODIMP get_accDefaultAction(VARIANT var_id, 142 BSTR* default_action); 143 144 // Retrieves the object's description. 145 CONTENT_EXPORT STDMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc); 146 147 // Retrieves the object that has the keyboard focus. 148 CONTENT_EXPORT STDMETHODIMP get_accFocus(VARIANT* focus_child); 149 150 // Retrieves the help information associated with the object. 151 CONTENT_EXPORT STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* heflp); 152 153 // Retrieves the specified object's shortcut. 154 CONTENT_EXPORT STDMETHODIMP get_accKeyboardShortcut(VARIANT var_id, 155 BSTR* access_key); 156 157 // Retrieves the name of the specified object. 158 CONTENT_EXPORT STDMETHODIMP get_accName(VARIANT var_id, BSTR* name); 159 160 // Retrieves the IDispatch interface of the object's parent. 161 CONTENT_EXPORT STDMETHODIMP get_accParent(IDispatch** disp_parent); 162 163 // Retrieves information describing the role of the specified object. 164 CONTENT_EXPORT STDMETHODIMP get_accRole(VARIANT var_id, VARIANT* role); 165 166 // Retrieves the current state of the specified object. 167 CONTENT_EXPORT STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state); 168 169 // Returns the value associated with the object. 170 CONTENT_EXPORT STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value); 171 172 // Make an object take focus or extend the selection. 173 CONTENT_EXPORT STDMETHODIMP accSelect(LONG flags_sel, VARIANT var_id); 174 175 CONTENT_EXPORT STDMETHODIMP get_accHelpTopic(BSTR* help_file, 176 VARIANT var_id, 177 LONG* topic_id); 178 179 CONTENT_EXPORT STDMETHODIMP get_accSelection(VARIANT* selected); 180 181 // Deprecated methods, not implemented. 182 CONTENT_EXPORT STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name) { 183 return E_NOTIMPL; 184 } 185 CONTENT_EXPORT STDMETHODIMP put_accValue(VARIANT var_id, BSTR put_val) { 186 return E_NOTIMPL; 187 } 188 189 // 190 // IAccessible2 methods. 191 // 192 193 // Returns role from a longer list of possible roles. 194 CONTENT_EXPORT STDMETHODIMP role(LONG* role); 195 196 // Returns the state bitmask from a larger set of possible states. 197 CONTENT_EXPORT STDMETHODIMP get_states(AccessibleStates* states); 198 199 // Returns the attributes specific to this IAccessible2 object, 200 // such as a cell's formula. 201 CONTENT_EXPORT STDMETHODIMP get_attributes(BSTR* attributes); 202 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); 206 207 // Get the window handle of the enclosing window. 208 CONTENT_EXPORT STDMETHODIMP get_windowHandle(HWND* window_handle); 209 210 // Get this object's index in its parent object. 211 CONTENT_EXPORT STDMETHODIMP get_indexInParent(LONG* index_in_parent); 212 213 CONTENT_EXPORT STDMETHODIMP get_nRelations(LONG* n_relations); 214 215 CONTENT_EXPORT STDMETHODIMP get_relation(LONG relation_index, 216 IAccessibleRelation** relation); 217 218 CONTENT_EXPORT STDMETHODIMP get_relations(LONG max_relations, 219 IAccessibleRelation** relations, 220 LONG* n_relations); 221 222 CONTENT_EXPORT STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type); 223 224 CONTENT_EXPORT STDMETHODIMP scrollToPoint( 225 enum IA2CoordinateType coordinate_type, 226 LONG x, 227 LONG y); 228 229 CONTENT_EXPORT STDMETHODIMP get_groupPosition(LONG* group_level, 230 LONG* similar_items_in_group, 231 LONG* position_in_group); 232 233 // 234 // IAccessibleEx methods not implemented. 235 // 236 CONTENT_EXPORT STDMETHODIMP get_extendedRole(BSTR* extended_role) { 237 return E_NOTIMPL; 238 } 239 CONTENT_EXPORT STDMETHODIMP get_localizedExtendedRole( 240 BSTR* localized_extended_role) { 241 return E_NOTIMPL; 242 } 243 CONTENT_EXPORT STDMETHODIMP get_nExtendedStates(LONG* n_extended_states) { 244 return E_NOTIMPL; 245 } 246 CONTENT_EXPORT STDMETHODIMP get_extendedStates(LONG max_extended_states, 247 BSTR** extended_states, 248 LONG* n_extended_states) { 249 return E_NOTIMPL; 250 } 251 CONTENT_EXPORT STDMETHODIMP get_localizedExtendedStates( 252 LONG max_localized_extended_states, 253 BSTR** localized_extended_states, 254 LONG* n_localized_extended_states) { 255 return E_NOTIMPL; 256 } 257 CONTENT_EXPORT STDMETHODIMP get_locale(IA2Locale* locale) { 258 return E_NOTIMPL; 259 } 260 261 // 262 // IAccessibleApplication methods. 263 // 264 CONTENT_EXPORT STDMETHODIMP get_appName(BSTR* app_name); 265 266 CONTENT_EXPORT STDMETHODIMP get_appVersion(BSTR* app_version); 267 268 CONTENT_EXPORT STDMETHODIMP get_toolkitName(BSTR* toolkit_name); 269 270 CONTENT_EXPORT STDMETHODIMP get_toolkitVersion(BSTR* toolkit_version); 271 272 // 273 // IAccessibleImage methods. 274 // 275 CONTENT_EXPORT STDMETHODIMP get_description(BSTR* description); 276 277 CONTENT_EXPORT STDMETHODIMP get_imagePosition( 278 enum IA2CoordinateType coordinate_type, 279 LONG* x, 280 LONG* y); 281 282 CONTENT_EXPORT STDMETHODIMP get_imageSize(LONG* height, LONG* width); 283 284 // 285 // IAccessibleTable methods. 286 // 287 288 // get_description - also used by IAccessibleImage 289 290 CONTENT_EXPORT STDMETHODIMP get_accessibleAt(long row, 291 long column, 292 IUnknown** accessible); 293 294 CONTENT_EXPORT STDMETHODIMP get_caption(IUnknown** accessible); 295 296 CONTENT_EXPORT STDMETHODIMP get_childIndex(long row_index, 297 long column_index, 298 long* cell_index); 299 300 CONTENT_EXPORT STDMETHODIMP get_columnDescription(long column, 301 BSTR* description); 302 303 CONTENT_EXPORT STDMETHODIMP get_columnExtentAt(long row, 304 long column, 305 long* n_columns_spanned); 306 307 CONTENT_EXPORT STDMETHODIMP get_columnHeader( 308 IAccessibleTable** accessible_table, 309 long* starting_row_index); 310 311 CONTENT_EXPORT STDMETHODIMP get_columnIndex(long cell_index, 312 long* column_index); 313 314 CONTENT_EXPORT STDMETHODIMP get_nColumns(long* column_count); 315 316 CONTENT_EXPORT STDMETHODIMP get_nRows(long* row_count); 317 318 CONTENT_EXPORT STDMETHODIMP get_nSelectedChildren(long* cell_count); 319 320 CONTENT_EXPORT STDMETHODIMP get_nSelectedColumns(long* column_count); 321 322 CONTENT_EXPORT STDMETHODIMP get_nSelectedRows(long *row_count); 323 324 CONTENT_EXPORT STDMETHODIMP get_rowDescription(long row, 325 BSTR* description); 326 327 CONTENT_EXPORT STDMETHODIMP get_rowExtentAt(long row, 328 long column, 329 long* n_rows_spanned); 330 331 CONTENT_EXPORT STDMETHODIMP get_rowHeader(IAccessibleTable** accessible_table, 332 long* starting_column_index); 333 334 CONTENT_EXPORT STDMETHODIMP get_rowIndex(long cell_index, 335 long* row_index); 336 337 CONTENT_EXPORT STDMETHODIMP get_selectedChildren(long max_children, 338 long** children, 339 long* n_children); 340 341 CONTENT_EXPORT STDMETHODIMP get_selectedColumns(long max_columns, 342 long** columns, 343 long* n_columns); 344 345 CONTENT_EXPORT STDMETHODIMP get_selectedRows(long max_rows, 346 long** rows, 347 long* n_rows); 348 349 CONTENT_EXPORT STDMETHODIMP get_summary(IUnknown** accessible); 350 351 CONTENT_EXPORT STDMETHODIMP get_isColumnSelected(long column, 352 boolean* is_selected); 353 354 CONTENT_EXPORT STDMETHODIMP get_isRowSelected(long row, 355 boolean* is_selected); 356 357 CONTENT_EXPORT STDMETHODIMP get_isSelected(long row, 358 long column, 359 boolean* is_selected); 360 361 CONTENT_EXPORT STDMETHODIMP get_rowColumnExtentsAtIndex(long index, 362 long* row, 363 long* column, 364 long* row_extents, 365 long* column_extents, 366 boolean* is_selected); 367 368 CONTENT_EXPORT STDMETHODIMP selectRow(long row) { 369 return E_NOTIMPL; 370 } 371 372 CONTENT_EXPORT STDMETHODIMP selectColumn(long column) { 373 return E_NOTIMPL; 374 } 375 376 CONTENT_EXPORT STDMETHODIMP unselectRow(long row) { 377 return E_NOTIMPL; 378 } 379 380 CONTENT_EXPORT STDMETHODIMP unselectColumn(long column) { 381 return E_NOTIMPL; 382 } 383 384 CONTENT_EXPORT STDMETHODIMP get_modelChange( 385 IA2TableModelChange* model_change) { 386 return E_NOTIMPL; 387 } 388 389 // 390 // IAccessibleTable2 methods. 391 // 392 // (Most of these are duplicates of IAccessibleTable methods, only the 393 // unique ones are included here.) 394 // 395 396 CONTENT_EXPORT STDMETHODIMP get_cellAt(long row, 397 long column, 398 IUnknown** cell); 399 400 CONTENT_EXPORT STDMETHODIMP get_nSelectedCells(long* cell_count); 401 402 CONTENT_EXPORT STDMETHODIMP get_selectedCells(IUnknown*** cells, 403 long* n_selected_cells); 404 405 CONTENT_EXPORT STDMETHODIMP get_selectedColumns(long** columns, 406 long* n_columns); 407 408 CONTENT_EXPORT STDMETHODIMP get_selectedRows(long** rows, 409 long* n_rows); 410 411 // 412 // IAccessibleTableCell methods. 413 // 414 415 CONTENT_EXPORT STDMETHODIMP get_columnExtent(long* n_columns_spanned); 416 417 CONTENT_EXPORT STDMETHODIMP get_columnHeaderCells( 418 IUnknown*** cell_accessibles, 419 long* n_column_header_cells); 420 421 CONTENT_EXPORT STDMETHODIMP get_columnIndex(long* column_index); 422 423 CONTENT_EXPORT STDMETHODIMP get_rowExtent(long* n_rows_spanned); 424 425 CONTENT_EXPORT STDMETHODIMP get_rowHeaderCells(IUnknown*** cell_accessibles, 426 long* n_row_header_cells); 427 428 CONTENT_EXPORT STDMETHODIMP get_rowIndex(long* row_index); 429 430 CONTENT_EXPORT STDMETHODIMP get_isSelected(boolean* is_selected); 431 432 CONTENT_EXPORT STDMETHODIMP get_rowColumnExtents(long* row, 433 long* column, 434 long* row_extents, 435 long* column_extents, 436 boolean* is_selected); 437 438 CONTENT_EXPORT STDMETHODIMP get_table(IUnknown** table); 439 440 // 441 // IAccessibleText methods. 442 // 443 444 CONTENT_EXPORT STDMETHODIMP get_nCharacters(LONG* n_characters); 445 446 CONTENT_EXPORT STDMETHODIMP get_caretOffset(LONG* offset); 447 448 CONTENT_EXPORT STDMETHODIMP get_nSelections(LONG* n_selections); 449 450 CONTENT_EXPORT STDMETHODIMP get_selection(LONG selection_index, 451 LONG* start_offset, 452 LONG* end_offset); 453 454 CONTENT_EXPORT STDMETHODIMP get_text(LONG start_offset, 455 LONG end_offset, 456 BSTR* text); 457 458 CONTENT_EXPORT STDMETHODIMP get_textAtOffset( 459 LONG offset, 460 enum IA2TextBoundaryType boundary_type, 461 LONG* start_offset, 462 LONG* end_offset, 463 BSTR* text); 464 465 CONTENT_EXPORT STDMETHODIMP get_textBeforeOffset( 466 LONG offset, 467 enum IA2TextBoundaryType boundary_type, 468 LONG* start_offset, 469 LONG* end_offset, 470 BSTR* text); 471 472 CONTENT_EXPORT STDMETHODIMP get_textAfterOffset( 473 LONG offset, 474 enum IA2TextBoundaryType boundary_type, 475 LONG* start_offset, 476 LONG* end_offset, 477 BSTR* text); 478 479 CONTENT_EXPORT STDMETHODIMP get_newText(IA2TextSegment* new_text); 480 481 CONTENT_EXPORT STDMETHODIMP get_oldText(IA2TextSegment* old_text); 482 483 CONTENT_EXPORT STDMETHODIMP get_offsetAtPoint( 484 LONG x, 485 LONG y, 486 enum IA2CoordinateType coord_type, 487 LONG* offset); 488 489 CONTENT_EXPORT STDMETHODIMP scrollSubstringTo( 490 LONG start_index, 491 LONG end_index, 492 enum IA2ScrollType scroll_type); 493 494 CONTENT_EXPORT STDMETHODIMP scrollSubstringToPoint( 495 LONG start_index, 496 LONG end_index, 497 enum IA2CoordinateType coordinate_type, 498 LONG x, LONG y); 499 500 CONTENT_EXPORT STDMETHODIMP addSelection(LONG start_offset, LONG end_offset); 501 502 CONTENT_EXPORT STDMETHODIMP removeSelection(LONG selection_index); 503 504 CONTENT_EXPORT STDMETHODIMP setCaretOffset(LONG offset); 505 506 CONTENT_EXPORT STDMETHODIMP setSelection(LONG selection_index, 507 LONG start_offset, 508 LONG end_offset); 509 510 // IAccessibleText methods not implemented. 511 CONTENT_EXPORT STDMETHODIMP get_attributes(LONG offset, LONG* start_offset, 512 LONG* end_offset, 513 BSTR* text_attributes) { 514 return E_NOTIMPL; 515 } 516 CONTENT_EXPORT STDMETHODIMP get_characterExtents(LONG offset, 517 enum IA2CoordinateType coord_type, 518 LONG* x, 519 LONG* y, 520 LONG* width, 521 LONG* height) { 522 return E_NOTIMPL; 523 } 524 525 // 526 // IAccessibleHypertext methods. 527 // 528 529 CONTENT_EXPORT STDMETHODIMP get_nHyperlinks(long* hyperlink_count); 530 531 CONTENT_EXPORT STDMETHODIMP get_hyperlink(long index, 532 IAccessibleHyperlink** hyperlink); 533 534 CONTENT_EXPORT STDMETHODIMP get_hyperlinkIndex(long char_index, 535 long* hyperlink_index); 536 537 // IAccessibleHyperlink not implemented. 538 CONTENT_EXPORT STDMETHODIMP get_anchor(long index, VARIANT* anchor) { 539 return E_NOTIMPL; 540 } 541 CONTENT_EXPORT STDMETHODIMP get_anchorTarget(long index, 542 VARIANT* anchor_target) { 543 return E_NOTIMPL; 544 } 545 CONTENT_EXPORT STDMETHODIMP get_startIndex( long* index) { 546 return E_NOTIMPL; 547 } 548 CONTENT_EXPORT STDMETHODIMP get_endIndex( long* index) { 549 return E_NOTIMPL; 550 } 551 CONTENT_EXPORT STDMETHODIMP get_valid(boolean* valid) { 552 return E_NOTIMPL; 553 } 554 555 // IAccessibleAction not implemented. 556 CONTENT_EXPORT STDMETHODIMP nActions(long* n_actions) { 557 return E_NOTIMPL; 558 } 559 CONTENT_EXPORT STDMETHODIMP doAction(long action_index) { 560 return E_NOTIMPL; 561 } 562 CONTENT_EXPORT STDMETHODIMP get_description(long action_index, 563 BSTR* description) { 564 return E_NOTIMPL; 565 } 566 CONTENT_EXPORT STDMETHODIMP get_keyBinding(long action_index, 567 long n_max_bindings, 568 BSTR** key_bindings, 569 long* n_bindings) { 570 return E_NOTIMPL; 571 } 572 CONTENT_EXPORT STDMETHODIMP get_name(long action_index, BSTR* name) { 573 return E_NOTIMPL; 574 } 575 CONTENT_EXPORT STDMETHODIMP get_localizedName(long action_index, 576 BSTR* localized_name) { 577 return E_NOTIMPL; 578 } 579 580 // 581 // IAccessibleValue methods. 582 // 583 584 CONTENT_EXPORT STDMETHODIMP get_currentValue(VARIANT* value); 585 586 CONTENT_EXPORT STDMETHODIMP get_minimumValue(VARIANT* value); 587 588 CONTENT_EXPORT STDMETHODIMP get_maximumValue(VARIANT* value); 589 590 CONTENT_EXPORT STDMETHODIMP setCurrentValue(VARIANT new_value); 591 592 // 593 // ISimpleDOMDocument methods. 594 // 595 596 CONTENT_EXPORT STDMETHODIMP get_URL(BSTR* url); 597 598 CONTENT_EXPORT STDMETHODIMP get_title(BSTR* title); 599 600 CONTENT_EXPORT STDMETHODIMP get_mimeType(BSTR* mime_type); 601 602 CONTENT_EXPORT STDMETHODIMP get_docType(BSTR* doc_type); 603 604 CONTENT_EXPORT STDMETHODIMP get_nameSpaceURIForID(short name_space_id, 605 BSTR* name_space_uri) { 606 return E_NOTIMPL; 607 } 608 CONTENT_EXPORT STDMETHODIMP put_alternateViewMediaTypes( 609 BSTR* comma_separated_media_types) { 610 return E_NOTIMPL; 611 } 612 613 // 614 // ISimpleDOMNode methods. 615 // 616 617 CONTENT_EXPORT STDMETHODIMP get_nodeInfo(BSTR* node_name, 618 short* name_space_id, 619 BSTR* node_value, 620 unsigned int* num_children, 621 unsigned int* unique_id, 622 unsigned short* node_type); 623 624 CONTENT_EXPORT STDMETHODIMP get_attributes(unsigned short max_attribs, 625 BSTR* attrib_names, 626 short* name_space_id, 627 BSTR* attrib_values, 628 unsigned short* num_attribs); 629 630 CONTENT_EXPORT STDMETHODIMP get_attributesForNames( 631 unsigned short num_attribs, 632 BSTR* attrib_names, 633 short* name_space_id, 634 BSTR* attrib_values); 635 636 CONTENT_EXPORT STDMETHODIMP get_computedStyle( 637 unsigned short max_style_properties, 638 boolean use_alternate_view, 639 BSTR *style_properties, 640 BSTR *style_values, 641 unsigned short *num_style_properties); 642 643 CONTENT_EXPORT STDMETHODIMP get_computedStyleForProperties( 644 unsigned short num_style_properties, 645 boolean use_alternate_view, 646 BSTR* style_properties, 647 BSTR* style_values); 648 649 CONTENT_EXPORT STDMETHODIMP scrollTo(boolean placeTopLeft); 650 651 CONTENT_EXPORT STDMETHODIMP get_parentNode(ISimpleDOMNode** node); 652 653 CONTENT_EXPORT STDMETHODIMP get_firstChild(ISimpleDOMNode** node); 654 655 CONTENT_EXPORT STDMETHODIMP get_lastChild(ISimpleDOMNode** node); 656 657 CONTENT_EXPORT STDMETHODIMP get_previousSibling(ISimpleDOMNode** node); 658 659 CONTENT_EXPORT STDMETHODIMP get_nextSibling(ISimpleDOMNode** node); 660 661 CONTENT_EXPORT STDMETHODIMP get_childAt(unsigned int child_index, 662 ISimpleDOMNode** node); 663 664 CONTENT_EXPORT STDMETHODIMP get_innerHTML(BSTR* innerHTML) { 665 return E_NOTIMPL; 666 } 667 668 CONTENT_EXPORT STDMETHODIMP get_localInterface(void** local_interface) { 669 return E_NOTIMPL; 670 } 671 672 CONTENT_EXPORT STDMETHODIMP get_language(BSTR* language) { 673 return E_NOTIMPL; 674 } 675 676 // 677 // ISimpleDOMText methods. 678 // 679 680 CONTENT_EXPORT STDMETHODIMP get_domText(BSTR* dom_text); 681 682 CONTENT_EXPORT STDMETHODIMP get_clippedSubstringBounds( 683 unsigned int start_index, 684 unsigned int end_index, 685 int* x, 686 int* y, 687 int* width, 688 int* height) { 689 return E_NOTIMPL; 690 } 691 692 CONTENT_EXPORT STDMETHODIMP get_unclippedSubstringBounds( 693 unsigned int start_index, 694 unsigned int end_index, 695 int* x, 696 int* y, 697 int* width, 698 int* height) { 699 return E_NOTIMPL; 700 } 701 702 CONTENT_EXPORT STDMETHODIMP scrollToSubstring(unsigned int start_index, 703 unsigned int end_index) { 704 return E_NOTIMPL; 705 } 706 707 CONTENT_EXPORT STDMETHODIMP get_fontFamily(BSTR *font_family) { 708 return E_NOTIMPL; 709 } 710 711 // 712 // IServiceProvider methods. 713 // 714 715 CONTENT_EXPORT STDMETHODIMP QueryService(REFGUID guidService, 716 REFIID riid, 717 void** object); 718 719 // IAccessibleEx methods not implemented. 720 CONTENT_EXPORT STDMETHODIMP GetObjectForChild(long child_id, 721 IAccessibleEx** ret) { 722 return E_NOTIMPL; 723 } 724 725 CONTENT_EXPORT STDMETHODIMP GetIAccessiblePair(IAccessible** acc, 726 long* child_id) { 727 return E_NOTIMPL; 728 } 729 730 CONTENT_EXPORT STDMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) { 731 return E_NOTIMPL; 732 } 733 734 CONTENT_EXPORT STDMETHODIMP ConvertReturnedElement( 735 IRawElementProviderSimple* element, 736 IAccessibleEx** acc) { 737 return E_NOTIMPL; 738 } 739 740 // 741 // IRawElementProviderSimple methods. 742 // 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); 748 749 // 750 // IRawElementProviderSimple methods not implemented 751 // 752 CONTENT_EXPORT STDMETHODIMP get_ProviderOptions(enum ProviderOptions* ret) { 753 return E_NOTIMPL; 754 } 755 756 CONTENT_EXPORT STDMETHODIMP get_HostRawElementProvider( 757 IRawElementProviderSimple** provider) { 758 return E_NOTIMPL; 759 } 760 761 // 762 // CComObjectRootEx methods. 763 // 764 765 CONTENT_EXPORT HRESULT WINAPI InternalQueryInterface( 766 void* this_ptr, 767 const _ATL_INTMAP_ENTRY* entries, 768 REFIID iid, 769 void** object); 770 771 // Accessors. 772 int32 ia_role() const { return ia_role_; } 773 int32 ia_state() const { return ia_state_; } 774 int32 ia2_role() const { return ia2_role_; } 775 int32 ia2_state() const { return ia2_state_; } 776 const std::vector<string16>& ia2_attributes() const { 777 return ia2_attributes_; 778 } 779 780 private: 781 // Add one to the reference count and return the same object. Always 782 // use this method when returning a BrowserAccessibilityWin object as 783 // an output parameter to a COM interface, never use it otherwise. 784 BrowserAccessibilityWin* NewReference(); 785 786 // Many MSAA methods take a var_id parameter indicating that the operation 787 // should be performed on a particular child ID, rather than this object. 788 // This method tries to figure out the target object from |var_id| and 789 // returns a pointer to the target object if it exists, otherwise NULL. 790 // Does not return a new reference. 791 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id); 792 793 // Initialize the role and state metadata from the role enum and state 794 // bitmasks defined in AccessibilityNodeData. 795 void InitRoleAndState(); 796 797 // Retrieve the value of an attribute from the string attribute map and 798 // if found and nonempty, allocate a new BSTR (with SysAllocString) 799 // and return S_OK. If not found or empty, return S_FALSE. 800 HRESULT GetStringAttributeAsBstr( 801 AccessibilityNodeData::StringAttribute attribute, 802 BSTR* value_bstr); 803 804 // If the string attribute |attribute| is present, add its value as an 805 // IAccessible2 attribute with the name |ia2_attr|. 806 void StringAttributeToIA2(AccessibilityNodeData::StringAttribute attribute, 807 const char* ia2_attr); 808 809 // If the bool attribute |attribute| is present, add its value as an 810 // IAccessible2 attribute with the name |ia2_attr|. 811 void BoolAttributeToIA2(AccessibilityNodeData::BoolAttribute attribute, 812 const char* ia2_attr); 813 814 // If the int attribute |attribute| is present, add its value as an 815 // IAccessible2 attribute with the name |ia2_attr|. 816 void IntAttributeToIA2(AccessibilityNodeData::IntAttribute attribute, 817 const char* ia2_attr); 818 819 // Get the text of this node for the purposes of IAccessibleText - it may 820 // be the name, it may be the value, etc. depending on the role. 821 const string16& TextForIAccessibleText(); 822 823 // If offset is a member of IA2TextSpecialOffsets this function updates the 824 // value of offset and returns, otherwise offset remains unchanged. 825 void HandleSpecialTextOffset(const string16& text, LONG* offset); 826 827 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType. 828 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); 829 830 // Search forwards (direction == 1) or backwards (direction == -1) 831 // from the given offset until the given boundary is found, and 832 // return the offset of that boundary. 833 LONG FindBoundary(const string16& text, 834 IA2TextBoundaryType ia2_boundary, 835 LONG start_offset, 836 ui::TextBoundaryDirection direction); 837 838 // Return a pointer to the object corresponding to the given renderer_id, 839 // does not make a new reference. 840 BrowserAccessibilityWin* GetFromRendererID(int32 renderer_id); 841 842 // Windows-specific unique ID (unique within the browser process), 843 // used for get_accChild, NotifyWinEvent, and as the unique ID for 844 // IAccessible2 and ISimpleDOM. 845 LONG unique_id_win_; 846 847 // IAccessible role and state. 848 int32 ia_role_; 849 int32 ia_state_; 850 851 // IAccessible2 role and state. 852 int32 ia2_role_; 853 int32 ia2_state_; 854 855 // IAccessible2 attributes. 856 std::vector<string16> ia2_attributes_; 857 858 // True in Initialize when the object is first created, and false 859 // subsequent times. 860 bool first_time_; 861 862 // The previous text, before the last update to this object. 863 string16 previous_text_; 864 865 // The old text to return in IAccessibleText::get_oldText - this is like 866 // previous_text_ except that it's NOT updated when the object 867 // is initialized again but the text doesn't change. 868 string16 old_text_; 869 870 // The previous state, used to see if there was a state change. 871 int32 old_ia_state_; 872 873 // Relationships between this node and other nodes. 874 std::vector<BrowserAccessibilityRelation*> relations_; 875 876 // The text of this node including embedded hyperlink characters. 877 string16 hypertext_; 878 879 // Maps the |hypertext_| embedded character offset to an index in 880 // |hyperlinks_|. 881 std::map<int32, int32> hyperlink_offset_to_index_; 882 883 // Collection of non-static text child indicies, each of which corresponds to 884 // a hyperlink. 885 std::vector<int32> hyperlinks_; 886 887 // The next unique id to use. 888 static LONG next_unique_id_win_; 889 890 // Give BrowserAccessibility::Create access to our constructor. 891 friend class BrowserAccessibility; 892 friend class BrowserAccessibilityRelation; 893 894 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); 895 }; 896 897 } // namespace content 898 899 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ 900