[GTK] Move GTK port off legacy clipboard
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 May 2013 09:12:44 +0000 (09:12 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 May 2013 09:12:44 +0000 (09:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=116221

Reviewed by Martin Robinson.

Source/WebCore:

Merge clipboard methods into PasteboardGtk that now wraps a
DataObjectGtk.

* GNUmakefile.list.am: Remove ClipboardGtk.h.
* dom/Clipboard.h: Remove GTK from the list of ports using legacy
clipboard.
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::createDraggingClipboard): Use
Clipboard::createForDragAndDrop().
* platform/Pasteboard.h:
(Pasteboard):
* platform/gtk/ClipboardGtk.cpp:
(WebCore::Editor::newGeneralClipboard): Use
Clipboard::createForCopyAndPaste().
(WebCore::Clipboard::createDragImage):
(WebCore::Clipboard::declareAndWriteDragImage):
* platform/gtk/ClipboardGtk.h: Removed.
* platform/gtk/DragDataGtk.cpp:
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::create): Create a new Pasteboard for a given
GtkClipboard or DataObjectGtk.
(WebCore::Pasteboard::createForCopyAndPaste): Create a Pasteboard
for the GDK_SELECTION_CLIPBOARD clipboard.
(WebCore::Pasteboard::createPrivate): Create a Pasteboard without
a GtkClipboard associated.
(WebCore::Pasteboard::createForDragAndDrop): Create a Pasteboard
for drag and drop operations.
(WebCore::selectionClipboard): Return a static Pasteboard for the
GDK_SELECTION_CLIPBOARD clipboard.
(WebCore::primaryClipboard): Return a static Pasteboard for the
GDK_SELECTION_PRIMARY clipboard.
(WebCore::Pasteboard::generalPasteboard): Return
selectionClipboard() or primaryClipboard() depending on whether
primary selection clipboard is the active one or not.
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::~Pasteboard):
(WebCore::Pasteboard::dataObject): Return the wrapped DataObjectGtk.
(WebCore::dataObjectTypeFromHTMLClipboardType): Copied from
ClipboardGtk.cpp.
(WebCore::Pasteboard::writeString): Adapted to upate the wrapped
DataObjectGtk and the GtkClipboard if needed.
(WebCore::Pasteboard::writeSelection): Ditto.
(WebCore::Pasteboard::writePlainText): Ditto.
(WebCore::Pasteboard::writeURL): Ditto.
(WebCore::Pasteboard::writeImage): Ditto.
(WebCore::Pasteboard::writePasteboard): Copy the wrapped
DataObjectGtk from the DataObjectGtk of the given Pasteboard and
upsate the GtkClipboard if needed.
(WebCore::Pasteboard::clear): Copied from ClipboardGtk.cpp.
(WebCore::Pasteboard::canSmartReplace): Check if current
GtkClipboard supports smart replace.
(WebCore::Pasteboard::setDragImage):
(WebCore::Pasteboard::documentFragment): Adapted to use the
wrapped DataObjectGtk reading from the current GtkClipboard if
present.
(WebCore::Pasteboard::plainText): Ditto.
(WebCore::Pasteboard::hasData): Copied from ClipboardGtk.cpp.
(WebCore::Pasteboard::types): Ditto.
(WebCore::Pasteboard::readString): Ditto.
(WebCore::Pasteboard::readFilenames): Ditto.

Source/WebKit/gtk:

* WebCoreSupport/DragClientGtk.cpp:
(WebKit::DragClient::startDrag): Get the DataObjectGtk from the
Pasteboard associated to the given Clipboard.

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebViewBase.cpp: Remove ClipboardGtk.h
include.
* WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
(WebKit::WebDragClient::startDrag): Get the DataObjectGtk from the
Pasteboard associated to the given Clipboard.

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/dom/Clipboard.h
Source/WebCore/page/gtk/EventHandlerGtk.cpp
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/gtk/ClipboardGtk.cpp
Source/WebCore/platform/gtk/ClipboardGtk.h [deleted file]
Source/WebCore/platform/gtk/DragDataGtk.cpp
Source/WebCore/platform/gtk/PasteboardGtk.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp

