Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / widget / nsIDragSession.idl
blobe96e6fc1c78d8e1e839e3271807f2d10e57ba3f6
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 "nsISupports.idl"
8 #include "nsITransferable.idl"
12 %{ C++
13 #include "nsSize.h"
15 interface nsIContentSecurityPolicy;
17 native nsSize(nsSize);
19 webidl DataTransfer;
20 webidl WindowContext;
21 webidl Node;
22 webidl Selection;
24 [scriptable, builtinclass, uuid(25bce737-73f0-43c7-bc20-c71044a73c5a)]
25 interface nsIDragSession : nsISupports
27 /**
28 * Set the current state of the drag, whether it can be dropped or not.
29 * usually the target "frame" sets this so the native system can render the correct feedback
31 attribute boolean canDrop;
33 /**
34 * Indicates if the drop event should be dispatched only to chrome.
36 attribute boolean onlyChromeDrop;
38 /**
39 * Sets the action (copy, move, link, et.c) for the current drag
41 attribute unsigned long dragAction;
43 /**
44 * Get the number of items that were dropped
46 readonly attribute unsigned long numDropItems;
48 /**
49 * The window context where the drag was started, which will be null if the
50 * drag originated outside the application. Useful for determining if a drop
51 * originated in the same window context.
53 [infallible]
54 attribute WindowContext sourceWindowContext;
56 /**
57 * The top-level window context where the drag was started, which will be
58 * null if the drag originated outside the application. Useful for
59 * determining if a drop originated in the same top-level window context.
61 [infallible]
62 attribute WindowContext sourceTopWindowContext;
64 /**
65 * The dom node that was originally dragged to start the session, which will be null if the
66 * drag originated outside the application.
68 readonly attribute Node sourceNode;
70 /**
71 * Replace source node and selection with new ones.
72 * If sourceNode is a native anonymous node, it may be replaced at reframing.
73 * If sourceNode is disconnected from the document, we cannot dispatch
74 * `dragend` event properly.
75 * When this is called, sourceNode or aNewSourceNode should be a native
76 * anonymous node.
78 [notxpcom, nostdcall] void updateSource(in Node aNewSourceNode,
79 in Selection aNewSelection);
81 /**
82 * the triggering principal. This may be different than sourceNode's
83 * principal when sourceNode is xul:browser and the drag is
84 * triggered in a browsing context inside it.
86 attribute nsIPrincipal triggeringPrincipal;
88 /**
89 * the triggering csp. This may be different than sourceNode's
90 * csp when sourceNode is xul:browser and the drag is
91 * triggered in a browsing context inside it.
93 attribute nsIContentSecurityPolicy csp;
95 /**
96 * The data transfer object for the current drag.
98 [binaryname(DataTransferXPCOM)]
99 attribute DataTransfer dataTransfer;
100 [notxpcom, nostdcall] DataTransfer getDataTransfer();
101 [notxpcom, nostdcall] void setDataTransfer(in DataTransfer aDataTransfer);
104 * Get data from a Drag&Drop. Can be called while the drag is in process
105 * or after the drop has completed.
107 * @param aTransferable the transferable for the data to be put into
108 * @param aItemIndex which of multiple drag items, zero-based
110 void getData ( in nsITransferable aTransferable, in unsigned long aItemIndex ) ;
113 * Check to set if any of the native data on the clipboard matches this data flavor
115 boolean isDataFlavorSupported ( in string aDataFlavor ) ;
117 void userCancelled();
119 void dragEventDispatchedToChildProcess();
121 // Called when nsIDragSession implementation should update the UI for the
122 // drag-and-drop based on the data got from the child process in response to
123 // NS_DRAGDROP_OVER sent from parent process to child process.
124 void updateDragEffect();
126 // Change the drag image, using similar arguments as
127 // nsIDragService::InvokeDragSessionWithImage.
128 void updateDragImage(in Node aImage, in long aImageX, in long aImageY);
131 * Returns effects allowed at starting the session for tests.
133 [notxpcom, nostdcall] unsigned long getEffectAllowedForTests();
136 * Returns true if current session was started with synthesized drag start.
138 [notxpcom, nostdcall] bool isSynthesizedForTests();
141 * Sets drag end point of synthesized session when the test does not dispatch
142 * "drop" event.
144 void setDragEndPointForTests(in long aScreenX, in long aScreenY);
147 * Returns true if the session is for dragging text in a text in text control
148 * element.
150 [notxpcom, nostdcall] bool isDraggingTextInTextControl();