[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

enrica at apple.com enrica at apple.com
Sun Feb 20 22:55:50 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 9d9813d0265f3e65ef20d88c05156f114556c20e
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 13 23:14:41 2011 +0000

    Source/WebCore: WebKit2: Add support for drag and drop
    https://bugs.webkit.org/show_bug.cgi?id=52343
    <rdar://problem/7660558>
    
    Reviewed by Darin Adler.
    
    This patch contains the changes required to support dropping content
    in WebKit on the Mac. The DragData class has been extended to provide
    additional context from the application (keyboard state, modal windows, etc.)
    as well as information of the drag pasteboard being used.
    The support for WebKit as drag source will be added with a separate patch.
    
    * WebCore.exp.in:
    * page/DragController.cpp:
    (WebCore::DragController::dragIsMove): Added DragData parameter.
    (WebCore::DragController::tryDocumentDrag): Modified call to dragIsMove.
    (WebCore::DragController::concludeEditDrag): Same as above.
    * page/DragController.h: Added parameter to isCopyKeyDown.
    * page/mac/DragControllerMac.mm:
    The following methods have been modified to use the information stored
    in the DragData class.
    (WebCore::DragController::isCopyKeyDown):
    (WebCore::DragController::dragOperation):
    * platform/DragData.h:
    (WebCore::DragData::flags):
    * platform/DragData.cpp: Added default flags parameter to the constructor.
    * platform/mac/DragDataMac.mm:
    (WebCore::DragData::DragData): Added constructor that receives the name of the pasteboard to use.
    (WebCore::DragData::canSmartReplace):
    (WebCore::DragData::containsColor):
    (WebCore::DragData::containsFiles):
    (WebCore::DragData::asFilenames):
    (WebCore::DragData::containsPlainText):
    (WebCore::DragData::asPlainText):
    (WebCore::DragData::containsCompatibleContent):
    (WebCore::DragData::asURL):
    (WebCore::DragData::asFragment):
    All the following files have been modified to add the DragData
    parameter to isCopyKeyDown. I plan to improve this in the future
    and make isCopyKeyDown not platform specific.
    * page/android/DragControllerAndroid.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/brew/DragControllerBrew.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/chromium/DragControllerChromium.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/efl/DragControllerEfl.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/gtk/DragControllerGtk.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/haiku/DragControllerHaiku.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/mac/DragControllerMac.mm:
    (WebCore::DragController::isCopyKeyDown):
    (WebCore::DragController::dragOperation):
    * page/qt/DragControllerQt.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/win/DragControllerWin.cpp:
    (WebCore::DragController::isCopyKeyDown):
    * page/wx/DragControllerWx.cpp:
    (WebCore::DragController::isCopyKeyDown):
    
    WebKit/mac: WebKit2: Add support for drag and drop
    https://bugs.webkit.org/show_bug.cgi?id=52343
    <rdar://problem/7660558>
    
    Reviewed by Darin Adler.
    
    The DragData class has been extended to provide
    additional context from the application (keyboard state, modal windows, etc.)
    as well as information of the drag pasteboard being used.
    These are the changes to align the behavior for WebKit.
    
    * WebView/WebView.mm:
    (-[WebView applicationFlags:]): Added.
    (-[WebView draggingEntered:]): Added parameter to the DragData constructor.
    (-[WebView draggingUpdated:]): Added parameter to the DragData constructor.
    (-[WebView draggingExited:]): Added parameter to the DragData constructor.
    (-[WebView performDragOperation:]): Added parameter to the DragData constructor.
    
    WebKit2: WebKit2: Add support for drag and drop
    https://bugs.webkit.org/show_bug.cgi?id=52343
    <rdar://problem/7660558>
    
    Reviewed by Darin Adler.
    
    This patch contains the changes required to support dropping content
    in WebKit on the Mac. The DragData class has been extended to provide
    additional context from the application (keyboard state, modal windows, etc.)
    as well as information of the drag pasteboard being used.
    The support for WebKit as drag source will be added with a separate patch.
    
    * Shared/DragControllerAction.h: Added.
    * UIProcess/API/mac/WKView.mm:
    Added implemention of the methods required to add suport for a drop target.
    To maintain asynchronous communication with the WebProcess, we always return
    the previous calculated value for the drag operation.
    (-[WKView _registerDraggedTypes]):
    (-[WKView initWithFrame:contextRef:pageGroupRef:]):
    (-[WKView applicationFlags:]):
    (-[WKView draggingEntered:]):
    (-[WKView draggingUpdated:]):
    (-[WKView draggingExited:]):
    (-[WKView prepareForDragOperation:]):
    (-[WKView performDragOperation:]):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::WebPageProxy):
    (WebKit::WebPageProxy::performDragControllerAction):
    (WebKit::WebPageProxy::didPerformDragControllerAction):
    * UIProcess/WebPageProxy.h:
    (WebKit::WebPageProxy::dragOperation):
    (WebKit::WebPageProxy::resetDragOperation):
    * UIProcess/WebPageProxy.messages.in:
    * WebKit2.xcodeproj/project.pbxproj:
    * WebProcess/WebCoreSupport/WebDragClient.cpp:
    (WebKit::WebDragClient::willPerformDragDestinationAction):
    (WebKit::WebDragClient::willPerformDragSourceAction):
    (WebKit::WebDragClient::actionMaskForDrag):
    (WebKit::WebDragClient::dragSourceActionMaskForPoint):
    (WebKit::WebDragClient::startDrag):
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::performDragControllerAction):
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/WebPage.messages.in:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75743 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b5ff792..99b84b5 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,67 @@
+2011-01-12  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Darin Adler.
+
+        WebKit2: Add support for drag and drop
+        https://bugs.webkit.org/show_bug.cgi?id=52343
+        <rdar://problem/7660558>
+               
+        This patch contains the changes required to support dropping content
+        in WebKit on the Mac. The DragData class has been extended to provide
+        additional context from the application (keyboard state, modal windows, etc.)
+        as well as information of the drag pasteboard being used.
+        The support for WebKit as drag source will be added with a separate patch.
+
+        * WebCore.exp.in:
+        * page/DragController.cpp:
+        (WebCore::DragController::dragIsMove): Added DragData parameter.
+        (WebCore::DragController::tryDocumentDrag): Modified call to dragIsMove.
+        (WebCore::DragController::concludeEditDrag): Same as above.
+        * page/DragController.h: Added parameter to isCopyKeyDown.
+        * page/mac/DragControllerMac.mm:
+        The following methods have been modified to use the information stored
+        in the DragData class.
+        (WebCore::DragController::isCopyKeyDown):
+        (WebCore::DragController::dragOperation):
+        * platform/DragData.h:
+        (WebCore::DragData::flags):
+        * platform/DragData.cpp: Added default flags parameter to the constructor.
+        * platform/mac/DragDataMac.mm:
+        (WebCore::DragData::DragData): Added constructor that receives the name of the pasteboard to use.
+        (WebCore::DragData::canSmartReplace):
+        (WebCore::DragData::containsColor):
+        (WebCore::DragData::containsFiles):
+        (WebCore::DragData::asFilenames):
+        (WebCore::DragData::containsPlainText):
+        (WebCore::DragData::asPlainText):
+        (WebCore::DragData::containsCompatibleContent):
+        (WebCore::DragData::asURL):
+        (WebCore::DragData::asFragment):
+        All the following files have been modified to add the DragData
+        parameter to isCopyKeyDown. I plan to improve this in the future
+        and make isCopyKeyDown not platform specific.
+        * page/android/DragControllerAndroid.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/brew/DragControllerBrew.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/chromium/DragControllerChromium.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/efl/DragControllerEfl.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/gtk/DragControllerGtk.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/haiku/DragControllerHaiku.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/mac/DragControllerMac.mm:
+        (WebCore::DragController::isCopyKeyDown):
+        (WebCore::DragController::dragOperation):
+        * page/qt/DragControllerQt.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/win/DragControllerWin.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+        * page/wx/DragControllerWx.cpp:
+        (WebCore::DragController::isCopyKeyDown):
+
 2011-01-13  David Kilzer  <ddkilzer at apple.com>
 
         Add missing MathMLElementFactory.h and MathMLNames.h to Xcode project