index a5c0851..904733b 100644 (file)
@@ -1,3 +1,71 @@
+2013-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Move GTK port off legacy clipboard
+        https://bugs.webkit.org/show_bug.cgi?id=116221
+
+        Reviewed by Martin Robinson.
+
+        Merge clipboard methods into PasteboardGtk that now wraps a
+        DataObjectGtk.
+
+        * GNUmakefile.list.am: Remove ClipboardGtk.h.
+        * dom/Clipboard.h: Remove GTK from the list of ports using legacy
+        clipboard.
+        * page/gtk/EventHandlerGtk.cpp:
+        (WebCore::EventHandler::createDraggingClipboard): Use
+        Clipboard::createForDragAndDrop().
+        * platform/Pasteboard.h:
+        (Pasteboard):
+        * platform/gtk/ClipboardGtk.cpp:
+        (WebCore::Editor::newGeneralClipboard): Use
+        Clipboard::createForCopyAndPaste().
+        (WebCore::Clipboard::createDragImage):
+        (WebCore::Clipboard::declareAndWriteDragImage):
+        * platform/gtk/ClipboardGtk.h: Removed.
+        * platform/gtk/DragDataGtk.cpp:
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::create): Create a new Pasteboard for a given
+        GtkClipboard or DataObjectGtk.
+        (WebCore::Pasteboard::createForCopyAndPaste): Create a Pasteboard
+        for the GDK_SELECTION_CLIPBOARD clipboard.
+        (WebCore::Pasteboard::createPrivate): Create a Pasteboard without
+        a GtkClipboard associated.
+        (WebCore::Pasteboard::createForDragAndDrop): Create a Pasteboard
+        for drag and drop operations.
+        (WebCore::selectionClipboard): Return a static Pasteboard for the
+        GDK_SELECTION_CLIPBOARD clipboard.
+        (WebCore::primaryClipboard): Return a static Pasteboard for the
+        GDK_SELECTION_PRIMARY clipboard.
+        (WebCore::Pasteboard::generalPasteboard): Return
+        selectionClipboard() or primaryClipboard() depending on whether
+        primary selection clipboard is the active one or not.
+        (WebCore::Pasteboard::Pasteboard):
+        (WebCore::Pasteboard::~Pasteboard):
+        (WebCore::Pasteboard::dataObject): Return the wrapped DataObjectGtk.
+        (WebCore::dataObjectTypeFromHTMLClipboardType): Copied from
+        ClipboardGtk.cpp.
+        (WebCore::Pasteboard::writeString): Adapted to upate the wrapped
+        DataObjectGtk and the GtkClipboard if needed.
+        (WebCore::Pasteboard::writeSelection): Ditto.
+        (WebCore::Pasteboard::writePlainText): Ditto.
+        (WebCore::Pasteboard::writeURL): Ditto.
+        (WebCore::Pasteboard::writeImage): Ditto.
+        (WebCore::Pasteboard::writePasteboard): Copy the wrapped
+        DataObjectGtk from the DataObjectGtk of the given Pasteboard and
+        upsate the GtkClipboard if needed.
+        (WebCore::Pasteboard::clear): Copied from ClipboardGtk.cpp.
+        (WebCore::Pasteboard::canSmartReplace): Check if current
+        GtkClipboard supports smart replace.
+        (WebCore::Pasteboard::setDragImage):
+        (WebCore::Pasteboard::documentFragment): Adapted to use the
+        wrapped DataObjectGtk reading from the current GtkClipboard if
+        present.
+        (WebCore::Pasteboard::plainText): Ditto.
+        (WebCore::Pasteboard::hasData): Copied from ClipboardGtk.cpp.
+        (WebCore::Pasteboard::types): Ditto.
+        (WebCore::Pasteboard::readString): Ditto.
+        (WebCore::Pasteboard::readFilenames): Ditto.
+
 2013-05-18  Alberto Garcia  <agarcia@igalia.com>
 
         [GTK] Parallel build fails if gtk-doc is enabled
index 6473206..478b1c1 100644 (file)
@@ -6205,7 +6205,6 @@ webcoregtk_sources += \
        Source/WebCore/platform/gtk/AsyncFileSystemGtk.cpp \
        Source/WebCore/platform/gtk/AsyncFileSystemGtk.h \
        Source/WebCore/platform/gtk/ClipboardGtk.cpp \
-       Source/WebCore/platform/gtk/ClipboardGtk.h \
        Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.cpp \
        Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.h \
        Source/WebCore/platform/gtk/DataObjectGtk.cpp \
index b9becfb..66b3081 100644 (file)
@@ -34,7 +34,7 @@
 // This DOM object now works by calling through to classes in the platform layer.
 // Specifically, the class currently named Pasteboard. The legacy style instead
 // uses this as an abstract base class.
-#define WTF_USE_LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS (PLATFORM(GTK) || PLATFORM(IOS) || PLATFORM(QT) || PLATFORM(WIN))
+#define WTF_USE_LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS (PLATFORM(IOS) || PLATFORM(QT) || PLATFORM(WIN))
 
 #if USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
 #define LEGACY_VIRTUAL virtual
index cfd6c88..10176f7 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "EventHandler.h"
 
-#include "ClipboardGtk.h"
+#include "Clipboard.h"
 #include "FloatPoint.h"
 #include "FocusController.h"
 #include "Frame.h"
@@ -96,7 +96,7 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widge
 
 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
 {
-    return ClipboardGtk::create(ClipboardWritable, DataObjectGtk::create(), Clipboard::DragAndDrop, m_frame);
+    return Clipboard::createForDragAndDrop();
 }
 
 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
index 523a4e6..f005a54 100644 (file)
@@ -33,8 +33,8 @@
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(GTK)
-// FIXME: Why does this include need to be in this header?
-#include <PasteboardHelper.h>
+#include "DragData.h"
+typedef struct _GtkClipboard GtkClipboard;
 #endif
 
 #if PLATFORM(WIN)
@@ -94,6 +94,12 @@ public:
     static String getStringSelection(Frame*, ShouldSerializeSelectedTextForClipboard);
 #endif
 
