[GTK] "ASSERTION FAILED: !m_adoptionIsRequired" when double clicking on a word
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2020 08:37:39 +0000 (08:37 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2020 08:37:39 +0000 (08:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211957

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Make SelectionData non-refcounted. We can just move in most of the cases to avoid copies.

* platform/Pasteboard.h:
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::createForDragAndDrop):
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::selectionData const):
* platform/gtk/SelectionData.h:

Source/WebKit:

Remove WebSelectionData wrapper since we can just encode/decode WebCore::SelectionData.

* Shared/WebCoreArgumentCoders.h:
* Shared/gtk/ArgumentCodersGtk.cpp:
(IPC::ArgumentCoder<SelectionData>::decode): Use modern decoder.
* Shared/gtk/ArgumentCodersGtk.h:
* Shared/gtk/WebSelectionData.cpp: Removed.
* Shared/gtk/WebSelectionData.h: Removed.
* SourcesGTK.txt:
* UIProcess/API/gtk/DragSource.h:
* UIProcess/API/gtk/DragSourceGtk3.cpp:
(WebKit::DragSource::DragSource):
(WebKit::DragSource::begin):
* UIProcess/API/gtk/DragSourceGtk4.cpp:
(WebKit::DragSource::begin):
* UIProcess/API/gtk/DropTarget.h:
* UIProcess/API/gtk/DropTargetGtk3.cpp:
(WebKit::DropTarget::accept):
(WebKit::DropTarget::enter):
(WebKit::DropTarget::update):
(WebKit::DropTarget::leaveTimerFired):
(WebKit::DropTarget::drop):
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::startDrag):
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseStartDrag):
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::performDragControllerAction):
(WebKit::WebPageProxy::startDrag):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.messages.in:
* UIProcess/gtk/Clipboard.h:
* UIProcess/gtk/ClipboardGtk3.cpp:
(WebKit::WriteAsyncData::WriteAsyncData):
(WebKit::Clipboard::write):
* UIProcess/gtk/ClipboardGtk4.cpp:
(WebKit::Clipboard::write):
* UIProcess/gtk/WebPasteboardProxyGtk.cpp:
(WebKit::WebPasteboardProxy::writeToClipboard):
(WebKit::WebPasteboardProxy::writeCustomData):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::writeToClipboard):
* WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

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

35 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/gtk/PasteboardGtk.cpp
Source/WebCore/platform/gtk/SelectionData.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp
Source/WebKit/Shared/gtk/ArgumentCodersGtk.h
Source/WebKit/Shared/gtk/WebSelectionData.cpp [deleted file]
Source/WebKit/Shared/gtk/WebSelectionData.h [deleted file]
Source/WebKit/SourcesGTK.txt
Source/WebKit/UIProcess/API/gtk/DragSource.h
Source/WebKit/UIProcess/API/gtk/DragSourceGtk3.cpp
Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp
Source/WebKit/UIProcess/API/gtk/DropTarget.h
Source/WebKit/UIProcess/API/gtk/DropTargetGtk3.cpp
Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/WebPasteboardProxy.h
Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
Source/WebKit/UIProcess/gtk/Clipboard.h
Source/WebKit/UIProcess/gtk/ClipboardGtk3.cpp
Source/WebKit/UIProcess/gtk/ClipboardGtk4.cpp
Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index eab2ad8..4cb3b0c 100644 (file)
@@ -1,5 +1,21 @@
 2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] "ASSERTION FAILED: !m_adoptionIsRequired" when double clicking on a word
+        https://bugs.webkit.org/show_bug.cgi?id=211957
+
+        Reviewed by Adrian Perez de Castro.
+
+        Make SelectionData non-refcounted. We can just move in most of the cases to avoid copies.
+
+        * platform/Pasteboard.h:
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::createForDragAndDrop):
+        (WebCore::Pasteboard::Pasteboard):
+        (WebCore::Pasteboard::selectionData const):
+        * platform/gtk/SelectionData.h:
+
+2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK] Add WebKitContextMenuItemType for paste as plaintext
         https://bugs.webkit.org/show_bug.cgi?id=177638
 
index fcff54c..1b82dd6 100644 (file)
@@ -43,6 +43,10 @@ OBJC_CLASS NSString;
 OBJC_CLASS NSArray;
 #endif
 
+#if PLATFORM(GTK)
+#include "SelectionData.h"
+#endif
+
 #if PLATFORM(WIN)
 #include "COMPtr.h"
 #include "WCDataObject.h"
@@ -62,7 +66,6 @@ class Element;
 class Frame;
 class PasteboardStrategy;
 class Range;
-class SelectionData;
 class SharedBuffer;
 
 enum class PlainTextURLReadingPolicy : bool { IgnoreURL, AllowURL };
@@ -176,6 +179,9 @@ public:
 #if PLATFORM(GTK)
     explicit Pasteboard(const String& name);
     explicit Pasteboard(SelectionData&);
+#if ENABLE(DRAG_SUPPORT)
+    explicit Pasteboard(SelectionData&&);
+#endif
 #endif
 
 #if PLATFORM(WIN)
@@ -317,7 +323,7 @@ private:
 #endif
 
 #if PLATFORM(GTK)
-    RefPtr<SelectionData> m_selectionData;
+    Optional<SelectionData> m_selectionData;
     String m_name;
 #endif
 
index 154439c..25380d1 100644 (file)
@@ -27,7 +27,6 @@
 #include "NotImplemented.h"
 #include "PasteboardStrategy.h"
 #include "PlatformStrategies.h"
