Title: [218837] trunk/Source
Revision
218837
Author
wenson_hs...@apple.com
Date
2017-06-27 12:11:34 -0700 (Tue, 27 Jun 2017)

Log Message

Refactor drag start codepaths to plumb a DragItem to client layers
https://bugs.webkit.org/show_bug.cgi?id=173832
Work towards <rdar://problem/32236827>

Reviewed by Ryosuke Niwa and Tim Horton.

Source/WebCore:

Refactor drag start logic in WebCore to set up a DragItem and propagate it to WebDragClient. No change in behavior.

* loader/EmptyClients.cpp:
* page/DragClient.h:
* page/DragController.cpp:
(WebCore::DragController::startDrag):
(WebCore::DragController::doImageDrag):
(WebCore::DragController::doSystemDrag):

Refactor to pass along a DragItem. Also, remove unused drag image anchor computation.

* page/DragController.h:
* platform/DragImage.h:
* platform/DragItem.h:

Add additional information needed to begin a drag on iOS.

(WebCore::DragItem::encode):
(WebCore::DragItem::decode):

Add IPC serialization/deserialization support for DragItem.

* platform/PasteboardWriterData.cpp:
(WebCore::PasteboardWriterData::isEmpty):
* platform/PasteboardWriterData.h:

Source/WebKit/mac:

Refactor code used to start a drag in WebKit1 to plumb a single DragItem from DragController to the client layer
in WebDragClient that contains all the information needed to begin a drag. Also renames _setDataInteractionData:
to _startDrag: to match logic used to start a drag on other platforms.

No behavior change -- the same information should be propagated to AppKit and UIKit when beginning a drag, only
through the DragItem struct.

* WebCoreSupport/WebDragClient.h:
* WebCoreSupport/WebDragClient.mm:
(WebDragClient::startDrag):
(WebDragClient::dragSourceActionMaskForPoint):
(WebDragClient::willPerformDragSourceAction):
(WebDragClient::beginDrag):
* WebView/WebView.mm:
(-[WebView _startDrag:]):
(-[WebView _setDataInteractionData:textIndicator:atClientPosition:anchorPoint:action:]): Deleted.
* WebView/WebViewInternal.h:

Source/WebKit/win:

Adjust for changes to WebDragClient::startDrag by pulling information out of DragItem.

* WebCoreSupport/WebDragClient.cpp:
(WebDragClient::startDrag):
* WebCoreSupport/WebDragClient.h:

Source/WebKit2:

Add support for serializing a DragItem over IPC. This encodes and decodes all members of DragItem except for the
PasteboardWriterData and the DragImage's image. The DragItem is sent over to the UI process in
WebDragClient::startDrag via the WebPageProxy::startDrag IPC message (renamed from WebPageProxy::setDragImage)
which now takes a DragItem.

* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::startDrag):
(WebKit::WebPageProxy::setDragImage): Deleted.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

Rename SetDragImage to StartDrag and refactor to receive only a DragItem and shareable bitmap handle.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::startDrag):
(WebKit::PageClientImpl::startDataInteractionWithImage): Deleted.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startDrag:item:]):
(-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]): Deleted.

Rename startDataInteractionWithImage to startDrag.

* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::startDrag):
(WebKit::WebPageProxy::setDragImage): Deleted.
* WebProcess/WebCoreSupport/WebDragClient.cpp:
(WebKit::WebDragClient::startDrag):
* WebProcess/WebCoreSupport/WebDragClient.h:
* WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
(WebKit::WebDragClient::startDrag):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::startDrag):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218836 => 218837)


--- trunk/Source/WebCore/ChangeLog	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/ChangeLog	2017-06-27 19:11:34 UTC (rev 218837)
@@ -1,3 +1,37 @@
+2017-06-27  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Refactor drag start codepaths to plumb a DragItem to client layers
+        https://bugs.webkit.org/show_bug.cgi?id=173832
+        Work towards <rdar://problem/32236827>
+
+        Reviewed by Ryosuke Niwa and Tim Horton.
+
+        Refactor drag start logic in WebCore to set up a DragItem and propagate it to WebDragClient. No change in behavior.
+
+        * loader/EmptyClients.cpp:
+        * page/DragClient.h:
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag):
+        (WebCore::DragController::doImageDrag):
+        (WebCore::DragController::doSystemDrag):
+
+        Refactor to pass along a DragItem. Also, remove unused drag image anchor computation.
+
+        * page/DragController.h:
+        * platform/DragImage.h:
+        * platform/DragItem.h:
+
+        Add additional information needed to begin a drag on iOS.
+
+        (WebCore::DragItem::encode):
+        (WebCore::DragItem::decode):
+
+        Add IPC serialization/deserialization support for DragItem.
+
+        * platform/PasteboardWriterData.cpp:
+        (WebCore::PasteboardWriterData::isEmpty):
+        * platform/PasteboardWriterData.h:
+
 2017-06-27  Frederic Wang  <fw...@igalia.com>
 
         Some tests to verify forbidden frame navigation time out

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (218836 => 218837)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2017-06-27 19:11:34 UTC (rev 218837)
@@ -131,7 +131,7 @@
     void willPerformDragDestinationAction(DragDestinationAction, const DragData&) final { }
     void willPerformDragSourceAction(DragSourceAction, const IntPoint&, DataTransfer&) final { }
     DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) final { return DragSourceActionNone; }
