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"
10 typedef short SelectionRegion
;
15 } // namespace mozilla
19 interface nsISelectionDisplay
;
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 // Custom Highlight API
45 // (see https://drafts.csswg.org/css-highlight-api-1/#enumdef-highlighttype)
46 const short SELECTION_HIGHLIGHT
= 11;
47 // End of RawSelectionType values.
48 const short NUM_SELECTIONTYPES
= 12;
50 // SelectionRegion values:
51 const short SELECTION_ANCHOR_REGION
= 0;
52 const short SELECTION_FOCUS_REGION
= 1;
53 const short SELECTION_WHOLE_SELECTION
= 2;
54 const short NUM_SELECTION_REGIONS
= 3;
56 const short SELECTION_OFF
= 0;
57 const short SELECTION_HIDDEN
=1;//>HIDDEN displays selection
58 const short SELECTION_ON
= 2;
59 const short SELECTION_DISABLED
= 3;
60 const short SELECTION_ATTENTION
= 4;
63 * SetDisplaySelection will set the display mode for the selection. OFF,ON,DISABLED
65 void setDisplaySelection
(in short toggle
);
68 * GetDisplaySelection will get the display mode for the selection. OFF,ON,DISABLED
70 short getDisplaySelection
();
73 * GetSelection will return the selection that the presentation
74 * shell may implement.
76 * @param aType This will hold the type of selection. This value must be one
77 * of RawSelectionType values.
78 * @param _return will hold the return value
80 [binaryname
(GetSelectionFromScript
)]
81 Selection getSelection
(in short type
);
84 * Return the selection object corresponding to a selection type.
86 [noscript
,nostdcall
,notxpcom
,binaryname
(GetSelection
)]
87 Selection getDOMSelection
(in short aType
);
90 * Called when the selection controller should take the focus.
92 * This will take care to hide the previously-focused selection, show this
93 * selection, and repaint both.
95 [noscript
,nostdcall
,notxpcom
]
96 void selectionWillTakeFocus
();
99 * Called when the selection controller has lost the focus.
101 * This will take care to hide and repaint the selection.
103 [noscript
,nostdcall
,notxpcom
]
104 void selectionWillLoseFocus
();
106 const short SCROLL_SYNCHRONOUS
= 1<<1;
107 const short SCROLL_FIRST_ANCESTOR_ONLY
= 1<<2;
108 const short SCROLL_CENTER_VERTICALLY
= 1<<4;
109 const short SCROLL_OVERFLOW_HIDDEN
= 1<<5;
110 const short SCROLL_FOR_CARET_MOVE
= 1<<6;
113 * ScrollSelectionIntoView scrolls a region of the selection,
114 * so that it is visible in the scrolled view.
116 * @param aType the selection to scroll into view. This value must be one
117 * of RawSelectionType values.
118 * @param aRegion the region inside the selection to scroll into view. //SelectionRegion
119 * @param aFlags the scroll flags. Valid bits include:
120 * SCROLL_SYNCHRONOUS: when set, scrolls the selection into view
121 * before returning. If not set, posts a request which is processed
122 * at some point after the method returns.
123 * SCROLL_FIRST_ANCESTOR_ONLY: if set, only the first ancestor will be scrolled
125 * SCROLL_OVERFLOW_HIDDEN: if set, scrolls even if the overflow is specified
127 * SCROLL_FOR_CARET_MOVE: set to indicate whether scrolling is in response
128 * to the caret being moved. Does not affect behavior (used for telemetry
131 * Note that if isSynchronous is true, then this might flush the pending
132 * reflow. It's dangerous for some objects. See bug 418470 comment 12.
134 void scrollSelectionIntoView
(in short type
, in short region
, in short flags
);
137 * RepaintSelection repaints the selection specified by aType.
139 * @param aType specifies the selection to repaint.
141 void repaintSelection
(in short type
);
144 * Set the caret as enabled or disabled. An enabled caret will
145 * draw or blink when made visible. A disabled caret will never show up.
146 * Can be called any time.
147 * @param aEnable PR_TRUE to enable caret. PR_FALSE to disable.
148 * @return always NS_OK
151 void setCaretEnabled
(in boolean enabled
);
154 * Set the caret readonly or not. An readonly caret will
155 * draw but not blink when made visible.
156 * @param aReadOnly PR_TRUE to enable caret. PR_FALSE to disable.
157 * @return always NS_OK
159 void setCaretReadOnly
(in boolean readOnly);
162 * Gets the current state of the caret.
163 * @param aEnabled [OUT] set to the current caret state, as set by SetCaretEnabled
164 * @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
167 boolean getCaretEnabled
();
170 * This is true if the caret is enabled, visible, and currently blinking.
171 * This is still true when the caret is enabled, visible, but in its "off"
174 readonly attribute
boolean caretVisible
;
177 * Show the caret even in selections. By default the caret is hidden unless the
178 * selection is collapsed. Use this function to show the caret even in selections.
179 * @param aVisibility PR_TRUE to show the caret in selections. PR_FALSE to hide.
180 * @return always NS_OK
182 void setCaretVisibilityDuringSelection
(in boolean visibility
);
184 /** CharacterMove will move the selection one character forward/backward in the document.
185 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
186 * the "point" of selection that is extended is considered the "focus" point.
187 * or the last point adjusted by the selection.
188 * @param aForward forward or backward if PR_FALSE
189 * @param aExtend should it collapse the selection of extend it?
191 void characterMove
(in boolean forward
, in boolean extend
);
193 /** PhysicalMove will move the selection one "unit" in a given direction
194 * within the document.
195 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
196 * the "point" of selection that is extended is considered the "focus" point.
197 * or the last point adjusted by the selection.
199 * @param aAmount character/line; word/lineBoundary
200 * @param aExtend should it collapse the selection of extend it?
202 void physicalMove
(in short direction
, in short amount
, in boolean extend
);
205 * nsFrameSelection::PhysicalMove depends on the ordering of these values;
206 * do not change without checking there!
208 const short MOVE_LEFT
= 0;
209 const short MOVE_RIGHT
= 1;
210 const short MOVE_UP
= 2;
211 const short MOVE_DOWN
= 3;
213 /** WordMove will move the selection one word forward/backward in the document.
214 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
215 * the "point" of selection that is extended is considered the "focus" point.
216 * or the last point adjusted by the selection.
217 * @param aForward forward or backward if PR_FALSE
218 * @param aExtend should it collapse the selection of extend it?
221 void wordMove
(in boolean forward
, in boolean extend
);
223 /** LineMove will move the selection one line forward/backward in the document.
224 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
225 * the "point" of selection that is extended is considered the "focus" point.
226 * or the last point adjusted by the selection.
227 * @param aForward forward or backward if PR_FALSE
228 * @param aExtend should it collapse the selection of extend it?
230 void lineMove
(in boolean forward
, in boolean extend
);
232 /** IntraLineMove will move the selection to the front of the line or end of the line
234 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
235 * the "point" of selection that is extended is considered the "focus" point.
236 * or the last point adjusted by the selection.
237 * @param aForward forward or backward if PR_FALSE
238 * @param aExtend should it collapse the selection of extend it?
240 void intraLineMove
(in boolean forward
, in boolean extend
);
242 /** PageMove will move the selection one page forward/backward in the document.
243 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
244 * the "point" of selection that is extended is considered the "focus" point.
245 * or the last point adjusted by the selection.
246 * @param aForward forward or backward if PR_FALSE
247 * @param aExtend should it collapse the selection of extend it?
250 void pageMove
(in boolean forward
, in boolean extend
);
252 /** CompleteScroll will move page view to the top or bottom of the document
253 * @param aForward forward or backward if PR_FALSE
255 void completeScroll
(in boolean forward
);
257 /** CompleteMove will move page view to the top or bottom of the document
258 * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
259 * the "point" of selection that is extended is considered the "focus" point.
260 * or the last point adjusted by the selection.
261 * @param aForward forward or backward if PR_FALSE
262 * @param aExtend should it collapse the selection of extend it?
265 void completeMove
(in boolean forward
, in boolean extend
);
268 /** ScrollPage will scroll the page without affecting the selection.
269 * @param aForward scroll forward or backwards in selection
271 void scrollPage
(in boolean forward
);
273 /** ScrollLine will scroll line up or down dependent on the boolean
274 * @param aForward scroll forward or backwards in selection
276 void scrollLine
(in boolean forward
);
278 /** ScrollCharacter will scroll right or left dependent on the boolean
279 * @param aRight if true will scroll right. if not will scroll left.
281 void scrollCharacter
(in boolean right
);
284 #define NS_ISELECTIONCONTROLLER_CID \
285 { 0x513b9460, 0xd56a, 0x4c4e, \
286 { 0xb6, 0xf9, 0x0b, 0x8a, 0xe4, 0x37, 0x2a, 0x3b }}
290 // RawSelectionType should be used to store nsISelectionController::SELECTION_*.
291 typedef short RawSelectionType
;
293 // SelectionTypeMask should be used to store bit-mask of selection types.
294 // The value can be retrieved with ToSelectionTypeMask() and checking if
295 // a selection type is in a mask with |SelectionType & SelectionTypeMask|.
296 typedef uint16_t SelectionTypeMask
;
298 // SelectionType should be used in internal handling because of type safe.
299 enum class SelectionType
: RawSelectionType
302 eNone
= nsISelectionController
::SELECTION_NONE
,
303 eNormal
= nsISelectionController
::SELECTION_NORMAL
,
304 eSpellCheck
= nsISelectionController
::SELECTION_SPELLCHECK
,
305 eIMERawClause
= nsISelectionController
::SELECTION_IME_RAWINPUT
,
306 eIMESelectedRawClause
= nsISelectionController
::SELECTION_IME_SELECTEDRAWTEXT
,
307 eIMEConvertedClause
= nsISelectionController
::SELECTION_IME_CONVERTEDTEXT
,
309 nsISelectionController
::SELECTION_IME_SELECTEDCONVERTEDTEXT
,
310 eAccessibility
= nsISelectionController
::SELECTION_ACCESSIBILITY
,
311 eFind
= nsISelectionController
::SELECTION_FIND
,
312 eURLSecondary
= nsISelectionController
::SELECTION_URLSECONDARY
,
313 eURLStrikeout
= nsISelectionController
::SELECTION_URLSTRIKEOUT
,
314 eHighlight
= nsISelectionController
::SELECTION_HIGHLIGHT
,
317 // Using anonymous enum to define constants because these constants may be
318 // used at defining fixed size array in some header files (e.g.,
319 // nsFrameSelection.h). So, the values needs to be defined here, but we cannot
320 // use static/const even with extern since it causes failing to link or
321 // initializes them after such headers.
324 // kSelectionTypeCount is number of SelectionType.
325 kSelectionTypeCount
= nsISelectionController
::NUM_SELECTIONTYPES
,
328 // kPresentSelectionTypes is selection types which may be displayed.
329 // I.e., selection types except eNone.
330 static
const SelectionType kPresentSelectionTypes
[] = {
331 SelectionType
::eNormal
,
332 SelectionType
::eSpellCheck
,
333 SelectionType
::eIMERawClause
,
334 SelectionType
::eIMESelectedRawClause
,
335 SelectionType
::eIMEConvertedClause
,
336 SelectionType
::eIMESelectedClause
,
337 SelectionType
::eAccessibility
,
338 SelectionType
::eFind
,
339 SelectionType
::eURLSecondary
,
340 SelectionType
::eURLStrikeout
,
341 SelectionType
::eHighlight
,
344 // Please include mozilla/dom/Selection.h for the following APIs.
345 const char* ToChar
(SelectionType aSelectionType
);
346 inline bool IsValidRawSelectionType
(RawSelectionType aRawSelectionType
);
347 inline SelectionType ToSelectionType
(RawSelectionType aRawSelectionType
);
348 inline RawSelectionType ToRawSelectionType
(SelectionType aSelectionType
);
349 inline SelectionTypeMask ToSelectionTypeMask
(SelectionType aSelectionType
);
351 } // namespace mozilla