1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is:
7 * http://www.whatwg.org/specs/web-apps/current-work/#the-datatransfer-interface
10 [ChromeConstructor(DOMString eventType, boolean isExternal)]
11 interface DataTransfer {
12 attribute DOMString dropEffect;
13 attribute DOMString effectAllowed;
15 //readonly attribute DataTransferItemList items;
18 void setDragImage(Element image, long x, long y);
20 readonly attribute DOMStringList types;
22 DOMString getData(DOMString format);
24 void setData(DOMString format, DOMString data);
26 void clearData(optional DOMString format);
28 readonly attribute FileList? files;
31 // Mozilla specific stuff
32 partial interface DataTransfer {
34 * Set the drag source. Usually you would not change this, but it will
35 * affect which node the drag and dragend events are fired at. The
36 * default target is the node that was dragged.
38 * @param element drag source to use
39 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
42 void addElement(Element element);
45 * The number of items being dragged.
47 readonly attribute unsigned long mozItemCount;
50 * Sets the drag cursor state. Primarily used to control the cursor during
51 * tab drags, but could be expanded to other uses. XXX Currently implemented
55 * auto - use default system behavior.
56 * default - set the cursor to an arrow during the drag operation.
58 * Values other than 'default' are indentical to setting mozCursor to
61 attribute DOMString mozCursor;
64 * Holds a list of the format types of the data that is stored for an item
65 * at the specified index. If the index is not in the range from 0 to
66 * itemCount - 1, an empty string list is returned.
69 DOMStringList mozTypesAt(unsigned long index);
72 * Remove the data associated with the given format for an item at the
73 * specified index. The index is in the range from zero to itemCount - 1.
75 * If the last format for the item is removed, the entire item is removed,
76 * reducing the itemCount by one.
78 * If format is empty, then the data associated with all formats is removed.
79 * If the format is not found, then this method has no effect.
81 * @param format the format to remove
82 * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater or equal than itemCount
83 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
86 void mozClearDataAt(DOMString format, unsigned long index);
89 * A data transfer may store multiple items, each at a given zero-based
90 * index. setDataAt may only be called with an index argument less than
91 * itemCount in which case an existing item is modified, or equal to
92 * itemCount in which case a new item is added, and the itemCount is
95 * Data should be added in order of preference, with the most specific
96 * format added first and the least specific format added last. If data of
97 * the given format already exists, it is replaced in the same position as
100 * The data should be either a string, a primitive boolean or number type
101 * (which will be converted into a string) or an nsISupports.
103 * @param format the format to add
104 * @param data the data to add
105 * @throws NS_ERROR_NULL_POINTER if the data is null
106 * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater than itemCount
107 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
110 void mozSetDataAt(DOMString format, any data, unsigned long index);
113 * Retrieve the data associated with the given format for an item at the
114 * specified index, or null if it does not exist. The index should be in the
115 * range from zero to itemCount - 1.
117 * @param format the format of the data to look up
118 * @returns the data of the given format, or null if it doesn't exist.
119 * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater or equal than itemCount
122 any mozGetDataAt(DOMString format, unsigned long index);
125 * Will be true when the user has cancelled the drag (typically by pressing
126 * Escape) and when the drag has been cancelled unexpectedly. This will be
127 * false otherwise, including when the drop has been rejected by its target.
128 * This property is only relevant for the dragend event.
130 readonly attribute boolean mozUserCancelled;
133 * The node that the mouse was pressed over to begin the drag. For external
134 * drags, or if the caller cannot access this node, this will be null.
136 readonly attribute Node? mozSourceNode;