@@ -299,6 +363,7 @@
 
         * html/canvas/WebGLRenderingContext.cpp:
 
+>>>>>>> .r75740
 2011-01-13  Adrienne Walker  <enne at google.com>
 
         Reviewed by Kenneth Russell.
@@ -758,6 +823,7 @@
         (WebCore::firstPositionInOrBeforeNode): Added.
         (WebCore::lastPositionInOrAfterNode): Added.
 
+>>>>>>> .r75734
 2011-01-12  Sam Weinig  <sam at webkit.org>
 
         Another build fix.
diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in
index e9418f0..97ef9b6 100644
--- a/Source/WebCore/WebCore.exp.in
+++ b/Source/WebCore/WebCore.exp.in
@@ -1328,7 +1328,8 @@ __ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE
 __ZN7WebCore14DragController11performDragEPNS_8DragDataE
 __ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE
 __ZN7WebCore14DragController9dragEndedEv
-__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationE
+__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationENS_20DragApplicationFlagsE
+__ZN7WebCore8DragDataC1ERKN3WTF6StringERKNS_8IntPointES7_NS_13DragOperationENS_20DragApplicationFlagsE
 #endif
 
 #if ENABLE(GEOLOCATION)
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index 02649dc..0a46c52 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -22381,6 +22381,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
 			compatibilityVersion = "Xcode 2.4";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp
index 77a8531..7be708c 100644
--- a/Source/WebCore/page/DragController.cpp
+++ b/Source/WebCore/page/DragController.cpp
@@ -141,9 +141,9 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
     return 0;
 }
 
-bool DragController::dragIsMove(SelectionController* selection)
+bool DragController::dragIsMove(SelectionController* selection, DragData* dragData)
 {
-    return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown();
+    return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown(dragData);
 }
 
 // FIXME: This method is poorly named.  We're just clearing the selection from the document this drag is exiting.
@@ -335,7 +335,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
         }
 
         Frame* innerFrame = element->document()->frame();
