Bug 1812348 [wpt PR 38171] - wake lock: Move tests in web_tests/wake-lock to either...
[gecko.git] / widget / nsIDragService.idl
blob4dd3efd051fd88216848bafe812c28a9b45e78c7
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsIArray.idl"
8 #include "nsISupports.idl"
9 #include "nsIDragSession.idl"
10 #include "nsIContentPolicy.idl"
12 webidl DragEvent;
13 webidl Node;
14 webidl Selection;
16 interface nsICookieJarSettings;
18 %{C++
19 #include "mozilla/EventForwards.h"
21 namespace mozilla {
22 namespace dom {
23 class ContentParent;
24 class DataTransfer;
25 class RemoteDragStartData;
26 } // namespace dom
27 } // namespace mozilla
30 [ptr] native ContentParentPtr(mozilla::dom::ContentParent);
31 [ptr] native DataTransferPtr(mozilla::dom::DataTransfer);
32 [ptr] native RemoteDragStartDataPtr(mozilla::dom::RemoteDragStartData);
33 native EventMessage(mozilla::EventMessage);
35 [scriptable, uuid(ebd6b3a2-af16-43af-a698-3091a087dd62), builtinclass]
36 interface nsIDragService : nsISupports
38 const long DRAGDROP_ACTION_NONE = 0;
39 const long DRAGDROP_ACTION_COPY = 1;
40 const long DRAGDROP_ACTION_MOVE = 2;
41 const long DRAGDROP_ACTION_LINK = 4;
42 const long DRAGDROP_ACTION_UNINITIALIZED = 64;
44 /**
45 * Starts a modal drag session with an array of transaferables.
47 * Note: This method is deprecated for non-native code.
49 * @param aPrincipal - the triggering principal of the drag, or null if
50 * it's from browser chrome or OS
51 * @param aCsp - The csp of the triggering Document
52 * @param aTransferables - an array of transferables to be dragged
53 * @param aActionType - specified which of copy/move/link are allowed
54 * @param aContentPolicyType - the contentPolicyType that will be
55 * passed to the loadInfo when creating a new channel
56 * (defaults to TYPE_OTHER)
58 [can_run_script]
59 void invokeDragSession (in Node aDOMNode,
60 in nsIPrincipal aPrincipal,
61 in nsIContentSecurityPolicy aCsp,
62 in nsICookieJarSettings aCookieJarSettings,
63 in nsIArray aTransferables,
64 in unsigned long aActionType,
65 [optional] in nsContentPolicyType aContentPolicyType);
67 /**
68 * Starts a modal drag session using an image. The first four arguments are
69 * the same as invokeDragSession.
71 * Note: This method is deprecated for non-native code.
73 * A custom image may be specified using the aImage argument. If this is
74 * supplied, the aImageX and aImageY arguments specify the offset within
75 * the image where the cursor would be positioned. That is, when the image
76 * is drawn, it is offset up and left the amount so that the cursor appears
77 * at that location within the image.
79 * If aImage is null, aImageX and aImageY are not used and the image is instead
80 * determined from the source node aDOMNode, and the offset calculated so that
81 * the initial location for the image appears in the same screen position as
82 * where the element is located. The node must be within a document.
84 * Currently, supported images are all DOM nodes. If this is an HTML <image> or
85 * <canvas>, the drag image is taken from the image data. If the element is in
86 * a document, it will be rendered at its displayed size, othewise, it will be
87 * rendered at its real size. For other types of elements, the element is
88 * rendered into an offscreen buffer in the same manner as it is currently
89 * displayed. The document selection is hidden while drawing.
91 * The aDragEvent must be supplied as the current screen coordinates of the
92 * event are needed to calculate the image location.
94 [noscript, can_run_script]
95 void invokeDragSessionWithImage(in Node aDOMNode,
96 in nsIPrincipal aPrincipal,
97 in nsIContentSecurityPolicy aCsp,
98 in nsICookieJarSettings aCookieJarSettings,
99 in nsIArray aTransferableArray,
100 in unsigned long aActionType,
101 in Node aImage,
102 in long aImageX,
103 in long aImageY,
104 in DragEvent aDragEvent,
105 in DataTransferPtr aDataTransfer);
107 /** Start a drag session with the data in aDragStartData from a child process.
108 * Other arguments are the same as invokeDragSessionWithImage.
110 [noscript, can_run_script]
111 void invokeDragSessionWithRemoteImage(in Node aDOMNode,
112 in nsIPrincipal aPrincipal,
113 in nsIContentSecurityPolicy aCsp,
114 in nsICookieJarSettings aCookieJarSettings,
115 in nsIArray aTransferableArray,
116 in unsigned long aActionType,
117 in RemoteDragStartDataPtr aDragStartData,
118 in DragEvent aDragEvent,
119 in DataTransferPtr aDataTransfer);
122 * Start a modal drag session using the selection as the drag image.
123 * The aDragEvent must be supplied as the current screen coordinates of the
124 * event are needed to calculate the image location.
126 * Note: This method is deprecated for non-native code.
128 [can_run_script]
129 void invokeDragSessionWithSelection(in Selection aSelection,
130 in nsIPrincipal aPrincipal,
131 in nsIContentSecurityPolicy aCsp,
132 in nsICookieJarSettings aCookieJarSettings,
133 in nsIArray aTransferableArray,
134 in unsigned long aActionType,
135 in DragEvent aDragEvent,
136 in DataTransferPtr aDataTransfer);
139 * Returns the current Drag Session
141 nsIDragSession getCurrentSession();
144 * Tells the Drag Service to start a drag session. This is called when
145 * an external drag occurs
147 void startDragSession() ;
150 * Similar to startDragSession(), automated tests may want to start
151 * session for emulating an external drag. At that time, this should
152 * be used instead of startDragSession().
154 * @param aAllowedEffect Set default drag action which means allowed effects
155 * in the session and every DnD events are initialized
156 * with one of specified value. So, the value can be
157 * DRAGDROP_ACTION_NONE, or one or more values of
158 * DRAGDROP_ACTION_(MOVE|COPY|LINK).
160 void startDragSessionForTests(in unsigned long aAllowedEffect);
163 * Tells the Drag Service to end a drag session. This is called when
164 * an external drag occurs
166 * If aDoneDrag is true, the drag has finished, otherwise the drag has
167 * just left the window.
169 [can_run_script]
170 void endDragSession(in boolean aDoneDrag,
171 [optional] in unsigned long aKeyModifiers);
174 * Fire a drag event at the source of the drag
176 [noscript, can_run_script]
177 void fireDragEventAtSource(in EventMessage aEventMessage,
178 in unsigned long aKeyModifiers);
181 * Increase/decrease dragging suppress level by one.
182 * If level is greater than one, dragging is disabled.
184 [can_run_script]
185 void suppress();
186 void unsuppress();
189 * aX and aY are in LayoutDevice pixels.
191 [noscript] void dragMoved(in long aX, in long aY);
193 [notxpcom, nostdcall] boolean maybeAddChildProcess(in ContentParentPtr aChild);
194 [notxpcom, nostdcall] boolean removeAllChildProcesses();
198 %{ C++