1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/webidl/DataTransfer.webidl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,137 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + * 1.9 + * The origin of this IDL file is: 1.10 + * http://www.whatwg.org/specs/web-apps/current-work/#the-datatransfer-interface 1.11 + */ 1.12 + 1.13 +[ChromeConstructor(DOMString eventType, boolean isExternal)] 1.14 +interface DataTransfer { 1.15 + attribute DOMString dropEffect; 1.16 + attribute DOMString effectAllowed; 1.17 + 1.18 + //readonly attribute DataTransferItemList items; 1.19 + 1.20 + [Throws] 1.21 + void setDragImage(Element image, long x, long y); 1.22 + 1.23 + readonly attribute DOMStringList types; 1.24 + [Throws] 1.25 + DOMString getData(DOMString format); 1.26 + [Throws] 1.27 + void setData(DOMString format, DOMString data); 1.28 + [Throws] 1.29 + void clearData(optional DOMString format); 1.30 + [Throws] 1.31 + readonly attribute FileList? files; 1.32 +}; 1.33 + 1.34 +// Mozilla specific stuff 1.35 +partial interface DataTransfer { 1.36 + /* 1.37 + * Set the drag source. Usually you would not change this, but it will 1.38 + * affect which node the drag and dragend events are fired at. The 1.39 + * default target is the node that was dragged. 1.40 + * 1.41 + * @param element drag source to use 1.42 + * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified 1.43 + */ 1.44 + [Throws] 1.45 + void addElement(Element element); 1.46 + 1.47 + /** 1.48 + * The number of items being dragged. 1.49 + */ 1.50 + readonly attribute unsigned long mozItemCount; 1.51 + 1.52 + /** 1.53 + * Sets the drag cursor state. Primarily used to control the cursor during 1.54 + * tab drags, but could be expanded to other uses. XXX Currently implemented 1.55 + * on Win32 only. 1.56 + * 1.57 + * Possible values: 1.58 + * auto - use default system behavior. 1.59 + * default - set the cursor to an arrow during the drag operation. 1.60 + * 1.61 + * Values other than 'default' are indentical to setting mozCursor to 1.62 + * 'auto'. 1.63 + */ 1.64 + attribute DOMString mozCursor; 1.65 + 1.66 + /** 1.67 + * Holds a list of the format types of the data that is stored for an item 1.68 + * at the specified index. If the index is not in the range from 0 to 1.69 + * itemCount - 1, an empty string list is returned. 1.70 + */ 1.71 + [Throws] 1.72 + DOMStringList mozTypesAt(unsigned long index); 1.73 + 1.74 + /** 1.75 + * Remove the data associated with the given format for an item at the 1.76 + * specified index. The index is in the range from zero to itemCount - 1. 1.77 + * 1.78 + * If the last format for the item is removed, the entire item is removed, 1.79 + * reducing the itemCount by one. 1.80 + * 1.81 + * If format is empty, then the data associated with all formats is removed. 1.82 + * If the format is not found, then this method has no effect. 1.83 + * 1.84 + * @param format the format to remove 1.85 + * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater or equal than itemCount 1.86 + * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified 1.87 + */ 1.88 + [Throws] 1.89 + void mozClearDataAt(DOMString format, unsigned long index); 1.90 + 1.91 + /* 1.92 + * A data transfer may store multiple items, each at a given zero-based 1.93 + * index. setDataAt may only be called with an index argument less than 1.94 + * itemCount in which case an existing item is modified, or equal to 1.95 + * itemCount in which case a new item is added, and the itemCount is 1.96 + * incremented by one. 1.97 + * 1.98 + * Data should be added in order of preference, with the most specific 1.99 + * format added first and the least specific format added last. If data of 1.100 + * the given format already exists, it is replaced in the same position as 1.101 + * the old data. 1.102 + * 1.103 + * The data should be either a string, a primitive boolean or number type 1.104 + * (which will be converted into a string) or an nsISupports. 1.105 + * 1.106 + * @param format the format to add 1.107 + * @param data the data to add 1.108 + * @throws NS_ERROR_NULL_POINTER if the data is null 1.109 + * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater than itemCount 1.110 + * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified 1.111 + */ 1.112 + [Throws] 1.113 + void mozSetDataAt(DOMString format, any data, unsigned long index); 1.114 + 1.115 + /** 1.116 + * Retrieve the data associated with the given format for an item at the 1.117 + * specified index, or null if it does not exist. The index should be in the 1.118 + * range from zero to itemCount - 1. 1.119 + * 1.120 + * @param format the format of the data to look up 1.121 + * @returns the data of the given format, or null if it doesn't exist. 1.122 + * @throws NS_ERROR_DOM_INDEX_SIZE_ERR if index is greater or equal than itemCount 1.123 + */ 1.124 + [Throws] 1.125 + any mozGetDataAt(DOMString format, unsigned long index); 1.126 + 1.127 + /** 1.128 + * Will be true when the user has cancelled the drag (typically by pressing 1.129 + * Escape) and when the drag has been cancelled unexpectedly. This will be 1.130 + * false otherwise, including when the drop has been rejected by its target. 1.131 + * This property is only relevant for the dragend event. 1.132 + */ 1.133 + readonly attribute boolean mozUserCancelled; 1.134 + 1.135 + /** 1.136 + * The node that the mouse was pressed over to begin the drag. For external 1.137 + * drags, or if the caller cannot access this node, this will be null. 1.138 + */ 1.139 + readonly attribute Node? mozSourceNode; 1.140 +};