nsIAccessibleText.idl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. typedef long AccessibleTextBoundary;
  8. interface nsIAccessible;
  9. interface nsIArray;
  10. interface nsIPersistentProperties;
  11. interface nsIAccessibleTextRange;
  12. [scriptable, builtinclass, uuid(93ad2ca1-f12b-4ab9-a793-95d9fa9d1774)]
  13. interface nsIAccessibleText : nsISupports
  14. {
  15. // In parameters for character offsets:
  16. // -1 will be treated as the equal to the end of the text
  17. // -2 will be treated as the caret position
  18. const int32_t TEXT_OFFSET_END_OF_TEXT = -1;
  19. const int32_t TEXT_OFFSET_CARET = -2;
  20. const AccessibleTextBoundary BOUNDARY_CHAR = 0;
  21. const AccessibleTextBoundary BOUNDARY_WORD_START = 1;
  22. const AccessibleTextBoundary BOUNDARY_WORD_END = 2;
  23. const AccessibleTextBoundary BOUNDARY_SENTENCE_START = 3; // don't use, deprecated
  24. const AccessibleTextBoundary BOUNDARY_SENTENCE_END = 4; // don't use, deprecated
  25. const AccessibleTextBoundary BOUNDARY_LINE_START = 5;
  26. const AccessibleTextBoundary BOUNDARY_LINE_END = 6;
  27. /**
  28. * The current current caret offset.
  29. * If set < 0 then caret will be placed at the end of the text
  30. */
  31. attribute long caretOffset;
  32. readonly attribute long characterCount;
  33. readonly attribute long selectionCount;
  34. /**
  35. * String methods may need to return multibyte-encoded strings,
  36. * since some locales can't be encoded using 16-bit chars.
  37. * So the methods below might return UTF-16 strings, or they could
  38. * return "string" values which are UTF-8.
  39. */
  40. AString getText (in long startOffset, in long endOffset);
  41. AString getTextAfterOffset (in long offset,
  42. in AccessibleTextBoundary boundaryType,
  43. out long startOffset,
  44. out long endOffset);
  45. AString getTextAtOffset (in long offset,
  46. in AccessibleTextBoundary boundaryType,
  47. out long startOffset,
  48. out long endOffset);
  49. AString getTextBeforeOffset (in long offset,
  50. in AccessibleTextBoundary boundaryType,
  51. out long startOffset,
  52. out long endOffset);
  53. /**
  54. * It would be better to return an unsigned long here,
  55. * to allow unicode chars > 16 bits
  56. */
  57. wchar getCharacterAtOffset (in long offset);
  58. /**
  59. * Get the accessible start/end offsets around the given offset,
  60. * return the text attributes for this range of text.
  61. *
  62. * @param includeDefAttrs [in] points whether text attributes applied to
  63. * the entire accessible should be included or not.
  64. * @param offset [in] text offset
  65. * @param rangeStartOffset [out] start offset of the range of text
  66. * @param rangeEndOffset [out] end offset of the range of text
  67. */
  68. nsIPersistentProperties getTextAttributes(in boolean includeDefAttrs,
  69. in long offset,
  70. out long rangeStartOffset,
  71. out long rangeEndOffset);
  72. /**
  73. * Return the text attributes that apply to the entire accessible.
  74. */
  75. readonly attribute nsIPersistentProperties defaultTextAttributes;
  76. /**
  77. * Returns the bounding box of the specified position.
  78. *
  79. * The virtual character after the last character of the represented text,
  80. * i.e. the one at position length is a special case. It represents the
  81. * current input position and will therefore typically be queried by AT more
  82. * often than other positions. Because it does not represent an existing
  83. * character its bounding box is defined in relation to preceding characters.
  84. * It should be roughly equivalent to the bounding box of some character when
  85. * inserted at the end of the text. Its height typically being the maximal
  86. * height of all the characters in the text or the height of the preceding
  87. * character, its width being at least one pixel so that the bounding box is
  88. * not degenerate.
  89. *
  90. * @param offset - Index of the character for which to return its bounding
  91. * box. The valid range is 0..length.
  92. * @param x - X coordinate of the bounding box of the referenced character.
  93. * @param y - Y coordinate of the bounding box of the referenced character.
  94. * @param width - Width of the bounding box of the referenced character.
  95. * @param height - Height of the bounding box of the referenced character.
  96. * @param coordType - Specifies if the coordinates are relative to the screen
  97. * or to the parent window (see constants declared in
  98. * nsIAccessibleCoordinateType).
  99. */
  100. void getCharacterExtents (in long offset,
  101. out long x,
  102. out long y,
  103. out long width,
  104. out long height,
  105. in unsigned long coordType);
  106. void getRangeExtents (in long startOffset,
  107. in long endOffset,
  108. out long x,
  109. out long y,
  110. out long width,
  111. out long height,
  112. in unsigned long coordType);
  113. /**
  114. * Get the text offset at the given point, or return -1
  115. * if no character exists at that point
  116. *
  117. * @param x - The position's x value for which to look up the index of the
  118. * character that is rendered on to the display at that point.
  119. * @param y - The position's y value for which to look up the index of the
  120. * character that is rendered on to the display at that point.
  121. * @param coordType - Screen coordinates or window coordinates (see constants
  122. * declared in nsIAccessibleCoordinateType).
  123. * @return offset - Index of the character under the given point or -1 if
  124. * the point is invalid or there is no character under
  125. * the point.
  126. */
  127. long getOffsetAtPoint (in long x, in long y,
  128. in unsigned long coordType);
  129. void getSelectionBounds (in long selectionNum,
  130. out long startOffset,
  131. out long endOffset);
  132. /**
  133. * Set the bounds for the given selection range
  134. */
  135. void setSelectionBounds (in long selectionNum,
  136. in long startOffset,
  137. in long endOffset);
  138. void addSelection (in long startOffset, in long endOffset);
  139. void removeSelection (in long selectionNum);
  140. /**
  141. * Makes a specific part of string visible on screen.
  142. *
  143. * @param startIndex 0-based character offset
  144. * @param endIndex 0-based character offset - the offset of the
  145. * character just past the last character of the
  146. * string
  147. * @param scrollType defines how to scroll (see nsIAccessibleScrollType for
  148. * available constants)
  149. */
  150. void scrollSubstringTo(in long startIndex, in long endIndex,
  151. in unsigned long scrollType);
  152. /**
  153. * Moves the top left of a substring to a specified location.
  154. *
  155. * @param startIndex 0-based character offset
  156. * @param endIndex 0-based character offset - the offset of the
  157. * character just past the last character of
  158. * the string
  159. * @param coordinateType specifies the coordinates origin (for available
  160. * constants refer to nsIAccessibleCoordinateType)
  161. * @param x defines the x coordinate
  162. * @param y defines the y coordinate
  163. */
  164. void scrollSubstringToPoint(in long startIndex, in long endIndex,
  165. in unsigned long coordinateType,
  166. in long x, in long y);
  167. /**
  168. * Return a range that encloses this text control or otherwise the document
  169. * this text accessible belongs to.
  170. */
  171. readonly attribute nsIAccessibleTextRange enclosingRange;
  172. /**
  173. * Return an array of disjoint ranges for selected text within the text control
  174. * or otherwise the document this accessible belongs to.
  175. */
  176. readonly attribute nsIArray selectionRanges;
  177. /**
  178. * Return an array of disjoint ranges of visible text within the text control
  179. * or otherwise the document this accessible belongs to.
  180. */
  181. readonly attribute nsIArray visibleRanges;
  182. /**
  183. * Return a range containing the given accessible.
  184. */
  185. nsIAccessibleTextRange getRangeByChild(in nsIAccessible child);
  186. /**
  187. * Return a range containing an accessible at the given point.
  188. */
  189. nsIAccessibleTextRange getRangeAtPoint(in long x, in long y);
  190. };
  191. /*
  192. Assumptions:
  193. Using wstring (UCS2) instead of string encoded in UTF-8.
  194. Multibyte encodings (or at least potentially multi-byte
  195. encodings) would be preferred for the reasons cited above.
  196. The following methods will throw an exception on failure
  197. (since not every text component will allow every operation):
  198. setSelectionBounds, addSelection, removeSelection, setCaretOffset.
  199. we assume that all text components support the idea of
  200. a caret offset, whether visible or "virtual". If this
  201. isn't the case, caretOffset can be made readonly and
  202. a setCaretOffset method provided which throws an exception
  203. on failure (as with *selection methods above).
  204. */