Bug 1750871 - run mochitest-remote on fission everywhere. r=releng-reviewers,aki
[gecko.git] / dom / base / nsISelectionController.idl
blob9838d7ed3053d8b6423fe1ad3d73beadf6722fd2
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsISelectionDisplay.idl"
9 %{C++
10 typedef short SelectionRegion;
11 namespace mozilla {
12 namespace dom {
13 class Selection;
14 } // namespace dom
15 } // namespace mozilla
18 interface nsIContent;
19 interface nsISelectionDisplay;
21 webidl Node;
22 webidl Selection;
24 [builtinclass, scriptable, uuid(3801c9d4-8e69-4bfc-9edb-b58278621f8f)]
25 interface nsISelectionController : nsISelectionDisplay
27 // Begin of RawSelectionType values.
28 const short SELECTION_NONE = 0;
29 // Corresponds to the Selection exposed via window.getSelection() and
30 // document.getSelection().
31 const short SELECTION_NORMAL = 1;
32 // Corresponds to the Selection used for spellchecking in <textarea>s and
33 // "contentEditable" elements.
34 const short SELECTION_SPELLCHECK = 2;
35 const short SELECTION_IME_RAWINPUT = 3;
36 const short SELECTION_IME_SELECTEDRAWTEXT = 4;
37 const short SELECTION_IME_CONVERTEDTEXT = 5;
38 const short SELECTION_IME_SELECTEDCONVERTEDTEXT = 6;
39 // For accessibility API usage
40 const short SELECTION_ACCESSIBILITY = 7;
41 const short SELECTION_FIND = 8;
42 const short SELECTION_URLSECONDARY = 9;
43 const short SELECTION_URLSTRIKEOUT = 10;
44 // End of RawSelectionType values.
45 const short NUM_SELECTIONTYPES = 11;
47 // SelectionRegion values:
48 const short SELECTION_ANCHOR_REGION = 0;
49 const short SELECTION_FOCUS_REGION = 1;
50 const short SELECTION_WHOLE_SELECTION = 2;
51 const short NUM_SELECTION_REGIONS = 3;
53 const short SELECTION_OFF = 0;
54 const short SELECTION_HIDDEN =1;//>HIDDEN displays selection
55 const short SELECTION_ON = 2;
56 const short SELECTION_DISABLED = 3;
57 const short SELECTION_ATTENTION = 4;
59 /**
60 * SetDisplaySelection will set the display mode for the selection. OFF,ON,DISABLED
62 void setDisplaySelection(in short toggle);
64 /**
65 * GetDisplaySelection will get the display mode for the selection. OFF,ON,DISABLED
67 short getDisplaySelection();
69 /**
70 * GetSelection will return the selection that the presentation
71 * shell may implement.
73 * @param aType This will hold the type of selection. This value must be one
74 * of RawSelectionType values.
75 * @param _return will hold the return value
77 [binaryname(GetSelectionFromScript)]
78 Selection getSelection(in short type);
80 /**
81 * Return the selection object corresponding to a selection type.
83 [noscript,nostdcall,notxpcom,binaryname(GetSelection)]
84 Selection getDOMSelection(in short aType);
86 /**
87 * Called when the selection controller should take the focus.
89 * This will take care to hide the previously-focused selection, show this
90 * selection, and repaint both.
92 [noscript,nostdcall,notxpcom]
93 void selectionWillTakeFocus();
95 /**
96 * Called when the selection controller has lost the focus.
98 * This will take care to hide and repaint the selection.
100 [noscript,nostdcall,notxpcom]
101 void selectionWillLoseFocus();
103 const short SCROLL_SYNCHRONOUS = 1<<1;
104 const short SCROLL_FIRST_ANCESTOR_ONLY = 1<<2;
105 const short SCROLL_CENTER_VERTICALLY = 1<<4;
106 const short SCROLL_OVERFLOW_HIDDEN = 1<<5;
107 const short SCROLL_FOR_CARET_MOVE = 1<<6;
110 * ScrollSelectionIntoView scrolls a region of the selection,
111 * so that it is visible in the scrolled view.
113 * @param aType the selection to scroll into view. This value must be one
114 * of RawSelectionType values.
115 * @param aRegion the region inside the selection to scroll into view. //SelectionRegion
116 * @param aFlags the scroll flags. Valid bits include:
117 * SCROLL_SYNCHRONOUS: when set, scrolls the selection into view
118 * before returning. If not set, posts a request which is processed
119 * at some point after the method returns.
120 * SCROLL_FIRST_ANCESTOR_ONLY: if set, only the first ancestor will be scrolled
121 * into view.
122 * SCROLL_OVERFLOW_HIDDEN: if set, scrolls even if the overflow is specified
123 * as hidden.
124 * SCROLL_FOR_CARET_MOVE: set to indicate whether scrolling is in response
125 * to the caret being moved. Does not affect behavior (used for telemetry
126 * purposes only).
128 * Note that if isSynchronous is true, then this might flush the pending
129 * reflow. It's dangerous for some objects. See bug 418470 comment 12.
131 void scrollSelectionIntoView(in short type, in short region, in short flags);
134 * RepaintSelection repaints the selection specified by aType.
136 * @param aType specifies the selection to repaint.
138 void repaintSelection(in short type);
141 * Set the caret as enabled or disabled. An enabled caret will
142 * draw or blink when made visible. A disabled caret will never show up.
143 * Can be called any time.
144 * @param aEnable PR_TRUE to enable caret. PR_FALSE to disable.
145 * @return always NS_OK
148 void setCaretEnabled(in boolean enabled);
151 * Set the caret readonly or not. An readonly caret will
152 * draw but not blink when made visible.
153 * @param aReadOnly PR_TRUE to enable caret. PR_FALSE to disable.
154 * @return always NS_OK
156 void setCaretReadOnly(in boolean readOnly);
159 * Gets the current state of the caret.
160 * @param aEnabled [OUT] set to the current caret state, as set by SetCaretEnabled
161 * @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
162 * else NS_OK
164 boolean getCaretEnabled();
167 * This is true if the caret is enabled, visible, and currently blinking.
168 * This is still true when the caret is enabled, visible, but in its "off"
169 * blink cycle.
171 readonly attribute boolean caretVisible;
174 * Show the caret even in selections. By default the caret is hidden unless the
175 * selection is collapsed. Use this function to show the caret even in selections.
176 * @param aVisibility PR_TRUE to show the caret in selections. PR_FALSE to hide.
177 * @return always NS_OK
179 void setCaretVisibilityDuringSelection(in boolean visibility);
181 /** CharacterMove will move the selection one character forward/backward in the document.
182 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
183 * the "point" of selection that is extended is considered the "focus" point.
184 * or the last point adjusted by the selection.
185 * @param aForward forward or backward if PR_FALSE
186 * @param aExtend should it collapse the selection of extend it?
188 void characterMove(in boolean forward, in boolean extend);
190 /** PhysicalMove will move the selection one "unit" in a given direction
191 * within the document.
192 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
193 * the "point" of selection that is extended is considered the "focus" point.
194 * or the last point adjusted by the selection.
195 * @param aDirection
196 * @param aAmount character/line; word/lineBoundary
197 * @param aExtend should it collapse the selection of extend it?
199 void physicalMove(in short direction, in short amount, in boolean extend);
202 * nsFrameSelection::PhysicalMove depends on the ordering of these values;
203 * do not change without checking there!
205 const short MOVE_LEFT = 0;
206 const short MOVE_RIGHT = 1;
207 const short MOVE_UP = 2;
208 const short MOVE_DOWN = 3;
210 /** WordMove will move the selection one word forward/backward in the document.
211 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
212 * the "point" of selection that is extended is considered the "focus" point.
213 * or the last point adjusted by the selection.
214 * @param aForward forward or backward if PR_FALSE
215 * @param aExtend should it collapse the selection of extend it?
218 void wordMove(in boolean forward, in boolean extend);
220 /** LineMove will move the selection one line forward/backward in the document.
221 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
222 * the "point" of selection that is extended is considered the "focus" point.
223 * or the last point adjusted by the selection.
224 * @param aForward forward or backward if PR_FALSE
225 * @param aExtend should it collapse the selection of extend it?
227 void lineMove(in boolean forward, in boolean extend);
229 /** IntraLineMove will move the selection to the front of the line or end of the line
230 * in the document.
231 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
232 * the "point" of selection that is extended is considered the "focus" point.
233 * or the last point adjusted by the selection.
234 * @param aForward forward or backward if PR_FALSE
235 * @param aExtend should it collapse the selection of extend it?
237 void intraLineMove(in boolean forward, in boolean extend);
239 /** PageMove will move the selection one page forward/backward in the document.
240 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
241 * the "point" of selection that is extended is considered the "focus" point.
242 * or the last point adjusted by the selection.
243 * @param aForward forward or backward if PR_FALSE
244 * @param aExtend should it collapse the selection of extend it?
246 [can_run_script]
247 void pageMove(in boolean forward, in boolean extend);
249 /** CompleteScroll will move page view to the top or bottom of the document
250 * @param aForward forward or backward if PR_FALSE
252 void completeScroll(in boolean forward);
254 /** CompleteMove will move page view to the top or bottom of the document
255 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
256 * the "point" of selection that is extended is considered the "focus" point.
257 * or the last point adjusted by the selection.
258 * @param aForward forward or backward if PR_FALSE
259 * @param aExtend should it collapse the selection of extend it?
261 [can_run_script]
262 void completeMove(in boolean forward, in boolean extend);
265 /** ScrollPage will scroll the page without affecting the selection.
266 * @param aForward scroll forward or backwards in selection
268 void scrollPage(in boolean forward);
270 /** ScrollLine will scroll line up or down dependent on the boolean
271 * @param aForward scroll forward or backwards in selection
273 void scrollLine(in boolean forward);
275 /** ScrollCharacter will scroll right or left dependent on the boolean
276 * @param aRight if true will scroll right. if not will scroll left.
278 void scrollCharacter(in boolean right);
280 /** CheckVisibility will return true if textnode and offsets are actually rendered
281 * in the current precontext.
282 * @param aNode textNode to test
283 * @param aStartOffset offset in dom to first char of textnode to test
284 * @param aEndOffset offset in dom to last char of textnode to test
285 * @param aReturnBool boolean returned TRUE if visible FALSE if not
287 boolean checkVisibility(in Node node, in short startOffset, in short endOffset);
288 [noscript,nostdcall] boolean checkVisibilityContent(in nsIContent node, in short startOffset, in short endOffset);
290 %{ C++
291 #define NS_ISELECTIONCONTROLLER_CID \
292 { 0x513b9460, 0xd56a, 0x4c4e, \
293 { 0xb6, 0xf9, 0x0b, 0x8a, 0xe4, 0x37, 0x2a, 0x3b }}
295 namespace mozilla {
297 // RawSelectionType should be used to store nsISelectionController::SELECTION_*.
298 typedef short RawSelectionType;
300 // SelectionTypeMask should be used to store bit-mask of selection types.
301 // The value can be retrieved with ToSelectionTypeMask() and checking if
302 // a selection type is in a mask with |SelectionType & SelectionTypeMask|.
303 typedef uint16_t SelectionTypeMask;
305 // SelectionType should be used in internal handling because of type safe.
306 enum class SelectionType : RawSelectionType
308 eInvalid = -1,
309 eNone = nsISelectionController::SELECTION_NONE,
310 eNormal = nsISelectionController::SELECTION_NORMAL,
311 eSpellCheck = nsISelectionController::SELECTION_SPELLCHECK,
312 eIMERawClause = nsISelectionController::SELECTION_IME_RAWINPUT,
313 eIMESelectedRawClause = nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT,
314 eIMEConvertedClause = nsISelectionController::SELECTION_IME_CONVERTEDTEXT,
315 eIMESelectedClause =
316 nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT,
317 eAccessibility = nsISelectionController::SELECTION_ACCESSIBILITY,
318 eFind = nsISelectionController::SELECTION_FIND,
319 eURLSecondary = nsISelectionController::SELECTION_URLSECONDARY,
320 eURLStrikeout = nsISelectionController::SELECTION_URLSTRIKEOUT,
323 // Using anonymous enum to define constants because these constants may be
324 // used at defining fixed size array in some header files (e.g.,
325 // nsFrameSelection.h). So, the values needs to be defined here, but we cannot
326 // use static/const even with extern since it causes failing to link or
327 // initializes them after such headers.
328 enum : size_t
330 // kSelectionTypeCount is number of SelectionType.
331 kSelectionTypeCount = nsISelectionController::NUM_SELECTIONTYPES,
334 // kPresentSelectionTypes is selection types which may be displayed.
335 // I.e., selection types except eNone.
336 static const SelectionType kPresentSelectionTypes[] = {
337 SelectionType::eNormal,
338 SelectionType::eSpellCheck,
339 SelectionType::eIMERawClause,
340 SelectionType::eIMESelectedRawClause,
341 SelectionType::eIMEConvertedClause,
342 SelectionType::eIMESelectedClause,
343 SelectionType::eAccessibility,
344 SelectionType::eFind,
345 SelectionType::eURLSecondary,
346 SelectionType::eURLStrikeout,
349 // Please include mozilla/dom/Selection.h for the following APIs.
350 const char* ToChar(SelectionType aSelectionType);
351 inline bool IsValidRawSelectionType(RawSelectionType aRawSelectionType);
352 inline SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
353 inline RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
354 inline SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType);
356 } // namespace mozilla