-    void startDrag(DragImage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, DragSourceAction) final { }
+    void startDrag(DragItem, DataTransfer&, Frame&) final { }
     void dragControllerDestroyed() final { }
 };
 

Modified: trunk/Source/WebCore/page/DragClient.h (218836 => 218837)


--- trunk/Source/WebCore/page/DragClient.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/page/DragClient.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -49,7 +49,7 @@
     virtual void didConcludeEditDrag() { }
     virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0;
     
-    virtual void startDrag(DragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, const FloatPoint& dragImageAnchor, DataTransfer&, Frame&, DragSourceAction) = 0;
+    virtual void startDrag(DragItem, DataTransfer&, Frame&) = 0;
     virtual void dragEnded() { }
 
     virtual void beginDrag(DragItem, Frame&, const IntPoint&, const IntPoint&, DataTransfer&, DragSourceAction) { }

Modified: trunk/Source/WebCore/page/DragController.cpp (218836 => 218837)


--- trunk/Source/WebCore/page/DragController.cpp	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/page/DragController.cpp	2017-06-27 19:11:34 UTC (rev 218837)
@@ -43,6 +43,7 @@
 #include "Editing.h"
 #include "Editor.h"
 #include "EditorClient.h"
+#include "ElementAncestorIterator.h"
 #include "EventHandler.h"
 #include "FloatRect.h"
 #include "FrameLoadRequest.h"
@@ -52,6 +53,7 @@
 #include "HTMLAttachmentElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLParserIdioms.h"
 #include "HTMLPlugInElement.h"
 #include "HitTestRequest.h"
 #include "HitTestResult.h"
@@ -963,7 +965,7 @@
             return false;
 
         if (mustUseLegacyDragClient) {
-            doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, dragImageBounds, dataTransfer, src, DragSourceActionSelection);
+            doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state);
             return true;
         }
 
@@ -996,10 +998,10 @@
         m_client.willPerformDragSourceAction(DragSourceActionImage, dragOrigin, dataTransfer);
 
         if (!dragImage)
-            doImageDrag(element, dragOrigin, hitTestResult.imageRect(), dataTransfer, src, m_dragOffset);
+            doImageDrag(element, dragOrigin, hitTestResult.imageRect(), src, m_dragOffset, state);
         else {
             // DHTML defined drag image
-            doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionImage);
+            doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state);
         }
 
         return true;
@@ -1051,7 +1053,7 @@
         }
 
         if (mustUseLegacyDragClient) {
-            doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionLink);
+            doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state);
             return true;
         }
 
@@ -1102,7 +1104,7 @@
             dragLoc = dragLocForSelectionDrag(src);
             m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y());
         }
-        doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionAttachment);
+        doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state);
         src.selection().setSelection(previousSelection);
         src.editor().setIgnoreSelectionChanges(false);
         return true;
@@ -1112,7 +1114,7 @@
     if (state.type == DragSourceActionDHTML && dragImage) {
         ASSERT(m_dragSourceAction & DragSourceActionDHTML);
         m_client.willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, dataTransfer);
-        doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionDHTML);
+        doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state);
         return true;
     }
 
@@ -1119,7 +1121,7 @@
     return false;
 }
 
-void DragController::doImageDrag(Element& element, const IntPoint& dragOrigin, const IntRect& layoutRect, DataTransfer& dataTransfer, Frame& frame, IntPoint& dragImageOffset)
+void DragController::doImageDrag(Element& element, const IntPoint& dragOrigin, const IntRect& layoutRect, Frame& frame, IntPoint& dragImageOffset, const DragState& state)
 {
     IntPoint mouseDownPoint = dragOrigin;
     DragImage dragImage;
@@ -1160,7 +1162,7 @@
         return;
 
     dragImageOffset = mouseDownPoint + scaledOrigin;
-    doSystemDrag(WTFMove(dragImage), dragImageOffset, dragOrigin, element.boundsInRootViewSpace(), dataTransfer, frame, DragSourceActionImage);
+    doSystemDrag(WTFMove(dragImage), dragImageOffset, dragOrigin, frame, state);
 }
 
 void DragController::beginDrag(DragItem dragItem, Frame& frame, const IntPoint& mouseDownPoint, const IntPoint& mouseDraggedPoint, DataTransfer& dataTransfer, DragSourceAction dragSourceAction)
@@ -1187,22 +1189,41 @@
     cleanupAfterSystemDrag();
 }
 