+#if PLATFORM(GTK)
+    static PassOwnPtr<Pasteboard> create(PassRefPtr<DataObjectGtk>);
+    static PassOwnPtr<Pasteboard> create(GtkClipboard*);
+    PassRefPtr<DataObjectGtk> dataObject() const;
+#endif
+
     // Deprecated. Use createForCopyAndPaste instead.
     static Pasteboard* generalPasteboard();
 
@@ -154,6 +160,11 @@ public:
 private:
     Pasteboard();
 
+#if PLATFORM(GTK)
+    Pasteboard(PassRefPtr<DataObjectGtk>);
+    Pasteboard(GtkClipboard*);
+#endif
+
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     String m_pasteboardName;
     long m_changeCount;
@@ -171,6 +182,11 @@ private:
     bool m_selectionMode;
 #endif
 
+#if PLATFORM(GTK)
+    RefPtr<DataObjectGtk> m_dataObject;
+    GtkClipboard* m_gtkClipboard;
+#endif
+
 };
 
 } // namespace WebCore
index dd0a372..d795cf5 100644 (file)
  */
 
 #include "config.h"
-#include "ClipboardGtk.h"
+#include "Clipboard.h"
 
 #include "CachedImage.h"
-#include "DragData.h"
+#include "Document.h"
 #include "Editor.h"
 #include "Element.h"
-#include "FileList.h"
 #include "Frame.h"
-#include "HTMLNames.h"
-#include "Image.h"
-#include "NotImplemented.h"
 #include "Pasteboard.h"
-#include "PasteboardHelper.h"
-#include "RenderImage.h"
-#include "ScriptExecutionContext.h"
-#include "markup.h"
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-#include <gtk/gtk.h>
 
 namespace WebCore {
 
-enum ClipboardDataType {
-    ClipboardDataTypeText,
-    ClipboardDataTypeMarkup,
-    ClipboardDataTypeURIList,
-    ClipboardDataTypeURL,
-    ClipboardDataTypeImage,
-    ClipboardDataTypeUnknown
-};
-
+// FIXME: this should be moved to editing/gtk/EditorGtk.cpp.
 PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame)
 {
-    return ClipboardGtk::create(policy, gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD), frame);
-}
-
-PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame)
-{
-    return ClipboardGtk::create(policy, dragData->platformData(), DragAndDrop, frame);
-}
-
-ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, GtkClipboard* clipboard, Frame* frame)
-    : Clipboard(policy, CopyAndPaste)
-    , m_dataObject(DataObjectGtk::forClipboard(clipboard))
-    , m_clipboard(clipboard)
-    , m_frame(frame)
-{
-}
-
-ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, ClipboardType clipboardType, Frame* frame)
-    : Clipboard(policy, clipboardType)
-    , m_dataObject(dataObject)
-    , m_clipboard(0)
-    , m_frame(frame)
-{
-}
-
-ClipboardGtk::~ClipboardGtk()
-{
-    if (m_dragImage)
-        m_dragImage->removeClient(this);
-}
-
-static ClipboardDataType dataObjectTypeFromHTMLClipboardType(const String& rawType)
-{
-    String type(rawType.stripWhiteSpace());
-
-    // Two special cases for IE compatibility
-    if (type == "Text" || type == "text")
-        return ClipboardDataTypeText;
-    if (type == "URL")
-        return ClipboardDataTypeURL;
-
-    // From the Mac port: Ignore any trailing charset - JS strings are
-    // Unicode, which encapsulates the charset issue.
-    if (type == "text/plain" || type.startsWith("text/plain;"))
-        return ClipboardDataTypeText;
-    if (type == "text/html" || type.startsWith("text/html;"))
-        return ClipboardDataTypeMarkup;
-    if (type == "Files" || type == "text/uri-list" || type.startsWith("text/uri-list;"))
-        return ClipboardDataTypeURIList;
-
-    // Not a known type, so just default to using the text portion.
-    return ClipboardDataTypeUnknown;
-}
-
-void ClipboardGtk::clearData(const String& typeString)
-{
-    if (!canWriteData())
-        return;
-
-    ClipboardDataType type = dataObjectTypeFromHTMLClipboardType(typeString);
-    switch (type) {
-    case ClipboardDataTypeURIList:
-    case ClipboardDataTypeURL:
-        m_dataObject->clearURIList();
-        break;
-    case ClipboardDataTypeMarkup:
-        m_dataObject->clearMarkup();
-        break;
-    case ClipboardDataTypeText:
-        m_dataObject->clearText();
-        break;
-    case ClipboardDataTypeImage:
-        m_dataObject->clearImage();
-        break;
-    case ClipboardDataTypeUnknown:
-        m_dataObject->clearAll();
-        break;
-    }
-
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_clipboard);
-}
-
-
-void ClipboardGtk::clearAllData()
-{
-    if (!canWriteData())
-        return;
-
-    // We do not clear filenames. According to the spec: "The clearData() method
-    // does not affect whether any files were included in the drag, so the types
-    // attribute's list might still not be empty after calling clearData() (it would 
-    // still contain the "Files" string if any files were included in the drag)."
-    m_dataObject->clearAllExceptFilenames();
-
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_clipboard);
-}
-
-String ClipboardGtk::getData(const String& typeString) const
-{
-    if (!canReadData() || !m_dataObject)
-        return String();
-
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_clipboard);
-
-    ClipboardDataType type = dataObjectTypeFromHTMLClipboardType(typeString);
-    if (type == ClipboardDataTypeURIList)
-        return m_dataObject->uriList();
-    if (type == ClipboardDataTypeURL)
-        return m_dataObject->url();
-    if (type == ClipboardDataTypeMarkup)
-        return m_dataObject->markup();
-    if (type == ClipboardDataTypeText)
-        return m_dataObject->text();
-
-    return String();
+    return Clipboard::createForCopyAndPaste(policy);
 }
 
