dom/interfaces/events/nsIDOMDataTransfer.idl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "domstubs.idl"
michael@0 7
michael@0 8 interface nsIVariant;
michael@0 9 interface nsIDOMFileList;
michael@0 10
michael@0 11 [scriptable, builtinclass, uuid(c71180e3-298b-4fbb-9ccb-82c822474741)]
michael@0 12 interface nsIDOMDataTransfer : nsISupports
michael@0 13 {
michael@0 14 /**
michael@0 15 * The actual effect that will be used, and should always be one of the
michael@0 16 * possible values of effectAllowed.
michael@0 17 *
michael@0 18 * For dragstart, drag and dragleave events, the dropEffect is initialized
michael@0 19 * to none. Any value assigned to the dropEffect will be set, but the value
michael@0 20 * isn't used for anything.
michael@0 21 *
michael@0 22 * For the dragenter and dragover events, the dropEffect will be initialized
michael@0 23 * based on what action the user is requesting. How this is determined is
michael@0 24 * platform specific, but typically the user can press modifier keys to
michael@0 25 * adjust which action is desired. Within an event handler for the dragenter
michael@0 26 * and dragover events, the dropEffect should be modified if the action the
michael@0 27 * user is requesting is not the one that is desired.
michael@0 28 *
michael@0 29 * For the drop and dragend events, the dropEffect will be initialized to
michael@0 30 * the action that was desired, which will be the value that the dropEffect
michael@0 31 * had after the last dragenter or dragover event.
michael@0 32 *
michael@0 33 * Possible values:
michael@0 34 * copy - a copy of the source item is made at the new location
michael@0 35 * move - an item is moved to a new location
michael@0 36 * link - a link is established to the source at the new location
michael@0 37 * none - the item may not be dropped
michael@0 38 *
michael@0 39 * Assigning any other value has no effect and retains the old value.
michael@0 40 */
michael@0 41 attribute DOMString dropEffect;
michael@0 42
michael@0 43 /*
michael@0 44 * Specifies the effects that are allowed for this drag. You may set this in
michael@0 45 * the dragstart event to set the desired effects for the source, and within
michael@0 46 * the dragenter and dragover events to set the desired effects for the
michael@0 47 * target. The value is not used for other events.
michael@0 48 *
michael@0 49 * Possible values:
michael@0 50 * copy - a copy of the source item is made at the new location
michael@0 51 * move - an item is moved to a new location
michael@0 52 * link - a link is established to the source at the new location
michael@0 53 * copyLink, copyMove, linkMove, all - combinations of the above
michael@0 54 * none - the item may not be dropped
michael@0 55 * uninitialized - the default value when the effect has not been set,
michael@0 56 * equivalent to all.
michael@0 57 *
michael@0 58 * Assigning any other value has no effect and retains the old value.
michael@0 59 */
michael@0 60 attribute DOMString effectAllowed;
michael@0 61
michael@0 62 /**
michael@0 63 * Holds a list of all the local files available on this data transfer.
michael@0 64 * A dataTransfer containing no files will return an empty list, and an
michael@0 65 * invalid index access on the resulting file list will return null.
michael@0 66 */
michael@0 67 readonly attribute nsIDOMFileList files;
michael@0 68
michael@0 69 /**
michael@0 70 * Holds a list of the format types of the data that is stored for the first
michael@0 71 * item, in the same order the data was added. An empty list will be
michael@0 72 * returned if no data was added.
michael@0 73 */
michael@0 74 readonly attribute nsISupports types;
michael@0 75
michael@0 76 /**
michael@0 77 * Remove the data associated with a given format. If format is empty or not
michael@0 78 * specified, the data associated with all formats is removed. If data for
michael@0 79 * the specified format does not exist, or the data transfer contains no
michael@0 80 * data, this method will have no effect.
michael@0 81 */
michael@0 82 void clearData([optional] in DOMString format);
michael@0 83
michael@0 84 /**
michael@0 85 * Set the data for a given format. If data for the format does not exist,
michael@0 86 * it is added at the end, such that the last item in the types list will be
michael@0 87 * the new format. If data for the format already exists, the existing data
michael@0 88 * is replaced in the same position. That is, the order of the types list is
michael@0 89 * not changed.
michael@0 90 *
michael@0 91 * @throws NS_ERROR_NULL_POINTER if the data is null
michael@0 92 */
michael@0 93 void setData(in DOMString format, in DOMString data);
michael@0 94
michael@0 95 /**
michael@0 96 * Retrieves the data for a given format, or an empty string if data for
michael@0 97 * that format does not exist or the data transfer contains no data.
michael@0 98 */
michael@0 99 DOMString getData(in DOMString format);
michael@0 100
michael@0 101 /**
michael@0 102 * Set the image to be used for dragging if a custom one is desired. Most of
michael@0 103 * the time, this would not be set, as a default image is created from the
michael@0 104 * node that was dragged.
michael@0 105 *
michael@0 106 * If the node is an HTML img element, an HTML canvas element or a XUL image
michael@0 107 * element, the image data is used. Otherwise, image should be a visible
michael@0 108 * node and the drag image will be created from this. If image is null, any
michael@0 109 * custom drag image is cleared and the default is used instead.
michael@0 110 *
michael@0 111 * The coordinates specify the offset into the image where the mouse cursor
michael@0 112 * should be. To center the image for instance, use values that are half the
michael@0 113 * width and height.
michael@0 114 *
michael@0 115 * @param image a node to use
michael@0 116 * @param x the horizontal offset
michael@0 117 * @param y the vertical offset
michael@0 118 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
michael@0 119 */
michael@0 120 void setDragImage(in nsIDOMElement image, in long x, in long y);
michael@0 121
michael@0 122 /*
michael@0 123 * Set the drag source. Usually you would not change this, but it will
michael@0 124 * affect which node the drag and dragend events are fired at. The
michael@0 125 * default target is the node that was dragged.
michael@0 126 *
michael@0 127 * @param element drag source to use
michael@0 128 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
michael@0 129 */
michael@0 130 void addElement(in nsIDOMElement element);
michael@0 131
michael@0 132 /**
michael@0 133 * The number of items being dragged.
michael@0 134 */
michael@0 135 readonly attribute unsigned long mozItemCount;
michael@0 136
michael@0 137 /**
michael@0 138 * Sets the drag cursor state. Primarily used to control the cursor during
michael@0 139 * tab drags, but could be expanded to other uses. XXX Currently implemented
michael@0 140 * on Win32 only.
michael@0 141 *
michael@0 142 * Possible values:
michael@0 143 * auto - use default system behavior.
michael@0 144 * default - set the cursor to an arrow during the drag operation.
michael@0 145 *
michael@0 146 * Values other than 'default' are indentical to setting mozCursor to
michael@0 147 * 'auto'.
michael@0 148 */
michael@0 149 attribute DOMString mozCursor;
michael@0 150
michael@0 151 /**
michael@0 152 * Holds a list of the format types of the data that is stored for an item
michael@0 153 * at the specified index. If the index is not in the range from 0 to
michael@0 154 * itemCount - 1, an empty string list is returned.
michael@0 155 */
michael@0 156 nsISupports mozTypesAt(in unsigned long index);
michael@0 157
michael@0 158 /**
michael@0 159 * Remove the data associated with the given format for an item at the
michael@0 160 * specified index. The index is in the range from zero to itemCount - 1.
michael@0 161 *
michael@0 162 * If the last format for the item is removed, the entire item is removed,
michael@0 163 * reducing the itemCount by one.
michael@0 164 *
michael@0 165 * If format is empty, then the data associated with all formats is removed.
michael@0 166 * If the format is not found, then this method has no effect.
michael@0 167 *
michael@0 168 * @param format the format to remove
michael@0 169 * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater or equal than itemCount
michael@0 170 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
michael@0 171 */
michael@0 172 void mozClearDataAt(in DOMString format, in unsigned long index);
michael@0 173
michael@0 174 /*
michael@0 175 * A data transfer may store multiple items, each at a given zero-based
michael@0 176 * index. setDataAt may only be called with an index argument less than
michael@0 177 * itemCount in which case an existing item is modified, or equal to
michael@0 178 * itemCount in which case a new item is added, and the itemCount is
michael@0 179 * incremented by one.
michael@0 180 *
michael@0 181 * Data should be added in order of preference, with the most specific
michael@0 182 * format added first and the least specific format added last. If data of
michael@0 183 * the given format already exists, it is replaced in the same position as
michael@0 184 * the old data.
michael@0 185 *
michael@0 186 * The data should be either a string, a primitive boolean or number type
michael@0 187 * (which will be converted into a string) or an nsISupports.
michael@0 188 *
michael@0 189 * @param format the format to add
michael@0 190 * @param data the data to add
michael@0 191 * @throws NS_ERROR_NULL_POINTER if the data is null
michael@0 192 * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater than itemCount
michael@0 193 * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
michael@0 194 */
michael@0 195 void mozSetDataAt(in DOMString format, in nsIVariant data, in unsigned long index);
michael@0 196
michael@0 197 /**
michael@0 198 * Retrieve the data associated with the given format for an item at the
michael@0 199 * specified index, or null if it does not exist. The index should be in the
michael@0 200 * range from zero to itemCount - 1.
michael@0 201 *
michael@0 202 * @param format the format of the data to look up
michael@0 203 * @returns the data of the given format, or null if it doesn't exist.
michael@0 204 * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater or equal than itemCount
michael@0 205 */
michael@0 206 nsIVariant mozGetDataAt(in DOMString format, in unsigned long index);
michael@0 207
michael@0 208 /**
michael@0 209 * Will be true when the user has cancelled the drag (typically by pressing
michael@0 210 * Escape) and when the drag has been cancelled unexpectedly. This will be
michael@0 211 * false otherwise, including when the drop has been rejected by its target.
michael@0 212 * This property is only relevant for the dragend event.
michael@0 213 */
michael@0 214 readonly attribute boolean mozUserCancelled;
michael@0 215
michael@0 216 /**
michael@0 217 * The node that the mouse was pressed over to begin the drag. For external
michael@0 218 * drags, or if the caller cannot access this node, this will be null.
michael@0 219 */
michael@0 220 readonly attribute nsIDOMNode mozSourceNode;
michael@0 221
michael@0 222 /*
michael@0 223 * Integer version of dropEffect, set to one of the constants in nsIDragService.
michael@0 224 */
michael@0 225 [noscript] attribute unsigned long dropEffectInt;
michael@0 226
michael@0 227 /*
michael@0 228 * Integer version of effectAllowed, set to one or a combination of the
michael@0 229 * constants in nsIDragService.
michael@0 230 */
michael@0 231 [noscript] attribute unsigned long effectAllowedInt;
michael@0 232 };

mercurial