-        operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : DragOperationCopy;
+        operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
         return true;
     }
     // If we're not over an editable region, make sure we're clearing any prior drag cursor.
@@ -449,7 +449,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
         return false;
     CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader();
     cachedResourceLoader->setAllowStaleResources(true);
-    if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable()) {
+    if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
         bool chosePlainText = false;
         RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
         if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
@@ -458,7 +458,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
         }
 
         m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
-        if (dragIsMove(innerFrame->selection())) {
+        if (dragIsMove(innerFrame->selection(), dragData)) {
             // NSTextView behavior is to always smart delete on moving a selection,
             // but only to smart insert if the selection granularity is word granularity.
             bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled();
diff --git a/Source/WebCore/page/DragController.h b/Source/WebCore/page/DragController.h
index 0e90a52..10bb5f8 100644
--- a/Source/WebCore/page/DragController.h
+++ b/Source/WebCore/page/DragController.h
@@ -99,8 +99,8 @@ namespace WebCore {
         bool tryDHTMLDrag(DragData*, DragOperation&);
         DragOperation dragOperation(DragData*);
         void cancelDrag();
-        bool dragIsMove(SelectionController*);
-        bool isCopyKeyDown();
+        bool dragIsMove(SelectionController*, DragData*);
+        bool isCopyKeyDown(DragData*);
 
         void mouseMovedIntoDocument(Document*);
 
diff --git a/Source/WebCore/page/android/DragControllerAndroid.cpp b/Source/WebCore/page/android/DragControllerAndroid.cpp
index b20ab60..e67daaf 100644
--- a/Source/WebCore/page/android/DragControllerAndroid.cpp
+++ b/Source/WebCore/page/android/DragControllerAndroid.cpp
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     return false;
 }
diff --git a/Source/WebCore/page/brew/DragControllerBrew.cpp b/Source/WebCore/page/brew/DragControllerBrew.cpp
index ef89821..5878c24 100644
--- a/Source/WebCore/page/brew/DragControllerBrew.cpp
+++ b/Source/WebCore/page/brew/DragControllerBrew.cpp
@@ -41,7 +41,7 @@ const int DragController::DragIconBottomInset = 3;
 const float DragController::DragImageAlpha = 0.75f;
 
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     return false;
 }
diff --git a/Source/WebCore/page/chromium/DragControllerChromium.cpp b/Source/WebCore/page/chromium/DragControllerChromium.cpp
index 75e0bd2..e17972d 100644
--- a/Source/WebCore/page/chromium/DragControllerChromium.cpp
+++ b/Source/WebCore/page/chromium/DragControllerChromium.cpp
@@ -54,7 +54,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
     return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
 }
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     // FIXME: This should not be OS specific.  Delegate to the embedder instead.
 #if OS(WINDOWS)
diff --git a/Source/WebCore/page/efl/DragControllerEfl.cpp b/Source/WebCore/page/efl/DragControllerEfl.cpp
index 3a23537..f5c0ecc 100644
--- a/Source/WebCore/page/efl/DragControllerEfl.cpp
+++ b/Source/WebCore/page/efl/DragControllerEfl.cpp
@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     return false;
 }
diff --git a/Source/WebCore/page/gtk/DragControllerGtk.cpp b/Source/WebCore/page/gtk/DragControllerGtk.cpp
index 4c56162..29749e2 100644
--- a/Source/WebCore/page/gtk/DragControllerGtk.cpp
+++ b/Source/WebCore/page/gtk/DragControllerGtk.cpp
@@ -42,7 +42,7 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     return false;
 }
diff --git a/Source/WebCore/page/haiku/DragControllerHaiku.cpp b/Source/WebCore/page/haiku/DragControllerHaiku.cpp
index ef08ac2..de8ca81 100644
--- a/Source/WebCore/page/haiku/DragControllerHaiku.cpp
+++ b/Source/WebCore/page/haiku/DragControllerHaiku.cpp
@@ -44,7 +44,7 @@ const int DragController::DragIconBottomInset = 3;
 const float DragController::DragImageAlpha = 0.75f;
 
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     if (modifiers() & B_COMMAND_KEY)
         return true;
