2009-06-24 Jessie Berlin <jberlin@apple.com>
Reviewed by Adam Roben.
Partially fixes: https://bugs.webkit.org/show_bug.cgi?id=24735
(<rdar://problem/5015942>)
Where on windows it was not possible to set an element as the drag
image using setDragImage on the dataTransfer object.
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.
Added a manual test because it is not possible to check that what is
contained in the image snapshot is indeed the requested element.
* dom/Clipboard.h:
(WebCore::Clipboard::dragImageElement):
Made getting the raw pointer from the RefPtr a const operation.
* manual-tests/drag-with-div-or-image-as-data-image.html: Added.
* platform/win/ClipboardWin.cpp:
(WebCore::ClipboardWin::createDragImage):
Get an image of the rendered element and its subtree.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@45087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/manual-tests/drag-with-div-or-image-as-data-image.html b/WebCore/manual-tests/drag-with-div-or-image-as-data-image.html
new file mode 100644
index 0000000..1d5a791
--- /dev/null
+++ b/WebCore/manual-tests/drag-with-div-or-image-as-data-image.html
@@ -0,0 +1,55 @@
+<html>
+ <head>
+ <title>Test for WebKit bug 24735: Poor setDragImage support on Windows</title>
+ <style type="text/css">
+
+ .draggable {
+ -webkit-user-drag: element;
+ -webkit-user-select: none;
+ }
+
+ #linkToUseAsImage {
+ background-color: silver;
+ }
+
+ #divToUseAsImage {
+ background-color: pink;
+ }
+
+ </style>
+
+ <script type="text/javascript">
+ function dragDivAndSeeImageDragged()
+ {
+ event.dataTransfer.setDragImage(document.getElementById("imgToUseAsImage"), event.pageX, event.pageY);
+ }
+
+ function dragImageAndSeeDivDragged()
+ {
+ event.dataTransfer.setDragImage(document.getElementById("divToUseAsImage"), event.pageX, event.pageY);
+ }
+ </script>
+ </head>
+ <body >
+ <h3>Test for <a href='https://bugs.webkit.org/show_bug.cgi?id=24735'>WebKit bug 24735</a>: Poor setDragImage support on Windows</h3>
+
+ <p>Instructions: </p>
+ <p>When you drag the first div, the image under the cursor should be of the second image. </p>
+ <p>When you drag the first image, the image under the cursor should be of the second div. </p>
+
+ <br />
+ <br />
+
+ <div class="draggable" ondragstart="dragDivAndSeeImageDragged()"> Drag me, I am a div! (first div)</div>
+ <br />
+ <br />
+ <img src="resources/webkit-background.png" class="draggable" ondragstart="dragImageAndSeeDivDragged()" />
+ <br />
+ <br />
+ <img src="resources/drag-image.png" id="imgToUseAsImage" />
+ <br />
+ <br />
+ <div id="divToUseAsImage"> When a drag is started on the image, this is the div that is used as the drag image! (second div)</div>
+
+ </body>
+</html>