-#include "SelectionData.h"
 #include "SharedBuffer.h"
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Optional.h>
@@ -57,7 +56,7 @@ std::unique_ptr<Pasteboard> Pasteboard::createForGlobalSelection()
 #if ENABLE(DRAG_SUPPORT)
 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop()
 {
-    return makeUnique<Pasteboard>(SelectionData::create());
+    return makeUnique<Pasteboard>(SelectionData());
 }
 
 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData)
@@ -65,10 +64,15 @@ std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dra
     ASSERT(dragData.platformData());
     return makeUnique<Pasteboard>(*dragData.platformData());
 }
+
+Pasteboard::Pasteboard(SelectionData&& selectionData)
+    : m_selectionData(WTFMove(selectionData))
+{
+}
 #endif
 
 Pasteboard::Pasteboard(SelectionData& selectionData)
-    : m_selectionData(&selectionData)
+    : m_selectionData(selectionData)
 {
 }
 
@@ -83,7 +87,7 @@ Pasteboard::~Pasteboard() = default;
 const SelectionData& Pasteboard::selectionData() const
 {
     ASSERT(m_selectionData);
-    return *m_selectionData.get();
+    return *m_selectionData;
 }
 
 static ClipboardDataType selectionDataTypeFromHTMLClipboardType(const String& type)
index b8b148c..cf2b51f 100644 (file)
 #include "Image.h"
 #include "SharedBuffer.h"
 #include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
 #include <wtf/URL.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
 
-class SelectionData : public RefCounted<SelectionData> {
+class SelectionData {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static Ref<SelectionData> create()
-    {
-        return adoptRef(*new SelectionData);
-    }
-
     void setText(const String&);
     const String& text() const { return m_text; }
     bool hasText() const { return !m_text.isEmpty(); }
index 0bc475f..fa683b8 100644 (file)
@@ -1,5 +1,66 @@
 2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] "ASSERTION FAILED: !m_adoptionIsRequired" when double clicking on a word
+        https://bugs.webkit.org/show_bug.cgi?id=211957
+
+        Reviewed by Adrian Perez de Castro.
+
+        Remove WebSelectionData wrapper since we can just encode/decode WebCore::SelectionData.
+
+        * Shared/WebCoreArgumentCoders.h:
+        * Shared/gtk/ArgumentCodersGtk.cpp:
+        (IPC::ArgumentCoder<SelectionData>::decode): Use modern decoder.
+        * Shared/gtk/ArgumentCodersGtk.h:
+        * Shared/gtk/WebSelectionData.cpp: Removed.
+        * Shared/gtk/WebSelectionData.h: Removed.
+        * SourcesGTK.txt:
+        * UIProcess/API/gtk/DragSource.h:
+        * UIProcess/API/gtk/DragSourceGtk3.cpp:
+        (WebKit::DragSource::DragSource):
+        (WebKit::DragSource::begin):
+        * UIProcess/API/gtk/DragSourceGtk4.cpp:
+        (WebKit::DragSource::begin):
+        * UIProcess/API/gtk/DropTarget.h:
+        * UIProcess/API/gtk/DropTargetGtk3.cpp:
+        (WebKit::DropTarget::accept):
+        (WebKit::DropTarget::enter):
+        (WebKit::DropTarget::update):
+        (WebKit::DropTarget::leaveTimerFired):
+        (WebKit::DropTarget::drop):
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::startDrag):
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseStartDrag):
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::performDragControllerAction):
+        (WebKit::WebPageProxy::startDrag):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebPasteboardProxy.h:
+        * UIProcess/WebPasteboardProxy.messages.in:
+        * UIProcess/gtk/Clipboard.h:
+        * UIProcess/gtk/ClipboardGtk3.cpp:
+        (WebKit::WriteAsyncData::WriteAsyncData):
+        (WebKit::Clipboard::write):
+        * UIProcess/gtk/ClipboardGtk4.cpp:
+        (WebKit::Clipboard::write):
+        * UIProcess/gtk/WebPasteboardProxyGtk.cpp:
+        (WebKit::WebPasteboardProxy::writeToClipboard):
+        (WebKit::WebPasteboardProxy::writeCustomData):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::writeToClipboard):
+        * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+        (WebKit::WebDragClient::startDrag):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::performDragControllerAction):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
+2020-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK] Add WebKitContextMenuItemType for paste as plaintext
         https://bugs.webkit.org/show_bug.cgi?id=177638
 
index fb9d8db..77f4623 100644 (file)
 #include <WebCore/CDMInstanceSession.h>
 #endif
 