diff --git a/Source/WebCore/page/mac/DragControllerMac.mm b/Source/WebCore/page/mac/DragControllerMac.mm
index 608a4fc..9b61510 100644
--- a/Source/WebCore/page/mac/DragControllerMac.mm
+++ b/Source/WebCore/page/mac/DragControllerMac.mm
@@ -42,19 +42,19 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData* dragData)
 {
-    return [[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask;
+    return dragData->flags() & DragApplicationIsCopyKeyDown;
 }
     
 DragOperation DragController::dragOperation(DragData* dragData)
 {
     ASSERT(dragData);
-    if ([NSApp modalWindow] || !dragData->containsURL(m_page->mainFrame()))
+
+    if ((dragData->flags() & DragApplicationIsModal) || !dragData->containsURL(m_page->mainFrame()))
         return DragOperationNone;
 
-    if (!m_documentUnderMouse || (![[m_page->mainFrame()->view()->getOuterView() window] attachedSheet] 
-        && [dragData->platformData() draggingSource] != m_page->mainFrame()->view()->getOuterView()))
+    if (!m_documentUnderMouse || (!(dragData->flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
         return DragOperationCopy;
 
     return DragOperationNone;
diff --git a/Source/WebCore/page/qt/DragControllerQt.cpp b/Source/WebCore/page/qt/DragControllerQt.cpp
index 24f0d3d..cdea55b 100644
--- a/Source/WebCore/page/qt/DragControllerQt.cpp
+++ b/Source/WebCore/page/qt/DragControllerQt.cpp
@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
 const float DragController::DragImageAlpha = 0.75f;
 
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     return false;
 }
diff --git a/Source/WebCore/page/win/DragControllerWin.cpp b/Source/WebCore/page/win/DragControllerWin.cpp
index a16fe7f..6b1cd3e 100644
--- a/Source/WebCore/page/win/DragControllerWin.cpp
+++ b/Source/WebCore/page/win/DragControllerWin.cpp
@@ -50,7 +50,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
     return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
 }
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     return ::GetAsyncKeyState(VK_CONTROL);
 }
diff --git a/Source/WebCore/page/wx/DragControllerWx.cpp b/Source/WebCore/page/wx/DragControllerWx.cpp
index c288a01..4a4d064 100644
--- a/Source/WebCore/page/wx/DragControllerWx.cpp
+++ b/Source/WebCore/page/wx/DragControllerWx.cpp
@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
 
 const float DragController::DragImageAlpha = 0.75f;
 
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
 {
     notImplemented();
     return false;
diff --git a/Source/WebCore/platform/DragData.cpp b/Source/WebCore/platform/DragData.cpp
index 4518909..a61feab 100644
--- a/Source/WebCore/platform/DragData.cpp
+++ b/Source/WebCore/platform/DragData.cpp
@@ -31,13 +31,24 @@ namespace WebCore {
 
 #if !PLATFORM(MAC)
 DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, 
-    DragOperation sourceOperationMask)
+    DragOperation sourceOperationMask, DragApplicationFlags flags)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(data)
     , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
 {  
 }
+
+DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint& globalPosition,
+    DragOperation sourceOperationMask, DragApplicationFlags flags)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(0)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+{
+}
 #endif
 
 } // namespace WebCore
diff --git a/Source/WebCore/platform/DragData.h b/Source/WebCore/platform/DragData.h
index 30f049c..791b7ce 100644
--- a/Source/WebCore/platform/DragData.h
+++ b/Source/WebCore/platform/DragData.h
@@ -34,12 +34,15 @@
 #include <wtf/Vector.h>
 
 #if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
 #ifdef __OBJC__ 
 #import <Foundation/Foundation.h>
 #import <AppKit/NSDragging.h>
 typedef id <NSDraggingInfo> DragDataRef;
+ at class NSPasteboard;
 #else
 typedef void* DragDataRef;
+class NSPasteboard;
 #endif
 #elif PLATFORM(QT)
 QT_BEGIN_NAMESPACE
@@ -72,14 +75,25 @@ class DocumentFragment;
 class KURL;
 class Range;
 
+enum DragApplicationFlags {
+    DragApplicationNone = 0,
+    DragApplicationIsModal = 1,
+    DragApplicationIsSource = 2,
+    DragApplicationHasAttachedSheet = 4,
+    DragApplicationIsCopyKeyDown = 8
+};
+    
 class DragData {
 public:
     enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames };
 
     // clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
-    DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation);
+    DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
+    DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
+
     const IntPoint& clientPosition() const { return m_clientPosition; }
     const IntPoint& globalPosition() const { return m_globalPosition; }
+    DragApplicationFlags flags() { return m_applicationFlags; }
     DragDataRef platformData() const { return m_platformDragData; }
     DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
     bool containsURL(Frame*, FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
@@ -99,6 +113,10 @@ private:
     IntPoint m_globalPosition;
     DragDataRef m_platformDragData;
     DragOperation m_draggingSourceOperationMask;
+    DragApplicationFlags m_applicationFlags;
+#if PLATFORM(MAC)
+    RetainPtr<NSPasteboard> m_pasteboard;
+#endif
 };
     
 }
diff --git a/Source/WebCore/platform/mac/DragDataMac.mm b/Source/WebCore/platform/mac/DragDataMac.mm
index a079f4a..64376b1 100644
--- a/Source/WebCore/platform/mac/DragDataMac.mm
+++ b/Source/WebCore/platform/mac/DragDataMac.mm
@@ -38,11 +38,24 @@
 namespace WebCore {
 
 DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, 
-    DragOperation sourceOperationMask)
+    DragOperation sourceOperationMask, DragApplicationFlags flags)
     : m_clientPosition(clientPosition)
     , m_globalPosition(globalPosition)
     , m_platformDragData(data)
     , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+    , m_pasteboard([m_platformDragData draggingPasteboard])
