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