+#if PLATFORM(GTK)
+#include "ArgumentCodersGtk.h"
+#endif
+
 #if PLATFORM(COCOA)
 namespace WTF {
 class MachSendRight;
index 3927544..9870eff 100644 (file)
@@ -101,76 +101,76 @@ void ArgumentCoder<SelectionData>::encode(Encoder& encoder, const SelectionData&
     encoder << canSmartReplace;
 }
 
-bool ArgumentCoder<SelectionData>::decode(Decoder& decoder, SelectionData& selection)
+Optional<SelectionData> ArgumentCoder<SelectionData>::decode(Decoder& decoder)
 {
-    selection.clearAll();
+    SelectionData selection;
 
     bool hasText;
     if (!decoder.decode(hasText))
-        return false;
+        return WTF::nullopt;
     if (hasText) {
         String text;
         if (!decoder.decode(text))
-            return false;
+            return WTF::nullopt;
         selection.setText(text);
     }
 
     bool hasMarkup;
     if (!decoder.decode(hasMarkup))
-        return false;
+        return WTF::nullopt;
     if (hasMarkup) {
         String markup;
         if (!decoder.decode(markup))
-            return false;
+            return WTF::nullopt;
         selection.setMarkup(markup);
     }
 
     bool hasURL;
     if (!decoder.decode(hasURL))
-        return false;
+        return WTF::nullopt;
     if (hasURL) {
         String url;
         if (!decoder.decode(url))
-            return false;
+            return WTF::nullopt;
         selection.setURL(URL(URL(), url), String());
     }
 
     bool hasURIList;
     if (!decoder.decode(hasURIList))
-        return false;
+        return WTF::nullopt;
     if (hasURIList) {
         String uriList;
         if (!decoder.decode(uriList))
-            return false;
+            return WTF::nullopt;
         selection.setURIList(uriList);
     }
 
     bool hasImage;
     if (!decoder.decode(hasImage))
-        return false;
+        return WTF::nullopt;
     if (hasImage) {
         RefPtr<Image> image;
         if (!decodeImage(decoder, image))
-            return false;
+            return WTF::nullopt;
         selection.setImage(image.get());
     }
 
     bool hasCustomData;
     if (!decoder.decode(hasCustomData))
-        return false;
+        return WTF::nullopt;
     if (hasCustomData) {
         RefPtr<SharedBuffer> buffer;
         if (!decoder.decode(buffer))
-            return false;
+            return WTF::nullopt;
         selection.setCustomData(Ref<SharedBuffer>(*buffer));
     }
 
     bool canSmartReplace;
     if (!decoder.decode(canSmartReplace))
-        return false;
+        return WTF::nullopt;
     selection.setCanSmartReplace(canSmartReplace);
 
-    return true;
+    return selection;
 }
 
 static void encodeGKeyFile(Encoder& encoder, GKeyFile* keyFile)
index 7745c6d..2a175e6 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ArgumentCodersGtk_h
-#define ArgumentCodersGtk_h
+#pragma once
 
 #include "ArgumentCoders.h"
 #include <wtf/glib/GRefPtr.h>
@@ -46,9 +45,7 @@ WARN_UNUSED_RETURN bool decode(Decoder&, GRefPtr<GtkPageSetup>&);
 
 template<> struct ArgumentCoder<WebCore::SelectionData> {
     static void encode(Encoder&, const WebCore::SelectionData&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::SelectionData&);
+    static Optional<WebCore::SelectionData> decode(Decoder&);
 };
 
 } // namespace IPC
-
-#endif // ArgumentCodersGtk_h
diff --git a/Source/WebKit/Shared/gtk/WebSelectionData.cpp b/Source/WebKit/Shared/gtk/WebSelectionData.cpp
deleted file mode 100644 (file)
index 9b506b3..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  Copyright (C) 2016 Red Hat Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "WebSelectionData.h"
-
-#include "ArgumentCodersGtk.h"
-#include "Decoder.h"
-#include "Encoder.h"
-#include <wtf/RetainPtr.h>
-
-namespace WebKit {
-
-WebSelectionData::WebSelectionData()
-    : selectionData(WebCore::SelectionData::create())
-{
-}
-
-WebSelectionData::WebSelectionData(const WebCore::SelectionData& data)
-    : selectionData(const_cast<WebCore::SelectionData&>(data))
-{
-}
-
-WebSelectionData::WebSelectionData(Ref<WebCore::SelectionData>&& data)
-    : selectionData(WTFMove(data))
-{
-}
-
-WebSelectionData::WebSelectionData(WebCore::SelectionData&& data)
-    : selectionData(data)
-{
-}
-
-void WebSelectionData::encode(IPC::Encoder& encoder) const
-{
-    encoder << selectionData.get();
-}
-
-bool WebSelectionData::decode(IPC::Decoder& decoder, WebSelectionData& selection)
-{
-    return decoder.decode(selection.selectionData.get());
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit/Shared/gtk/WebSelectionData.h b/Source/WebKit/Shared/gtk/WebSelectionData.h
deleted file mode 100644 (file)
index 205f8ee..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *  Copyright (C) 2016 Red Hat Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#pragma once
-
-#include <WebCore/SelectionData.h>
-
-namespace IPC {
-class Decoder;
-class Encoder;
-}
-
-namespace WebKit {
-
-struct WebSelectionData {
-    WebSelectionData();
-    explicit WebSelectionData(const WebCore::SelectionData&);
-    explicit WebSelectionData(Ref<WebCore::SelectionData>&&);
-    explicit WebSelectionData(WebCore::SelectionData&&);
-
-    Ref<WebCore::SelectionData> selectionData;
-
-    void encode(IPC::Encoder&) const;
-    static WARN_UNUSED_RETURN bool decode(IPC::Decoder&, WebSelectionData&);
-};
-
-} // namespace WebKit
-
index 76f1e08..7d78450 100644 (file)
@@ -103,7 +103,6 @@ Shared/gtk/NativeWebWheelEventGtk.cpp
 Shared/gtk/PrintInfoGtk.cpp
 Shared/gtk/WebErrorsGtk.cpp
 Shared/gtk/WebEventFactory.cpp
-Shared/gtk/WebSelectionData.cpp
 
 Shared/linux/WebMemorySamplerLinux.cpp
 
index 8c6a54e..5322b8c 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(DRAG_SUPPORT)
 
 #include <WebCore/DragActions.h>
+#include <WebCore/SelectionData.h>
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/glib/GRefPtr.h>
@@ -38,10 +39,6 @@ typedef struct _GtkWidget GtkWidget;
 typedef struct _GdkDragContext GdkDragContext;
 #endif
 
-namespace WebCore {
-class SelectionData;
-}
-
 namespace WebKit {
 
 class ShareableBitmap;
@@ -53,14 +50,14 @@ public:
     explicit DragSource(GtkWidget*);
     ~DragSource();
 
-    void begin(Ref<WebCore::SelectionData>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&&);
+    void begin(WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&&);
 
 private:
     GtkWidget* m_webView { nullptr };
 #if !USE(GTK4)
     GRefPtr<GdkDragContext> m_drag;
 #endif
-    RefPtr<WebCore::SelectionData> m_selectionData;
+    Optional<WebCore::SelectionData> m_selectionData;
 };
 
 } // namespace WebKit
index 4c26ad2..3ed4ccc 100644 (file)
@@ -84,7 +84,7 @@ DragSource::DragSource(GtkWidget* webView)
         if (!drag.m_selectionData)
             return;
 
-        drag.m_selectionData = nullptr;
+        drag.m_selectionData = WTF::nullopt;
         drag.m_drag = nullptr;
 
         GdkDevice* device = gdk_drag_context_get_device(context);
@@ -106,7 +106,7 @@ DragSource::~DragSource()
     g_signal_handlers_disconnect_by_data(m_webView, this);
 }
 