+{
+}
+
+DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition,
+    DragOperation sourceOperationMask, DragApplicationFlags flags)
+    : m_clientPosition(clientPosition)
+    , m_globalPosition(globalPosition)
+    , m_platformDragData(0)
+    , m_draggingSourceOperationMask(sourceOperationMask)
+    , m_applicationFlags(flags)
+    , m_pasteboard([NSPasteboard pasteboardWithName:dragStorageName])
 {
 }
     
@@ -50,22 +63,22 @@ bool DragData::canSmartReplace() const
 {
     //Need to call this so that the various Pasteboard type strings are intialised
     Pasteboard::generalPasteboard();
-    return [[[m_platformDragData draggingPasteboard] types] containsObject:WebSmartPastePboardType];
+    return [[m_pasteboard.get() types] containsObject:WebSmartPastePboardType];
 }
 
 bool DragData::containsColor() const
 {
-    return [[[m_platformDragData draggingPasteboard] types] containsObject:NSColorPboardType];
+    return [[m_pasteboard.get() types] containsObject:NSColorPboardType];
 }
 
 bool DragData::containsFiles() const
 {
-    return [[[m_platformDragData draggingPasteboard] types] containsObject:NSFilenamesPboardType];
+    return [[m_pasteboard.get() types] containsObject:NSFilenamesPboardType];
 }
 
 void DragData::asFilenames(Vector<String>& result) const
 {
-    NSArray *filenames = [[m_platformDragData draggingPasteboard] propertyListForType:NSFilenamesPboardType];
+    NSArray *filenames = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
     NSEnumerator *fileEnumerator = [filenames objectEnumerator];
     
     while (NSString *filename = [fileEnumerator nextObject])
@@ -74,19 +87,18 @@ void DragData::asFilenames(Vector<String>& result) const
 
 bool DragData::containsPlainText() const
 {
-    NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
-    NSArray *types = [pasteboard types];
+    NSArray *types = [m_pasteboard.get() types];
     
     return [types containsObject:NSStringPboardType] 
         || [types containsObject:NSRTFDPboardType]
         || [types containsObject:NSRTFPboardType]
         || [types containsObject:NSFilenamesPboardType]
-        || [NSURL URLFromPasteboard:pasteboard];
+        || [NSURL URLFromPasteboard:m_pasteboard.get()];
 }
 
 String DragData::asPlainText(Frame *frame) const
 {
-    Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
+    Pasteboard pasteboard(m_pasteboard.get());
     return pasteboard.plainText(frame);
 }
 
@@ -113,8 +125,7 @@ static NSArray *insertablePasteboardTypes()
     
 bool DragData::containsCompatibleContent() const
 {
-    NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
-    NSMutableSet *types = [NSMutableSet setWithArray:[pasteboard types]];
+    NSMutableSet *types = [NSMutableSet setWithArray:[m_pasteboard.get() types]];
     [types intersectSet:[NSSet setWithArray:insertablePasteboardTypes()]];
     return [types count] != 0;
 }
@@ -133,13 +144,13 @@ String DragData::asURL(Frame* frame, FilenameConversionPolicy filenamePolicy, St
         if (NSString *URLTitleString = [[m_platformDragData draggingPasteboard] stringForType:WebURLNamePboardType])
             *title = URLTitleString;
     }
-    Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
+    Pasteboard pasteboard(m_pasteboard.get());
     return pasteboard.asURL(frame);
 }
 
 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
 {
-    Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
+    Pasteboard pasteboard(m_pasteboard.get());
     
     return pasteboard.documentFragment(frame, range, allowPlainText, chosePlainText);
 }
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index bd6acae..69384e0 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,23 @@
+2011-01-12  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Darin Adler.
+
+        WebKit2: Add support for drag and drop
+        https://bugs.webkit.org/show_bug.cgi?id=52343
+        <rdar://problem/7660558>
+        
+        The DragData class has been extended to provide
+        additional context from the application (keyboard state, modal windows, etc.)
+        as well as information of the drag pasteboard being used.
+        These are the changes to align the behavior for WebKit.
+
+        * WebView/WebView.mm:
+        (-[WebView applicationFlags:]): Added.
+        (-[WebView draggingEntered:]): Added parameter to the DragData constructor.
+        (-[WebView draggingUpdated:]): Added parameter to the DragData constructor.
+        (-[WebView draggingExited:]): Added parameter to the DragData constructor.
+        (-[WebView performDragOperation:]): Added parameter to the DragData constructor.
+
 2011-01-12  Beth Dakin  <bdakin at apple.com>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 638d328..49582b5 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -3765,11 +3765,25 @@ static bool needsWebViewInitThreadWorkaround()
     return [documentView _shouldAutoscrollForDraggingInfo:draggingInfo];
 }
 
+- (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo
+{
+    uint32_t flags = 0;
+    if ([NSApp modalWindow])
+        flags = DragApplicationIsModal;
+    if ([[self window] attachedSheet])
+        flags |= DragApplicationHasAttachedSheet;
+    if ([draggingInfo draggingSource] == self)
+        flags |= DragApplicationIsSource;
+    if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
+        flags |= DragApplicationIsCopyKeyDown;
+    return static_cast<DragApplicationFlags>(flags);
+}
+
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
 {
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     return core(self)->dragController()->dragEntered(&dragData);
 }
 
@@ -3781,7 +3795,7 @@ static bool needsWebViewInitThreadWorkaround()
 
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     return page->dragController()->dragUpdated(&dragData);
 }
 
