XUL:Specs:TransferData: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(No difference)
|
Revision as of 04:43, 6 March 2006
Current State
- Clipboard and drag/drop APIs require too much code, and don't really do much of the hard work for you.
Requirements
- Should be able to do clipboard and drag/drop operations without complex code.
- Need drag/drop APIs that are unprivileged
- Need to have an event which is fired on the drag source when a drag is cancelled and when a drop is done on another application
- Drag images showing what is being dragged, for example icons or treecells.
- Shouldn't have to serialize and deserialize DOM nodes or other objects when moving between the same application.
The WhatWG defines some drag and drop functionality, based on the IE model. It mostly concerns the way the drag/drop events are fired. Need clarfication on it, but it seems that only strings can be specified as the dragged data.
Security
- An application should only be able to retrieve items being dragged from the same origin domain. This means that a drag can occur between different domains. For different domains, the drag data is only available to a different domain after the drop.
- Clipboard operations are only available for privileged applications, apart from built in behaviour of widgets or shortcut keys.
Plan
At the moment, I'm thinking of a top-level JS API for various UI components. The APIs should be designed for JS usage (or at least scripting usage), rather than C++ usage so the arguments should be scriptable rather than XPCOM types.
Sticking thse APIs below here so I can remember them. They are just based on the existing C++ drag service, clipboard and transferable interfaces, as a start.
interface nsITransferLazyData : nsISupports { nsIVariant getData(in AString aFlavor, in nsITransferData aTransferable); } interface nsITransferData : nsISupports { /** * Retrieve the data for a particular flavor. If an empty string is supplied * for the flavor, return the best one. */ nsIVariant getData(in AString flavor); void getFlavors([array, size_is(length)] out AString flavors, out unsigned long length); void addData(in AString flavor, nsIVariant data); void addLazyData(in AString flavor, nsITransferLazyData lazydata); void removeData(in AString flavor); } interface nsIClipboardJS : nsISupports { nsITransferData getDataTransfer(in AString flavor); void setDataTransfer(in AString flavor, nsITransferData data); nsIVariant getData(in AString flavor); void setData(in AString flavor, nsIVariant data); } interface nsIDragJS : nsISupports { void startDrag(in nsIDOMNode sourceNode, PRInt32 action); void startDragTransfer(in nsIDOMNode sourceNode, [array, size_is(length)] items, unsigned long length, PRInt32 action); }