Support smart copy and paste during drag and drop
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2008 00:21:42 +0000 (00:21 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2008 00:21:42 +0000 (00:21 +0000)
Reviewed by Alice

In order for the drag and drop tests in Windows DRT to pass
we need to support smart cut and paste operations during
drag and drop on windows.

There is no layout test as drag and drop is still unsupported
on windows.  Once supported smart drag/drop is tested by existing
tests

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/win/ClipboardUtilitiesWin.cpp
WebCore/platform/win/ClipboardUtilitiesWin.h
WebCore/platform/win/ClipboardWin.cpp
WebCore/platform/win/DragDataWin.cpp

index bfd8b3c837030baaac8ab0b0f785b5bd819fe877..0e9eb98fef4356cf0fd4cb5e8caadae417fcecc3 100644 (file)
@@ -1,3 +1,24 @@
+2008-01-17  Oliver Hunt  <oliver@apple.com>
+
+        Support smart copy and paste during drag and drop
+        
+        Reviewed by Alice
+        
+        In order for the drag and drop tests in Windows DRT to pass
+        we need to support smart cut and paste operations during
+        drag and drop on windows.
+        
+        There is no layout test as drag and drop is still unsupported
+        on windows.  Once supported smart drag/drop is tested by existing
+        tests
+
+        * platform/win/ClipboardUtilitiesWin.cpp:
+        (WebCore::smartPasteFormat):
+        * platform/win/ClipboardUtilitiesWin.h:
+        * platform/win/ClipboardWin.cpp:
+        (WebCore::ClipboardWin::writeRange):
+        * platform/win/DragDataWin.cpp:
+
 2008-01-17  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Anders.
index fd4180e6e0a4e202890114b02848801550564f74..066e235c8796ccd64c4caa79fcba852c3b11562f 100644 (file)
@@ -265,6 +265,13 @@ FORMATETC* htmlFormat()
     return &htmlFormat;
 }
 
+FORMATETC* smartPasteFormat()
+{
+    static UINT cf = RegisterClipboardFormat(L"WebKit Smart Paste Format");
+    static FORMATETC htmlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+    return &htmlFormat;
+}
+
 static bool urlFromPath(CFStringRef path, String& url)
 {
     if (!path)
index 095ca40a1b6f74a8fb011b7a2288b58cc942c53a..49898ea367e380fbc5a42a8f745d6fd76af99966 100644 (file)
@@ -49,6 +49,7 @@ FORMATETC* filenameWFormat();
 FORMATETC* filenameFormat();
 FORMATETC* htmlFormat();
 FORMATETC* cfHDropFormat();
+FORMATETC* smartPasteFormat();
 
 DeprecatedCString markupToCF_HTML(const String& markup, const String& srcURL);
 String urlToMarkup(const KURL& url, const String& title);
index 197dcf6cdec0ee974808dc7294fd992bce01af56..fbbbedb625d97cc1157820ba5ad5ad36f165cf40 100644 (file)
@@ -33,6 +33,7 @@
 #include "DeprecatedString.h"
 #include "Document.h"
 #include "DragData.h"
+#include "Editor.h"
 #include "Element.h"
 #include "EventHandler.h"
 #include "Frame.h"
@@ -728,6 +729,10 @@ void ClipboardWin::writeRange(Range* selectedRange, Frame* frame)
     medium.hGlobal = createGlobalData(str);
     if (medium.hGlobal && FAILED(m_writableDataObject->SetData(plainTextWFormat(), &medium, TRUE)))
         ::GlobalFree(medium.hGlobal);
+
+    medium.hGlobal = 0;
+    if (frame->editor()->canSmartCopyOrDelete())
+        m_writableDataObject->SetData(smartPasteFormat(), &medium, TRUE);
 }
 
 bool ClipboardWin::hasData()
index fe119426f256217e4f8d86cee6be4c79361b665f..26f72d65f0779709c13ad8617ddf2632ae370e2f 100644 (file)
@@ -108,7 +108,7 @@ bool DragData::containsColor() const
 
 bool DragData::canSmartReplace() const
 {
-    return false
+    return SUCCEEDED(m_platformDragData->QueryGetData(smartPasteFormat()))
 }
 
 bool DragData::containsCompatibleContent() const