Title: [206197] trunk/Source
Revision
206197
Author
carlo...@webkit.org
Date
2016-09-20 23:17:13 -0700 (Tue, 20 Sep 2016)

Log Message

[GTK] Clean up DataObjectGtk handling
https://bugs.webkit.org/show_bug.cgi?id=162267

Reviewed by Michael Catanzaro.

Source/WebCore:

* platform/Pasteboard.h: Use Ref instead of RefPtr for DataObjectGtk member.
* platform/PasteboardStrategy.h: Pass a const reference to DataObjectGtk in write method and return a Ref from read.
* platform/PlatformPasteboard.h: Ditto.
* platform/gtk/DataObjectGtk.h:
(WebCore::DataObjectGtk::image): Use Image instead of GdkPixbuf.
(WebCore::DataObjectGtk::setImage):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::createForDragAndDrop): Use a reference instead of a pointer.
(WebCore::Pasteboard::Pasteboard): Receives a reference, so we can also remove the ASSERT.
(WebCore::Pasteboard::dataObject):
(WebCore::Pasteboard::writeToClipboard): Remove the ShouldIncludeSmartPaste parameter, callers should also update
canSmartPaste property of DataObjectGtk before calling this.
(WebCore::Pasteboard::writePlainText):
(WebCore::Pasteboard::write): Do not convert the image the GdkPixbuf, pass the image to the DataObjectGtk instead.
* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::fillSelectionData): Convert the DataObjectGtk image to GdkPixbuf right before
passing it to gtk_selection_data_set_pixbuf().
(WebCore::ClipboardSetData::ClipboardSetData): Use reference instead of pointer.
(WebCore::getClipboardContentsCallback):
(WebCore::clearClipboardContentsCallback): Never clear the saved DataObjectGtk, that was only needed when we had
a global DataObjectGtk associated to a GtkClipboard.
(WebCore::PasteboardHelper::writeClipboardContents): Use TemporaryChange to set the settingClipboardDataObject global.
* platform/gtk/PlatformPasteboardGtk.cpp:
(WebCore::PlatformPasteboard::writeToClipboard):
(WebCore::PlatformPasteboard::readFromClipboard):

Source/WebKit2:

In some cases the ownership of DataObjectGtk instances is not clear enough, and we have hacks to avoid memory
leaks because of that.

* Shared/gtk/ArgumentCodersGtk.cpp:
(IPC::encodeImage): Use Image instead of GdkPixbuf.
(IPC::decodeImage): Ditto.
(IPC::ArgumentCoder<DataObjectGtk>::encode):
(IPC::ArgumentCoder<DataObjectGtk>::decode):
(IPC::encode): Deleted.
(IPC::decode): Deleted.
(IPC::ArgumentCoder<DragData>::encode): Deleted.
(IPC::ArgumentCoder<DragData>::decode): Deleted.
* Shared/gtk/ArgumentCodersGtk.h:
* Shared/gtk/PasteboardContent.cpp:
(WebKit::PasteboardContent::PasteboardContent): Add empty constructor that creates a new DataObjectGtk, a
constructor that receives a const reference and another one that takes the ownership of the given DataObjectGtk.
(WebKit::PasteboardContent::encode):
(WebKit::PasteboardContent::decode):
* Shared/gtk/PasteboardContent.h: Use Ref instead of RefPtr for the DataObjectGtk member.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::startDrag): Transfer the DataObjectGtk to the DragAndDropHandler, instead of using DragData.
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::performDragControllerAction): Instead of sending a DragData object to the web process,
send the DataObjectGtk and DragData members needed as parameters.
(WebKit::WebPageProxy::startDrag): Transfer the received DataObjectGtk to page client, instead of using
DragData. Also notify the web process that drag started.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in: Update StartDrag message parameters.
* UIProcess/gtk/DragAndDropHandler.cpp:
(WebKit::DragAndDropHandler::DragAndDropHandler): Remove unneeded initialization.
(WebKit::DragAndDropHandler::startDrag): Take ownership of the given DataObjectGtk.
* UIProcess/gtk/DragAndDropHandler.h:
* UIProcess/gtk/WebPasteboardProxyGtk.cpp:
(WebKit::WebPasteboardProxy::writeToClipboard):
(WebKit::WebPasteboardProxy::readFromClipboard):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::writeToClipboard):
(WebKit::WebPlatformStrategies::readFromClipboard):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
(WebKit::convertCairoSurfaceToShareableBitmap):
(WebKit::WebDragClient::startDrag): Do not create a DragData and pass the DataObjectGtk directly to the
message. Also notify the WebPage that drag is about to start.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction): Remove explicit DataObjectGtk derefs and simply create a
DragData using the DataObjectGtk pointer as platform data.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Update PerformDragControllerAction message parameters.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206196 => 206197)