@@ -3793,7 +3807,7 @@ static bool needsWebViewInitThreadWorkaround()
 
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     page->dragController()->dragExited(&dragData);
 }
 
@@ -3806,7 +3820,7 @@ static bool needsWebViewInitThreadWorkaround()
 {
     IntPoint client([draggingInfo draggingLocation]);
     IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
-    DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
     return core(self)->dragController()->performDrag(&dragData);
 }
 
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 8af95b0..06daccb 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,50 @@
+2011-01-13  Enrica Casucci  <enrica at apple.com>
+
+        Reviewed by Darin Adler.
+
+        WebKit2: Add support for drag and drop
+        https://bugs.webkit.org/show_bug.cgi?id=52343
+        <rdar://problem/7660558>
+               
+        This patch contains the changes required to support dropping content
+        in WebKit on the Mac. The DragData class has been extended to provide
+        additional context from the application (keyboard state, modal windows, etc.)
+        as well as information of the drag pasteboard being used.
+        The support for WebKit as drag source will be added with a separate patch.
+
+        * Shared/DragControllerAction.h: Added.
+        * UIProcess/API/mac/WKView.mm:
+        Added implemention of the methods required to add suport for a drop target.
+        To maintain asynchronous communication with the WebProcess, we always return
+        the previous calculated value for the drag operation.
+        (-[WKView _registerDraggedTypes]):
+        (-[WKView initWithFrame:contextRef:pageGroupRef:]):
+        (-[WKView applicationFlags:]):
+        (-[WKView draggingEntered:]):
+        (-[WKView draggingUpdated:]):
+        (-[WKView draggingExited:]):
+        (-[WKView prepareForDragOperation:]):
+        (-[WKView performDragOperation:]):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::performDragControllerAction):
+        (WebKit::WebPageProxy::didPerformDragControllerAction):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::dragOperation):
+        (WebKit::WebPageProxy::resetDragOperation):
+        * UIProcess/WebPageProxy.messages.in:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebDragClient.cpp:
+        (WebKit::WebDragClient::willPerformDragDestinationAction):
+        (WebKit::WebDragClient::willPerformDragSourceAction):
+        (WebKit::WebDragClient::actionMaskForDrag):
+        (WebKit::WebDragClient::dragSourceActionMaskForPoint):
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::performDragControllerAction):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2011-01-13  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by John Sullivan.
diff --git a/WebKit2/Shared/DragControllerAction.h b/WebKit2/Shared/DragControllerAction.h
new file mode 100644
index 0000000..b37e811
--- /dev/null
+++ b/WebKit2/Shared/DragControllerAction.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DragControllerAction_h
+#define DragControllerAction_h
+
+namespace WebKit {
+
+enum DragControllerAction {
+    DragControllerActionEntered,
+    DragControllerActionUpdated,
+    DragControllerActionExited,
+    DragControllerActionPerformDrag
+};
+
+} // namespace WebKit
+
+#endif // DragControllerAction_h
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index 91843e2..37830dd 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -50,9 +50,12 @@
 #import "WebSystemInterface.h"
 #import <QuartzCore/QuartzCore.h>
 #import <WebCore/ColorMac.h>
+#import <WebCore/DragController.h>
+#import <WebCore/DragData.h>
 #import <WebCore/FloatRect.h>
 #import <WebCore/IntRect.h>
 #import <WebCore/KeyboardEvent.h>
+#import <WebCore/PlatformMouseEvent.h>
 #import <WebCore/PlatformScreen.h>
 #import <WebKitSystemInterface.h>
 #import <wtf/RefPtr.h>
@@ -154,6 +157,25 @@ static bool useNewDrawingArea()
     return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil];
 }
 
+static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type";
+static NSString * const WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
+static NSString * const WebURLPboardType = @"public.url";
+static NSString * const WebURLNamePboardType = @"public.url-name";
+
+- (void)_registerDraggedTypes
+{
+    NSArray *editableTypes = [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType,
+#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
+        NSPICTPboardType,
+#endif
+        NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil];
+    NSArray *URLTypes = [NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType,  WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil];
+    NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes];
+    [types addObjectsFromArray:URLTypes];
+    [self registerForDraggedTypes:[types allObjects]];
+    [types release];
+}
+
 - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
 {
     self = [super initWithFrame:frame];
@@ -176,6 +198,8 @@ static bool useNewDrawingArea()
     _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef));
     _data->_page->initializeWebPage();
 
+    [self _registerDraggedTypes];
+
     WebContext::statistics().wkViewCount++;
 
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
@@ -977,6 +1001,62 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     return resultRect;
 }
 