-void DragController::doSystemDrag(DragImage image, const IntPoint& dragLoc, const IntPoint& eventPos, const IntRect& dragImageBounds, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)
+void DragController::doSystemDrag(DragImage image, const IntPoint& dragLoc, const IntPoint& eventPos, Frame& frame, const DragState& state)
 {
-    FloatPoint dragImageAnchor = { 0.5, 0.5 };
-    if (dragSourceAction == DragSourceActionLink)
-        dragImageAnchor.setY(1);
-    else if (!dragImageBounds.isEmpty()) {
-        dragImageAnchor.setX((eventPos.x() - dragImageBounds.x()) / (float)dragImageBounds.width());
-        dragImageAnchor.setY((eventPos.y() - dragImageBounds.y()) / (float)dragImageBounds.height());
-    }
-
     m_didInitiateDrag = true;
     m_dragInitiator = frame.document();
     // Protect this frame and view, as a load may occur mid drag and attempt to unload this frame
     Ref<MainFrame> frameProtector(m_page.mainFrame());
     RefPtr<FrameView> viewProtector = frameProtector->view();
-    m_client.startDrag(WTFMove(image), viewProtector->rootViewToContents(frame.view()->contentsToRootView(dragLoc)), viewProtector->rootViewToContents(frame.view()->contentsToRootView(eventPos)), dragImageAnchor, dataTransfer, frameProtector.get(), dragSourceAction);
+
+    DragItem item;
+    item.image = WTFMove(image);
+    item.sourceAction = state.type;
+    item.eventPositionInContentCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(eventPos));
+    item.dragLocationInContentCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(dragLoc));
+    item.eventPositionInWindowCoordinates = frame.view()->contentsToWindow(item.eventPositionInContentCoordinates);
+    item.dragLocationInWindowCoordinates = frame.view()->contentsToWindow(item.dragLocationInContentCoordinates);
+    if (auto element = state.source) {
+        item.elementBounds = element->boundsInRootViewSpace();
+        RefPtr<Element> link;
+        if (element->isLink())
+            link = element;
+        else {
+            for (auto& currentElement : elementLineage(element.get())) {
+                if (currentElement.isLink()) {
+                    link = &currentElement;
+                    break;
+                }
+            }
+        }
+        if (link) {
+            auto titleAttribute = link->attributeWithoutSynchronization(HTMLNames::titleAttr);
+            item.title = titleAttribute.isEmpty() ? link->innerText() : titleAttribute.string();
+            item.url = ""
+        }
+    }
+    m_client.startDrag(WTFMove(item), *state.dataTransfer, frameProtector.get());
     // DragClient::startDrag can cause our Page to dispear, deallocating |this|.
     if (!frameProtector->page())
         return;

Modified: trunk/Source/WebCore/page/DragController.h (218836 => 218837)


--- trunk/Source/WebCore/page/DragController.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/page/DragController.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -115,8 +115,8 @@
         void mouseMovedIntoDocument(Document*);
         bool shouldUseCachedImageForDragImage(const Image&) const;
 
-        void doImageDrag(Element&, const IntPoint&, const IntRect&, DataTransfer&, Frame&, IntPoint&);
-        void doSystemDrag(DragImage, const IntPoint&, const IntPoint&, const IntRect& dragImageBounds, DataTransfer&, Frame&, DragSourceAction);
+        void doImageDrag(Element&, const IntPoint&, const IntRect&, Frame&, IntPoint&, const DragState&);
+        void doSystemDrag(DragImage, const IntPoint&, const IntPoint&, Frame&, const DragState&);
 
         void beginDrag(DragItem, Frame&, const IntPoint& mouseDownPoint, const IntPoint& mouseDraggedPoint, DataTransfer&, DragSourceAction);
 

Modified: trunk/Source/WebCore/platform/DragImage.h (218836 => 218837)