--- trunk/Source/WebCore/ChangeLog	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/ChangeLog	2016-09-21 06:17:13 UTC (rev 206197)
@@ -1,3 +1,36 @@
+2016-09-20  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Clean up DataObjectGtk handling
+        https://bugs.webkit.org/show_bug.cgi?id=162267
+
+        Reviewed by Michael Catanzaro.
+
+        * platform/Pasteboard.h: Use Ref instead of RefPtr for DataObjectGtk member.
+        * platform/PasteboardStrategy.h: Pass a const reference to DataObjectGtk in write method and return a Ref from read.
+        * platform/PlatformPasteboard.h: Ditto.
+        * platform/gtk/DataObjectGtk.h:
+        (WebCore::DataObjectGtk::image): Use Image instead of GdkPixbuf.
+        (WebCore::DataObjectGtk::setImage):
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::createForDragAndDrop): Use a reference instead of a pointer.
+        (WebCore::Pasteboard::Pasteboard): Receives a reference, so we can also remove the ASSERT.
+        (WebCore::Pasteboard::dataObject):
+        (WebCore::Pasteboard::writeToClipboard): Remove the ShouldIncludeSmartPaste parameter, callers should also update
+        canSmartPaste property of DataObjectGtk before calling this.
+        (WebCore::Pasteboard::writePlainText):
+        (WebCore::Pasteboard::write): Do not convert the image the GdkPixbuf, pass the image to the DataObjectGtk instead.
+        * platform/gtk/PasteboardHelper.cpp:
+        (WebCore::PasteboardHelper::fillSelectionData): Convert the DataObjectGtk image to GdkPixbuf right before
+        passing it to gtk_selection_data_set_pixbuf().
+        (WebCore::ClipboardSetData::ClipboardSetData): Use reference instead of pointer.
+        (WebCore::getClipboardContentsCallback):
+        (WebCore::clearClipboardContentsCallback): Never clear the saved DataObjectGtk, that was only needed when we had
+        a global DataObjectGtk associated to a GtkClipboard.
+        (WebCore::PasteboardHelper::writeClipboardContents): Use TemporaryChange to set the settingClipboardDataObject global.
+        * platform/gtk/PlatformPasteboardGtk.cpp:
+        (WebCore::PlatformPasteboard::writeToClipboard):
+        (WebCore::PlatformPasteboard::readFromClipboard):
+
 2016-09-20  Alex Christensen  <achristen...@webkit.org>
 
         Require WTFMove for String::adopt

Modified: trunk/Source/WebCore/platform/Pasteboard.h (206196 => 206197)


--- trunk/Source/WebCore/platform/Pasteboard.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/Pasteboard.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -138,7 +138,7 @@
 
 #if PLATFORM(GTK)
     explicit Pasteboard(const String& name);
-    explicit Pasteboard(RefPtr<DataObjectGtk>&&);
+    explicit Pasteboard(DataObjectGtk&);
 #endif
 
 #if PLATFORM(WIN)
@@ -220,10 +220,9 @@
 #endif
 
 #if PLATFORM(GTK)
-    enum class ShouldIncludeSmartPaste { No, Yes };
-    void writeToClipboard(ShouldIncludeSmartPaste = ShouldIncludeSmartPaste::No);
+    void writeToClipboard();
     void readFromClipboard();
-    RefPtr<DataObjectGtk> m_dataObject;
+    Ref<DataObjectGtk> m_dataObject;
     String m_name;
 #endif
 

Modified: trunk/Source/WebCore/platform/PasteboardStrategy.h (206196 => 206197)


--- trunk/Source/WebCore/platform/PasteboardStrategy.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/PasteboardStrategy.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -73,8 +73,8 @@
     virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0;
 #endif
 #if PLATFORM(GTK)
-    virtual void writeToClipboard(const String& pasteboardName, const RefPtr<DataObjectGtk>&) = 0;
-    virtual RefPtr<DataObjectGtk> readFromClipboard(const String& pasteboardName) = 0;
+    virtual void writeToClipboard(const String& pasteboardName, const DataObjectGtk&) = 0;
+    virtual Ref<DataObjectGtk> readFromClipboard(const String& pasteboardName) = 0;
 #endif // PLATFORM(GTK)
 protected:
     virtual ~PasteboardStrategy()

Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (206196 => 206197)


--- trunk/Source/WebCore/platform/PlatformPasteboard.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -86,8 +86,8 @@
     WEBCORE_EXPORT int count();
 
 #if PLATFORM(GTK)
-    WEBCORE_EXPORT void writeToClipboard(const RefPtr<DataObjectGtk>&, std::function<void()>&& primarySelectionCleared);
-    WEBCORE_EXPORT RefPtr<DataObjectGtk> readFromClipboard();
+    WEBCORE_EXPORT void writeToClipboard(const DataObjectGtk&, std::function<void()>&& primarySelectionCleared);
+    WEBCORE_EXPORT Ref<DataObjectGtk> readFromClipboard();
 #endif
 
 private:

Modified: trunk/Source/WebCore/platform/gtk/DataObjectGtk.h (206196 => 206197)


--- trunk/Source/WebCore/platform/gtk/DataObjectGtk.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/gtk/DataObjectGtk.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -18,11 +18,10 @@
 
 #pragma once
 
-#include "FileList.h"
+#include "Image.h"
 #include "URL.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
-#include <wtf/glib/GRefPtr.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
@@ -37,8 +36,8 @@
     const URL& url() const { return m_url; }
     const String& uriList() const { return m_uriList; }
     const Vector<String>& filenames() const { return m_filenames; }
-    GdkPixbuf* image() const { return m_image.get(); }
-    void setImage(GdkPixbuf* newImage) { m_image = newImage; }
+    Image* image() const { return m_image.get(); }
+    void setImage(Image* newImage) { m_image = newImage; }
     void setURL(const URL&, const String&);
     bool hasUnknownTypeData() const { return !m_unknownTypeData.isEmpty(); }
     bool hasText() const { return !m_text.isEmpty(); }
@@ -74,7 +73,7 @@
     URL m_url;
     String m_uriList;
     Vector<String> m_filenames;
-    GRefPtr<GdkPixbuf> m_image;
+    RefPtr<Image> m_image;
     HashMap<String, String> m_unknownTypeData;
     bool m_canSmartReplace { false };
 };

Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (206196 => 206197)


--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -62,7 +62,8 @@
 
 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData)
 {
-    return std::make_unique<Pasteboard>(dragData.platformData());
+    ASSERT(dragData.platformData());
+    return std::make_unique<Pasteboard>(*dragData.platformData());
 }
 #endif
 
@@ -75,10 +76,9 @@
 {
 }
 
-Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject)
-    : m_dataObject(WTFMove(dataObject))
+Pasteboard::Pasteboard(DataObjectGtk& dataObject)
+    : m_dataObject(dataObject)
 {
-    ASSERT(m_dataObject);
 }
 
 Pasteboard::Pasteboard(const String& name)
@@ -93,7 +93,7 @@
 
 const DataObjectGtk& Pasteboard::dataObject() const
 {
-    return *m_dataObject;
+    return m_dataObject.get();
 }
 
 static ClipboardDataType dataObjectTypeFromHTMLClipboardType(const String& rawType)
@@ -119,11 +119,11 @@
     return ClipboardDataTypeUnknown;
 }
 
-void Pasteboard::writeToClipboard(ShouldIncludeSmartPaste shouldIncludeSmartPaste)
+void Pasteboard::writeToClipboard()
 {
     if (m_name.isNull())
         return;
-    m_dataObject->setCanSmartReplace(shouldIncludeSmartPaste == ShouldIncludeSmartPaste::Yes);
+
     platformStrategies()->pasteboardStrategy()->writeToClipboard(m_name, m_dataObject);
 }
 
@@ -159,8 +159,9 @@
 {
     m_dataObject->clearAll();
     m_dataObject->setText(text);
+    m_dataObject->setCanSmartReplace(smartReplaceOption == CanSmartReplace);
 
-    writeToClipboard(smartReplaceOption == CanSmartReplace ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No);
+    writeToClipboard();
 }
 
 void Pasteboard::write(const PasteboardURL& pasteboardURL)
@@ -180,11 +181,8 @@
         m_dataObject->setURL(pasteboardImage.url.url, pasteboardImage.url.title);
         m_dataObject->setMarkup(pasteboardImage.url.markup);
     }
+    m_dataObject->setImage(pasteboardImage.image.get());
 
-    GRefPtr<GdkPixbuf> pixbuf = adoptGRef(pasteboardImage.image->getGdkPixbuf());
-    if (pixbuf)
-        m_dataObject->setImage(pixbuf.get());
-
     writeToClipboard();
 }
 
@@ -193,8 +191,9 @@
     m_dataObject->clearAll();
     m_dataObject->setText(pasteboardContent.text);
     m_dataObject->setMarkup(pasteboardContent.markup);
+    m_dataObject->setCanSmartReplace(pasteboardContent.canSmartCopyOrDelete);
 
-    writeToClipboard(pasteboardContent.canSmartCopyOrDelete ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No);
+    writeToClipboard();
 }
 
 void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)

Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp (206196 => 206197)


--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -25,9 +25,8 @@
 
 #include "DataObjectGtk.h"
 #include "GtkVersioning.h"
-#include "Pasteboard.h"
-#include "TextResourceDecoder.h"
 #include <gtk/gtk.h>
+#include <wtf/TemporaryChange.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/CString.h>
 
@@ -148,10 +147,11 @@
         gtk_selection_data_set(selectionData, netscapeURLAtom, 8,
             reinterpret_cast<const guchar*>(resultData.get()), strlen(resultData.get()));
 
-    } else if (info == TargetTypeImage)
-        gtk_selection_data_set_pixbuf(selectionData, dataObject.image());
+    } else if (info == TargetTypeImage && dataObject.hasImage()) {
+        GRefPtr<GdkPixbuf> pixbuf = adoptGRef(dataObject.image()->getGdkPixbuf());
+        gtk_selection_data_set_pixbuf(selectionData, pixbuf.get());
 
-    else if (info == TargetTypeSmartPaste)
+    } else if (info == TargetTypeSmartPaste)
         gtk_selection_data_set_text(selectionData, "", -1);
 
     else if (info == TargetTypeUnknown) {
@@ -257,7 +257,7 @@
 static DataObjectGtk* settingClipboardDataObject = 0;
 
 struct ClipboardSetData {
-    ClipboardSetData(DataObjectGtk* dataObject, std::function<void()>&& selectionClearedCallback)
+    ClipboardSetData(DataObjectGtk& dataObject, std::function<void()>&& selectionClearedCallback)
         : dataObject(dataObject)
         , selectionClearedCallback(WTFMove(selectionClearedCallback))
     {
@@ -267,7 +267,7 @@
     {
     }
 
-    RefPtr<DataObjectGtk> dataObject;
+    Ref<DataObjectGtk> dataObject;
     std::function<void()> selectionClearedCallback;
 };
 
@@ -274,17 +274,12 @@
 static void getClipboardContentsCallback(GtkClipboard*, GtkSelectionData *selectionData, guint info, gpointer userData)
 {
     auto* data = ""
-    PasteboardHelper::singleton().fillSelectionData(selectionData, info, *data->dataObject);
+    PasteboardHelper::singleton().fillSelectionData(selectionData, info, data->dataObject);
 }
 
 static void clearClipboardContentsCallback(GtkClipboard*, gpointer userData)
 {
     std::unique_ptr<ClipboardSetData> data(static_cast<ClipboardSetData*>(userData));
-
-    // Only clear the DataObject for this clipboard if we are not currently setting it.
-    if (data->dataObject.get() != settingClipboardDataObject)
-        data->dataObject->clearAll();
-
     if (data->selectionClearedCallback)
         data->selectionClearedCallback();
 }
@@ -297,16 +292,13 @@
     GtkTargetEntry* table = gtk_target_table_new_from_list(list.get(), &numberOfTargets);
 
     if (numberOfTargets > 0 && table) {
-        settingClipboardDataObject = const_cast<DataObjectGtk*>(&dataObject);
-
-        auto data = "" WTFMove(primarySelectionCleared));
+        TemporaryChange<DataObjectGtk*> change(settingClipboardDataObject, const_cast<DataObjectGtk*>(&dataObject));
+        auto data = "" WTFMove(primarySelectionCleared));
         if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, data.get())) {
             gtk_clipboard_set_can_store(clipboard, nullptr, 0);
             // When gtk_clipboard_set_with_data() succeeds clearClipboardContentsCallback takes the ownership of data, so we leak it here.
             data.release();
         }
