Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | /* THIS IS A PUBLIC INTERFACE */ |
michael@0 | 9 | |
michael@0 | 10 | interface nsIDOMNode; |
michael@0 | 11 | interface nsIDOMRange; |
michael@0 | 12 | interface nsINode; |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * Interface for manipulating and querying the current selected range |
michael@0 | 16 | * of nodes within the document. |
michael@0 | 17 | * |
michael@0 | 18 | * @version 1.0 |
michael@0 | 19 | */ |
michael@0 | 20 | |
michael@0 | 21 | [scriptable, builtinclass, uuid(e0a4d4b3-f34e-44bd-b1f2-4e3bde9b6915)] |
michael@0 | 22 | interface nsISelection : nsISupports |
michael@0 | 23 | { |
michael@0 | 24 | /** |
michael@0 | 25 | * Returns the node in which the selection begins. |
michael@0 | 26 | */ |
michael@0 | 27 | readonly attribute nsIDOMNode anchorNode; |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * The offset within the (text) node where the selection begins. |
michael@0 | 31 | */ |
michael@0 | 32 | readonly attribute long anchorOffset; |
michael@0 | 33 | |
michael@0 | 34 | /** |
michael@0 | 35 | * Returns the node in which the selection ends. |
michael@0 | 36 | */ |
michael@0 | 37 | readonly attribute nsIDOMNode focusNode; |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * The offset within the (text) node where the selection ends. |
michael@0 | 41 | */ |
michael@0 | 42 | readonly attribute long focusOffset; |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Indicates if the selection is collapsed or not. |
michael@0 | 46 | */ |
michael@0 | 47 | readonly attribute boolean isCollapsed; |
michael@0 | 48 | [noscript,notxpcom,nostdcall] boolean collapsed(); |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Returns the number of ranges in the selection. |
michael@0 | 52 | */ |
michael@0 | 53 | readonly attribute long rangeCount; |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Returns the range at the specified index. |
michael@0 | 57 | */ |
michael@0 | 58 | nsIDOMRange getRangeAt(in long index); |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Collapses the selection to a single point, at the specified offset |
michael@0 | 62 | * in the given DOM node. When the selection is collapsed, and the content |
michael@0 | 63 | * is focused and editable, the caret will blink there. |
michael@0 | 64 | * @param parentNode The given dom node where the selection will be set |
michael@0 | 65 | * @param offset Where in given dom node to place the selection (the offset into the given node) |
michael@0 | 66 | */ |
michael@0 | 67 | void collapse(in nsIDOMNode parentNode, in long offset); |
michael@0 | 68 | [noscript] void collapseNative(in nsINode parentNode, in long offset); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * Extends the selection by moving the selection end to the specified node and offset, |
michael@0 | 72 | * preserving the selection begin position. The new selection end result will always |
michael@0 | 73 | * be from the anchorNode to the new focusNode, regardless of direction. |
michael@0 | 74 | * @param parentNode The node where the selection will be extended to |
michael@0 | 75 | * @param offset Where in node to place the offset in the new selection end |
michael@0 | 76 | */ |
michael@0 | 77 | void extend(in nsIDOMNode parentNode, in long offset); |
michael@0 | 78 | [noscript] void extendNative(in nsINode parentNode, in long offset); |
michael@0 | 79 | |
michael@0 | 80 | /** |
michael@0 | 81 | * Collapses the whole selection to a single point at the start |
michael@0 | 82 | * of the current selection (irrespective of direction). If content |
michael@0 | 83 | * is focused and editable, the caret will blink there. |
michael@0 | 84 | */ |
michael@0 | 85 | void collapseToStart(); |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Collapses the whole selection to a single point at the end |
michael@0 | 89 | * of the current selection (irrespective of direction). If content |
michael@0 | 90 | * is focused and editable, the caret will blink there. |
michael@0 | 91 | */ |
michael@0 | 92 | void collapseToEnd(); |
michael@0 | 93 | |
michael@0 | 94 | /** |
michael@0 | 95 | * Indicates whether the node is part of the selection. If partlyContained |
michael@0 | 96 | * is set to PR_TRUE, the function returns true when some part of the node |
michael@0 | 97 | * is part of the selection. If partlyContained is set to PR_FALSE, the |
michael@0 | 98 | * function only returns true when the entire node is part of the selection. |
michael@0 | 99 | */ |
michael@0 | 100 | boolean containsNode(in nsIDOMNode node, in boolean partlyContained); |
michael@0 | 101 | |
michael@0 | 102 | /** |
michael@0 | 103 | * Adds all children of the specified node to the selection. |
michael@0 | 104 | * @param parentNode the parent of the children to be added to the selection. |
michael@0 | 105 | */ |
michael@0 | 106 | void selectAllChildren(in nsIDOMNode parentNode); |
michael@0 | 107 | |
michael@0 | 108 | /** |
michael@0 | 109 | * Adds a range to the current selection. |
michael@0 | 110 | */ |
michael@0 | 111 | void addRange(in nsIDOMRange range); |
michael@0 | 112 | |
michael@0 | 113 | /** |
michael@0 | 114 | * Removes a range from the current selection. |
michael@0 | 115 | */ |
michael@0 | 116 | void removeRange(in nsIDOMRange range); |
michael@0 | 117 | |
michael@0 | 118 | /** |
michael@0 | 119 | * Removes all ranges from the current selection. |
michael@0 | 120 | */ |
michael@0 | 121 | void removeAllRanges(); |
michael@0 | 122 | |
michael@0 | 123 | /** |
michael@0 | 124 | * Deletes this selection from document the nodes belong to. |
michael@0 | 125 | */ |
michael@0 | 126 | void deleteFromDocument(); |
michael@0 | 127 | |
michael@0 | 128 | /** |
michael@0 | 129 | * Returns the whole selection into a plain text string. |
michael@0 | 130 | */ |
michael@0 | 131 | DOMString toString(); |
michael@0 | 132 | |
michael@0 | 133 | /** |
michael@0 | 134 | * Modifies the selection. Note that the parameters are case-insensitive. |
michael@0 | 135 | * |
michael@0 | 136 | * @param alter can be one of { "move", "extend" } |
michael@0 | 137 | * - "move" collapses the selection to the end of the selection and |
michael@0 | 138 | * applies the movement direction/granularity to the collapsed |
michael@0 | 139 | * selection. |
michael@0 | 140 | * - "extend" leaves the start of the selection unchanged, and applies |
michael@0 | 141 | * movement direction/granularity to the end of the selection. |
michael@0 | 142 | * @param direction can be one of { "forward", "backward", "left", "right" } |
michael@0 | 143 | * @param granularity can be one of { "character", "word", |
michael@0 | 144 | * "line", "lineboundary" } |
michael@0 | 145 | * |
michael@0 | 146 | * @returns NS_ERROR_NOT_IMPLEMENTED if the granularity is "sentence", |
michael@0 | 147 | * "sentenceboundary", "paragraph", "paragraphboundary", or |
michael@0 | 148 | * "documentboundary". Returns NS_ERROR_INVALID_ARG if alter, direction, |
michael@0 | 149 | * or granularity has an unrecognized value. |
michael@0 | 150 | */ |
michael@0 | 151 | void modify(in DOMString alter, in DOMString direction, |
michael@0 | 152 | in DOMString granularity); |
michael@0 | 153 | }; |