--- trunk/Source/WebCore/platform/DragImage.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/platform/DragImage.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -97,10 +97,10 @@
 
 class DragImage final {
 public:
-    DragImage();
+    WEBCORE_EXPORT DragImage();
     explicit DragImage(DragImageRef);
     DragImage(DragImage&&);
-    ~DragImage();
+    WEBCORE_EXPORT ~DragImage();
 
     DragImage& operator=(DragImage&&);
 

Modified: trunk/Source/WebCore/platform/DragItem.h (218836 => 218837)


--- trunk/Source/WebCore/platform/DragItem.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/platform/DragItem.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -27,6 +27,8 @@
 
 #include "DragImage.h"
 #include "FloatPoint.h"
+#include "IntPoint.h"
+#include "IntRect.h"
 #include "PasteboardWriterData.h"
 
 namespace WebCore {
@@ -37,7 +39,65 @@
     // Where the image should be positioned relative to the cursor.
     FloatPoint imageAnchorPoint;
 
+    DragSourceAction sourceAction { DragSourceActionNone };
+    IntPoint eventPositionInContentCoordinates;
+    IntPoint dragLocationInContentCoordinates;
+    IntPoint eventPositionInWindowCoordinates;
+    IntPoint dragLocationInWindowCoordinates;
+    String title;
+    URL url;
+    IntRect elementBounds;
+
     PasteboardWriterData data;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static bool decode(Decoder&, DragItem&);
 };
 
+template<class Encoder>
+void DragItem::encode(Encoder& encoder) const
+{
+    // FIXME(173815): We should encode and decode PasteboardWriterData and platform drag image data
+    // here too, as part of moving off of the legacy dragging codepath.
+    encoder.encodeEnum(sourceAction);
+    encoder << imageAnchorPoint << eventPositionInContentCoordinates << dragLocationInContentCoordinates << eventPositionInWindowCoordinates << dragLocationInWindowCoordinates << title << url << elementBounds;
+    bool hasIndicatorData = image.hasIndicatorData();
+    encoder << hasIndicatorData;
+    if (hasIndicatorData)
+        encoder << image.indicatorData().value();
 }
+
+template<class Decoder>
+bool DragItem::decode(Decoder& decoder, DragItem& result)
+{
+    if (!decoder.decodeEnum(result.sourceAction))
+        return false;
+    if (!decoder.decode(result.imageAnchorPoint))
+        return false;
+    if (!decoder.decode(result.eventPositionInContentCoordinates))
+        return false;
+    if (!decoder.decode(result.dragLocationInContentCoordinates))
+        return false;
+    if (!decoder.decode(result.eventPositionInWindowCoordinates))
+        return false;
+    if (!decoder.decode(result.dragLocationInWindowCoordinates))
+        return false;
+    if (!decoder.decode(result.title))
+        return false;
+    if (!decoder.decode(result.url))
+        return false;
+    if (!decoder.decode(result.elementBounds))
+        return false;
+    bool hasIndicatorData;
+    if (!decoder.decode(hasIndicatorData))
+        return false;
+    if (hasIndicatorData) {
+        TextIndicatorData indicatorData;
+        if (!decoder.decode(indicatorData))
+            return false;
+        result.image.setIndicatorData(indicatorData);
+    }
+    return true;
+}
+
+}

Modified: trunk/Source/WebCore/platform/PasteboardWriterData.cpp (218836 => 218837)


--- trunk/Source/WebCore/platform/PasteboardWriterData.cpp	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/platform/PasteboardWriterData.cpp	2017-06-27 19:11:34 UTC (rev 218837)
@@ -48,13 +48,7 @@
 
 bool PasteboardWriterData::isEmpty() const
 {
-    if (m_plainText)
-        return false;
-
-    if (m_url)
-        return false;
-
-    return true;
+    return !m_plainText && !m_url && !m_webContent;
 }
 
 void PasteboardWriterData::setPlainText(PlainText plainText)

Modified: trunk/Source/WebCore/platform/PasteboardWriterData.h (218836 => 218837)


--- trunk/Source/WebCore/platform/PasteboardWriterData.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebCore/platform/PasteboardWriterData.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -35,8 +35,8 @@
 
 class PasteboardWriterData final {
 public:
-    PasteboardWriterData();
-    ~PasteboardWriterData();
+    WEBCORE_EXPORT PasteboardWriterData();
+    WEBCORE_EXPORT ~PasteboardWriterData();
 
     WEBCORE_EXPORT bool isEmpty() const;
 

Modified: trunk/Source/WebKit/mac/ChangeLog (218836 => 218837)


--- trunk/Source/WebKit/mac/ChangeLog	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-06-27 19:11:34 UTC (rev 218837)
@@ -1,3 +1,29 @@
+2017-06-27  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Refactor drag start codepaths to plumb a DragItem to client layers
+        https://bugs.webkit.org/show_bug.cgi?id=173832
+        Work towards <rdar://problem/32236827>
+
+        Reviewed by Ryosuke Niwa and Tim Horton.
+
+        Refactor code used to start a drag in WebKit1 to plumb a single DragItem from DragController to the client layer
+        in WebDragClient that contains all the information needed to begin a drag. Also renames _setDataInteractionData:
+        to _startDrag: to match logic used to start a drag on other platforms.
+
+        No behavior change -- the same information should be propagated to AppKit and UIKit when beginning a drag, only
+        through the DragItem struct.
+
+        * WebCoreSupport/WebDragClient.h:
+        * WebCoreSupport/WebDragClient.mm:
+        (WebDragClient::startDrag):
+        (WebDragClient::dragSourceActionMaskForPoint):
+        (WebDragClient::willPerformDragSourceAction):
+        (WebDragClient::beginDrag):
+        * WebView/WebView.mm:
+        (-[WebView _startDrag:]):
+        (-[WebView _setDataInteractionData:textIndicator:atClientPosition:anchorPoint:action:]): Deleted.
+        * WebView/WebViewInternal.h:
+
 2017-06-25  Konstantin Tokarev  <annu...@yandex.ru>
 
         Remove excessive headers from _javascript_Core

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h (218836 => 218837)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -39,7 +39,7 @@
     void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&) override;
     void dragControllerDestroyed() override;
     WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
-    void startDrag(WebCore::DragImage, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, const WebCore::FloatPoint&, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction) override;
+    void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&) override;
 
     void beginDrag(WebCore::DragItem, WebCore::Frame&, const WebCore::IntPoint& mouseDownPosition, const WebCore::IntPoint& mouseDraggedPosition, WebCore::DataTransfer&, WebCore::DragSourceAction) override;
 

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm (218836 => 218837)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -50,6 +50,7 @@
 #import <WebCore/Editor.h>
 #import <WebCore/EditorClient.h>
 #import <WebCore/EventHandler.h>