-void DragSource::begin(Ref<SelectionData>&& selectionData, DragOperation operation, RefPtr<ShareableBitmap>&& image)
+void DragSource::begin(SelectionData&& selectionData, DragOperation operation, RefPtr<ShareableBitmap>&& image)
 {
     if (m_drag) {
         gtk_drag_cancel(m_drag.get());
index 327a50c..5210143 100644 (file)
@@ -44,7 +44,7 @@ DragSource::~DragSource()
 {
 }
 
-void DragSource::begin(Ref<SelectionData>&&, DragOperation, RefPtr<ShareableBitmap>&&)
+void DragSource::begin(SelectionData&&, DragOperation, RefPtr<ShareableBitmap>&&)
 {
 }
 
index 89a0d28..54c8ed1 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <WebCore/DragActions.h>
 #include <WebCore/IntPoint.h>
+#include <WebCore/SelectionData.h>
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RunLoop.h>
@@ -41,10 +42,6 @@ typedef struct _GdkDragContext GdkDragContext;
 typedef struct _GtkSelectionData GtkSelectionData;
 #endif
 
-namespace WebCore {
-class SelectionData;
-}
-
 namespace WebKit {
 
 class ShareableBitmap;
@@ -75,7 +72,7 @@ private:
 #endif
     Optional<WebCore::IntPoint> m_position;
     unsigned m_dataRequestCount { 0 };
-    RefPtr<WebCore::SelectionData> m_selectionData;
+    Optional<WebCore::SelectionData> m_selectionData;
     WebCore::DragOperation m_operation { WebCore::DragOperationNone };
 #if !USE(GTK4)
     RunLoop::Timer<DropTarget> m_leaveTimer;
index 388dec0..c13b29b 100644 (file)
@@ -103,7 +103,7 @@ void DropTarget::accept(unsigned time)
     }
 
     m_dataRequestCount = 0;
-    m_selectionData = SelectionData::create();
+    m_selectionData = SelectionData();
 
     // WebCore needs the selection data to decide, so we need to preload the
     // data of targets we support. Once all data requests are done we start
@@ -141,7 +141,7 @@ void DropTarget::enter(IntPoint&& position, unsigned time)
     ASSERT(page);
     page->resetCurrentDragInformation();
 
-    DragData dragData(m_selectionData.get(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(m_drop.get())));
+    DragData dragData(&m_selectionData.value(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(m_drop.get())));
     page->dragEntered(dragData);
 }
 
@@ -155,7 +155,7 @@ void DropTarget::update(IntPoint&& position, unsigned time)
     auto* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_webView));
     ASSERT(page);
 
-    DragData dragData(m_selectionData.get(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(m_drop.get())));
+    DragData dragData(&m_selectionData.value(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(m_drop.get())));
     page->dragUpdated(dragData);
 }
 
@@ -229,13 +229,13 @@ void DropTarget::leaveTimerFired()
     auto* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_webView));
     ASSERT(page);
 
-    DragData dragData(m_selectionData.get(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), DragOperationNone);
+    DragData dragData(&m_selectionData.value(), *m_position, convertWidgetPointToScreenPoint(m_webView, *m_position), DragOperationNone);
     page->dragExited(dragData);
     page->resetCurrentDragInformation();
 
     m_drop = nullptr;
     m_position = WTF::nullopt;
-    m_selectionData = nullptr;
+    m_selectionData = WTF::nullopt;
 }
 
 void DropTarget::leave()
@@ -256,13 +256,13 @@ void DropTarget::drop(IntPoint&& position, unsigned time)
     uint32_t flags = 0;
     if (gdk_drag_context_get_selected_action(m_drop.get()) == GDK_ACTION_COPY)
         flags |= DragApplicationIsCopyKeyDown;
-    DragData dragData(m_selectionData.get(), position, convertWidgetPointToScreenPoint(m_webView, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(m_drop.get())), static_cast<DragApplicationFlags>(flags));
+    DragData dragData(&m_selectionData.value(), position, convertWidgetPointToScreenPoint(m_webView, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(m_drop.get())), static_cast<DragApplicationFlags>(flags));
     page->performDragOperation(dragData, { }, { }, { });
     gtk_drag_finish(m_drop.get(), TRUE, FALSE, time);
 
     m_drop = nullptr;
     m_position = WTF::nullopt;
-    m_selectionData = nullptr;
+    m_selectionData = WTF::nullopt;
 }
 
 } // namespace WebKit
index aab0f7e..3b93c23 100644 (file)
@@ -328,7 +328,7 @@ void PageClientImpl::didChangeContentSize(const IntSize& size)
 }
 
 #if ENABLE(DRAG_SUPPORT)