-bool ClipboardGtk::setData(const String& typeString, const String& data)
-{
-    if (!canWriteData())
-        return false;
-
-    bool success = false;
-    ClipboardDataType type = dataObjectTypeFromHTMLClipboardType(typeString);
-    if (type == ClipboardDataTypeURIList || type == ClipboardDataTypeURL) {
-        m_dataObject->setURIList(data);
-        success = true;
-    } else if (type == ClipboardDataTypeMarkup) {
-        m_dataObject->setMarkup(data);
-        success = true;
-    } else if (type == ClipboardDataTypeText) {
-        m_dataObject->setText(data);
-        success = true;
-    }
-
-    return success;
-}
-
-ListHashSet<String> ClipboardGtk::types() const
-{
-    if (!canReadTypes())
-        return ListHashSet<String>();
-
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_clipboard);
-
-    ListHashSet<String> types;
-    if (m_dataObject->hasText()) {
-        types.add("text/plain");
-        types.add("Text");
-        types.add("text");
-    }
-
-    if (m_dataObject->hasMarkup())
-        types.add("text/html");
-
-    if (m_dataObject->hasURIList()) {
-        types.add("text/uri-list");
-        types.add("URL");
-    }
-
-    if (m_dataObject->hasFilenames())
-        types.add("Files");
-
-    return types;
-}
-
-PassRefPtr<FileList> ClipboardGtk::files() const
-{
-    if (!canReadData())
-        return FileList::create();
-
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_clipboard);
-
-    RefPtr<FileList> fileList = FileList::create();
-    const Vector<String>& filenames = m_dataObject->filenames();
-    for (size_t i = 0; i < filenames.size(); i++)
-        fileList->append(File::create(filenames[i], File::AllContentTypes));
-    return fileList.release();
-}
-
-void ClipboardGtk::setDragImage(CachedImage* image, const IntPoint& location)
-{
-    setDragImage(image, 0, location);
-}
-
-void ClipboardGtk::setDragImageElement(Node* element, const IntPoint& location)
-{
-    setDragImage(0, element, location);
-}
-
-void ClipboardGtk::setDragImage(CachedImage* image, Node* element, const IntPoint& location)
-{
-    if (!canSetDragImage())
-        return;
-
-    if (m_dragImage)
-        m_dragImage->removeClient(this);
-    m_dragImage = image;
-    if (m_dragImage)
-        m_dragImage->addClient(this);
-
-    m_dragLoc = location;
-    m_dragImageElement = element;
-}
-
-DragImageRef ClipboardGtk::createDragImage(IntPoint& location) const
+DragImageRef Clipboard::createDragImage(IntPoint& location) const
 {
     location = m_dragLoc;
 
     if (m_dragImage)
         return createDragImageFromImage(m_dragImage->image());
-    if (m_dragImageElement && m_frame)
-        return m_frame->nodeImage(m_dragImageElement.get());
 
-    return 0; // We do not have enough information to create a drag image, use the default icon.
-}
-
-static CachedImage* getCachedImage(Element* element)
-{
-    // Attempt to pull CachedImage from element
-    ASSERT(element);
-    RenderObject* renderer = element->renderer();
-    if (!renderer || !renderer->isImage())
-        return 0;
-
-    RenderImage* image = static_cast<RenderImage*>(renderer);
-    if (image->cachedImage() && !image->cachedImage()->errorOccurred())
-        return image->cachedImage();
-
-    return 0;
-}
-
-void ClipboardGtk::declareAndWriteDragImage(Element* element, const KURL& url, const String& label, Frame* frame)
-{
-    m_dataObject->setURL(url, label);
-    m_dataObject->setMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs));
-
-    CachedImage* image = getCachedImage(element);
-    if (!image || !image->isLoaded())
-        return;
-
-    GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->imageForRenderer(element->renderer())->getGdkPixbuf());
-    if (!pixbuf)
-        return;
-
-    m_dataObject->setImage(pixbuf.get());
-}
-
-void ClipboardGtk::writeURL(const KURL& url, const String& label, Frame*)
-{
-    m_dataObject->setURL(url, label);
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_clipboard);
-}
-
-void ClipboardGtk::writeRange(Range* range, Frame* frame)
-{
-    ASSERT(range);
-
-    m_dataObject->setText(frame->editor().selectedTextForClipboard());
-    m_dataObject->setMarkup(createMarkup(range, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
-
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_clipboard);
-}
-
-void ClipboardGtk::writePlainText(const String& text)
-{
-    m_dataObject->setText(text);
+    if (m_dragImageElement) {
+        Document* document = m_dragImageElement->document();
+        if (Frame* frame = document->frame())
+            return frame->nodeImage(m_dragImageElement.get());
+    }
 
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_clipboard);
+    return 0; // We do not have enough information to create a drag image, use the default icon.
 }
 