-
-        settingClipboardDataObject = nullptr;
     } else
         gtk_clipboard_clear(clipboard);
 

Modified: trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp (206196 => 206197)


--- trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -34,15 +34,15 @@
     ASSERT(m_clipboard);
 }
 
-void PlatformPasteboard::writeToClipboard(const RefPtr<DataObjectGtk>& dataObject, std::function<void()>&& primarySelectionCleared)
+void PlatformPasteboard::writeToClipboard(const DataObjectGtk& dataObject, std::function<void()>&& primarySelectionCleared)
 {
-    PasteboardHelper::singleton().writeClipboardContents(m_clipboard, *dataObject, gtk_clipboard_get(GDK_SELECTION_PRIMARY) == m_clipboard ? WTFMove(primarySelectionCleared) : nullptr);
+    PasteboardHelper::singleton().writeClipboardContents(m_clipboard, dataObject, gtk_clipboard_get(GDK_SELECTION_PRIMARY) == m_clipboard ? WTFMove(primarySelectionCleared) : nullptr);
 }
 
-RefPtr<DataObjectGtk> PlatformPasteboard::readFromClipboard()
+Ref<DataObjectGtk> PlatformPasteboard::readFromClipboard()
 {
-    RefPtr<DataObjectGtk> dataObject = DataObjectGtk::create();
-    PasteboardHelper::singleton().getClipboardContents(m_clipboard, *dataObject);
+    Ref<DataObjectGtk> dataObject(DataObjectGtk::create());
+    PasteboardHelper::singleton().getClipboardContents(m_clipboard, dataObject.get());
     return dataObject;
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (206196 => 206197)


--- trunk/Source/WebKit2/ChangeLog	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-21 06:17:13 UTC (rev 206197)
@@ -1,3 +1,61 @@
+2016-09-20  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Clean up DataObjectGtk handling
+        https://bugs.webkit.org/show_bug.cgi?id=162267
+
+        Reviewed by Michael Catanzaro.
+
+        In some cases the ownership of DataObjectGtk instances is not clear enough, and we have hacks to avoid memory
+        leaks because of that.
+
+        * Shared/gtk/ArgumentCodersGtk.cpp:
+        (IPC::encodeImage): Use Image instead of GdkPixbuf.
+        (IPC::decodeImage): Ditto.
+        (IPC::ArgumentCoder<DataObjectGtk>::encode):
+        (IPC::ArgumentCoder<DataObjectGtk>::decode):
+        (IPC::encode): Deleted.
+        (IPC::decode): Deleted.
+        (IPC::ArgumentCoder<DragData>::encode): Deleted.
+        (IPC::ArgumentCoder<DragData>::decode): Deleted.
+        * Shared/gtk/ArgumentCodersGtk.h:
+        * Shared/gtk/PasteboardContent.cpp:
+        (WebKit::PasteboardContent::PasteboardContent): Add empty constructor that creates a new DataObjectGtk, a
+        constructor that receives a const reference and another one that takes the ownership of the given DataObjectGtk.
+        (WebKit::PasteboardContent::encode):
+        (WebKit::PasteboardContent::decode):
+        * Shared/gtk/PasteboardContent.h: Use Ref instead of RefPtr for the DataObjectGtk member.
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::startDrag): Transfer the DataObjectGtk to the DragAndDropHandler, instead of using DragData.
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::performDragControllerAction): Instead of sending a DragData object to the web process,
+        send the DataObjectGtk and DragData members needed as parameters.
+        (WebKit::WebPageProxy::startDrag): Transfer the received DataObjectGtk to page client, instead of using
+        DragData. Also notify the web process that drag started.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in: Update StartDrag message parameters.
+        * UIProcess/gtk/DragAndDropHandler.cpp:
+        (WebKit::DragAndDropHandler::DragAndDropHandler): Remove unneeded initialization.
+        (WebKit::DragAndDropHandler::startDrag): Take ownership of the given DataObjectGtk.
+        * UIProcess/gtk/DragAndDropHandler.h:
+        * UIProcess/gtk/WebPasteboardProxyGtk.cpp:
+        (WebKit::WebPasteboardProxy::writeToClipboard):
+        (WebKit::WebPasteboardProxy::readFromClipboard):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::writeToClipboard):
+        (WebKit::WebPlatformStrategies::readFromClipboard):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+        (WebKit::convertCairoSurfaceToShareableBitmap):
+        (WebKit::WebDragClient::startDrag): Do not create a DragData and pass the DataObjectGtk directly to the
+        message. Also notify the WebPage that drag is about to start.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::performDragControllerAction): Remove explicit DataObjectGtk derefs and simply create a
+        DragData using the DataObjectGtk pointer as platform data.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in: Update PerformDragControllerAction message parameters.
+
 2016-09-20  Hunseop Jeong  <hs85.je...@samsung.com>
 
         [EFL] ewk_context_menu_item_select test have been failed

Modified: trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp (206196 => 206197)


--- trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -30,10 +30,9 @@
 #include "ShareableBitmap.h"
 #include "WebCoreArgumentCoders.h"
 #include <WebCore/DataObjectGtk.h>
-#include <WebCore/DragData.h>
 #include <WebCore/GraphicsContext.h>
-#include <WebCore/GtkVersioning.h>
-#include <WebCore/PlatformContextCairo.h>
+#include <WebCore/Image.h>
+#include <gtk/gtk.h>
 #include <wtf/glib/GUniquePtr.h>
 
 using namespace WebCore;