-void PageClientImpl::startDrag(Ref<SelectionData>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage)
+void PageClientImpl::startDrag(SelectionData&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage)
 {
     webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), WTFMove(selection), dragOperation, WTFMove(dragImage));
 }
index 7272734..ed39e74 100644 (file)
@@ -100,7 +100,7 @@ private:
     void selectionDidChange() override;
     RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&) override;
 #if ENABLE(DRAG_SUPPORT)
-    void startDrag(Ref<WebCore::SelectionData>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) override;
+    void startDrag(WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) override;
     void didPerformDragControllerAction() override;
 #endif
 
index 925d8f8..15f66fd 100644 (file)
@@ -1779,7 +1779,7 @@ void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase* webViewBase, const IntRe
 }
 
 #if ENABLE(DRAG_SUPPORT)
-void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, Ref<SelectionData>&& selectionData, DragOperation dragOperation, RefPtr<ShareableBitmap>&& image)
+void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, SelectionData&& selectionData, DragOperation dragOperation, RefPtr<ShareableBitmap>&& image)
 {
     WebKitWebViewBasePrivate* priv = webViewBase->priv;
     if (!priv->dragSource)
index a1dded3..703e36d 100644 (file)
@@ -82,7 +82,7 @@ void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase*);
 void webkitWebViewBasePageClosed(WebKitWebViewBase*);
 
 #if ENABLE(DRAG_SUPPORT)
-void webkitWebViewBaseStartDrag(WebKitWebViewBase*, Ref<WebCore::SelectionData>&&, WebCore::DragOperation, RefPtr<WebKit::ShareableBitmap>&&);
+void webkitWebViewBaseStartDrag(WebKitWebViewBase*, WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<WebKit::ShareableBitmap>&&);
 void webkitWebViewBaseDidPerformDragControllerAction(WebKitWebViewBase*);
 #endif
 
index 8fc767f..202b2b9 100644 (file)
@@ -250,7 +250,7 @@ public:
     
 #if ENABLE(DRAG_SUPPORT)
 #if PLATFORM(GTK)
-    virtual void startDrag(Ref<WebCore::SelectionData>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) = 0;
+    virtual void startDrag(WebCore::SelectionData&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) = 0;
 #else
     virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle&) { }
 #endif
index 6547f4b..ff3e3ed 100644 (file)
 #endif
 
 #if PLATFORM(GTK)
-#include "WebSelectionData.h"
+#include <WebCore/SelectionData.h>
 #endif
 
 #if USE(CAIRO)
@@ -2410,8 +2410,7 @@ void WebPageProxy::performDragControllerAction(DragControllerAction action, Drag
         m_process->assumeReadAccessToBaseURL(*this, url);
 
     ASSERT(dragData.platformData());
-    WebSelectionData selection(*dragData.platformData());
-    send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), selection, dragData.flags()));
+    send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), *dragData.platformData(), dragData.flags()));
 #else
     send(Messages::WebPage::PerformDragControllerAction(action, dragData, sandboxExtensionHandle, sandboxExtensionsForUpload));
 #endif
@@ -2431,10 +2430,10 @@ void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, WebCor
 }
 
 #if PLATFORM(GTK)
-void WebPageProxy::startDrag(WebSelectionData&& selection, uint64_t dragOperation, const ShareableBitmap::Handle& dragImageHandle)
+void WebPageProxy::startDrag(SelectionData&& selectionData, uint64_t dragOperation, const ShareableBitmap::Handle& dragImageHandle)
 {
     RefPtr<ShareableBitmap> dragImage = !dragImageHandle.isNull() ? ShareableBitmap::create(dragImageHandle) : nullptr;
-    pageClient().startDrag(WTFMove(selection.selectionData), static_cast<WebCore::DragOperation>(dragOperation), WTFMove(dragImage));
+    pageClient().startDrag(WTFMove(selectionData), static_cast<WebCore::DragOperation>(dragOperation), WTFMove(dragImage));
 
     didStartDrag();
 }
index 32ec494..0b04c1e 100644 (file)
@@ -219,6 +219,7 @@ class GraphicsLayer;
 class IntSize;
 class ProtectionSpace;
 class RunLoopObserver;
+class SelectionData;
 class SharedBuffer;
 class TextIndicator;
 class ValidationBubble;
@@ -350,7 +351,6 @@ struct WebAutocorrectionData;
 struct WebHitTestResultData;
 struct WebNavigationDataStore;
 struct WebPopupItem;
-struct WebSelectionData;
 struct WebSpeechSynthesisVoice;
 struct URLSchemeTaskParameters;
 struct UserMessage;
@@ -1164,7 +1164,7 @@ public:
                          const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize);
 #endif
 #if PLATFORM(GTK)
-    void startDrag(WebSelectionData&&, uint64_t dragOperation, const ShareableBitmap::Handle& dragImage);
+    void startDrag(WebCore::SelectionData&&, uint64_t dragOperation, const ShareableBitmap::Handle& dragImage);
 #endif
 #endif
 
