NEW 22998
Setting the drag image during a drag operation does not work
https://bugs.webkit.org/show_bug.cgi?id=22998
Summary Setting the drag image during a drag operation does not work
Antoine Quint
Reported 2008-12-26 04:05:49 PST
From my tests, calling event.dataTransfer.setDragImage() within a "dragenter" event handler in JS code is a no-op and .setDragImage() only does what's intended within a "dragstart" event handler. This might be a "feature" and not a bug, but I'm not sure why there would such a limitation to the use of .setDragImage().
Attachments
Testcase (2.43 KB, text/html)
2008-12-26 04:06 PST, Antoine Quint
no flags
Another test case (2.33 KB, text/html)
2010-08-26 16:06 PDT, Mike Thole
no flags
Antoine Quint
Comment 1 2008-12-26 04:06:55 PST
Created attachment 26254 [details] Testcase This testcases shows that Clipboard::setDragImage() only works when called within a "dragstart" event handler. Indeed, when dragging the black square above, we set the drag image to be some element elsewhere in the DOM, and this works fine. As you initiate a drag from the black rectangle, you should see this message: This is a custom drag image. However, when you are dragging something else, say an image or URL shortcut from the Finder, over the black rectangle, attempting to set a custom drag image fails.
Simon Fraser (smfr)
Comment 2 2008-12-26 16:35:42 PST
It seems this is by design. The docs <http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/DragAndDrop.html#//apple_ref/doc/uid/30001233-177395> say "When a drag operation begins, you can use the setDragImage method of the dataTransfer object". In terms of the implementation, DragController::tryDHTMLDrag() actually creates a new Clipboard object on every mouse drag, with a policy of ClipboardReadable or ClipboardTypesReadable. setDragImage() then bails on setting the image for this Clipboard because of that policy. If it were possible to change the drag image after the start of the drag, I think there would have to be some 'same origin' policy to avoid pages changing the drag images of drags from other documents, or from outside the browser.
Antoine Quint
Comment 3 2008-12-27 02:40:29 PST
I think the current policy is too restrictive, I would prefer to have something like a same-domain policy so that I could have an element dragged from one of my webpages opened in one window dropped onto another webpages off my website in another window, and have the drop page be able to update the drag image to reflect the state of the element once dropped onto the current drop zone.
Mike Thole
Comment 4 2010-08-26 16:06:11 PDT
Created attachment 65639 [details] Another test case I was also surprised to find that the drag image can only be set during the "dragstart" event handler. Attaching another test case that demonstrates the issue: RainbowDragging.html
Note You need to log in before you can comment on or make changes to this bug.