-bool ClipboardGtk::hasData()
+void Clipboard::declareAndWriteDragImage(Element* element, const KURL& url, const String& label, Frame* frame)
 {
-    if (m_clipboard)
-        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_clipboard);
-
-    return m_dataObject->hasText() || m_dataObject->hasMarkup()
-        || m_dataObject->hasURIList() || m_dataObject->hasImage();
+    m_pasteboard->writeImage(element->toNode(), url, label);
 }
 
 }
diff --git a/Source/WebCore/platform/gtk/ClipboardGtk.h b/Source/WebCore/platform/gtk/ClipboardGtk.h
deleted file mode 100644 (file)
index ee9d63c..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007, Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardGtk_h
-#define ClipboardGtk_h
-
-#include "CachedImageClient.h"
-#include "Clipboard.h"
-#include "DataObjectGtk.h"
-
-namespace WebCore {
-    class CachedImage;
-    class Frame;
-    class PasteboardHelper;
-
-    // State available during IE's events for drag and drop and copy/paste
-    // Created from the EventHandlerGtk to be used by the dom
-    class ClipboardGtk : public Clipboard, public CachedImageClient {
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
-        static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, GtkClipboard* clipboard, Frame* frame)
-        {
-            return adoptRef(new ClipboardGtk(policy, clipboard, frame));
-        }
-
-        static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, ClipboardType clipboardType, Frame* frame)
-        {
-            return adoptRef(new ClipboardGtk(policy, dataObject, clipboardType, frame));
-        }
-        virtual ~ClipboardGtk();
-
-        void clearData(const String&);
-        void clearAllData();
-        String getData(const String&) const;
-        bool setData(const String&, const String&);
-
-        virtual ListHashSet<String> types() const;
-        virtual PassRefPtr<FileList> files() const;
-
-        void setDragImage(CachedImage*, const IntPoint&);
-        void setDragImageElement(Node*, const IntPoint&);
-        void setDragImage(CachedImage*, Node*, const IntPoint&);
-
-        virtual DragImageRef createDragImage(IntPoint&) const;
-        virtual void declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*);
-        virtual void writeURL(const KURL&, const String&, Frame*);
-        virtual void writeRange(Range*, Frame*);
-        virtual void writePlainText(const String&);
-
-        virtual bool hasData();
-
-        PassRefPtr<DataObjectGtk> dataObject() { return m_dataObject; }
-        GtkClipboard* clipboard() { return m_clipboard; }
-
-    private:
-        ClipboardGtk(ClipboardAccessPolicy, GtkClipboard*, Frame*);
-        ClipboardGtk(ClipboardAccessPolicy, PassRefPtr<DataObjectGtk>, ClipboardType, Frame*);
-
-        RefPtr<DataObjectGtk> m_dataObject;
-        GtkClipboard* m_clipboard;
-        Frame* m_frame;
-    };
-}
-
-#endif
index 02a4749..797c78b 100644 (file)
@@ -17,8 +17,7 @@
 #include "config.h"
 #include "DragData.h"
 
-#include "Clipboard.h"
-#include "ClipboardGtk.h"
+#include "DataObjectGtk.h"
 #include "Document.h"
 #include "DocumentFragment.h"
 #include "Frame.h"
index 1a0bcbd..e3a1fe5 100644 (file)
 #include "Pasteboard.h"
 
 #include "CachedImage.h"
-#include "ClipboardGtk.h"
 #include "DataObjectGtk.h"
 #include "DocumentFragment.h"
 #include "Editor.h"
 #include "Frame.h"
-#include "GOwnPtrGtk.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
-#include "KURL.h"
-#include "NotImplemented.h"
-#include "TextResourceDecoder.h"
 #include "Image.h"
+#include "KURL.h"
+#include "PasteboardHelper.h"
 #include "RenderImage.h"
 #include "markup.h"
 #include <gtk/gtk.h>