@@ -41,16 +40,11 @@
 
 namespace IPC {
 
-static void encodeImage(Encoder& encoder, const GdkPixbuf* pixbuf)
+static void encodeImage(Encoder& encoder, Image& image)
 {
-    IntSize imageSize(gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
-    auto graphicsContext = bitmap->createGraphicsContext();
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
+    bitmap->createGraphicsContext()->drawImage(image, IntPoint());
 
-    cairo_t* cr = graphicsContext->platformContext()->cr();
-    gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
-    cairo_paint(cr);
-
     ShareableBitmap::Handle handle;
     bitmap->createHandle(handle);
 
@@ -57,7 +51,7 @@
     encoder << handle;
 }
 
-static bool decodeImage(Decoder& decoder, GRefPtr<GdkPixbuf>& pixbuf)
+static bool decodeImage(Decoder& decoder, RefPtr<Image>& image)
 {
     ShareableBitmap::Handle handle;
     if (!decoder.decode(handle))
@@ -66,61 +60,51 @@
     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
     if (!bitmap)
         return false;
-
-    RefPtr<Image> image = bitmap->createImage();
+    image = bitmap->createImage();
     if (!image)
         return false;
-
-    RefPtr<cairo_surface_t> surface = image->nativeImageForCurrentFrame();
-    if (!surface)
-        return false;
-
-    pixbuf = adoptGRef(gdk_pixbuf_get_from_surface(surface.get(), 0, 0, cairo_image_surface_get_width(surface.get()), cairo_image_surface_get_height(surface.get())));
-    if (!pixbuf)
-        return false;
-
     return true;
 }
 
-void encode(Encoder& encoder, const DataObjectGtk* dataObject)
+void ArgumentCoder<DataObjectGtk>::encode(Encoder& encoder, const DataObjectGtk& dataObject)
 {
-    bool hasText = dataObject->hasText();
+    bool hasText = dataObject.hasText();
     encoder << hasText;
     if (hasText)
-        encoder << dataObject->text();
+        encoder << dataObject.text();
 
-    bool hasMarkup = dataObject->hasMarkup();
+    bool hasMarkup = dataObject.hasMarkup();
     encoder << hasMarkup;
     if (hasMarkup)
-        encoder << dataObject->markup();
+        encoder << dataObject.markup();
 
-    bool hasURL = dataObject->hasURL();
+    bool hasURL = dataObject.hasURL();
     encoder << hasURL;
     if (hasURL)
-        encoder << dataObject->url().string();
+        encoder << dataObject.url().string();
 
-    bool hasURIList = dataObject->hasURIList();
+    bool hasURIList = dataObject.hasURIList();
     encoder << hasURIList;
     if (hasURIList)
-        encoder << dataObject->uriList();
+        encoder << dataObject.uriList();
 
-    bool hasImage = dataObject->hasImage();
+    bool hasImage = dataObject.hasImage();
     encoder << hasImage;
     if (hasImage)
-        encodeImage(encoder, dataObject->image());
+        encodeImage(encoder, *dataObject.image());
 
-    bool hasUnknownTypeData = dataObject->hasUnknownTypeData();
+    bool hasUnknownTypeData = dataObject.hasUnknownTypeData();
     encoder << hasUnknownTypeData;
     if (hasUnknownTypeData)
-        encoder << dataObject->unknownTypes();
+        encoder << dataObject.unknownTypes();
 
-    bool canSmartReplace = dataObject->canSmartReplace();
+    bool canSmartReplace = dataObject.canSmartReplace();
     encoder << canSmartReplace;
 }
 
-bool decode(Decoder& decoder, RefPtr<DataObjectGtk>& dataObject)
+bool ArgumentCoder<DataObjectGtk>::decode(Decoder& decoder, DataObjectGtk& dataObject)
 {
-    RefPtr<DataObjectGtk> data = ""
+    dataObject.clearAll();
 
     bool hasText;
     if (!decoder.decode(hasText))
@@ -129,7 +113,7 @@
         String text;
         if (!decoder.decode(text))
             return false;
-        data->setText(text);
+        dataObject.setText(text);
     }
 
     bool hasMarkup;
@@ -139,7 +123,7 @@
         String markup;
         if (!decoder.decode(markup))
             return false;
-        data->setMarkup(markup);
+        dataObject.setMarkup(markup);
     }
 
     bool hasURL;
@@ -149,7 +133,7 @@
         String url;
         if (!decoder.decode(url))
             return false;
-        data->setURL(URL(URL(), url), String());
+        dataObject.setURL(URL(URL(), url), String());
     }
 
     bool hasURIList;
@@ -159,7 +143,7 @@
         String uriList;
         if (!decoder.decode(uriList))
             return false;
-        data->setURIList(uriList);
+        dataObject.setURIList(uriList);
     }
 
     bool hasImage;
@@ -166,10 +150,10 @@
     if (!decoder.decode(hasImage))
         return false;
     if (hasImage) {
-        GRefPtr<GdkPixbuf> image;
+        RefPtr<Image> image;
         if (!decodeImage(decoder, image))
             return false;
-        data->setImage(image.get());
+        dataObject.setImage(image.get());
     }
 
     bool hasUnknownTypeData;
@@ -182,68 +166,17 @@
 
         auto end = unknownTypes.end();
         for (auto it = unknownTypes.begin(); it != end; ++it)
-            data->setUnknownTypeData(it->key, it->value);
+            dataObject.setUnknownTypeData(it->key, it->value);
     }
 
     bool canSmartReplace;
     if (!decoder.decode(canSmartReplace))
         return false;
-    data->setCanSmartReplace(canSmartReplace);
+    dataObject.setCanSmartReplace(canSmartReplace);
 
-    dataObject = data;
-
     return true;
 }
 
