tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ia2AccessibleText.h (13001B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:expandtab:shiftwidth=2:tabstop=2:
      3 */
      4 /* This Source Code Form is subject to the terms of the Mozilla Public
      5 * License, v. 2.0. If a copy of the MPL was not distributed with this
      6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      7 
      8 #ifndef _ACCESSIBLE_TEXT_H
      9 #define _ACCESSIBLE_TEXT_H
     10 
     11 #include "AccessibleText.h"
     12 #include "nsIAccessibleText.h"
     13 
     14 namespace mozilla {
     15 template <class T>
     16 class StaticAutoPtr;
     17 template <class T>
     18 class StaticRefPtr;
     19 
     20 namespace a11y {
     21 class HyperTextAccessibleBase;
     22 
     23 class ia2AccessibleText : public IAccessibleText {
     24 public:
     25  // IAccessibleText
     26  virtual HRESULT STDMETHODCALLTYPE addSelection(
     27      /* [in] */ long startOffset,
     28      /* [in] */ long endOffset);
     29 
     30  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
     31      /* [in] */ long offset,
     32      /* [out] */ long* startOffset,
     33      /* [out] */ long* endOffset,
     34      /* [retval][out] */ BSTR* textAttributes);
     35 
     36  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_caretOffset(
     37      /* [retval][out] */ long* offset);
     38 
     39  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_characterExtents(
     40      /* [in] */ long offset,
     41      /* [in] */ enum IA2CoordinateType coordType,
     42      /* [out] */ long* x,
     43      /* [out] */ long* y,
     44      /* [out] */ long* width,
     45      /* [retval][out] */ long* height);
     46 
     47  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nSelections(
     48      /* [retval][out] */ long* nSelections);
     49 
     50  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_offsetAtPoint(
     51      /* [in] */ long x,
     52      /* [in] */ long y,
     53      /* [in] */ enum IA2CoordinateType coordType,
     54      /* [retval][out] */ long* offset);
     55 
     56  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selection(
     57      /* [in] */ long selectionIndex,
     58      /* [out] */ long* startOffset,
     59      /* [retval][out] */ long* endOffset);
     60 
     61  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_text(
     62      /* [in] */ long startOffset,
     63      /* [in] */ long endOffset,
     64      /* [retval][out] */ BSTR* text);
     65 
     66  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_textBeforeOffset(
     67      /* [in] */ long offset,
     68      /* [in] */ enum IA2TextBoundaryType boundaryType,
     69      /* [out] */ long* startOffset,
     70      /* [out] */ long* endOffset,
     71      /* [retval][out] */ BSTR* text);
     72 
     73  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_textAfterOffset(
     74      /* [in] */ long offset,
     75      /* [in] */ enum IA2TextBoundaryType boundaryType,
     76      /* [out] */ long* startOffset,
     77      /* [out] */ long* endOffset,
     78      /* [retval][out] */ BSTR* text);
     79 
     80  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_textAtOffset(
     81      /* [in] */ long offset,
     82      /* [in] */ enum IA2TextBoundaryType boundaryType,
     83      /* [out] */ long* startOffset,
     84      /* [out] */ long* endOffset,
     85      /* [retval][out] */ BSTR* text);
     86 
     87  virtual HRESULT STDMETHODCALLTYPE removeSelection(
     88      /* [in] */ long selectionIndex);
     89 
     90  virtual HRESULT STDMETHODCALLTYPE setCaretOffset(
     91      /* [in] */ long offset);
     92 
     93  virtual HRESULT STDMETHODCALLTYPE setSelection(
     94      /* [in] */ long selectionIndex,
     95      /* [in] */ long startOffset,
     96      /* [in] */ long endOffset);
     97 
     98  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nCharacters(
     99      /* [retval][out] */ long* nCharacters);
    100 
    101  virtual HRESULT STDMETHODCALLTYPE scrollSubstringTo(
    102      /* [in] */ long startIndex,
    103      /* [in] */ long endIndex,
    104      /* [in] */ enum IA2ScrollType scrollType);
    105 
    106  virtual HRESULT STDMETHODCALLTYPE scrollSubstringToPoint(
    107      /* [in] */ long startIndex,
    108      /* [in] */ long endIndex,
    109      /* [in] */ enum IA2CoordinateType coordinateType,
    110      /* [in] */ long x,
    111      /* [in] */ long y);
    112 
    113  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_newText(
    114      /* [retval][out] */ IA2TextSegment* newText);
    115 
    116  virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_oldText(
    117      /* [retval][out] */ IA2TextSegment* oldText);
    118 
    119  static void InitTextChangeData();
    120  static void UpdateTextChangeData(HyperTextAccessibleBase* aAcc, bool aInsert,
    121                                   const nsAString& aStr, int32_t aStart,
    122                                   uint32_t aLen);
    123 
    124 protected:
    125  // This can't be a RefPtr because RemoteAccessibles aren't ref counted. It
    126  // can't be an id because this is global and ids are only unique within the
    127  // document. Since this is only used for comparison, we use a raw pointer.
    128  // This should *never* be dereferenced, only used for comparison!
    129  static HyperTextAccessibleBase* sLastTextChangeAcc;
    130  static StaticAutoPtr<nsString> sLastTextChangeString;
    131  static bool sLastTextChangeWasInsert;
    132  static uint32_t sLastTextChangeStart;
    133  static uint32_t sLastTextChangeEnd;
    134 
    135 private:
    136  HRESULT GetModifiedText(bool aGetInsertedText, IA2TextSegment* aNewText);
    137  AccessibleTextBoundary GetGeckoTextBoundary(
    138      enum IA2TextBoundaryType coordinateType);
    139  HyperTextAccessibleBase* TextAcc();
    140 };
    141 
    142 }  // namespace a11y
    143 }  // namespace mozilla
    144 
    145 #define FORWARD_IACCESSIBLETEXT(Class)                                         \
    146  virtual HRESULT STDMETHODCALLTYPE addSelection(long startOffset,             \
    147                                                 long endOffset) {             \
    148    return Class::addSelection(startOffset, endOffset);                        \
    149  }                                                                            \
    150                                                                               \
    151  virtual HRESULT STDMETHODCALLTYPE get_attributes(                            \
    152      long offset, long* startOffset, long* endOffset, BSTR* textAttributes) { \
    153    return Class::get_attributes(offset, startOffset, endOffset,               \
    154                                 textAttributes);                              \
    155  }                                                                            \
    156                                                                               \
    157  virtual HRESULT STDMETHODCALLTYPE get_caretOffset(long* offset) {            \
    158    return Class::get_caretOffset(offset);                                     \
    159  }                                                                            \
    160                                                                               \
    161  virtual HRESULT STDMETHODCALLTYPE get_characterExtents(                      \
    162      long offset, enum IA2CoordinateType coordType, long* x, long* y,         \
    163      long* width, long* height) {                                             \
    164    return Class::get_characterExtents(offset, coordType, x, y, width,         \
    165                                       height);                                \
    166  }                                                                            \
    167                                                                               \
    168  virtual HRESULT STDMETHODCALLTYPE get_nSelections(long* nSelections) {       \
    169    return Class::get_nSelections(nSelections);                                \
    170  }                                                                            \
    171                                                                               \
    172  virtual HRESULT STDMETHODCALLTYPE get_offsetAtPoint(                         \
    173      long x, long y, enum IA2CoordinateType coordType, long* offset) {        \
    174    return Class::get_offsetAtPoint(x, y, coordType, offset);                  \
    175  }                                                                            \
    176                                                                               \
    177  virtual HRESULT STDMETHODCALLTYPE get_selection(                             \
    178      long selectionIndex, long* startOffset, long* endOffset) {               \
    179    return Class::get_selection(selectionIndex, startOffset, endOffset);       \
    180  }                                                                            \
    181                                                                               \
    182  virtual HRESULT STDMETHODCALLTYPE get_text(long startOffset, long endOffset, \
    183                                             BSTR* text) {                     \
    184    return Class::get_text(startOffset, endOffset, text);                      \
    185  }                                                                            \
    186                                                                               \
    187  virtual HRESULT STDMETHODCALLTYPE get_textBeforeOffset(                      \
    188      long offset, enum IA2TextBoundaryType boundaryType, long* startOffset,   \
    189      long* endOffset, BSTR* text) {                                           \
    190    return Class::get_textBeforeOffset(offset, boundaryType, startOffset,      \
    191                                       endOffset, text);                       \
    192  }                                                                            \
    193                                                                               \
    194  virtual HRESULT STDMETHODCALLTYPE get_textAfterOffset(                       \
    195      long offset, enum IA2TextBoundaryType boundaryType, long* startOffset,   \
    196      long* endOffset, BSTR* text) {                                           \
    197    return Class::get_textAfterOffset(offset, boundaryType, startOffset,       \
    198                                      endOffset, text);                        \
    199  }                                                                            \
    200                                                                               \
    201  virtual HRESULT STDMETHODCALLTYPE get_textAtOffset(                          \
    202      long offset, enum IA2TextBoundaryType boundaryType, long* startOffset,   \
    203      long* endOffset, BSTR* text) {                                           \
    204    return Class::get_textAtOffset(offset, boundaryType, startOffset,          \
    205                                   endOffset, text);                           \
    206  }                                                                            \
    207                                                                               \
    208  virtual HRESULT STDMETHODCALLTYPE removeSelection(long selectionIndex) {     \
    209    return Class::removeSelection(selectionIndex);                             \
    210  }                                                                            \
    211                                                                               \
    212  virtual HRESULT STDMETHODCALLTYPE setCaretOffset(long offset) {              \
    213    return Class::setCaretOffset(offset);                                      \
    214  }                                                                            \
    215                                                                               \
    216  virtual HRESULT STDMETHODCALLTYPE setSelection(                              \
    217      long selectionIndex, long startOffset, long endOffset) {                 \
    218    return Class::setSelection(selectionIndex, startOffset, endOffset);        \
    219  }                                                                            \
    220                                                                               \
    221  virtual HRESULT STDMETHODCALLTYPE get_nCharacters(long* nCharacters) {       \
    222    return Class::get_nCharacters(nCharacters);                                \
    223  }                                                                            \
    224                                                                               \
    225  virtual HRESULT STDMETHODCALLTYPE scrollSubstringTo(                         \
    226      long startIndex, long endIndex, enum IA2ScrollType scrollType) {         \
    227    return Class::scrollSubstringTo(startIndex, endIndex, scrollType);         \
    228  }                                                                            \
    229                                                                               \
    230  virtual HRESULT STDMETHODCALLTYPE scrollSubstringToPoint(                    \
    231      long startIndex, long endIndex, enum IA2CoordinateType coordinateType,   \
    232      long x, long y) {                                                        \
    233    return Class::scrollSubstringToPoint(startIndex, endIndex, coordinateType, \
    234                                         x, y);                                \
    235  }                                                                            \
    236                                                                               \
    237  virtual HRESULT STDMETHODCALLTYPE get_newText(IA2TextSegment* newText) {     \
    238    return Class::get_newText(newText);                                        \
    239  }                                                                            \
    240                                                                               \
    241  virtual HRESULT STDMETHODCALLTYPE get_oldText(IA2TextSegment* oldText) {     \
    242    return Class::get_oldText(oldText);                                        \
    243  }
    244 
    245 #endif