-#include <wtf/gobject/GRefPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
 
 #if ENABLE(SVG)
 #include "SVGNames.h"
 
 namespace WebCore {
 
-Pasteboard* Pasteboard::generalPasteboard()
+enum ClipboardDataType {
+    ClipboardDataTypeText,
+    ClipboardDataTypeMarkup,
+    ClipboardDataTypeURIList,
+    ClipboardDataTypeURL,
+    ClipboardDataTypeImage,
+    ClipboardDataTypeUnknown
+};
+
+PassOwnPtr<Pasteboard> Pasteboard::create(GtkClipboard* gtkClipboard)
 {
-    static Pasteboard* pasteboard = new Pasteboard();
+    return adoptPtr(new Pasteboard(gtkClipboard));
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::create(PassRefPtr<DataObjectGtk> dataObject)
+{
+    return adoptPtr(new Pasteboard(dataObject));
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createForCopyAndPaste()
+{
+    return create(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createPrivate()
+{
+    return create(DataObjectGtk::create());
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createForDragAndDrop()
+{
+    return create(DataObjectGtk::create());
+}
+
+PassOwnPtr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData)
+{
+    return create(dragData.platformData());
+}
+
+static Pasteboard* selectionClipboard()
+{
+    static Pasteboard* pasteboard = Pasteboard::create(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)).leakPtr();
     return pasteboard;
 }
 
-Pasteboard::Pasteboard()
+static Pasteboard* primaryClipboard()
 {
+    static Pasteboard* pasteboard = Pasteboard::create(gtk_clipboard_get(GDK_SELECTION_PRIMARY)).leakPtr();
+    return pasteboard;
 }
 
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
+Pasteboard* Pasteboard::generalPasteboard()
+{
+    return PasteboardHelper::defaultPasteboardHelper()->usePrimarySelectionClipboard() ? primaryClipboard() : selectionClipboard();
+}
+
+Pasteboard::Pasteboard(PassRefPtr<DataObjectGtk> dataObject)
+    : m_dataObject(dataObject)
+    , m_gtkClipboard(0)
+{
+    ASSERT(m_dataObject);
+}
+
+Pasteboard::Pasteboard(GtkClipboard* gtkClipboard)
+    : m_dataObject(DataObjectGtk::forClipboard(gtkClipboard))
+    , m_gtkClipboard(gtkClipboard)
 {
-    PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
-    GtkClipboard* clipboard = helper->getCurrentClipboard(frame);
+    ASSERT(m_dataObject);
+}
 
-    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-    dataObject->clearAll();
+Pasteboard::~Pasteboard()
+{
+}
+
+PassRefPtr<DataObjectGtk> Pasteboard::dataObject() const
+{
+    return m_dataObject;
+}
 
-    dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText());
-    dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
-    helper->writeClipboardContents(clipboard, canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
+static ClipboardDataType dataObjectTypeFromHTMLClipboardType(const String& rawType)
+{
+    String type(rawType.stripWhiteSpace());
+
+    // Two special cases for IE compatibility
+    if (type == "Text" || type == "text")
+        return ClipboardDataTypeText;
+    if (type == "URL")
+        return ClipboardDataTypeURL;
+
+    // From the Mac port: Ignore any trailing charset - JS strings are
+    // Unicode, which encapsulates the charset issue.
+    if (type == "text/plain" || type.startsWith("text/plain;"))
+        return ClipboardDataTypeText;
+    if (type == "text/html" || type.startsWith("text/html;"))
+        return ClipboardDataTypeMarkup;
+    if (type == "Files" || type == "text/uri-list" || type.startsWith("text/uri-list;"))
+        return ClipboardDataTypeURIList;
+
+    // Not a known type, so just default to using the text portion.
+    return ClipboardDataTypeUnknown;
+}
+
+bool Pasteboard::writeString(const String& type, const String& data)
+{
+    switch (dataObjectTypeFromHTMLClipboardType(type)) {
+    case ClipboardDataTypeURIList:
+    case ClipboardDataTypeURL:
+        m_dataObject->setURIList(data);
+        return true;
+    case ClipboardDataTypeMarkup:
+        m_dataObject->setMarkup(data);
+        return true;
+    case ClipboardDataTypeText:
+        m_dataObject->setText(data);
+        return true;
+    case ClipboardDataTypeImage:
+    case ClipboardDataTypeUnknown:
+        break;
+    }
+
+    return false;
+}
+
+void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
+{
+    m_dataObject->clearAll();
+    m_dataObject->setText(shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText());
+    m_dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
+
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard, canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
 }
 
 void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
 {
-    GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
-    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-    dataObject->clearAll();
+    m_dataObject->clearAll();
+    m_dataObject->setText(text);
 
-    dataObject->setText(text);
-    PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard,
-        (smartReplaceOption == CanSmartReplace) ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard, (smartReplaceOption == CanSmartReplace) ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
 }
 
 void Pasteboard::writeURL(const KURL& url, const String& label, Frame* frame)
 {
-    if (url.isEmpty())
-        return;
+    ASSERT(!url.isEmpty());
 
-    PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
-    GtkClipboard* clipboard = helper->getCurrentClipboard(frame);
+    m_dataObject->clearAll();
+    m_dataObject->setURL(url, label);
 
-    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-    dataObject->clearAll();
-
-    dataObject->setURL(url, label);
-    helper->writeClipboardContents(clipboard);
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
 }
 
 static KURL getURLForImageNode(Node* node)
@@ -127,53 +225,98 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String& title)
     Image* image = cachedImage->imageForRenderer(renderer);
     ASSERT(image);
 
-    GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
-    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-    dataObject->clearAll();
+    m_dataObject->clearAll();
 
     KURL url = getURLForImageNode(node);
     if (!url.isEmpty()) {
-        dataObject->setURL(url, title);
+        m_dataObject->setURL(url, title);
 
-        dataObject->setMarkup(createMarkup(toElement(node), IncludeNode, 0, ResolveAllURLs));
+        m_dataObject->setMarkup(createMarkup(toElement(node), IncludeNode, 0, ResolveAllURLs));
     }
 
     GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->getGdkPixbuf());
-    dataObject->setImage(pixbuf.get());
+    m_dataObject->setImage(pixbuf.get());
 
-    PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard);
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
 }
 