+#import <WebCore/FloatPoint.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/Image.h>
 #import <WebCore/MainFrame.h>
@@ -100,13 +101,16 @@
     [[m_webView _UIDelegateForwarder] webView:m_webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:mouseDownPoint withPasteboard:[NSPasteboard pasteboardWithName:dataTransfer.pasteboard().name()]];
 }
 
-void WebDragClient::startDrag(DragImage dragImage, const IntPoint& at, const IntPoint& eventPos, const FloatPoint&, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)
+void WebDragClient::startDrag(DragItem dragItem, DataTransfer& dataTransfer, Frame& frame)
 {
+    auto& dragImage = dragItem.image;
+    auto dragLocationInContentCoordinates = dragItem.dragLocationInContentCoordinates;
+
     RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(&frame) frameView] documentView];
     if (![htmlView.get() isKindOfClass:[WebHTMLView class]])
         return;
     
-    NSEvent *event = dragSourceAction == DragSourceActionLink ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];
+    NSEvent *event = dragItem.sourceAction == DragSourceActionLink ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];
     WebHTMLView* topHTMLView = getTopHTMLView(&frame);
     RetainPtr<WebHTMLView> topViewProtector = topHTMLView;
     
@@ -124,7 +128,7 @@
     SEL selector = @selector(webView:dragImage:at:offset:event:pasteboard:source:slideBack:forView:);
     if ([delegate respondsToSelector:selector]) {
         @try {
-            [delegate webView:m_webView dragImage:dragNSImage at:at offset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES forView:topHTMLView];
+            [delegate webView:m_webView dragImage:dragNSImage at:dragLocationInContentCoordinates offset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES forView:topHTMLView];
         } @catch (id exception) {
             ReportDiscardedDelegateException(selector, exception);
         }
@@ -131,7 +135,7 @@
     } else
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-        [topHTMLView dragImage:dragNSImage at:at offset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES];
+        [topHTMLView dragImage:dragNSImage at:dragLocationInContentCoordinates offset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES];
 #pragma clang diagnostic pop
 }
 
@@ -198,7 +202,7 @@
 {
 }
 
-void WebDragClient::startDrag(WebCore::DragImage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, WebCore::DragSourceAction)
+void WebDragClient::startDrag(WebCore::DragItem, DataTransfer&, Frame&)
 {
 }
 
@@ -239,9 +243,9 @@
 {
 }
 
-void WebDragClient::startDrag(DragImage dragImage, const IntPoint& point, const IntPoint& eventLocation, const FloatPoint& dragImageAnchor, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)
+void WebDragClient::startDrag(DragItem dragItem, DataTransfer&, Frame&)
 {
-    [m_webView _setDataInteractionData:dragImage.get().get() textIndicator:dragImage.indicatorData() atClientPosition:eventLocation anchorPoint:dragImageAnchor action:dragSourceAction];
+    [m_webView _startDrag:dragItem];
 }
 
 void WebDragClient::beginDrag(DragItem, Frame&, const IntPoint&, const IntPoint&, DataTransfer&, DragSourceAction)

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (218836 => 218837)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -133,6 +133,7 @@
 #import <WebCore/DocumentLoader.h>
 #import <WebCore/DragController.h>
 #import <WebCore/DragData.h>
+#import <WebCore/DragItem.h>
 #import <WebCore/Editing.h>
 #import <WebCore/Editor.h>
 #import <WebCore/Event.h>
@@ -1829,8 +1830,12 @@
     return _private->page->mainFrame().eventHandler().tryToBeginDataInteractionAtPoint(IntPoint(clientPosition), IntPoint(globalPosition));
 }
 
