diff options
author | Gae24 <96017547+Gae24@users.noreply.github.com> | 2024-11-25 11:49:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 10:49:04 +0000 |
commit | c9e3d3e25e37068cff5164d83dfa906a7d74f528 (patch) | |
tree | 0c7dd286f6437ca17a98d74a68b4a0c821ca46c5 /components/script/dom/webidls | |
parent | 810a91ecac71f656ca6573045ff51e7fee35ca53 (diff) | |
download | servo-c9e3d3e25e37068cff5164d83dfa906a7d74f528.tar.gz servo-c9e3d3e25e37068cff5164d83dfa906a7d74f528.zip |
Implement `DataTransfer` and related interfaces (#34205)
* add datatransfer interfaces
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* implement DataTransfer interface
implemented Constructor, setter and getter for drop_effect and effect_allowed, Items and SetDragImage
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* implement DataTransferItem interface
Implemented Kind, Type, GetAsString, GetAsFile.
Marked DataTransfer as weakReferenceable to access its field
inside DataTransferItemList and DataTransferItem.
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* implement DataTransferItemList interface
implemented Lenght, Getter, Add, Remove, Clear
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* added DataTransfer's old interface
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* DataTransfer: implemented GetData, SetData, SetData
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* set Weakref to DataTransfer in DataTransferItemList and DataTransferItem
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* DataTransfer: implemented Types and Files
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* cleanup get_data, set_data, clear_data
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* fix clippy warning
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* add drag data store
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* fix DataTransfer's Types() behaviour
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* DataTransferItem: use the underlying drag data store
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* fix DataTransferItemList's getter and remove
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* fix clippy warnings
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* update test expectations
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Diffstat (limited to 'components/script/dom/webidls')
-rw-r--r-- | components/script/dom/webidls/DataTransfer.webidl | 24 | ||||
-rw-r--r-- | components/script/dom/webidls/DataTransferItem.webidl | 15 | ||||
-rw-r--r-- | components/script/dom/webidls/DataTransferItemList.webidl | 15 |
3 files changed, 54 insertions, 0 deletions
diff --git a/components/script/dom/webidls/DataTransfer.webidl b/components/script/dom/webidls/DataTransfer.webidl new file mode 100644 index 00000000000..2e546f0c579 --- /dev/null +++ b/components/script/dom/webidls/DataTransfer.webidl @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// https://html.spec.whatwg.org/multipage/#datatransfer + +[Exposed=Window] +interface DataTransfer { + constructor(); + + attribute DOMString dropEffect; + attribute DOMString effectAllowed; + + [SameObject] readonly attribute DataTransferItemList items; + + undefined setDragImage(Element image, long x, long y); + + /* old interface */ + readonly attribute /* FrozenArray<DOMString> */ any types; + DOMString getData(DOMString format); + undefined setData(DOMString format, DOMString data); + undefined clearData(optional DOMString format); + [SameObject] readonly attribute FileList files; +}; diff --git a/components/script/dom/webidls/DataTransferItem.webidl b/components/script/dom/webidls/DataTransferItem.webidl new file mode 100644 index 00000000000..56008f13715 --- /dev/null +++ b/components/script/dom/webidls/DataTransferItem.webidl @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// https://html.spec.whatwg.org/multipage/#datatransferitem + +[Exposed=Window] +interface DataTransferItem { + readonly attribute DOMString kind; + readonly attribute DOMString type; + undefined getAsString(FunctionStringCallback? _callback); + File? getAsFile(); +}; + +callback FunctionStringCallback = undefined (DOMString data); diff --git a/components/script/dom/webidls/DataTransferItemList.webidl b/components/script/dom/webidls/DataTransferItemList.webidl new file mode 100644 index 00000000000..efdcb72806e --- /dev/null +++ b/components/script/dom/webidls/DataTransferItemList.webidl @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// https://html.spec.whatwg.org/multipage/#datatransferitemlist + +[Exposed=Window] +interface DataTransferItemList { + readonly attribute unsigned long length; + getter DataTransferItem (unsigned long index); + [Throws] DataTransferItem? add(DOMString data, DOMString type); + [Throws] DataTransferItem? add(File data); + [Throws] undefined remove(unsigned long index); + undefined clear(); +}; |