-void Pasteboard::writeClipboard(Clipboard* clipboard)
+void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)
 {
-    GtkClipboard* gtkClipboard = static_cast<ClipboardGtk*>(clipboard)->clipboard();
-    if (gtkClipboard)
-        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(gtkClipboard);
+    RefPtr<DataObjectGtk> sourceDataObject = sourcePasteboard.dataObject();
+    m_dataObject->clearAll();
+
+    if (sourceDataObject->hasText())
+        m_dataObject->setText(sourceDataObject->text());
+    if (sourceDataObject->hasMarkup())
+        m_dataObject->setMarkup(sourceDataObject->markup());
+    if (sourceDataObject->hasURL())
+        m_dataObject->setURL(sourceDataObject->url(), sourceDataObject->urlLabel());
+    if (sourceDataObject->hasURIList())
+        m_dataObject->setURIList(sourceDataObject->uriList());
+    if (sourceDataObject->hasImage())
+        m_dataObject->setImage(sourceDataObject->image());
+
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
 }
 
 void Pasteboard::clear()
 {
-    gtk_clipboard_clear(gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD));
+    // We do not clear filenames. According to the spec: "The clearData() method
+    // does not affect whether any files were included in the drag, so the types
+    // attribute's list might still not be empty after calling clearData() (it would
+    // still contain the "Files" string if any files were included in the drag)."
+    m_dataObject->clearAllExceptFilenames();
+
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
+}
+
+void Pasteboard::clear(const String& type)
+{
+    switch (dataObjectTypeFromHTMLClipboardType(type)) {
+    case ClipboardDataTypeURIList:
+    case ClipboardDataTypeURL:
+        m_dataObject->clearURIList();
+        break;
+    case ClipboardDataTypeMarkup:
+        m_dataObject->clearMarkup();
+        break;
+    case ClipboardDataTypeText:
+        m_dataObject->clearText();
+        break;
+    case ClipboardDataTypeImage:
+        m_dataObject->clearImage();
+        break;
+    case ClipboardDataTypeUnknown:
+        m_dataObject->clearAll();
+        break;
+    }
+
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
 }
 
 bool Pasteboard::canSmartReplace()
 {
-    return PasteboardHelper::defaultPasteboardHelper()->clipboardContentSupportsSmartReplace(
-        gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD));
+    return m_gtkClipboard && PasteboardHelper::defaultPasteboardHelper()->clipboardContentSupportsSmartReplace(m_gtkClipboard);
+}
+
+void Pasteboard::setDragImage(DragImageRef, const IntPoint& hotSpot)
+{
 }
 
 PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
                                                           bool allowPlainText, bool& chosePlainText)
 {
-    PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
-    GtkClipboard* clipboard = helper->getCurrentClipboard(frame);
-    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-    helper->getClipboardContents(clipboard);
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
 
     chosePlainText = false;
 
-    if (dataObject->hasMarkup()) {
-        RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), dataObject->markup(), "", DisallowScriptingAndPluginContent);
+    if (m_dataObject->hasMarkup()) {
+        RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), m_dataObject->markup(), "", DisallowScriptingAndPluginContent);
         if (fragment)
             return fragment.release();
     }
@@ -181,9 +324,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
     if (!allowPlainText)
         return 0;
 
-    if (dataObject->hasText()) {
+    if (m_dataObject->hasText()) {
         chosePlainText = true;
-        RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), dataObject->text());
+        RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), m_dataObject->text());
         if (fragment)
             return fragment.release();
     }
@@ -193,12 +336,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
 
 String Pasteboard::plainText(Frame* frame)
 {
-    PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
-    GtkClipboard* clipboard = helper->getCurrentClipboard(frame);
-    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-
-    helper->getClipboardContents(clipboard);
-    return dataObject->text();
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
+    return m_dataObject->text();
 }
 
 bool Pasteboard::isSelectionMode() const
@@ -211,4 +351,68 @@ void Pasteboard::setSelectionMode(bool selectionMode)
     PasteboardHelper::defaultPasteboardHelper()->setUsePrimarySelectionClipboard(selectionMode);
 }
 