-#if ENABLE(DRAG_SUPPORT)
-void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
-{
-    encoder << dragData.clientPosition();
-    encoder << dragData.globalPosition();
-    encoder << static_cast<uint64_t>(dragData.draggingSourceOperationMask());
-    encoder << static_cast<uint64_t>(dragData.flags());
-
-    DataObjectGtk* platformData = dragData.platformData();
-    encoder << static_cast<bool>(platformData);
-    if (platformData)
-        IPC::encode(encoder, platformData);
-}
-
-bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
-{
-    IntPoint clientPosition;
-    if (!decoder.decode(clientPosition))
-        return false;
-
-    IntPoint globalPosition;
-    if (!decoder.decode(globalPosition))
-        return false;
-
-    uint64_t sourceOperationMask;
-    if (!decoder.decode(sourceOperationMask))
-        return false;
-
-    uint64_t flags;
-    if (!decoder.decode(flags))
-        return false;
-
-    bool hasPlatformData;
-    if (!decoder.decode(hasPlatformData))
-        return false;
-
-    RefPtr<DataObjectGtk> platformData;
-    if (hasPlatformData) {
-        if (!IPC::decode(decoder, platformData))
-            return false;
-    }
-
-    dragData = DragData(platformData.leakRef(), clientPosition, globalPosition, static_cast<DragOperation>(sourceOperationMask),
-                        static_cast<DragApplicationFlags>(flags));
-
-    return true;
-}
-#endif // ENABLE(DRAG_SUPPORT)
-
 static void encodeGKeyFile(Encoder& encoder, GKeyFile* keyFile)
 {
     gsize dataSize;

Modified: trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h (206196 => 206197)


--- trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -34,18 +34,10 @@
 
 namespace WebCore {
 class DataObjectGtk;
-class DragData;
 }
 
 namespace IPC {
 
-#if ENABLE(DRAG_SUPPORT)
-template<> struct ArgumentCoder<WebCore::DragData> {
-    static void encode(Encoder&, const WebCore::DragData&);
-    static bool decode(Decoder&, WebCore::DragData&);
-};
-#endif
-
 void encode(Encoder&, GtkPrintSettings*);
 bool decode(Decoder&, GRefPtr<GtkPrintSettings>&);
 
@@ -52,8 +44,10 @@
 void encode(Encoder&, GtkPageSetup*);
 bool decode(Decoder&, GRefPtr<GtkPageSetup>&);
 
-void encode(Encoder&, const WebCore::DataObjectGtk*);
-bool decode(Decoder&, RefPtr<WebCore::DataObjectGtk>&);
+template<> struct ArgumentCoder<WebCore::DataObjectGtk> {
+    static void encode(Encoder&, const WebCore::DataObjectGtk&);
+    static bool decode(Decoder&, WebCore::DataObjectGtk&);
+};
 
 } // namespace IPC
 

Modified: trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp (206196 => 206197)


--- trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -27,20 +27,29 @@
 
 namespace WebKit {
 
-PasteboardContent::PasteboardContent(const RefPtr<WebCore::DataObjectGtk>& data)
-    : dataObject(data)
+PasteboardContent::PasteboardContent()
+    : dataObject(WebCore::DataObjectGtk::create())
 {
-    ASSERT(dataObject);
 }
 
+PasteboardContent::PasteboardContent(const WebCore::DataObjectGtk& data)
+    : dataObject(const_cast<WebCore::DataObjectGtk&>(data))
+{
+}
+
+PasteboardContent::PasteboardContent(Ref<WebCore::DataObjectGtk>&& data)
+    : dataObject(WTFMove(data))
+{
+}
+
 void PasteboardContent::encode(IPC::Encoder& encoder) const
 {
-    IPC::encode(encoder, dataObject.get());
+    encoder << dataObject.get();
 }
 
 bool PasteboardContent::decode(IPC::Decoder& decoder, PasteboardContent& pasteboardContent)
 {
-    return IPC::decode(decoder, pasteboardContent.dataObject);
+    return decoder.decode(pasteboardContent.dataObject.get());
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h (206196 => 206197)


--- trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -29,10 +29,11 @@
 namespace WebKit {
 
 struct PasteboardContent {
-    PasteboardContent() = default;
-    explicit PasteboardContent(const RefPtr<WebCore::DataObjectGtk>&);
+    PasteboardContent();
+    explicit PasteboardContent(const WebCore::DataObjectGtk&);
+    explicit PasteboardContent(Ref<WebCore::DataObjectGtk>&&);
 
-    RefPtr<WebCore::DataObjectGtk> dataObject;
+    Ref<WebCore::DataObjectGtk> dataObject;
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, PasteboardContent&);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -254,10 +254,10 @@
 }
 
 #if ENABLE(DRAG_SUPPORT)
-void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+void PageClientImpl::startDrag(Ref<DataObjectGtk>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage)
 {
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget);
-    webkitWebViewBaseDragAndDropHandler(webView).startDrag(dragData, dragImage);
+    webkitWebViewBaseDragAndDropHandler(webView).startDrag(WTFMove(selection), dragOperation, WTFMove(dragImage));
 
     // A drag starting should prevent a double-click from happening. This might
     // happen if a drag is followed very quickly by another click (like in the WTR).

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -86,7 +86,7 @@
 #endif
     void selectionDidChange() override;
 #if ENABLE(DRAG_SUPPORT)
-    void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) override;
+    void startDrag(Ref<WebCore::DataObjectGtk>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) override;
 #endif
 
     void enterAcceleratedCompositingMode(const LayerTreeContext&) override;

Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/PageClient.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -157,7 +157,7 @@
     virtual void didChangeContentSize(const WebCore::IntSize&) = 0;
 
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) = 0;
+    virtual void startDrag(Ref<WebCore::DataObjectGtk>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) = 0;
 #endif
 
     virtual void setCursor(const WebCore::Cursor&) = 0;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -155,6 +155,10 @@
 #include <WebCore/TextIndicatorWindow.h>
 #endif
 
+#if PLATFORM(GTK)
+#include "PasteboardContent.h"
+#endif
+
 #if USE(CAIRO)
 #include <WebCore/CairoUtilities.h>
 #endif
@@ -1768,7 +1772,10 @@
     String url = ""
     if (!url.isEmpty())
         m_process->assumeReadAccessToBaseURL(url);
-    m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID);
+
+    ASSERT(dragData.platformData());
+    PasteboardContent selection(*dragData.platformData());
+    m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), selection, dragData.flags()), m_pageID);
 #else
     m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
 #endif