-- (void)_setDataInteractionData:(CGImageRef)image textIndicator:(std::optional<TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action
+- (void)_startDrag:(const DragItem&)dragItem
 {
+    auto& dragImage = dragItem.image;
+    auto image = dragImage.get().get();
+    auto indicatorData = dragImage.indicatorData();
+
     if (indicatorData)
         _private->textIndicatorData = adoptNS([[WebUITextIndicatorData alloc] initWithImage:image textIndicatorData:indicatorData.value() scale:_private->page->deviceScaleFactor()]);
     else

Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (218836 => 218837)


--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -63,6 +63,12 @@
 struct DictionaryPopupInfo;
 }
 
+#if PLATFORM(IOS) && ENABLE(DRAG_SUPPORT)
+namespace WebCore {
+struct DragItem;
+}
+#endif
+
 class WebMediaPlaybackTargetPicker;
 class WebSelectionServiceController;
 
@@ -261,7 +267,7 @@
 #endif
 
 #if ENABLE(DATA_INTERACTION) && defined(__cplusplus)
-- (void)_setDataInteractionData:(CGImageRef)image textIndicator:(std::optional<WebCore::TextIndicatorData>)textIndicator atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;
+- (void)_startDrag:(const WebCore::DragItem&)dragItem;
 - (void)_didConcludeEditDataInteraction;
 #endif
 

Modified: trunk/Source/WebKit/win/ChangeLog (218836 => 218837)


--- trunk/Source/WebKit/win/ChangeLog	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/win/ChangeLog	2017-06-27 19:11:34 UTC (rev 218837)
@@ -1,3 +1,17 @@
+2017-06-27  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Refactor drag start codepaths to plumb a DragItem to client layers
+        https://bugs.webkit.org/show_bug.cgi?id=173832
+        Work towards <rdar://problem/32236827>
+
+        Reviewed by Ryosuke Niwa and Tim Horton.
+
+        Adjust for changes to WebDragClient::startDrag by pulling information out of DragItem.
+
+        * WebCoreSupport/WebDragClient.cpp:
+        (WebDragClient::startDrag):
+        * WebCoreSupport/WebDragClient.h:
+
 2017-06-25  Konstantin Tokarev  <annu...@yandex.ru>
 
         Remove excessive headers from _javascript_Core

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp (218836 => 218837)


--- trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp	2017-06-27 19:11:34 UTC (rev 218837)
@@ -31,6 +31,7 @@
 #include <WebCore/DataTransfer.h>
 #include <WebCore/DragController.h>
 #include <WebCore/DragData.h>
+#include <WebCore/DragItem.h>
 #include <WebCore/EventHandler.h>
 #include <WebCore/FrameView.h>
 #include <WebCore/GraphicsContext.h>
@@ -98,11 +99,15 @@
         const_cast<Pasteboard&>(dataTransfer.pasteboard()).setExternalDataObject(newDataObject.get());
 }
 
-void WebDragClient::startDrag(DragImage image, const IntPoint& imageOrigin, const IntPoint& dragPoint, const FloatPoint&, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)
+void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame& frame)
 {
     //FIXME: Allow UIDelegate to override behaviour <rdar://problem/5015953>
 
     //We liberally protect everything, to protect against a load occurring mid-drag
+    auto& image = item.image;
+    auto imageOrigin = item.dragLocationInContentCoordinates;
+    auto dragPoint = item.eventPositionInContentCoordinates;
+
     RefPtr<Frame> frameProtector = &frame;
     COMPtr<IDragSourceHelper> helper;
     COMPtr<IDataObject> dataObject;
@@ -125,7 +130,7 @@
                 sdi.hbmpDragImage = image.get();
                 sdi.ptOffset.x = dragPoint.x() - imageOrigin.x();
                 sdi.ptOffset.y = dragPoint.y() - imageOrigin.y();
-                if (dragSourceAction == DragSourceActionLink)
+                if (item.sourceAction == DragSourceActionLink)
                     sdi.ptOffset.y = b.bmHeight - sdi.ptOffset.y;
 
                 helper->InitializeFromBitmap(&sdi, dataObject.get());

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.h (218836 => 218837)


--- trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -38,7 +38,7 @@
     virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint&);
     virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&);
     virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&);
-    virtual void startDrag(WebCore::DragImage, const WebCore::IntPoint&, const WebCore::IntPoint&, const WebCore::FloatPoint&, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction);
+    virtual void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&);
 
 private:
     WebView* m_webView;

Modified: trunk/Source/WebKit2/ChangeLog (218836 => 218837)


--- trunk/Source/WebKit2/ChangeLog	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-27 19:11:34 UTC (rev 218837)
@@ -1,5 +1,49 @@
 2017-06-27  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        Refactor drag start codepaths to plumb a DragItem to client layers
+        https://bugs.webkit.org/show_bug.cgi?id=173832
+        Work towards <rdar://problem/32236827>
+
+        Reviewed by Ryosuke Niwa and Tim Horton.
+
+        Add support for serializing a DragItem over IPC. This encodes and decodes all members of DragItem except for the
+        PasteboardWriterData and the DragImage's image. The DragItem is sent over to the UI process in
+        WebDragClient::startDrag via the WebPageProxy::startDrag IPC message (renamed from WebPageProxy::setDragImage)
+        which now takes a DragItem.
+
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::startDrag):
+        (WebKit::WebPageProxy::setDragImage): Deleted.
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+
+        Rename SetDragImage to StartDrag and refactor to receive only a DragItem and shareable bitmap handle.
+
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::startDrag):
+        (WebKit::PageClientImpl::startDataInteractionWithImage): Deleted.
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startDrag:item:]):
+        (-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]): Deleted.
+
+        Rename startDataInteractionWithImage to startDrag.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::startDrag):
+        (WebKit::WebPageProxy::setDragImage): Deleted.
+        * WebProcess/WebCoreSupport/WebDragClient.cpp:
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebCoreSupport/WebDragClient.h:
+        * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::startDrag):
+
+2017-06-27  Wenson Hsieh  <wenson_hs...@apple.com>
+
         [iOS DnD] [WK2] WKWebView does not handle drag sessions that exit and re-enter
         https://bugs.webkit.org/show_bug.cgi?id=173856
         <rdar://problem/32957100>

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -31,6 +31,7 @@
 #import "LoadParameters.h"
 #import "PageClient.h"
 #import "WebProcessProxy.h"
