Bug 1908539 restrict MacOS platform audio processing to Nightly r=webrtc-reviewers...
[gecko.git] / dom / base / nsISelectionController.idl
blob9c76e45f4305cdfc960c919e41b75682e85c0b3f
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 const short SELECTION_TARGET_TEXT = 11;
45 // Custom Highlight API
46 // (see https://drafts.csswg.org/css-highlight-api-1/#enumdef-highlighttype)
47 const short SELECTION_HIGHLIGHT = 12;
48 // End of RawSelectionType values.
49 const short NUM_SELECTIONTYPES = 13;
51 // SelectionRegion values:
52 const short SELECTION_ANCHOR_REGION = 0;
53 const short SELECTION_FOCUS_REGION = 1;
54 const short SELECTION_WHOLE_SELECTION = 2;
55 const short NUM_SELECTION_REGIONS = 3;
57 const short SELECTION_OFF = 0;
58 const short SELECTION_HIDDEN =1;//>HIDDEN displays selection
59 const short SELECTION_ON = 2;
60 const short SELECTION_DISABLED = 3;
61 const short SELECTION_ATTENTION = 4;
63 /**
64 * SetDisplaySelection will set the display mode for the selection. OFF,ON,DISABLED
66 void setDisplaySelection(in short toggle);
68 /**
69 * GetDisplaySelection will get the display mode for the selection. OFF,ON,DISABLED
71 short getDisplaySelection();
73 /**
74 * GetSelection will return the selection that the presentation
75 * shell may implement.
77 * @param aType This will hold the type of selection. This value must be one
78 * of RawSelectionType values.
79 * @param _return will hold the return value
81 [binaryname(GetSelectionFromScript)]
82 Selection getSelection(in short type);
84 /**
85 * Return the selection object corresponding to a selection type.
87 [noscript,nostdcall,notxpcom,binaryname(GetSelection)]
88 Selection getDOMSelection(in short aType);
90 /**
91 * Called when the selection controller should take the focus.
93 * This will take care to hide the previously-focused selection, show this
94 * selection, and repaint both.
96 [noscript,nostdcall,notxpcom]
97 void selectionWillTakeFocus();
99 /**
100 * Called when the selection controller has lost the focus.
102 * This will take care to hide and repaint the selection.
104 [noscript,nostdcall,notxpcom]
105 void selectionWillLoseFocus();
107 const short SCROLL_SYNCHRONOUS = 1<<1;
108 const short SCROLL_FIRST_ANCESTOR_ONLY = 1<<2;
109 const short SCROLL_CENTER_VERTICALLY = 1<<4;
110 const short SCROLL_OVERFLOW_HIDDEN = 1<<5;
111 const short SCROLL_FOR_CARET_MOVE = 1<<6;
114 * ScrollSelectionIntoView scrolls a region of the selection,
115 * so that it is visible in the scrolled view.
117 * @param aType the selection to scroll into view. This value must be one
118 * of RawSelectionType values.
119 * @param aRegion the region inside the selection to scroll into view. //SelectionRegion
120 * @param aFlags the scroll flags. Valid bits include:
121 * SCROLL_SYNCHRONOUS: when set, scrolls the selection into view
122 * before returning. If not set, posts a request which is processed
123 * at some point after the method returns.
124 * SCROLL_FIRST_ANCESTOR_ONLY: if set, only the first ancestor will be scrolled
125 * into view.
126 * SCROLL_OVERFLOW_HIDDEN: if set, scrolls even if the overflow is specified
127 * as hidden.
128 * SCROLL_FOR_CARET_MOVE: set to indicate whether scrolling is in response
129 * to the caret being moved. Does not affect behavior (used for telemetry
130 * purposes only).
132 * Note that if isSynchronous is true, then this might flush the pending
133 * reflow. It's dangerous for some objects. See bug 418470 comment 12.
135 void scrollSelectionIntoView(in short type, in short region, in short flags);
138 * RepaintSelection repaints the selection specified by aType.
140 * @param aType specifies the selection to repaint.
142 void repaintSelection(in short type);
145 * Set the caret as enabled or disabled. An enabled caret will
146 * draw or blink when made visible. A disabled caret will never show up.
147 * Can be called any time.
148 * @param aEnable PR_TRUE to enable caret. PR_FALSE to disable.
149 * @return always NS_OK
152 void setCaretEnabled(in boolean enabled);
155 * Set the caret readonly or not. An readonly caret will
156 * draw but not blink when made visible.
157 * @param aReadOnly PR_TRUE to enable caret. PR_FALSE to disable.
158 * @return always NS_OK
160 void setCaretReadOnly(in boolean readOnly);
163 * Gets the current state of the caret.
164 * @param aEnabled [OUT] set to the current caret state, as set by SetCaretEnabled
165 * @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
166 * else NS_OK
168 boolean getCaretEnabled();
171 * This is true if the caret is enabled, visible, and currently blinking.
172 * This is still true when the caret is enabled, visible, but in its "off"
173 * blink cycle.
175 readonly attribute boolean caretVisible;
178 * Show the caret even in selections. By default the caret is hidden unless the
179 * selection is collapsed. Use this function to show the caret even in selections.
180 * @param aVisibility PR_TRUE to show the caret in selections. PR_FALSE to hide.
181 * @return always NS_OK
183 void setCaretVisibilityDuringSelection(in boolean visibility);
185 /** CharacterMove will move the selection one character forward/backward in the document.
186 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
187 * the "point" of selection that is extended is considered the "focus" point.
188 * or the last point adjusted by the selection.
189 * @param aForward forward or backward if PR_FALSE
190 * @param aExtend should it collapse the selection of extend it?
192 void characterMove(in boolean forward, in boolean extend);
194 /** PhysicalMove will move the selection one "unit" in a given direction
195 * within the document.
196 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
197 * the "point" of selection that is extended is considered the "focus" point.
198 * or the last point adjusted by the selection.
199 * @param aDirection
200 * @param aAmount character/line; word/lineBoundary
201 * @param aExtend should it collapse the selection of extend it?
203 void physicalMove(in short direction, in short amount, in boolean extend);
206 * nsFrameSelection::PhysicalMove depends on the ordering of these values;
207 * do not change without checking there!
209 const short MOVE_LEFT = 0;
210 const short MOVE_RIGHT = 1;
211 const short MOVE_UP = 2;
212 const short MOVE_DOWN = 3;
214 /** WordMove will move the selection one word forward/backward in the document.
215 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
216 * the "point" of selection that is extended is considered the "focus" point.
217 * or the last point adjusted by the selection.
218 * @param aForward forward or backward if PR_FALSE
219 * @param aExtend should it collapse the selection of extend it?
222 void wordMove(in boolean forward, in boolean extend);
224 /** LineMove will move the selection one line forward/backward in the document.
225 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
226 * the "point" of selection that is extended is considered the "focus" point.
227 * or the last point adjusted by the selection.
228 * @param aForward forward or backward if PR_FALSE
229 * @param aExtend should it collapse the selection of extend it?
231 void lineMove(in boolean forward, in boolean extend);
233 /** IntraLineMove will move the selection to the front of the line or end of the line
234 * in the document.
235 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
236 * the "point" of selection that is extended is considered the "focus" point.
237 * or the last point adjusted by the selection.
238 * @param aForward forward or backward if PR_FALSE
239 * @param aExtend should it collapse the selection of extend it?
241 void intraLineMove(in boolean forward, in boolean extend);
243 /** PageMove will move the selection one page forward/backward in the document.
244 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
245 * the "point" of selection that is extended is considered the "focus" point.
246 * or the last point adjusted by the selection.
247 * @param aForward forward or backward if PR_FALSE
248 * @param aExtend should it collapse the selection of extend it?
250 [can_run_script]
251 void pageMove(in boolean forward, in boolean extend);
253 /** CompleteScroll will move page view to the top or bottom of the document
254 * @param aForward forward or backward if PR_FALSE
256 void completeScroll(in boolean forward);
258 /** CompleteMove will move page view to the top or bottom of the document
259 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
260 * the "point" of selection that is extended is considered the "focus" point.
261 * or the last point adjusted by the selection.
262 * @param aForward forward or backward if PR_FALSE
263 * @param aExtend should it collapse the selection of extend it?
265 [can_run_script]
266 void completeMove(in boolean forward, in boolean extend);
269 /** ScrollPage will scroll the page without affecting the selection.
270 * @param aForward scroll forward or backwards in selection
272 void scrollPage(in boolean forward);
274 /** ScrollLine will scroll line up or down dependent on the boolean
275 * @param aForward scroll forward or backwards in selection
277 void scrollLine(in boolean forward);
279 /** ScrollCharacter will scroll right or left dependent on the boolean
280 * @param aRight if true will scroll right. if not will scroll left.
282 void scrollCharacter(in boolean right);
284 %{ C++
285 #define NS_ISELECTIONCONTROLLER_CID \
286 { 0x513b9460, 0xd56a, 0x4c4e, \
287 { 0xb6, 0xf9, 0x0b, 0x8a, 0xe4, 0x37, 0x2a, 0x3b }}
289 namespace mozilla {
291 // RawSelectionType should be used to store nsISelectionController::SELECTION_*.
292 typedef short RawSelectionType;
294 // SelectionTypeMask should be used to store bit-mask of selection types.
295 // The value can be retrieved with ToSelectionTypeMask() and checking if
296 // a selection type is in a mask with |SelectionType & SelectionTypeMask|.
297 typedef uint16_t SelectionTypeMask;
299 // SelectionType should be used in internal handling because of type safe.
300 enum class SelectionType : RawSelectionType
302 eInvalid = -1,
303 eNone = nsISelectionController::SELECTION_NONE,
304 eNormal = nsISelectionController::SELECTION_NORMAL,
305 eSpellCheck = nsISelectionController::SELECTION_SPELLCHECK,
306 eIMERawClause = nsISelectionController::SELECTION_IME_RAWINPUT,
307 eIMESelectedRawClause = nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT,
308 eIMEConvertedClause = nsISelectionController::SELECTION_IME_CONVERTEDTEXT,
309 eIMESelectedClause =
310 nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT,
311 eAccessibility = nsISelectionController::SELECTION_ACCESSIBILITY,
312 eFind = nsISelectionController::SELECTION_FIND,
313 eURLSecondary = nsISelectionController::SELECTION_URLSECONDARY,
314 eURLStrikeout = nsISelectionController::SELECTION_URLSTRIKEOUT,
315 eTargetText = nsISelectionController::SELECTION_TARGET_TEXT,
316 eHighlight = nsISelectionController::SELECTION_HIGHLIGHT,
319 // kPresentSelectionTypes is selection types which may be displayed.
320 // I.e., selection types except eNone.
321 static const SelectionType kPresentSelectionTypes[] = {
322 SelectionType::eNormal,
323 SelectionType::eSpellCheck,
324 SelectionType::eIMERawClause,
325 SelectionType::eIMESelectedRawClause,
326 SelectionType::eIMEConvertedClause,
327 SelectionType::eIMESelectedClause,
328 SelectionType::eAccessibility,
329 SelectionType::eFind,
330 SelectionType::eURLSecondary,
331 SelectionType::eURLStrikeout,
332 SelectionType::eTargetText,
333 SelectionType::eHighlight,
336 // Please include mozilla/dom/Selection.h for the following APIs.
337 inline bool IsValidRawSelectionType(RawSelectionType aRawSelectionType);
338 inline SelectionType ToSelectionType(RawSelectionType aRawSelectionType);
339 inline RawSelectionType ToRawSelectionType(SelectionType aSelectionType);
340 inline SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType);
342 } // namespace mozilla