index 49c19bd..cf81a64 100644 (file)
@@ -318,7 +318,7 @@ messages -> WebPageProxy {
     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)
 #endif
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    StartDrag(struct WebKit::WebSelectionData selection, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
+    StartDrag(WebCore::SelectionData selectionData, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
 #endif
 
 #if ENABLE(DRAG_SUPPORT)
index 7b8aba8..168bbf7 100644 (file)
@@ -41,6 +41,7 @@ class SharedBufferDataReference;
 namespace WebCore {
 class Color;
 class PasteboardCustomData;
+class SelectionData;
 struct PasteboardImage;
 struct PasteboardItemInfo;
 struct PasteboardURL;
@@ -51,7 +52,6 @@ namespace WebKit {
 
 class WebFrameProxy;
 class WebProcessProxy;
-struct WebSelectionData;
 
 class WebPasteboardProxy : public IPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(WebPasteboardProxy);
@@ -127,7 +127,7 @@ private:
     void readText(const String& pasteboardName, CompletionHandler<void(String&&)>&&);
     void readFilePaths(const String& pasteboardName, CompletionHandler<void(Vector<String>&&)>&&);
     void readBuffer(const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(IPC::SharedBufferDataReference&&)>&&);
-    void writeToClipboard(const String& pasteboardName, WebSelectionData&&);
+    void writeToClipboard(const String& pasteboardName, WebCore::SelectionData&&);
     void clearClipboard(const String& pasteboardName);
 
     WebFrameProxy* m_primarySelectionOwner { nullptr };
index 7fd767f..c0dbb0e 100644 (file)
@@ -65,7 +65,7 @@ messages -> WebPasteboardProxy NotRefCounted {
     ReadText(String pasteboardName) -> (String text) Synchronous
     ReadFilePaths(String pasteboardName) -> (Vector<String> types) Synchronous
     ReadBuffer(String pasteboardName, String pasteboardType) -> (IPC::SharedBufferDataReference data) Synchronous
-    WriteToClipboard(String pasteboardName, struct WebKit::WebSelectionData pasteboardContent)
+    WriteToClipboard(String pasteboardName, WebCore::SelectionData pasteboardContent)
     ClearClipboard(String pasteboardName)
 #endif
 
index 9a7bbaa..7866cdb 100644 (file)
@@ -56,7 +56,7 @@ public:
     void readText(CompletionHandler<void(String&&)>&&);
     void readFilePaths(CompletionHandler<void(Vector<String>&&)>&&);
     void readBuffer(const char*, CompletionHandler<void(Ref<WebCore::SharedBuffer>&&)>&&);
-    void write(Ref<WebCore::SelectionData>&&);
+    void write(WebCore::SelectionData&&);
     void clear();
 
 private:
index 913d339..12b355d 100644 (file)
@@ -146,34 +146,34 @@ void Clipboard::readBuffer(const char* format, CompletionHandler<void(Ref<WebCor
 struct WriteAsyncData {
     WTF_MAKE_STRUCT_FAST_ALLOCATED;
 
-    WriteAsyncData(Ref<WebCore::SelectionData>&& selection, Clipboard& clipboard)
+    WriteAsyncData(WebCore::SelectionData&& selection, Clipboard& clipboard)
         : selectionData(WTFMove(selection))
         , clipboard(clipboard)
     {
     }
 
-    Ref<WebCore::SelectionData> selectionData;
+    WebCore::SelectionData selectionData;
     Clipboard& clipboard;
 };
 
 enum ClipboardTargetType { Markup, Text, Image, URIList, SmartPaste, Custom };
 
-void Clipboard::write(Ref<WebCore::SelectionData>&& selectionData)
+void Clipboard::write(WebCore::SelectionData&& selectionData)
 {
     SetForScope<WebFrameProxy*> frameWritingToClipboard(m_frameWritingToClipboard, WebPasteboardProxy::singleton().primarySelectionOwner());
 
     GRefPtr<GtkTargetList> list = adoptGRef(gtk_target_list_new(nullptr, 0));
-    if (selectionData->hasURIList())
+    if (selectionData.hasURIList())
         gtk_target_list_add(list.get(), gdk_atom_intern_static_string("text/uri-list"), 0, ClipboardTargetType::URIList);
-    if (selectionData->hasMarkup())
+    if (selectionData.hasMarkup())
         gtk_target_list_add(list.get(), gdk_atom_intern_static_string("text/html"), 0, ClipboardTargetType::Markup);
-    if (selectionData->hasImage())
+    if (selectionData.hasImage())
         gtk_target_list_add_image_targets(list.get(), ClipboardTargetType::Image, TRUE);
-    if (selectionData->hasText())
+    if (selectionData.hasText())
         gtk_target_list_add_text_targets(list.get(), ClipboardTargetType::Text);
-    if (selectionData->canSmartReplace())
+    if (selectionData.canSmartReplace())
         gtk_target_list_add(list.get(), gdk_atom_intern_static_string("application/vnd.webkitgtk.smartpaste"), 0, ClipboardTargetType::SmartPaste);
-    if (selectionData->hasCustomData())
+    if (selectionData.hasCustomData())
         gtk_target_list_add(list.get(), gdk_atom_intern_static_string(WebCore::PasteboardCustomData::gtkType()), 0, ClipboardTargetType::Custom);
 
     int numberOfTargets;
@@ -187,25 +187,24 @@ void Clipboard::write(Ref<WebCore::SelectionData>&& selectionData)
     gboolean succeeded = gtk_clipboard_set_with_data(m_clipboard, table, numberOfTargets,
         [](GtkClipboard*, GtkSelectionData* selection, guint info, gpointer userData) {
             auto& data = *static_cast<WriteAsyncData*>(userData);
-            auto& selectionData = data.selectionData.get();
             switch (info) {
             case ClipboardTargetType::Markup: {
-                CString markup = selectionData.markup().utf8();
+                CString markup = data.selectionData.markup().utf8();
                 gtk_selection_data_set(selection, gdk_atom_intern_static_string("text/html"), 8, reinterpret_cast<const guchar*>(markup.data()), markup.length());
                 break;
             }
             case ClipboardTargetType::Text:
-                gtk_selection_data_set_text(selection, selectionData.text().utf8().data(), -1);
+                gtk_selection_data_set_text(selection, data.selectionData.text().utf8().data(), -1);
                 break;
             case ClipboardTargetType::Image: {
-                if (selectionData.hasImage()) {
-                    GRefPtr<GdkPixbuf> pixbuf = adoptGRef(selectionData.image()->getGdkPixbuf());
+                if (data.selectionData.hasImage()) {
+                    GRefPtr<GdkPixbuf> pixbuf = adoptGRef(data.selectionData.image()->getGdkPixbuf());
                     gtk_selection_data_set_pixbuf(selection, pixbuf.get());
                 }
                 break;
             }
             case ClipboardTargetType::URIList: {
-                CString uriList = selectionData.uriList().utf8();
+                CString uriList = data.selectionData.uriList().utf8();
                 gtk_selection_data_set(selection, gdk_atom_intern_static_string("text/uri-list"), 8, reinterpret_cast<const guchar*>(uriList.data()), uriList.length());
                 break;
             }
@@ -213,8 +212,8 @@ void Clipboard::write(Ref<WebCore::SelectionData>&& selectionData)
                 gtk_selection_data_set_text(selection, "", -1);
                 break;
             case ClipboardTargetType::Custom:
-                if (selectionData.hasCustomData()) {
-                    auto* buffer = selectionData.customData();
+                if (data.selectionData.hasCustomData()) {
+                    auto* buffer = data.selectionData.customData();
                     gtk_selection_data_set(selection, gdk_atom_intern_static_string(WebCore::PasteboardCustomData::gtkType()), 8, reinterpret_cast<const guchar*>(buffer->data()), buffer->size());
                 }
                 break;
index 13d372f..07abb71 100644 (file)
@@ -156,36 +156,36 @@ void Clipboard::readBuffer(const char* format, CompletionHandler<void(Ref<WebCor
     }, new ReadBufferAsyncData(WTFMove(completionHandler)));
 }
 
-void Clipboard::write(Ref<WebCore::SelectionData>&& selectionData)
+void Clipboard::write(WebCore::SelectionData&& selectionData)
 {
     Vector<GdkContentProvider*> providers;
-    if (selectionData->hasMarkup()) {
-        CString markup = selectionData->markup().utf8();
+    if (selectionData.hasMarkup()) {
+        CString markup = selectionData.markup().utf8();
         GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(markup.data(), markup.length()));
         providers.append(gdk_content_provider_new_for_bytes("text/html", bytes.get()));
     }
 
-    if (selectionData->hasURIList()) {
-        CString uriList = selectionData->uriList().utf8();
+    if (selectionData.hasURIList()) {
+        CString uriList = selectionData.uriList().utf8();
         GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(uriList.data(), uriList.length()));
         providers.append(gdk_content_provider_new_for_bytes("text/uri-list", bytes.get()));
     }
 
-    if (selectionData->hasImage()) {
-        GRefPtr<GdkPixbuf> pixbuf = adoptGRef(selectionData->image()->getGdkPixbuf());
+    if (selectionData.hasImage()) {
+        GRefPtr<GdkPixbuf> pixbuf = adoptGRef(selectionData.image()->getGdkPixbuf());
         providers.append(gdk_content_provider_new_typed(GDK_TYPE_PIXBUF, pixbuf.get()));
     }
 
-    if (selectionData->hasText())
-        providers.append(gdk_content_provider_new_typed(G_TYPE_STRING, selectionData->text().utf8().data()));
+    if (selectionData.hasText())
+        providers.append(gdk_content_provider_new_typed(G_TYPE_STRING, selectionData.text().utf8().data()));
 
-    if (selectionData->canSmartReplace()) {
+    if (selectionData.canSmartReplace()) {
         GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(nullptr, 0));
         providers.append(gdk_content_provider_new_for_bytes("application/vnd.webkitgtk.smartpaste", bytes.get()));
     }
 
-    if (selectionData->hasCustomData()) {
-        GRefPtr<GBytes> bytes = selectionData->customData()->createGBytes();
+    if (selectionData.hasCustomData()) {
+        GRefPtr<GBytes> bytes = selectionData.customData()->createGBytes();
         providers.append(gdk_content_provider_new_for_bytes(WebCore::PasteboardCustomData::gtkType(), bytes.get()));
     }
 
index c6dd462..3debf38 100644 (file)
 #include "Clipboard.h"
 #include "SharedBufferDataReference.h"
 #include "WebFrameProxy.h"
-#include "WebSelectionData.h"
 #include <WebCore/Pasteboard.h>
 #include <WebCore/PasteboardCustomData.h>
 #include <WebCore/PasteboardItemInfo.h>
 #include <WebCore/PlatformPasteboard.h>
+#include <WebCore/SelectionData.h>
 #include <WebCore/SharedBuffer.h>
 #include <wtf/ListHashSet.h>
 #include <wtf/SetForScope.h>
@@ -61,9 +61,9 @@ void WebPasteboardProxy::readBuffer(const String& pasteboardName, const String&
     Clipboard::get(pasteboardName).readBuffer(pasteboardType.utf8().data(), WTFMove(completionHandler));
 }
 
-void WebPasteboardProxy::writeToClipboard(const String& pasteboardName, WebSelectionData&& selection)
+void WebPasteboardProxy::writeToClipboard(const String& pasteboardName, SelectionData&& selectionData)
 {
-    Clipboard::get(pasteboardName).write(WTFMove(selection.selectionData));
+    Clipboard::get(pasteboardName).write(WTFMove(selectionData));
 }
 
 void WebPasteboardProxy::clearClipboard(const String& pasteboardName)
@@ -123,21 +123,21 @@ void WebPasteboardProxy::writeCustomData(IPC::Connection&, const Vector<Pasteboa
         return;
     }
 
-    auto selectionData = SelectionData::create();
+    SelectionData selectionData;
     const auto& customData = data[0];
     customData.forEachPlatformStringOrBuffer([&selectionData] (auto& type, auto& stringOrBuffer) {
         if (WTF::holds_alternative<String>(stringOrBuffer)) {
             if (type == "text/plain"_s)
-                selectionData->setText(WTF::get<String>(stringOrBuffer));
+                selectionData.setText(WTF::get<String>(stringOrBuffer));
             else if (type == "text/html"_s)
-                selectionData->setMarkup(WTF::get<String>(stringOrBuffer));
+                selectionData.setMarkup(WTF::get<String>(stringOrBuffer));
             else if (type == "text/uri-list"_s)
-                selectionData->setURIList(WTF::get<String>(stringOrBuffer));
+                selectionData.setURIList(WTF::get<String>(stringOrBuffer));
         }
     });
 
     if (customData.hasSameOriginCustomData() || !customData.origin().isEmpty())
-        selectionData->setCustomData(customData.createSharedBuffer());
+        selectionData.setCustomData(customData.createSharedBuffer());
 
     Clipboard::get(pasteboardName).write(WTFMove(selectionData));
     completionHandler(0);
index 1ba4d3b..3904bef 100644 (file)
@@ -71,7 +71,7 @@
 #endif
 
 #if PLATFORM(GTK)
-#include "WebSelectionData.h"
+#include <WebCore/SelectionData.h>
 #endif
 
 namespace WebKit {
@@ -325,7 +325,7 @@ RefPtr<SharedBuffer> WebPlatformStrategies::readBufferFromClipboard(const String
 
 void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, SelectionData&& selectionData)
 {
-    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, WebSelectionData(selectionData)), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, WTFMove(selectionData)), 0);
 }
 
 void WebPlatformStrategies::clearClipboard(const String& pasteboardName)
index 1867c98..eed7b99 100644 (file)
 #include "ShareableBitmap.h"
 #include "WebPage.h"
 #include "WebPageProxyMessages.h"
-#include "WebSelectionData.h"
 #include <WebCore/CairoOperations.h>
 #include <WebCore/DataTransfer.h>
 #include <WebCore/DragData.h>
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/Pasteboard.h>
 #include <WebCore/PlatformContextCairo.h>
+#include <WebCore/SelectionData.h>
 #include <cairo.h>
 
 namespace WebKit {
@@ -75,8 +75,7 @@ void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame&)
 
     m_page->willStartDrag();
 
-    WebSelectionData selection(dataTransfer.pasteboard().selectionData());
-    m_page->send(Messages::WebPageProxy::StartDrag(selection, dataTransfer.sourceOperation(), handle));
+    m_page->send(Messages::WebPageProxy::StartDrag(dataTransfer.pasteboard().selectionData(), dataTransfer.sourceOperation(), handle));
 }
 
 }; // namespace WebKit.
index 868531a..4ac447c 100644 (file)
 
 #if PLATFORM(GTK)
 #include "WebPrintOperationGtk.h"
-#include "WebSelectionData.h"
+#include <WebCore/SelectionData.h>
 #include <gtk/gtk.h>
 #endif
 
@@ -3936,14 +3936,14 @@ NotificationPermissionRequestManager* WebPage::notificationPermissionRequestMana
 #if ENABLE(DRAG_SUPPORT)
 
 #if PLATFORM(GTK)
-void WebPage::performDragControllerAction(DragControllerAction action, const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t draggingSourceOperationMask, WebSelectionData&& selection, uint32_t flags)
+void WebPage::performDragControllerAction(DragControllerAction action, const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t draggingSourceOperationMask, SelectionData&& selectionData, uint32_t flags)
 {
     if (!m_page) {
         send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }, { }));
         return;
     }
 
-    DragData dragData(selection.selectionData.ptr(), clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
+    DragData dragData(&selectionData, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
     switch (action) {
     case DragControllerAction::Entered: {
         DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
index feb30eb..0b1d81c 100644 (file)
@@ -186,6 +186,7 @@ class PrintContext;
 class Range;
 class ResourceRequest;
 class ResourceResponse;
+class SelectionData;
 class SelectionRect;
 class SharedBuffer;
 class SubstituteData;
@@ -296,7 +297,6 @@ struct WebAutocorrectionData;
 struct WebAutocorrectionContext;
 struct WebPageCreationParameters;
 struct WebPreferencesStore;
-struct WebSelectionData;
 struct WebsitePoliciesData;
 
 #if ENABLE(UI_SIDE_COMPOSITING)
@@ -895,7 +895,7 @@ public:
     void restoreSelectionInFocusedEditableElement();
 
 #if ENABLE(DRAG_SUPPORT) && PLATFORM(GTK)
-    void performDragControllerAction(DragControllerAction, const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t draggingSourceOperationMask, WebSelectionData&&, uint32_t flags);
+    void performDragControllerAction(DragControllerAction, const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t draggingSourceOperationMask, WebCore::SelectionData&&, uint32_t flags);
 #endif
 
 #if ENABLE(DRAG_SUPPORT) && !PLATFORM(GTK)
index eeb090f..81a7f78 100644 (file)
@@ -307,7 +307,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
 
     # Drag and drop.
 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
-    PerformDragControllerAction(enum:uint8_t WebKit::DragControllerAction action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, struct WebKit::WebSelectionData selection, uint32_t flags)
+    PerformDragControllerAction(enum:uint8_t WebKit::DragControllerAction action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WebCore::SelectionData selection, uint32_t flags)
 #endif
 #if !PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
     PerformDragControllerAction(enum:uint8_t WebKit::DragControllerAction action, WebCore::DragData dragData, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::SandboxExtension::HandleArray sandboxExtensionsForUpload)