Home | History | Annotate | Download | only in accessibility
      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, base::string16> role_string_map;
     90   static std::map<int32, base::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_characterExtents(
    449       LONG offset,
    450       enum IA2CoordinateType coord_type,
    451       LONG* out_x,
    452       LONG* out_y,
    453       LONG* out_width,
    454       LONG* out_height);
    455 
    456   CONTENT_EXPORT STDMETHODIMP get_nSelections(LONG* n_selections);
    457 
    458   CONTENT_EXPORT STDMETHODIMP get_selection(LONG selection_index,
    459                                             LONG* start_offset,
    460                                             LONG* end_offset);
    461 
    462   CONTENT_EXPORT STDMETHODIMP get_text(LONG start_offset,
    463                                        LONG end_offset,
    464                                        BSTR* text);
    465 
    466   CONTENT_EXPORT STDMETHODIMP get_textAtOffset(
    467       LONG offset,
    468       enum IA2TextBoundaryType boundary_type,
    469       LONG* start_offset,
    470       LONG* end_offset,
    471       BSTR* text);
    472 
    473   CONTENT_EXPORT STDMETHODIMP get_textBeforeOffset(
    474       LONG offset,
    475       enum IA2TextBoundaryType boundary_type,
    476       LONG* start_offset,
    477       LONG* end_offset,
    478       BSTR* text);
    479 
    480   CONTENT_EXPORT STDMETHODIMP get_textAfterOffset(
    481       LONG offset,
    482       enum IA2TextBoundaryType boundary_type,
    483       LONG* start_offset,
    484       LONG* end_offset,
    485       BSTR* text);
    486 
    487   CONTENT_EXPORT STDMETHODIMP get_newText(IA2TextSegment* new_text);
    488 
    489   CONTENT_EXPORT STDMETHODIMP get_oldText(IA2TextSegment* old_text);
    490 
    491   CONTENT_EXPORT STDMETHODIMP get_offsetAtPoint(
    492       LONG x,
    493       LONG y,
    494       enum IA2CoordinateType coord_type,
    495       LONG* offset);
    496 
    497   CONTENT_EXPORT STDMETHODIMP scrollSubstringTo(
    498        LONG start_index,
    499        LONG end_index,
    500        enum IA2ScrollType scroll_type);
    501 
    502   CONTENT_EXPORT STDMETHODIMP scrollSubstringToPoint(
    503       LONG start_index,
    504       LONG end_index,
    505       enum IA2CoordinateType coordinate_type,
    506       LONG x, LONG y);
    507 
    508   CONTENT_EXPORT STDMETHODIMP addSelection(LONG start_offset, LONG end_offset);
    509 
    510   CONTENT_EXPORT STDMETHODIMP removeSelection(LONG selection_index);
    511 
    512   CONTENT_EXPORT STDMETHODIMP setCaretOffset(LONG offset);
    513 
    514   CONTENT_EXPORT STDMETHODIMP setSelection(LONG selection_index,
    515                                            LONG start_offset,
    516                                            LONG end_offset);
    517 
    518   // IAccessibleText methods not implemented.
    519   CONTENT_EXPORT STDMETHODIMP get_attributes(LONG offset, LONG* start_offset,
    520                                              LONG* end_offset,
    521                                              BSTR* text_attributes) {
    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* out_x,
    686       int* out_y,
    687       int* out_width,
    688       int* out_height);
    689 
    690   CONTENT_EXPORT STDMETHODIMP get_unclippedSubstringBounds(
    691       unsigned int start_index,
    692       unsigned int end_index,
    693       int* out_x,
    694       int* out_y,
    695       int* out_width,
    696       int* out_height);
    697 
    698   CONTENT_EXPORT STDMETHODIMP scrollToSubstring(unsigned int start_index,
    699                                                 unsigned int end_index);
    700 
    701   CONTENT_EXPORT STDMETHODIMP get_fontFamily(BSTR *font_family)  {
    702     return E_NOTIMPL;
    703   }
    704 
    705   //
    706   // IServiceProvider methods.
    707   //
    708 
    709   CONTENT_EXPORT STDMETHODIMP QueryService(REFGUID guidService,
    710                                            REFIID riid,
    711                                            void** object);
    712 
    713   // IAccessibleEx methods not implemented.
    714   CONTENT_EXPORT STDMETHODIMP GetObjectForChild(long child_id,
    715                                                 IAccessibleEx** ret) {
    716     return E_NOTIMPL;
    717   }
    718 
    719   CONTENT_EXPORT STDMETHODIMP GetIAccessiblePair(IAccessible** acc,
    720                                                  long* child_id) {
    721     return E_NOTIMPL;
    722   }
    723 
    724   CONTENT_EXPORT STDMETHODIMP GetRuntimeId(SAFEARRAY** runtime_id) {
    725     return E_NOTIMPL;
    726   }
    727 
    728   CONTENT_EXPORT STDMETHODIMP ConvertReturnedElement(
    729       IRawElementProviderSimple* element,
    730       IAccessibleEx** acc) {
    731     return E_NOTIMPL;
    732   }
    733 
    734   //
    735   // IRawElementProviderSimple methods.
    736   //
    737   // The GetPatternProvider/GetPropertyValue methods need to be implemented for
    738   // the on-screen keyboard to show up in Windows 8 metro.
    739   CONTENT_EXPORT STDMETHODIMP GetPatternProvider(PATTERNID id,
    740                                                  IUnknown** provider);
    741   CONTENT_EXPORT STDMETHODIMP GetPropertyValue(PROPERTYID id, VARIANT* ret);
    742 
    743   //
    744   // IRawElementProviderSimple methods not implemented
    745   //
    746   CONTENT_EXPORT STDMETHODIMP get_ProviderOptions(enum ProviderOptions* ret) {
    747     return E_NOTIMPL;
    748   }
    749 
    750   CONTENT_EXPORT STDMETHODIMP get_HostRawElementProvider(
    751       IRawElementProviderSimple** provider) {
    752     return E_NOTIMPL;
    753   }
    754 
    755   //
    756   // CComObjectRootEx methods.
    757   //
    758 
    759   CONTENT_EXPORT HRESULT WINAPI InternalQueryInterface(
    760       void* this_ptr,
    761       const _ATL_INTMAP_ENTRY* entries,
    762       REFIID iid,
    763       void** object);
    764 
    765   // Accessors.
    766   int32 ia_role() const { return ia_role_; }
    767   int32 ia_state() const { return ia_state_; }
    768   const base::string16& role_name() const { return role_name_; }
    769   int32 ia2_role() const { return ia2_role_; }
    770   int32 ia2_state() const { return ia2_state_; }
    771   const std::vector<base::string16>& ia2_attributes() const {
    772     return ia2_attributes_;
    773   }
    774 
    775   // BrowserAccessibility::role is shadowed by IAccessible2::role, so
    776   // we provide an alias for it.
    777   int32 blink_role() const { return BrowserAccessibility::role(); }
    778 
    779  private:
    780   // Add one to the reference count and return the same object. Always
    781   // use this method when returning a BrowserAccessibilityWin object as
    782   // an output parameter to a COM interface, never use it otherwise.
    783   BrowserAccessibilityWin* NewReference();
    784 
    785   // Many MSAA methods take a var_id parameter indicating that the operation
    786   // should be performed on a particular child ID, rather than this object.
    787   // This method tries to figure out the target object from |var_id| and
    788   // returns a pointer to the target object if it exists, otherwise NULL.
    789   // Does not return a new reference.
    790   BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id);
    791 
    792   // Initialize the role and state metadata from the role enum and state
    793   // bitmasks defined in AccessibilityNodeData.
    794   void InitRoleAndState();
    795 
    796   // Retrieve the value of an attribute from the string attribute map and
    797   // if found and nonempty, allocate a new BSTR (with SysAllocString)
    798   // and return S_OK. If not found or empty, return S_FALSE.
    799   HRESULT GetStringAttributeAsBstr(
    800       AccessibilityNodeData::StringAttribute attribute,
    801       BSTR* value_bstr);
    802 
    803   // If the string attribute |attribute| is present, add its value as an
    804   // IAccessible2 attribute with the name |ia2_attr|.
    805   void StringAttributeToIA2(AccessibilityNodeData::StringAttribute attribute,
    806                             const char* ia2_attr);
    807 
    808   // If the bool attribute |attribute| is present, add its value as an
    809   // IAccessible2 attribute with the name |ia2_attr|.
    810   void BoolAttributeToIA2(AccessibilityNodeData::BoolAttribute attribute,
    811                           const char* ia2_attr);
    812 
    813   // If the int attribute |attribute| is present, add its value as an
    814   // IAccessible2 attribute with the name |ia2_attr|.
    815   void IntAttributeToIA2(AccessibilityNodeData::IntAttribute attribute,
    816                          const char* ia2_attr);
    817 
    818   // Get the value text, which might come from the floating-point
    819   // value for some roles.
    820   base::string16 GetValueText();
    821 
    822   // Get the text of this node for the purposes of IAccessibleText - it may
    823   // be the name, it may be the value, etc. depending on the role.
    824   base::string16 TextForIAccessibleText();
    825 
    826   // If offset is a member of IA2TextSpecialOffsets this function updates the
    827   // value of offset and returns, otherwise offset remains unchanged.
    828   void HandleSpecialTextOffset(const base::string16& text, LONG* offset);
    829 
    830   // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
    831   ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
    832 
    833   // Search forwards (direction == 1) or backwards (direction == -1)
    834   // from the given offset until the given boundary is found, and
    835   // return the offset of that boundary.
    836   LONG FindBoundary(const base::string16& text,
    837                     IA2TextBoundaryType ia2_boundary,
    838                     LONG start_offset,
    839                     ui::TextBoundaryDirection direction);
    840 
    841   // Return a pointer to the object corresponding to the given renderer_id,
    842   // does not make a new reference.
    843   BrowserAccessibilityWin* GetFromRendererID(int32 renderer_id);
    844 
    845   // Windows-specific unique ID (unique within the browser process),
    846   // used for get_accChild, NotifyWinEvent, and as the unique ID for
    847   // IAccessible2 and ISimpleDOM.
    848   LONG unique_id_win_;
    849 
    850   // IAccessible role and state.
    851   int32 ia_role_;
    852   int32 ia_state_;
    853   base::string16 role_name_;
    854 
    855   // IAccessible2 role and state.
    856   int32 ia2_role_;
    857   int32 ia2_state_;
    858 
    859   // IAccessible2 attributes.
    860   std::vector<base::string16> ia2_attributes_;
    861 
    862   // True in Initialize when the object is first created, and false
    863   // subsequent times.
    864   bool first_time_;
    865 
    866   // The previous text, before the last update to this object.
    867   base::string16 previous_text_;
    868 
    869   // The old text to return in IAccessibleText::get_oldText - this is like
    870   // previous_text_ except that it's NOT updated when the object
    871   // is initialized again but the text doesn't change.
    872   base::string16 old_text_;
    873 
    874   // The previous state, used to see if there was a state change.
    875   int32 old_ia_state_;
    876 
    877   // Relationships between this node and other nodes.
    878   std::vector<BrowserAccessibilityRelation*> relations_;
    879 
    880   // The text of this node including embedded hyperlink characters.
    881   base::string16 hypertext_;
    882 
    883   // Maps the |hypertext_| embedded character offset to an index in
    884   // |hyperlinks_|.
    885   std::map<int32, int32> hyperlink_offset_to_index_;
    886 
    887   // Collection of non-static text child indicies, each of which corresponds to
    888   // a hyperlink.
    889   std::vector<int32> hyperlinks_;
    890 
    891   // The previous scroll position, so we can tell if this object scrolled.
    892   int previous_scroll_x_;
    893   int previous_scroll_y_;
    894 
    895   // The next unique id to use.
    896   static LONG next_unique_id_win_;
    897 
    898   // Give BrowserAccessibility::Create access to our constructor.
    899   friend class BrowserAccessibility;
    900   friend class BrowserAccessibilityRelation;
    901 
    902   DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin);
    903 };
    904 
    905 }  // namespace content
    906 
    907 #endif  // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_
    908