+- (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo
+{
+    uint32_t flags = 0;
+    if ([NSApp modalWindow])
+        flags = DragApplicationIsModal;
+    if ([[self window] attachedSheet])
+        flags |= DragApplicationHasAttachedSheet;
+    if ([draggingInfo draggingSource] == self)
+        flags |= DragApplicationIsSource;
+    if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
+        flags |= DragApplicationIsCopyKeyDown;
+    return static_cast<DragApplicationFlags>(flags);
+}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
+{
+    IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+    IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+    
+    _data->_page->performDragControllerAction(DragControllerActionEntered, &dragData, [[draggingInfo draggingPasteboard] name]);
+    return NSDragOperationCopy;
+}
+
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
+{
+    IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+    IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+    _data->_page->performDragControllerAction(DragControllerActionUpdated, &dragData, [[draggingInfo draggingPasteboard] name]);
+    return _data->_page->dragOperation();
+}
+
+- (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
+{
+    IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+    IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+    _data->_page->performDragControllerAction(DragControllerActionExited, &dragData, [[draggingInfo draggingPasteboard] name]);
+    _data->_page->resetDragOperation();
+}
+
+- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo
+{
+    return YES;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo
+{
+    IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+    IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+    DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+    _data->_page->performDragControllerAction(DragControllerActionPerformDrag, &dragData, [[draggingInfo draggingPasteboard] name]);
+    return YES;
+}
+
 - (void)_updateWindowVisibility
 {
     _data->_page->updateWindowIsVisible(![[self window] isMiniaturized]);
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index b818898..4be0a17 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -64,6 +64,7 @@
 #include "WebProtectionSpace.h"
 #include "WebSecurityOrigin.h"
 #include "WebURLRequest.h"
+#include <WebCore/DragData.h>
 #include <WebCore/FloatRect.h>
 #include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/WindowFeatures.h>
@@ -124,6 +125,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, WebContext* context, WebPageG
     , m_hasSpellDocumentTag(false)
     , m_pendingLearnOrIgnoreWordMessageCount(0)
     , m_mainFrameHasCustomRepresentation(false)
+    , m_currentDragOperation(DragOperationNone)
 {
 #ifndef NDEBUG
     webPageProxyCounter.increment();
@@ -588,6 +590,18 @@ void WebPageProxy::setActualVisibleContentRect(const IntRect& rect)
 }
 #endif
 
+void WebPageProxy::performDragControllerAction(DragControllerAction action, WebCore::DragData* dragData, const String& dragStorageName)
+{
+    if (!isValid())
+        return;
+    process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags()), m_pageID);
+}
+
+void WebPageProxy::didPerformDragControllerAction(uint64_t resultOperation)
+{
+    m_currentDragOperation = static_cast<DragOperation>(resultOperation);
+}
+
 void WebPageProxy::handleMouseEvent(const WebMouseEvent& event)
 {
     if (!isValid())
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 47b8ea1..f0b4ce6 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -28,6 +28,7 @@
 
 #include "APIObject.h"
 #include "ContextMenuState.h"
+#include "DragControllerAction.h"
 #include "DrawingAreaProxy.h"
 #include "GeolocationPermissionRequestManagerProxy.h"
 #include "SelectionState.h"
@@ -47,6 +48,7 @@
 #include "WebPopupMenuProxy.h"
 #include "WebResourceLoadClient.h"
 #include "WebUIClient.h"
+#include <WebCore/DragActions.h>
 #include <WebCore/EditAction.h>
 #include <WebCore/Editor.h>
 #include <WebCore/FrameLoaderTypes.h>
@@ -68,6 +70,7 @@ namespace CoreIPC {
 namespace WebCore {
     class AuthenticationChallenge;
     class Cursor;
+    class DragData;
     class FloatRect;
     class IntSize;
     class ProtectionSpace;
@@ -269,6 +272,10 @@ public:
 
     void backForwardRemovedItem(uint64_t itemID);
 
+    // Drag and drop support.
+    void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String&);
+    void didPerformDragControllerAction(uint64_t resultOperation);
+
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
     void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
 
@@ -294,6 +301,9 @@ public:
     WebPageGroup* pageGroup() const { return m_pageGroup.get(); }
 
     bool isValid();
+    
+    WebCore::DragOperation dragOperation() { return m_currentDragOperation; }
+    void resetDragOperation() { m_currentDragOperation = WebCore::DragOperationNone; }
 
     // REMOVE: For demo purposes only.
     const String& urlAtProcessExit() const { return m_urlAtProcessExit; }
@@ -592,6 +602,7 @@ private:
     unsigned m_pendingLearnOrIgnoreWordMessageCount;
 
     bool m_mainFrameHasCustomRepresentation;
+    WebCore::DragOperation m_currentDragOperation;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/WebPageProxy.messages.in b/WebKit2/UIProcess/WebPageProxy.messages.in
index 00632ba..2d576be 100644
--- a/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -186,4 +186,7 @@ messages -> WebPageProxy {
     GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
     LearnWord(WTF::String word);
     IgnoreWord(WTF::String word);
+    
+    # Drag and drop.
+    DidPerformDragControllerAction(uint64_t resultOperation)
 }
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index e701ff6..3b021b3 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -657,6 +657,7 @@
 		C0E3AA7A1209E83000A49D01 /* ModuleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0E3AA481209E45000A49D01 /* ModuleMac.mm */; };
 		C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0E3AA451209E2BA00A49D01 /* Module.cpp */; };
 		C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */ = {isa = PBXBuildFile; fileRef = C0E3AA441209E2BA00A49D01 /* Module.h */; };
+		C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */ = {isa = PBXBuildFile; fileRef = C517388012DF8F4F00EE3F47 /* DragControllerAction.h */; };
 		C5237F6012441CA300780472 /* WebEditorClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C5237F5F12441CA300780472 /* WebEditorClientMac.mm */; };
 		D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */; };
 		D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484311FF4B6500032B39 /* WebPopupMenu.h */; };