+#import <WebCore/DragItem.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/SearchPopupMenuCocoa.h>
 #import <WebCore/ValidationBubble.h>
@@ -104,9 +105,9 @@
 
 #if PLATFORM(IOS) && ENABLE(DRAG_SUPPORT)
 
-void WebPageProxy::setDragImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<TextIndicatorData> textIndicator, const FloatPoint& dragImageAnchor, uint64_t action)
+void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle)
 {
-    m_pageClient.startDataInteractionWithImage(clientPosition, dragImageHandle, textIndicator, dragImageAnchor, action);
+    m_pageClient.startDrag(dragItem, dragImageHandle);
 }
 
 void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::Handle&, uint64_t, const String&, const String&, const String&, const String&, const String&, const SharedMemory::Handle&, uint64_t)

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -56,6 +56,12 @@
 struct ViewportAttributes;
 }
 
+#if ENABLE(DRAG_SUPPORT)
+namespace WebCore {
+struct DragItem;
+}
+#endif
+
 namespace WebKit {
 
 class DrawingAreaProxy;
@@ -373,7 +379,7 @@
 #if ENABLE(DATA_INTERACTION)
     virtual void didPerformDataInteractionControllerOperation(bool handled) = 0;
     virtual void didHandleStartDataInteractionRequest(bool started) = 0;
-    virtual void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) = 0;
+    virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) = 0;
     virtual void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) = 0;
     virtual void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) = 0;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -832,7 +832,7 @@
     void dragCancelled();
     void setDragCaretRect(const WebCore::IntRect&);
 #if PLATFORM(COCOA)
-    void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& dragImageAnchor, uint64_t action);
+    void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& dragImageHandle);
     void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension,
                          const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize);
 #if ENABLE(ATTACHMENT_ELEMENT)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-06-27 19:11:34 UTC (rev 218837)
@@ -302,7 +302,7 @@
     DidEndDragging();
 #endif
 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
-    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, std::optional<WebCore::TextIndicatorData> textIndicator, WebCore::FloatPoint dragImageAnchor, uint64_t action)
+    StartDrag(struct WebCore::DragItem dragItem, WebKit::ShareableBitmap::Handle dragImage)
     SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
 #if ENABLE(ATTACHMENT_ELEMENT)
     SetPromisedDataForAttachment(String pasteboardName, String filename, String extension, String title, String url, String visibleURL)

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -208,7 +208,7 @@
 #if ENABLE(DATA_INTERACTION)
     void didPerformDataInteractionControllerOperation(bool handled) override;
     void didHandleStartDataInteractionRequest(bool started) override;
-    void startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) override;
+    void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override;
     void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) override;
     void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -786,9 +786,9 @@
     [m_contentView _didHandleStartDataInteractionRequest:started];
 }
 
-void PageClientImpl::startDataInteractionWithImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData> indicatorData, const FloatPoint& anchorPoint, uint64_t action)
+void PageClientImpl::startDrag(const DragItem& item, const ShareableBitmap::Handle& image)
 {
-    [m_contentView _startDataInteractionWithImage:ShareableBitmap::create(image)->makeCGImageCopy() withIndicatorData:indicatorData atClientPosition:CGPointMake(clientPosition.x(), clientPosition.y()) anchorPoint:anchorPoint action:action];
+    [m_contentView _startDrag:ShareableBitmap::create(image)->makeCGImageCopy() item:item];
 }
 
 void PageClientImpl::didConcludeEditDataInteraction(std::optional<TextIndicatorData> data)

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -57,6 +57,12 @@
 class TextStream;
 }
 