@@ -1784,16 +1791,12 @@
 }
 
 #if PLATFORM(GTK)
-void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
+void WebPageProxy::startDrag(PasteboardContent&& selection, uint64_t dragOperation, const ShareableBitmap::Handle& dragImageHandle)
 {
-    RefPtr<ShareableBitmap> dragImage = 0;
-    if (!dragImageHandle.isNull()) {
-        dragImage = ShareableBitmap::create(dragImageHandle);
-        if (!dragImage)
-            return;
-    }
+    RefPtr<ShareableBitmap> dragImage = !dragImageHandle.isNull() ? ShareableBitmap::create(dragImageHandle) : nullptr;
+    m_pageClient.startDrag(WTFMove(selection.dataObject), static_cast<WebCore::DragOperation>(dragOperation), WTFMove(dragImage));
 
-    m_pageClient.startDrag(dragData, dragImage.release());
+    m_process->send(Messages::WebPage::DidStartDrag(), m_pageID);
 }
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -809,7 +809,7 @@
 #endif
 #endif
 #if PLATFORM(GTK)
-    void startDrag(const WebCore::DragData&, const ShareableBitmap::Handle& dragImage);
+    void startDrag(PasteboardContent&&, uint64_t dragOperation, const ShareableBitmap::Handle& dragImage);
 #endif
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2016-09-21 06:17:13 UTC (rev 206197)
@@ -308,7 +308,7 @@
 #endif
 #endif
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    StartDrag(WebCore::DragData dragData, WebKit::ShareableBitmap::Handle dragImage)
+    StartDrag(struct WebKit::PasteboardContent selection, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
 #endif
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -44,9 +44,6 @@
 
 DragAndDropHandler::DragAndDropHandler(WebPageProxy& page)
     : m_page(page)
-#if GTK_CHECK_VERSION(3, 16, 0)
-    , m_dragContext(nullptr)
-#endif
 {
 }
 
@@ -111,18 +108,18 @@
     return static_cast<DragOperation>(action);
 }
 
-void DragAndDropHandler::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+void DragAndDropHandler::startDrag(Ref<DataObjectGtk>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage)
 {
 #if GTK_CHECK_VERSION(3, 16, 0)
-    m_draggingDataObject = adoptRef(dragData.platformData());
+    m_draggingDataObject = WTFMove(selection);
     GRefPtr<GtkTargetList> targetList = PasteboardHelper::singleton().targetListForDataObject(*m_draggingDataObject);
 #else
-    RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());
+    RefPtr<DataObjectGtk> dataObject = WTFMove(selection);
     GRefPtr<GtkTargetList> targetList = PasteboardHelper::singleton().targetListForDataObject(*dataObject);
 #endif
 
     GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());
-    GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
+    GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragOperation),
         GDK_BUTTON_PRIMARY, currentEvent.get());
 
 #if GTK_CHECK_VERSION(3, 16, 0)
@@ -135,7 +132,7 @@
 #else
     // We don't have gtk_drag_cancel() in GTK+ < 3.16, so we use the old code.
     // See https://bugs.webkit.org/show_bug.cgi?id=138468
-    m_draggingDataObjects.set(context, dataObject.get());
+    m_draggingDataObjects.set(context, WTFMove(dataObject));
 #endif
 
     if (dragImage) {

Modified: trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -23,16 +23,17 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DragAndDropHandler_h
-#define DragAndDropHandler_h
+#pragma once
 
 #if ENABLE(DRAG_SUPPORT)
 
 #include <WebCore/DataObjectGtk.h>
+#include <WebCore/DragActions.h>
 #include <WebCore/IntPoint.h>
 #include <gtk/gtk.h>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/glib/GRefPtr.h>
 
 typedef struct _GdkDragContext GdkDragContext;
 typedef struct _GtkSelectionData GtkSelectionData;
@@ -51,7 +52,7 @@
 public:
     DragAndDropHandler(WebPageProxy&);
 
-    void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+    void startDrag(Ref<WebCore::DataObjectGtk>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage);
     void fillDragData(GdkDragContext*, GtkSelectionData*, unsigned info);
     void finishDrag(GdkDragContext*);
 
@@ -90,5 +91,3 @@
 } // namespace WebKit
 
 #endif // ENABLE(DRAG_SUPPORT)
-
-#endif // DragAndDropHandler_h

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp (206196 => 206197)


--- trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -41,7 +41,7 @@
 void WebPasteboardProxy::writeToClipboard(const String& pasteboardName, const PasteboardContent& pasteboardContent)
 {
     TemporaryChange<WebFrameProxy*> frameWritingToClipboard(m_frameWritingToClipboard, m_primarySelectionOwner);
-    PlatformPasteboard(pasteboardName).writeToClipboard(pasteboardContent.dataObject, [this] {
+    PlatformPasteboard(pasteboardName).writeToClipboard(pasteboardContent.dataObject.get(), [this] {
         if (m_frameWritingToClipboard == m_primarySelectionOwner)
             return;
         setPrimarySelectionOwner(nullptr);
@@ -50,7 +50,7 @@
 
 void WebPasteboardProxy::readFromClipboard(const String& pasteboardName, PasteboardContent& pasteboardContent)
 {
-    pasteboardContent = PasteboardContent(PlatformPasteboard(pasteboardName).readFromClipboard().get());
+    pasteboardContent = PasteboardContent(PlatformPasteboard(pasteboardName).readFromClipboard());
 }
 
 void WebPasteboardProxy::setPrimarySelectionOwner(WebFrameProxy* frame)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (206196 => 206197)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -346,17 +346,17 @@
 #if PLATFORM(GTK)
 // PasteboardStrategy
 
-void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>& dataObject)
+void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, const DataObjectGtk& dataObject)
 {
-    PasteboardContent pasteboardContent = PasteboardContent(dataObject.get());
+    PasteboardContent pasteboardContent(dataObject);
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, pasteboardContent), 0);
 }
 
-RefPtr<WebCore::DataObjectGtk> WebPlatformStrategies::readFromClipboard(const String& pasteboardName)
+Ref<DataObjectGtk> WebPlatformStrategies::readFromClipboard(const String& pasteboardName)
 {
     PasteboardContent pasteboardContent;
     WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadFromClipboard(pasteboardName), Messages::WebPasteboardProxy::ReadFromClipboard::Reply(pasteboardContent), 0);
-    return pasteboardContent.dataObject;
+    return WTFMove(pasteboardContent.dataObject);
 }
 
 #endif // PLATFORM(GTK)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (206196 => 206197)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -87,8 +87,8 @@
     long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override;
 #endif
 #if PLATFORM(GTK)
-    void writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>&) override;
-    RefPtr<WebCore::DataObjectGtk> readFromClipboard(const String& pasteboardName) override;
+    void writeToClipboard(const String& pasteboardName, const WebCore::DataObjectGtk&) override;
+    Ref<WebCore::DataObjectGtk> readFromClipboard(const String& pasteboardName) override;
 #endif
 };
 

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


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -29,6 +29,7 @@
 #if ENABLE(DRAG_SUPPORT)
 
 #include "ArgumentCodersGtk.h"
+#include "PasteboardContent.h"
 #include "ShareableBitmap.h"
 #include "WebPage.h"
 #include "WebPageProxyMessages.h"
@@ -43,10 +44,10 @@
 
 namespace WebKit {
 
-static PassRefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_surface_t* surface)
+static RefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_surface_t* surface)
 {
     if (!surface)
-        return 0;
+        return nullptr;
 
     IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
@@ -53,7 +54,7 @@
     auto graphicsContext = bitmap->createGraphicsContext();
 
     graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), *graphicsContext);
-    return bitmap.release();
+    return bitmap;
 }
 
 void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, DataTransfer& dataTransfer, Frame&, bool)
@@ -65,9 +66,10 @@
     if (bitmap && !bitmap->createHandle(handle))
         return;
 
-    const auto& dataObject = dataTransfer.pasteboard().dataObject();
-    DragData dragData(const_cast<DataObjectGtk*>(&dataObject), clientPosition, globalPosition, dataTransfer.sourceOperation());
-    m_page->send(Messages::WebPageProxy::StartDrag(dragData, handle));
+    m_page->willStartDrag();
+
+    PasteboardContent selection(dataTransfer.pasteboard().dataObject());
+    m_page->send(Messages::WebPageProxy::StartDrag(selection, dataTransfer.sourceOperation(), handle));
 }
 
 }; // namespace WebKit.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (206196 => 206197)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-21 06:17:13 UTC (rev 206197)
@@ -217,9 +217,10 @@
 #endif
 
 #if PLATFORM(GTK)
+#include "PasteboardContent.h"
+#include "WebPrintOperationGtk.h"
+#include <WebCore/DataObjectGtk.h>
 #include <gtk/gtk.h>
-#include "DataObjectGtk.h"
-#include "WebPrintOperationGtk.h"
 #endif
 
 #if PLATFORM(IOS)
@@ -3396,15 +3397,14 @@
 #if ENABLE(DRAG_SUPPORT)
 
 #if PLATFORM(GTK)
-void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dragData)
+void WebPage::performDragControllerAction(uint64_t action, const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t draggingSourceOperationMask, PasteboardContent&& selection, uint32_t flags)
 {
     if (!m_page) {
         send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0));
-        DataObjectGtk* data = ""
-        data->deref();
         return;
     }
 
+    DragData dragData(selection.dataObject.ptr(), clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
     switch (action) {
     case DragControllerActionEntered: {
         DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
@@ -3428,11 +3428,7 @@
     default:
         ASSERT_NOT_REACHED();
     }
-    // DragData does not delete its platformData so we need to do that here.
-    DataObjectGtk* data = ""
-    data->deref();
 }
-
 #else
 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsHandleArray)
 {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (206196 => 206197)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-21 06:17:13 UTC (rev 206197)
@@ -204,6 +204,10 @@
 class RemoteLayerTreeTransaction;
 #endif
 
+#if PLATFORM(GTK)
+struct PasteboardContent;
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 class WebTouchEvent;
 #endif
@@ -729,7 +733,7 @@
 
 #if ENABLE(DRAG_SUPPORT)
 #if PLATFORM(GTK)
-    void performDragControllerAction(uint64_t action, WebCore::DragData);
+    void performDragControllerAction(uint64_t action, const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t draggingSourceOperationMask, PasteboardContent&&, uint32_t flags);
 #else
     void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (206196 => 206197)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-09-21 03:10:57 UTC (rev 206196)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-09-21 06:17:13 UTC (rev 206197)
@@ -236,7 +236,7 @@
 
     # Drag and drop.
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    PerformDragControllerAction(uint64_t action, WebCore::DragData dragData)
+    PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, struct WebKit::PasteboardContent selection, uint32_t flags)
 #endif
 #if !PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
     PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, String dragStorageName, uint32_t flags, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::SandboxExtension::HandleArray sandboxExtensionsForUpload)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to