At the start of a drag operation you can use event.dataTransfer.setDragImage(...) to change the graphic to display by the cursor during the operation. On Mac this is supported for both images and elements. On Windows Safari has support for only images as the first parameter of setDragImage. It is not supported on <a> and <img> tags that has their own implementations that can't be overridden. Google Chrome has the function but no graphics shows up around the cursor for any drag operation. All versions should behave like the Mac version.
<rdar://problem/5015942>
*** Bug 24734 has been marked as a duplicate of this bug. ***
Created attachment 31785 [details] Adds the ability to set an element as the drag image on Windows Does not fix the case of dragging a link where the default link image is still used, even when the -webkit-user-drag is set to "element". This is the same behavior as is found on OS X.
Comment on attachment 31785 [details] Adds the ability to set an element as the drag image on Windows > DragImageRef ClipboardWin::createDragImage(IntPoint& loc) const > { > HBITMAP result = 0; > - //FIXME: Need to be able to draw element <rdar://problem/5015942> > if (m_dragImage) { > result = createDragImageFromImage(m_dragImage->image()); > loc = m_dragLoc; > + } else if (m_dragImageElement) { > + Node* node = dragImageElement(); > + result = node->document()->frame()->nodeImage(node); > + loc = m_dragLoc; > } It's strange to use m_dragImageElement on the first line, then dragImageElement() on the second. I don't really have a preference, but using m_dragImageElement consistently would match the code above more closely. r=me
(In reply to comment #4) > (From update of attachment 31785 [details] [review]) > > DragImageRef ClipboardWin::createDragImage(IntPoint& loc) const > > { > > HBITMAP result = 0; > > - //FIXME: Need to be able to draw element <rdar://problem/5015942> > > if (m_dragImage) { > > result = createDragImageFromImage(m_dragImage->image()); > > loc = m_dragLoc; > > + } else if (m_dragImageElement) { > > + Node* node = dragImageElement(); changed to be: Node* node = m_dragImageElement.get(); > > + result = node->document()->frame()->nodeImage(node); > > + loc = m_dragLoc; > > } > > It's strange to use m_dragImageElement on the first line, then > dragImageElement() on the second. I don't really have a preference, but using > m_dragImageElement consistently would match the code above more closely. > > r=me >
Does jberlin have commit-bit or does aroben plan to land this with modifications?
(In reply to comment #6) > Does jberlin have commit-bit Yes. <http://trac.webkit.org/search?q=jberlin&noquickjump=1&changeset=on>
(In reply to comment #6) > Does jberlin have commit-bit or does aroben plan to land this with > modifications? > I did commit, but I didn't mark it as fixed because the bug mentions the desire to see the link tag be able to be given a custom setDragImage and that is currently not supported on either mac or windows. Sorry I didn't respond earlier. For some reason I kept getting an "internal error" message when I navigated to this page.
Comment on attachment 31785 [details] Adds the ability to set an element as the drag image on Windows committed with revision 45087
Created a new bug for not being able to set the drag image of a link: https://bugs.webkit.org/show_bug.cgi?id=27670 Marking this bug as fixed, since the last committed patch addressed all other concerns.