+#if ENABLE(DRAG_SUPPORT)
+namespace WebCore {
+struct DragItem;
+}
+#endif
+
 namespace WebKit {
 class InputViewUpdateDeferrer;
 class NativeWebTouchEvent;
@@ -329,7 +335,7 @@
 #if ENABLE(DATA_INTERACTION)
 - (void)_didPerformDataInteractionControllerOperation:(BOOL)handled;
 - (void)_didHandleStartDataInteractionRequest:(BOOL)started;
-- (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image withIndicatorData:(std::optional<WebCore::TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;
+- (void)_startDrag:(RetainPtr<CGImageRef>)image item:(const WebCore::DragItem&)item;
 - (void)_didConcludeEditDataInteraction:(std::optional<WebCore::TextIndicatorData>)data;
 - (void)_didChangeDataInteractionCaretRect:(CGRect)previousRect currentRect:(CGRect)rect;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -101,6 +101,7 @@
 #import <UIKit/UIURLDragPreviewView.h>
 #import <UIKit/_UITextDragCaretView.h>
 #import <WebCore/DragData.h>
+#import <WebCore/DragItem.h>
 #import <WebCore/PlatformPasteboard.h>
 #import <WebCore/WebItemProviderPasteboard.h>
 #endif // ENABLE(DRAG_SUPPORT)
@@ -4220,12 +4221,13 @@
     [self cleanUpDragSourceSessionState];
 }
 
-- (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image withIndicatorData:(std::optional<TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action
+- (void)_startDrag:(RetainPtr<CGImageRef>)image item:(const DragItem&)item
 {
-    ASSERT(action != DragSourceActionNone);
+    ASSERT(item.sourceAction != DragSourceActionNone);
+
     _dataInteractionState.image = adoptNS([[UIImage alloc] initWithCGImage:image.get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]);
-    _dataInteractionState.indicatorData = indicatorData;
-    _dataInteractionState.sourceAction = static_cast<DragSourceAction>(action);
+    _dataInteractionState.indicatorData = item.image.indicatorData();
+    _dataInteractionState.sourceAction = static_cast<DragSourceAction>(item.sourceAction);
 }
 
 - (void)_didHandleStartDataInteractionRequest:(BOOL)started

Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (218836 => 218837)


--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -48,6 +48,7 @@
 #import "WebProcessProxy.h"
 #import <WebCore/DictationAlternative.h>
 #import <WebCore/DictionaryLookup.h>
+#import <WebCore/DragItem.h>
 #import <WebCore/GraphicsLayer.h>
 #import <WebCore/NSApplicationSPI.h>
 #import <WebCore/RuntimeApplicationChecks.h>
@@ -269,10 +270,10 @@
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
-void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<TextIndicatorData>, const FloatPoint&, uint64_t action)
+void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle)
 {
     if (auto dragImage = ShareableBitmap::create(dragImageHandle))
-        m_pageClient.setDragImage(clientPosition, dragImage.releaseNonNull(), static_cast<DragSourceAction>(action));
+        m_pageClient.setDragImage(dragItem.dragLocationInWindowCoordinates, dragImage.releaseNonNull(), static_cast<DragSourceAction>(dragItem.sourceAction));
 
     didStartDrag();
 }

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp (218836 => 218837)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp	2017-06-27 19:11:34 UTC (rev 218837)
@@ -52,7 +52,7 @@
 }
 
 #if !PLATFORM(COCOA) && !PLATFORM(GTK)
-void WebDragClient::startDrag(DragImage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, DragSourceAction)
+void WebDragClient::startDrag(DragItem, DataTransfer&, Frame&)
 {
 }
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h (218836 => 218837)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h	2017-06-27 19:11:34 UTC (rev 218837)
@@ -46,7 +46,7 @@
     void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&) override;
     WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override;
 
-    void startDrag(WebCore::DragImage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, const WebCore::FloatPoint& dragImageAnchor, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction) override;
+    void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&) override;
     void didConcludeEditDrag() override;
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp (218836 => 218837)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp	2017-06-27 19:11:34 UTC (rev 218837)
@@ -60,8 +60,9 @@
 {
 }
 
-void WebDragClient::startDrag(DragImage dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, const FloatPoint&, DataTransfer& dataTransfer, Frame&, DragSourceAction)
+void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame&)
 {
+    auto& dragImage = item.image;
     RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage.get().get());
     ShareableBitmap::Handle handle;
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (218836 => 218837)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-06-27 17:43:03 UTC (rev 218836)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-06-27 19:11:34 UTC (rev 218837)
@@ -92,8 +92,9 @@
 {
 }
 
-void WebDragClient::startDrag(DragImage image, const IntPoint& point, const IntPoint&, const FloatPoint&, DataTransfer&, Frame& frame, DragSourceAction dragSourceAction)
+void WebDragClient::startDrag(DragItem dragItem, DataTransfer&, Frame& frame)
 {
+    auto& image = dragItem.image;
     IntSize bitmapSize([image.get() size]);
     RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get().get(), bitmapSize, frame);
     ShareableBitmap::Handle handle;
@@ -101,9 +102,7 @@
         return;
 
     m_page->willStartDrag();
-
-    // FIXME: Seems this message should be named StartDrag, not SetDragImage.
-    m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, std::nullopt, { }, dragSourceAction));
+    m_page->send(Messages::WebPageProxy::StartDrag(dragItem, handle));
 }
 
 static WebCore::CachedImage* cachedImage(Element& element)
@@ -207,8 +206,10 @@
     return bitmap;
 }
 
-void WebDragClient::startDrag(DragImage image, const IntPoint& point, const IntPoint& eventLocation, const FloatPoint& dragImageAnchor, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)
+void WebDragClient::startDrag(DragItem dragItem, DataTransfer& dataTransfer, Frame& frame)
 {
+    auto& image = dragItem.image;
+
     IntSize bitmapSize(CGImageGetWidth(image.get().get()), CGImageGetHeight(image.get().get()));
     auto bitmap = convertCGImageToBitmap(image.get().get(), bitmapSize, frame);
     ShareableBitmap::Handle handle;
@@ -216,7 +217,7 @@
         return;
 
     m_page->willStartDrag();
-    m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, image.indicatorData(), dragImageAnchor, dragSourceAction));
+    m_page->send(Messages::WebPageProxy::StartDrag(dragItem, handle));
 }
 
 void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, Frame*)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to