+bool Pasteboard::hasData()
+{
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
+
+    return m_dataObject->hasText() || m_dataObject->hasMarkup() || m_dataObject->hasURIList() || m_dataObject->hasImage();
+}
+
+ListHashSet<String> Pasteboard::types()
+{
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
+
+    ListHashSet<String> types;
+    if (m_dataObject->hasText()) {
+        types.add("text/plain");
+        types.add("Text");
+        types.add("text");
+    }
+
+    if (m_dataObject->hasMarkup())
+        types.add("text/html");
+
+    if (m_dataObject->hasURIList()) {
+        types.add("text/uri-list");
+        types.add("URL");
+    }
+
+    if (m_dataObject->hasFilenames())
+        types.add("Files");
+
+    return types;
+}
+
+String Pasteboard::readString(const String& type)
+{
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
+
+    switch (dataObjectTypeFromHTMLClipboardType(type)) {
+    case ClipboardDataTypeURIList:
+        return m_dataObject->uriList();
+    case ClipboardDataTypeURL:
+        return m_dataObject->url();
+    case ClipboardDataTypeMarkup:
+        return m_dataObject->markup();
+    case ClipboardDataTypeText:
+        return m_dataObject->text();
+    case ClipboardDataTypeImage:
+    case ClipboardDataTypeUnknown:
+        break;
+    }
+
+    return String();
+}
+
+Vector<String> Pasteboard::readFilenames()
+{
+    if (m_gtkClipboard)
+        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
+
+    return m_dataObject->filenames();
+}
+
 }
index efdc337..026c19f 100644 (file)
@@ -1,3 +1,14 @@
+2013-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Move GTK port off legacy clipboard
+        https://bugs.webkit.org/show_bug.cgi?id=116221
+
+        Reviewed by Martin Robinson.
+
+        * WebCoreSupport/DragClientGtk.cpp:
+        (WebKit::DragClient::startDrag): Get the DataObjectGtk from the
+        Pasteboard associated to the given Clipboard.
+
 2013-05-17  Gustavo Noronha Silva  <gustavo.noronha@collabora.com>
 
         Unreviewed build fix. Remove assertion that doesn't make sense anymore since the
index 92800d9..e39b470 100644 (file)
@@ -19,7 +19,7 @@
 #include "config.h"
 #include "DragClientGtk.h"
 
-#include "ClipboardGtk.h"
+#include "Clipboard.h"
 #include "ClipboardUtilitiesGtk.h"
 #include "DataObjectGtk.h"
 #include "Document.h"
@@ -30,6 +30,7 @@
 #include "GRefPtrGtk.h"
 #include "GtkVersioning.h"
 #include "NotImplemented.h"
+#include "Pasteboard.h"
 #include "PasteboardHelper.h"
 #include "RenderObject.h"
 #include "webkitwebframeprivate.h"
@@ -75,10 +76,8 @@ DragSourceAction DragClient::dragSourceActionMaskForPoint(const IntPoint&)
 
 void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag)
 {
-    ClipboardGtk* clipboardGtk = reinterpret_cast<ClipboardGtk*>(clipboard);
-
     WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame));
-    RefPtr<DataObjectGtk> dataObject = clipboardGtk->dataObject();
+    RefPtr<DataObjectGtk> dataObject = clipboard->pasteboard().dataObject();
     GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
     GOwnPtr<GdkEvent> currentEvent(gtk_get_current_event());
 
index 68a82bb..0722705 100644 (file)
@@ -1,3 +1,16 @@
+2013-05-18  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Move GTK port off legacy clipboard
+        https://bugs.webkit.org/show_bug.cgi?id=116221
+
+        Reviewed by Martin Robinson.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp: Remove ClipboardGtk.h
+        include.
+        * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+        (WebKit::WebDragClient::startDrag): Get the DataObjectGtk from the
+        Pasteboard associated to the given Clipboard.
+
 2013-05-18  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         [EFL][WK2] Refactor ewk_view_custom_encoding_set/get API
index dcf336c..389724e 100644 (file)
@@ -42,7 +42,6 @@
 #include "WebKitWebViewBasePrivate.h"
 #include "WebPageProxy.h"
 #include "WebViewBaseInputMethodFilter.h"
-#include <WebCore/ClipboardGtk.h>
 #include <WebCore/ClipboardUtilitiesGtk.h>
 #include <WebCore/DataObjectGtk.h>
 #include <WebCore/DragData.h>
index d808ed4..406f0ea 100644 (file)
 #include "ShareableBitmap.h"
 #include "WebPage.h"
 #include "WebPageProxyMessages.h"
-#include <WebCore/ClipboardGtk.h>
+#include <WebCore/Clipboard.h>
+#include <WebCore/DataObjectGtk.h>
 #include <WebCore/DragData.h>
 #include <WebCore/GraphicsContext.h>
+#include <WebCore/Pasteboard.h>
 #include <WebCore/PlatformContextCairo.h>
 
 using namespace WebCore;
@@ -61,7 +63,7 @@ void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosi
     if (bitmap && !bitmap->createHandle(handle))
         return;
 
-    RefPtr<DataObjectGtk> dataObject = reinterpret_cast<ClipboardGtk*>(clipboard)->dataObject();
+    RefPtr<DataObjectGtk> dataObject = clipboard->pasteboard().dataObject();
     DragData dragData(dataObject.get(), clientPosition, globalPosition, clipboard->sourceOperation());
     m_page->send(Messages::WebPageProxy::StartDrag(dragData, handle));
 }