@@ -1409,6 +1410,7 @@
 		C0E3AA441209E2BA00A49D01 /* Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Module.h; sourceTree = "<group>"; };
 		C0E3AA451209E2BA00A49D01 /* Module.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Module.cpp; sourceTree = "<group>"; };
 		C0E3AA481209E45000A49D01 /* ModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModuleMac.mm; sourceTree = "<group>"; };
+		C517388012DF8F4F00EE3F47 /* DragControllerAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragControllerAction.h; sourceTree = "<group>"; };
 		C5237F5F12441CA300780472 /* WebEditorClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebEditorClientMac.mm; sourceTree = "<group>"; };
 		D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPopupMenu.cpp; sourceTree = "<group>"; };
 		D3B9484311FF4B6500032B39 /* WebPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenu.h; sourceTree = "<group>"; };
@@ -1724,6 +1726,7 @@
 				1A2D956D12848564001EB962 /* ChildProcess.h */,
 				1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */,
 				1A2C306F12D555450063DAA2 /* ContextMenuState.h */,
+				C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
 				0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
 				762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
 				BCCF6B2312C93E7A008F9C35 /* ImageOptions.h */,
@@ -3028,6 +3031,7 @@
 				1A64235312DD187C00CAAE2C /* Region.h in Headers */,
 				1A64245E12DE29A100CAAE2C /* UpdateInfo.h in Headers */,
 				1A64256812DE42EC00CAAE2C /* BackingStore.h in Headers */,
+				C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
index fc1608e..d11017f 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
@@ -34,29 +34,24 @@ namespace WebKit {
 
 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*)
 {
-    notImplemented();
 }
 
 void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
 {
-    notImplemented();
 }
 
 DragDestinationAction WebDragClient::actionMaskForDrag(DragData*)
 {
-    notImplemented();
-    return DragDestinationActionNone;
+    return DragDestinationActionAny;
 }
 
 DragSourceAction WebDragClient::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
 {
-    notImplemented();
-    return DragSourceActionNone;
+    return DragSourceActionAny;
 }
 
 void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool)
 {
-    notImplemented();
 }
 
 DragImageRef WebDragClient::createDragImageForLink(KURL&, const String&, Frame*)
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 543557c..97ee909 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -71,6 +71,8 @@
 #include <WebCore/DocumentFragment.h>
 #include <WebCore/DocumentLoader.h>
 #include <WebCore/DocumentMarkerController.h>
+#include <WebCore/DragController.h>
+#include <WebCore/DragData.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/FocusController.h>
 #include <WebCore/Frame.h>
@@ -818,6 +820,7 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, Page* page)
             return frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent);
         case WebCore::MouseEventMoved:
             return frame->eventHandler()->mouseMoved(platformMouseEvent);
+
         default:
             ASSERT_NOT_REACHED();
             return false;
@@ -1250,6 +1253,36 @@ bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt)
 }
 #endif
 
+void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags)
+{
+    if (!m_page) {
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone));
+        return;
+    }
+
+    DragData dragData(dragStorageName, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
+    switch (action) {
+    case DragControllerActionEntered:
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragEntered(&dragData)));
+        break;
+
+    case DragControllerActionUpdated:
+        send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragUpdated(&dragData)));
+        break;
+        
+    case DragControllerActionExited:
+        m_page->dragController()->dragExited(&dragData);
+        break;
+        
+    case DragControllerActionPerformDrag:
+        m_page->dragController()->performDrag(&dragData);
+        break;
+        
+    default:
+        ASSERT_NOT_REACHED();
+    }
+}
+
 WebEditCommand* WebPage::webEditCommand(uint64_t commandID)
 {
     return m_editCommandMap.get(commandID).get();
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index 492f54b..21ca442 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -298,6 +298,7 @@ public:
 #endif
 
     void replaceSelectionWithText(WebCore::Frame*, const String&);
+    void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags);
 
     bool mainFrameHasCustomRepresentation() const;
 
diff --git a/WebKit2/WebProcess/WebPage/WebPage.messages.in b/WebKit2/WebProcess/WebPage/WebPage.messages.in
index ca65458..3a2e394 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -96,6 +96,9 @@ messages -> WebPage {
     HideFindUI()
     CountStringMatches(WTF::String string, uint32_t findOptions, unsigned maxMatchCount)
 
+    # Drag and drop.
+    PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags)
+
     # Popup menu.
     DidChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
     SetTextForActivePopupMenu(int32_t index);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list