<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174868] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174868">174868</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-10-19 00:33:19 -0700 (Sun, 19 Oct 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Move GtkDragAndDropHelper from Platform to WebKit2
https://bugs.webkit.org/show_bug.cgi?id=137422
Reviewed by Martin Robinson.
Source/WebCore:
Remove ClipboardUtilitiesGtk and GtkDragAndDropHelper.
* PlatformGTK.cmake:
* platform/gtk/ClipboardUtilitiesGtk.cpp: Removed.
* platform/gtk/ClipboardUtilitiesGtk.h: Removed.
* platform/gtk/GtkDragAndDropHelper.cpp: Removed.
* platform/gtk/GtkDragAndDropHelper.h: Removed.
Source/WebKit2:
WebKitWebViewBase is currently the only user of
GtkDragAndDropHelper, that was added to share the code with
WebKit1. Move all the drag and drop logic to a new class
DragAndDropHandler.
* PlatformGTK.cmake: Add new files to compilation.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::startDrag):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseConstructed):
(webkitWebViewBaseDragDataGet):
(webkitWebViewBaseDragEnd):
(webkitWebViewBaseDragDataReceived):
(webkitWebViewBaseDragMotion):
(webkitWebViewBaseDragLeave):
(webkitWebViewBaseDragDrop):
(webkitWebViewBaseDragAndDropHandler):
(dragExitedCallback): Deleted.
(webkitWebViewBaseStartDrag): Deleted.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/gtk/DragAndDropHandler.cpp: Added.
(WebKit::DragAndDropHandler::create):
(WebKit::DragAndDropHandler::DragAndDropHandler):
(WebKit::DragAndDropHandler::DroppingContext::DroppingContext):
(WebKit::dragOperationToGdkDragActions):
(WebKit::dragOperationToSingleGdkDragAction):
(WebKit::gdkDragActionToDragOperation):
(WebKit::DragAndDropHandler::startDrag):
(WebKit::DragAndDropHandler::fillDragData):
(WebKit::DragAndDropHandler::finishDrag):
(WebKit::DragAndDropHandler::dataObjectForDropData):
(WebKit::DragAndDropHandler::dragEntered):
(WebKit::DragAndDropHandler::requestDragData):
(WebKit::DragAndDropHandler::dragMotion):
(WebKit::DragAndDropHandler::dragLeave):
(WebKit::DragAndDropHandler::drop):
* UIProcess/gtk/DragAndDropHandler.h: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasePrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessgtkDragAndDropHandlercpp">trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkDragAndDropHandlerh">trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgtkClipboardUtilitiesGtkcpp">trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkClipboardUtilitiesGtkh">trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkGtkDragAndDropHelpercpp">trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkGtkDragAndDropHelperh">trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebCore/ChangeLog        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-10-19 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move GtkDragAndDropHelper from Platform to WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=137422
+
+ Reviewed by Martin Robinson.
+
+ Remove ClipboardUtilitiesGtk and GtkDragAndDropHelper.
+
+ * PlatformGTK.cmake:
+ * platform/gtk/ClipboardUtilitiesGtk.cpp: Removed.
+ * platform/gtk/ClipboardUtilitiesGtk.h: Removed.
+ * platform/gtk/GtkDragAndDropHelper.cpp: Removed.
+ * platform/gtk/GtkDragAndDropHelper.h: Removed.
+
</ins><span class="cx"> 2014-10-19 Roger Fong <roger_fong@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed. Style fix following r174855.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -213,7 +213,6 @@
</span><span class="cx"> platform/graphics/gtk/ImageBufferGtk.cpp
</span><span class="cx"> platform/graphics/gtk/ImageGtk.cpp
</span><span class="cx">
</span><del>- platform/gtk/ClipboardUtilitiesGtk.cpp
</del><span class="cx"> platform/gtk/ContextMenuGtk.cpp
</span><span class="cx"> platform/gtk/ContextMenuItemGtk.cpp
</span><span class="cx"> platform/gtk/CursorGtk.cpp
</span><span class="lines">@@ -223,7 +222,6 @@
</span><span class="cx"> platform/gtk/DragImageGtk.cpp
</span><span class="cx"> platform/gtk/GRefPtrGtk.cpp
</span><span class="cx"> platform/gtk/GtkClickCounter.cpp
</span><del>- platform/gtk/GtkDragAndDropHelper.cpp
</del><span class="cx"> platform/gtk/GtkInputMethodFilter.cpp
</span><span class="cx"> platform/gtk/GtkUtilities.cpp
</span><span class="cx"> platform/gtk/GtkVersioning.c
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkClipboardUtilitiesGtkcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.cpp (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.cpp        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.cpp        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -1,75 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010, Igalia S.L.
- *
- * 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 "ClipboardUtilitiesGtk.h"
-
-namespace WebCore {
-
-GdkDragAction dragOperationToGdkDragActions(DragOperation coreAction)
-{
- GdkDragAction gdkAction = static_cast<GdkDragAction>(0);
- if (coreAction == DragOperationNone)
- return gdkAction;
-
- if (coreAction & DragOperationCopy)
- gdkAction = static_cast<GdkDragAction>(GDK_ACTION_COPY | gdkAction);
- if (coreAction & DragOperationMove)
- gdkAction = static_cast<GdkDragAction>(GDK_ACTION_MOVE | gdkAction);
- if (coreAction & DragOperationLink)
- gdkAction = static_cast<GdkDragAction>(GDK_ACTION_LINK | gdkAction);
- if (coreAction & DragOperationPrivate)
- gdkAction = static_cast<GdkDragAction>(GDK_ACTION_PRIVATE | gdkAction);
-
- return gdkAction;
-}
-
-GdkDragAction dragOperationToSingleGdkDragAction(DragOperation coreAction)
-{
- if (coreAction == DragOperationEvery || coreAction & DragOperationCopy)
- return GDK_ACTION_COPY;
- if (coreAction & DragOperationMove)
- return GDK_ACTION_MOVE;
- if (coreAction & DragOperationLink)
- return GDK_ACTION_LINK;
- if (coreAction & DragOperationPrivate)
- return GDK_ACTION_PRIVATE;
- return static_cast<GdkDragAction>(0);
-}
-
-DragOperation gdkDragActionToDragOperation(GdkDragAction gdkAction)
-{
- // We have no good way to detect DragOperationEvery other than
- // to use it when all applicable flags are on.
- if (gdkAction & GDK_ACTION_COPY && gdkAction & GDK_ACTION_MOVE
- && gdkAction & GDK_ACTION_LINK && gdkAction & GDK_ACTION_PRIVATE)
- return DragOperationEvery;
-
- unsigned int action = DragOperationNone;
- if (gdkAction & GDK_ACTION_COPY)
- action |= DragOperationCopy;
- if (gdkAction & GDK_ACTION_MOVE)
- action |= DragOperationMove;
- if (gdkAction & GDK_ACTION_LINK)
- action |= DragOperationLink;
- if (gdkAction & GDK_ACTION_PRIVATE)
- action |= DragOperationPrivate;
- return static_cast<DragOperation>(action);
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkClipboardUtilitiesGtkh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.h (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.h        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebCore/platform/gtk/ClipboardUtilitiesGtk.h        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -1,33 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010, Igalia S.L.
- *
- * 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
- */
-
-#ifndef ClipboardUtilitiesGtk_h
-#define ClipboardUtilitiesGtk_h
-
-#include "DragActions.h"
-#include <gdk/gdk.h>
-
-namespace WebCore {
-
-GdkDragAction dragOperationToGdkDragActions(DragOperation);
-GdkDragAction dragOperationToSingleGdkDragAction(DragOperation);
-DragOperation gdkDragActionToDragOperation(GdkDragAction);
-
-}
-
-#endif // ClipboardUtilitiesGtk_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkGtkDragAndDropHelpercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.cpp        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -1,172 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011, Igalia S.L.
- *
- * 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 "GtkDragAndDropHelper.h"
-
-#if ENABLE(DRAG_SUPPORT)
-
-#include "ClipboardUtilitiesGtk.h"
-#include "DragData.h"
-#include "GtkUtilities.h"
-#include "GtkVersioning.h"
-#include "PasteboardHelper.h"
-#include <gtk/gtk.h>
-#include <wtf/gobject/GMainLoopSource.h>
-
-namespace WebCore {
-
-struct DroppingContext {
- DroppingContext(GdkDragContext* gdkContext, const IntPoint& position)
- : gdkContext(gdkContext)
- , dataObject(DataObjectGtk::create())
- , lastMotionPosition(position)
- , dropHappened(false)
- , exitedCallback(0)
- {
- }
-
- GdkDragContext* gdkContext;
- RefPtr<DataObjectGtk> dataObject;
- WebCore::IntPoint lastMotionPosition;
- int pendingDataRequests;
- bool dropHappened;
- DragExitedCallback exitedCallback;
-};
-
-GtkDragAndDropHelper::GtkDragAndDropHelper()
- : m_widget(nullptr)
-{
-}
-
-GtkDragAndDropHelper::~GtkDragAndDropHelper()
-{
-}
-
-bool GtkDragAndDropHelper::handleDragEnd(GdkDragContext* dragContext)
-{
- return m_draggingDataObjects.remove(dragContext);
-}
-
-void GtkDragAndDropHelper::handleGetDragData(GdkDragContext* context, GtkSelectionData* selectionData, guint info)
-{
- DataObjectGtk* dataObject = m_draggingDataObjects.get(context);
- if (!dataObject)
- return;
- PasteboardHelper::defaultPasteboardHelper()->fillSelectionData(selectionData, info, dataObject);
-}
-
-void GtkDragAndDropHelper::handleDragLeaveLater(DroppingContext* context)
-{
- auto iterator = m_droppingContexts.find(context->gdkContext);
- if (iterator == m_droppingContexts.end())
- return;
-
- // If the view doesn't know about the drag yet (there are still pending data)
- // requests, don't update it with information about the drag.
- if (context->pendingDataRequests)
- return;
-
- const IntPoint& position = context->lastMotionPosition;
- DragData dragData(context->dataObject.get(), position,
- convertWidgetPointToScreenPoint(m_widget, position),
- DragOperationNone);
- context->exitedCallback(m_widget, dragData, context->dropHappened);
-
- m_droppingContexts.remove(iterator);
-}
-
-void GtkDragAndDropHelper::handleDragLeave(GdkDragContext* gdkContext, DragExitedCallback exitedCallback)
-{
- DroppingContext* context = m_droppingContexts.get(gdkContext);
- if (!context)
- return;
-
- // During a drop GTK+ will fire a drag-leave signal right before firing
- // the drag-drop signal. We want the actions for drag-leave to happen after
- // those for drag-drop, so schedule them to happen asynchronously here.
- context->exitedCallback = exitedCallback;
- GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] handleDragLeaveLater", std::function<void()>(std::bind(&GtkDragAndDropHelper::handleDragLeaveLater, this, context)));
-}
-
-static void queryNewDropContextData(DroppingContext* dropContext, GtkWidget* widget, guint time)
-{
- GdkDragContext* gdkContext = dropContext->gdkContext;
- Vector<GdkAtom> acceptableTargets(PasteboardHelper::defaultPasteboardHelper()->dropAtomsForContext(widget, gdkContext));
- dropContext->pendingDataRequests = acceptableTargets.size();
- for (size_t i = 0; i < acceptableTargets.size(); i++)
- gtk_drag_get_data(widget, gdkContext, acceptableTargets.at(i), time);
-}
-
-DataObjectGtk* GtkDragAndDropHelper::handleDragMotion(GdkDragContext* context, const IntPoint& position, unsigned time)
-{
- std::unique_ptr<DroppingContext>& droppingContext = m_droppingContexts.add(context, nullptr).iterator->value;
- if (!droppingContext) {
- droppingContext = std::make_unique<DroppingContext>(context, position);
- queryNewDropContextData(droppingContext.get(), m_widget, time);
- } else
- droppingContext->lastMotionPosition = position;
-
- // Don't send any drag information to WebCore until we've retrieved all
- // the data for this drag operation. Otherwise we'd have to block to wait
- // for the drag's data.
- if (droppingContext->pendingDataRequests > 0)
- return nullptr;
-
- return droppingContext->dataObject.get();
-}
-
-DataObjectGtk* GtkDragAndDropHelper::handleDragDataReceived(GdkDragContext* context, GtkSelectionData* selectionData, unsigned info, IntPoint& position)
-{
- DroppingContext* droppingContext = m_droppingContexts.get(context);
- if (!droppingContext)
- return nullptr;
-
- droppingContext->pendingDataRequests--;
- PasteboardHelper::defaultPasteboardHelper()->fillDataObjectFromDropData(selectionData, info, droppingContext->dataObject.get());
-
- if (droppingContext->pendingDataRequests)
- return nullptr;
-
- // The coordinates passed to drag-data-received signal are sometimes
- // inaccurate in DRT, so use the coordinates of the last motion event.
- position = droppingContext->lastMotionPosition;
-
- // If there are no more pending requests, start sending dragging data to WebCore.
- return droppingContext->dataObject.get();
-}
-
-DataObjectGtk* GtkDragAndDropHelper::handleDragDrop(GdkDragContext* context)
-{
- DroppingContext* droppingContext = m_droppingContexts.get(context);
- if (!droppingContext)
- return nullptr;
-
- droppingContext->dropHappened = true;
-
- return droppingContext->dataObject.get();
-}
-
-void GtkDragAndDropHelper::startedDrag(GdkDragContext* context, DataObjectGtk* dataObject)
-{
- m_draggingDataObjects.set(context, dataObject);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(DRAG_SUPPORT)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkGtkDragAndDropHelperh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -1,64 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011, Igalia S.L.
- *
- * 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
- */
-
-#ifndef GtkDragAndDropHelper_h
-#define GtkDragAndDropHelper_h
-
-#if ENABLE(DRAG_SUPPORT)
-
-#include "DataObjectGtk.h"
-#include <wtf/FastMalloc.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-struct DroppingContext;
-class DragData;
-class IntPoint;
-
-typedef void (*DragExitedCallback)(GtkWidget*, DragData&, bool dropHappened);
-
-class GtkDragAndDropHelper {
- WTF_MAKE_NONCOPYABLE(GtkDragAndDropHelper);
- WTF_MAKE_FAST_ALLOCATED;
-
-public:
- GtkDragAndDropHelper();
- ~GtkDragAndDropHelper();
-
- void setWidget(GtkWidget* widget) { m_widget = widget; }
- bool handleDragEnd(GdkDragContext*);
- void handleGetDragData(GdkDragContext*, GtkSelectionData*, guint info);
- void handleDragLeave(GdkDragContext*, DragExitedCallback);
- void handleDragLeaveLater(DroppingContext*);
- DataObjectGtk* handleDragMotion(GdkDragContext*, const IntPoint&, unsigned time);
- DataObjectGtk* handleDragDataReceived(GdkDragContext*, GtkSelectionData*, unsigned info, IntPoint&);
- DataObjectGtk* handleDragDrop(GdkDragContext*);
- void startedDrag(GdkDragContext*, DataObjectGtk*);
-
-private:
- GtkWidget* m_widget;
- HashMap<GdkDragContext*, std::unique_ptr<DroppingContext>> m_droppingContexts;
- HashMap<GdkDragContext*, RefPtr<DataObjectGtk>> m_draggingDataObjects;
-};
-
-}
-
-#endif // ENABLE(DRAG_SUPPORT)
-
-#endif // DataObjectGtk_h
</del></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebKit2/ChangeLog        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2014-10-19 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Move GtkDragAndDropHelper from Platform to WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=137422
+
+ Reviewed by Martin Robinson.
+
+ WebKitWebViewBase is currently the only user of
+ GtkDragAndDropHelper, that was added to share the code with
+ WebKit1. Move all the drag and drop logic to a new class
+ DragAndDropHandler.
+
+ * PlatformGTK.cmake: Add new files to compilation.
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::startDrag):
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseConstructed):
+ (webkitWebViewBaseDragDataGet):
+ (webkitWebViewBaseDragEnd):
+ (webkitWebViewBaseDragDataReceived):
+ (webkitWebViewBaseDragMotion):
+ (webkitWebViewBaseDragLeave):
+ (webkitWebViewBaseDragDrop):
+ (webkitWebViewBaseDragAndDropHandler):
+ (dragExitedCallback): Deleted.
+ (webkitWebViewBaseStartDrag): Deleted.
+ * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+ * UIProcess/gtk/DragAndDropHandler.cpp: Added.
+ (WebKit::DragAndDropHandler::create):
+ (WebKit::DragAndDropHandler::DragAndDropHandler):
+ (WebKit::DragAndDropHandler::DroppingContext::DroppingContext):
+ (WebKit::dragOperationToGdkDragActions):
+ (WebKit::dragOperationToSingleGdkDragAction):
+ (WebKit::gdkDragActionToDragOperation):
+ (WebKit::DragAndDropHandler::startDrag):
+ (WebKit::DragAndDropHandler::fillDragData):
+ (WebKit::DragAndDropHandler::finishDrag):
+ (WebKit::DragAndDropHandler::dataObjectForDropData):
+ (WebKit::DragAndDropHandler::dragEntered):
+ (WebKit::DragAndDropHandler::requestDragData):
+ (WebKit::DragAndDropHandler::dragMotion):
+ (WebKit::DragAndDropHandler::dragLeave):
+ (WebKit::DragAndDropHandler::drop):
+ * UIProcess/gtk/DragAndDropHandler.h: Added.
+
</ins><span class="cx"> 2014-10-18 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> WorkQueue dispatches functions but isn’t a FunctionDispatcher
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -251,6 +251,7 @@
</span><span class="cx">
</span><span class="cx"> UIProcess/cairo/BackingStoreCairo.cpp
</span><span class="cx">
</span><ins>+ UIProcess/gtk/DragAndDropHandler.cpp
</ins><span class="cx"> UIProcess/gtk/ExperimentalFeatures.cpp
</span><span class="cx"> UIProcess/gtk/TextCheckerGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebContextGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -271,7 +271,12 @@
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx"> void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
</span><span class="cx"> {
</span><del>- webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), dragData, dragImage);
</del><ins>+ WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget);
+ webkitWebViewBaseDragAndDropHandler(webView).startDrag(dragData, dragImage);
+
+ // A drag starting should prevent a double-click from happening. This might
+ // happen if a drag is followed very quickly by another click (like in the WTR).
+ webkitWebViewBaseResetClickCounter(webView);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -48,13 +48,8 @@
</span><span class="cx"> #include "WebUserContentControllerProxy.h"
</span><span class="cx"> #include "WebViewBaseInputMethodFilter.h"
</span><span class="cx"> #include <WebCore/CairoUtilities.h>
</span><del>-#include <WebCore/ClipboardUtilitiesGtk.h>
-#include <WebCore/DataObjectGtk.h>
-#include <WebCore/DragData.h>
-#include <WebCore/DragIcon.h>
</del><span class="cx"> #include <WebCore/GUniquePtrGtk.h>
</span><span class="cx"> #include <WebCore/GtkClickCounter.h>
</span><del>-#include <WebCore/GtkDragAndDropHelper.h>
</del><span class="cx"> #include <WebCore/GtkUtilities.h>
</span><span class="cx"> #include <WebCore/GtkVersioning.h>
</span><span class="cx"> #include <WebCore/NotImplemented.h>
</span><span class="lines">@@ -101,10 +96,6 @@
</span><span class="cx"> GtkClickCounter clickCounter;
</span><span class="cx"> CString tooltipText;
</span><span class="cx"> IntRect tooltipArea;
</span><del>-#if ENABLE(DRAG_SUPPORT)
- GtkDragAndDropHelper dragAndDropHelper;
-#endif
- DragIcon dragIcon;
</del><span class="cx"> #if !GTK_CHECK_VERSION(3, 13, 4)
</span><span class="cx"> IntSize resizerSize;
</span><span class="cx"> #endif
</span><span class="lines">@@ -143,6 +134,10 @@
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
</span><span class="cx"> OwnPtr<RedirectedXCompositeWindow> redirectedWindow;
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(DRAG_SUPPORT)
+ std::unique_ptr<DragAndDropHandler> dragAndDropHandler;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> WEBKIT_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
</span><span class="lines">@@ -419,15 +414,12 @@
</span><span class="cx">
</span><span class="cx"> GtkWidget* viewWidget = GTK_WIDGET(object);
</span><span class="cx"> gtk_widget_set_can_focus(viewWidget, TRUE);
</span><del>- gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), 0, 0,
- static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
</del><ins>+ gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), nullptr, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
</ins><span class="cx"> gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::defaultPasteboardHelper()->targetList());
</span><span class="cx">
</span><span class="cx"> WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(object)->priv;
</span><span class="cx"> priv->pageClient = PageClientImpl::create(viewWidget);
</span><del>-#if ENABLE(DRAG_SUPPORT)
- priv->dragAndDropHelper.setWidget(viewWidget);
-#endif
</del><span class="cx">
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
</span><span class="cx"> GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
</span><span class="lines">@@ -847,37 +839,21 @@
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx"> static void webkitWebViewBaseDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint /* time */)
</span><span class="cx"> {
</span><del>- WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info);
</del><ins>+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
+ ASSERT(priv->dragAndDropHandler);
+ priv->dragAndDropHandler->fillDragData(context, selectionData, info);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void webkitWebViewBaseDragEnd(GtkWidget* widget, GdkDragContext* context)
</span><span class="cx"> {
</span><del>- WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
- if (!webViewBase->priv->dragAndDropHelper.handleDragEnd(context))
- return;
-
- GdkDevice* device = gdk_drag_context_get_device(context);
- int x = 0, y = 0;
- gdk_device_get_window_at_position(device, &x, &y);
- int xRoot = 0, yRoot = 0;
- gdk_device_get_position(device, 0, &xRoot, &yRoot);
- webViewBase->priv->pageProxy->dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot),
- gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
</del><ins>+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
+ ASSERT(priv->dragAndDropHandler);
+ priv->dragAndDropHandler->finishDrag(context);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void webkitWebViewBaseDragDataReceived(GtkWidget* widget, GdkDragContext* context, gint /* x */, gint /* y */, GtkSelectionData* selectionData, guint info, guint time)
</span><span class="cx"> {
</span><del>- WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
- IntPoint position;
- DataObjectGtk* dataObject = webViewBase->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info, position);
- if (!dataObject)
- return;
-
- DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
- webViewBase->priv->pageProxy->resetCurrentDragInformation();
- webViewBase->priv->pageProxy->dragEntered(dragData);
- DragOperation operation = webViewBase->priv->pageProxy->currentDragOperation();
- gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
</del><ins>+ webkitWebViewBaseDragAndDropHandler(WEBKIT_WEB_VIEW_BASE(widget)).dragEntered(context, selectionData, info, time);
</ins><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(DRAG_SUPPORT)
</span><span class="cx">
</span><span class="lines">@@ -912,50 +888,22 @@
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx"> static gboolean webkitWebViewBaseDragMotion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
</span><span class="cx"> {
</span><del>- WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
- IntPoint position(x, y);
- DataObjectGtk* dataObject = webViewBase->priv->dragAndDropHelper.handleDragMotion(context, position, time);
- if (!dataObject)
- return TRUE;
-
- DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
- webViewBase->priv->pageProxy->dragUpdated(dragData);
- DragOperation operation = webViewBase->priv->pageProxy->currentDragOperation();
- gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
</del><ins>+ webkitWebViewBaseDragAndDropHandler(WEBKIT_WEB_VIEW_BASE(widget)).dragMotion(context, IntPoint(x, y), time);
</ins><span class="cx"> return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void dragExitedCallback(GtkWidget* widget, DragData& dragData, bool dropHappened)
-{
- // Don't call dragExited if we have just received a drag-drop signal. This
- // happens in the case of a successful drop onto the view.
- if (dropHappened)
- return;
-
- WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
- webViewBase->priv->pageProxy->dragExited(dragData);
- webViewBase->priv->pageProxy->resetCurrentDragInformation();
-}
-
</del><span class="cx"> static void webkitWebViewBaseDragLeave(GtkWidget* widget, GdkDragContext* context, guint /* time */)
</span><span class="cx"> {
</span><del>- WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback);
</del><ins>+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
+ ASSERT(priv->dragAndDropHandler);
+ priv->dragAndDropHandler->dragLeave(context);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
</span><span class="cx"> {
</span><del>- WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
- DataObjectGtk* dataObject = webViewBase->priv->dragAndDropHelper.handleDragDrop(context);
- if (!dataObject)
- return FALSE;
-
- IntPoint position(x, y);
- DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
- SandboxExtension::Handle handle;
- SandboxExtension::HandleArray sandboxExtensionForUpload;
- webViewBase->priv->pageProxy->performDragOperation(dragData, String(), handle, sandboxExtensionForUpload);
- gtk_drag_finish(context, TRUE, FALSE, time);
- return TRUE;
</del><ins>+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
+ ASSERT(priv->dragAndDropHandler);
+ return priv->dragAndDropHandler->drop(context, IntPoint(x, y), time);
</ins><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(DRAG_SUPPORT)
</span><span class="cx">
</span><span class="lines">@@ -1115,31 +1063,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><del>-void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
</del><ins>+DragAndDropHandler& webkitWebViewBaseDragAndDropHandler(WebKitWebViewBase* webViewBase)
</ins><span class="cx"> {
</span><span class="cx"> WebKitWebViewBasePrivate* priv = webViewBase->priv;
</span><del>-
- RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());
- GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
- GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());
- GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(webViewBase),
- targetList.get(),
- dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
- 1, /* button */
- currentEvent.get());
- priv->dragAndDropHelper.startedDrag(context, dataObject.get());
-
-
- // A drag starting should prevent a double-click from happening. This might
- // happen if a drag is followed very quickly by another click (like in the DRT).
- priv->clickCounter.reset();
-
- if (dragImage) {
- RefPtr<cairo_surface_t> image(dragImage->createCairoSurface());
- priv->dragIcon.setImage(image.get());
- priv->dragIcon.useForDrag(context);
- } else
- gtk_drag_set_icon_default(context);
</del><ins>+ if (!priv->dragAndDropHandler)
+ priv->dragAndDropHandler = DragAndDropHandler::create(*priv->pageProxy);
+ return *priv->dragAndDropHandler;
</ins><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(DRAG_SUPPORT)
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (174867 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h        2014-10-19 07:01:55 UTC (rev 174867)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #ifndef WebKitWebViewBasePrivate_h
</span><span class="cx"> #define WebKitWebViewBasePrivate_h
</span><span class="cx">
</span><ins>+#include "DragAndDropHandler.h"
</ins><span class="cx"> #include "WebContextMenuProxyGtk.h"
</span><span class="cx"> #include "WebInspectorProxy.h"
</span><span class="cx"> #include "WebKitPrivate.h"
</span><span class="lines">@@ -41,7 +42,6 @@
</span><span class="cx"> void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
</span><span class="cx"> void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase*, const WebCore::IntRect&);
</span><span class="cx"> void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*);
</span><del>-void webkitWebViewBaseStartDrag(WebKitWebViewBase*, const WebCore::DragData&, PassRefPtr<WebKit::ShareableBitmap> dragImage);
</del><span class="cx"> void webkitWebViewBaseChildMoveResize(WebKitWebViewBase*, GtkWidget*, const WebCore::IntRect&);
</span><span class="cx"> void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase*);
</span><span class="cx"> void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*);
</span><span class="lines">@@ -74,4 +74,8 @@
</span><span class="cx"> void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector, WebKit::AttachmentSide);
</span><span class="cx"> void webkitWebViewBaseResetClickCounter(WebKitWebViewBase*);
</span><span class="cx">
</span><ins>+#if ENABLE(DRAG_SUPPORT)
+WebKit::DragAndDropHandler& webkitWebViewBaseDragAndDropHandler(WebKitWebViewBase*);
+#endif
+
</ins><span class="cx"> #endif // WebKitWebViewBasePrivate_h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkDragAndDropHandlercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp (0 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -0,0 +1,274 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DragAndDropHandler.h"
+
+#if ENABLE(DRAG_SUPPORT)
+
+#include "WebPageProxy.h"
+#include <WebCore/DataObjectGtk.h>
+#include <WebCore/DragData.h>
+#include <WebCore/DragIcon.h>
+#include <WebCore/GRefPtrGtk.h>
+#include <WebCore/GtkUtilities.h>
+#include <WebCore/PasteboardHelper.h>
+#include <gtk/gtk.h>
+#include <wtf/gobject/GMainLoopSource.h>
+#include <wtf/gobject/GUniquePtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+std::unique_ptr<DragAndDropHandler> DragAndDropHandler::create(WebPageProxy& page)
+{
+ return std::unique_ptr<DragAndDropHandler>(new DragAndDropHandler(page));
+}
+
+DragAndDropHandler::DragAndDropHandler(WebPageProxy& page)
+ : m_page(page)
+{
+}
+
+DragAndDropHandler::DroppingContext::DroppingContext(GdkDragContext* gdkContext, const IntPoint& position)
+ : gdkContext(gdkContext)
+ , dataObject(DataObjectGtk::create())
+ , lastMotionPosition(position)
+ , dropHappened(false)
+{
+}
+
+static inline GdkDragAction dragOperationToGdkDragActions(DragOperation coreAction)
+{
+ GdkDragAction gdkAction = static_cast<GdkDragAction>(0);
+ if (coreAction == DragOperationNone)
+ return gdkAction;
+
+ if (coreAction & DragOperationCopy)
+ gdkAction = static_cast<GdkDragAction>(GDK_ACTION_COPY | gdkAction);
+ if (coreAction & DragOperationMove)
+ gdkAction = static_cast<GdkDragAction>(GDK_ACTION_MOVE | gdkAction);
+ if (coreAction & DragOperationLink)
+ gdkAction = static_cast<GdkDragAction>(GDK_ACTION_LINK | gdkAction);
+ if (coreAction & DragOperationPrivate)
+ gdkAction = static_cast<GdkDragAction>(GDK_ACTION_PRIVATE | gdkAction);
+
+ return gdkAction;
+}
+
+static inline GdkDragAction dragOperationToSingleGdkDragAction(DragOperation coreAction)
+{
+ if (coreAction == DragOperationEvery || coreAction & DragOperationCopy)
+ return GDK_ACTION_COPY;
+ if (coreAction & DragOperationMove)
+ return GDK_ACTION_MOVE;
+ if (coreAction & DragOperationLink)
+ return GDK_ACTION_LINK;
+ if (coreAction & DragOperationPrivate)
+ return GDK_ACTION_PRIVATE;
+ return static_cast<GdkDragAction>(0);
+}
+
+static inline DragOperation gdkDragActionToDragOperation(GdkDragAction gdkAction)
+{
+ // We have no good way to detect DragOperationEvery other than
+ // to use it when all applicable flags are on.
+ if (gdkAction & GDK_ACTION_COPY
+ && gdkAction & GDK_ACTION_MOVE
+ && gdkAction & GDK_ACTION_LINK
+ && gdkAction & GDK_ACTION_PRIVATE)
+ return DragOperationEvery;
+
+ unsigned action = DragOperationNone;
+ if (gdkAction & GDK_ACTION_COPY)
+ action |= DragOperationCopy;
+ if (gdkAction & GDK_ACTION_MOVE)
+ action |= DragOperationMove;
+ if (gdkAction & GDK_ACTION_LINK)
+ action |= DragOperationLink;
+ if (gdkAction & GDK_ACTION_PRIVATE)
+ action |= DragOperationPrivate;
+ return static_cast<DragOperation>(action);
+}
+
+void DragAndDropHandler::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+ RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());
+ GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
+ GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());
+
+ GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
+ GDK_BUTTON_PRIMARY, currentEvent.get());
+ m_draggingDataObjects.set(context, dataObject.get());
+
+ if (dragImage) {
+ RefPtr<cairo_surface_t> image(dragImage->createCairoSurface());
+ m_dragIcon.setImage(image.get());
+ m_dragIcon.useForDrag(context);
+ } else
+ gtk_drag_set_icon_default(context);
+}
+
+void DragAndDropHandler::fillDragData(GdkDragContext* context, GtkSelectionData* selectionData, unsigned info)
+{
+ if (DataObjectGtk* dataObject = m_draggingDataObjects.get(context))
+ PasteboardHelper::defaultPasteboardHelper()->fillSelectionData(selectionData, info, dataObject);
+}
+
+void DragAndDropHandler::finishDrag(GdkDragContext* context)
+{
+ if (!m_draggingDataObjects.remove(context))
+ return;
+
+ GdkDevice* device = gdk_drag_context_get_device(context);
+ int x = 0, y = 0;
+ gdk_device_get_window_at_position(device, &x, &y);
+ int xRoot = 0, yRoot = 0;
+ gdk_device_get_position(device, nullptr, &xRoot, &yRoot);
+ m_page.dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
+}
+
+DataObjectGtk* DragAndDropHandler::dataObjectForDropData(GdkDragContext* context, GtkSelectionData* selectionData, unsigned info, IntPoint& position)
+{
+ DroppingContext* droppingContext = m_droppingContexts.get(context);
+ if (!droppingContext)
+ return nullptr;
+
+ droppingContext->pendingDataRequests--;
+ PasteboardHelper::defaultPasteboardHelper()->fillDataObjectFromDropData(selectionData, info, droppingContext->dataObject.get());
+ if (droppingContext->pendingDataRequests)
+ return nullptr;
+
+ // The coordinates passed to drag-data-received signal are sometimes
+ // inaccurate in WTR, so use the coordinates of the last motion event.
+ position = droppingContext->lastMotionPosition;
+
+ // If there are no more pending requests, start sending dragging data to WebCore.
+ return droppingContext->dataObject.get();
+}
+
+void DragAndDropHandler::dragEntered(GdkDragContext* context, GtkSelectionData* selectionData, unsigned info, unsigned time)
+{
+ IntPoint position;
+ DataObjectGtk* dataObject = dataObjectForDropData(context, selectionData, info, position);
+ if (!dataObject)
+ return;
+
+ DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
+ m_page.resetCurrentDragInformation();
+ m_page.dragEntered(dragData);
+ DragOperation operation = m_page.currentDragOperation();
+ gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
+}
+
+DataObjectGtk* DragAndDropHandler::requestDragData(GdkDragContext* context, const IntPoint& position, unsigned time)
+{
+ std::unique_ptr<DroppingContext>& droppingContext = m_droppingContexts.add(context, nullptr).iterator->value;
+ if (!droppingContext) {
+ GtkWidget* widget = m_page.viewWidget();
+ droppingContext = std::make_unique<DroppingContext>(context, position);
+ Vector<GdkAtom> acceptableTargets(PasteboardHelper::defaultPasteboardHelper()->dropAtomsForContext(widget, droppingContext->gdkContext));
+ droppingContext->pendingDataRequests = acceptableTargets.size();
+ for (auto& target : acceptableTargets)
+ gtk_drag_get_data(widget, droppingContext->gdkContext, target, time);
+ } else
+ droppingContext->lastMotionPosition = position;
+
+ // Don't send any drag information to WebCore until we've retrieved all the data for this drag operation.
+ // Otherwise we'd have to block to wait for the drag's data.
+ if (droppingContext->pendingDataRequests > 0)
+ return nullptr;
+
+ return droppingContext->dataObject.get();
+}
+
+void DragAndDropHandler::dragMotion(GdkDragContext* context, const IntPoint& position, unsigned time)
+{
+ DataObjectGtk* dataObject = requestDragData(context, position, time);
+ if (!dataObject)
+ return;
+
+ DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
+ m_page.dragUpdated(dragData);
+ DragOperation operation = m_page.currentDragOperation();
+ gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
+}
+
+void DragAndDropHandler::dragLeave(GdkDragContext* context)
+{
+ DroppingContext* droppingContext = m_droppingContexts.get(context);
+ if (!droppingContext)
+ return;
+
+ // During a drop GTK+ will fire a drag-leave signal right before firing
+ // the drag-drop signal. We want the actions for drag-leave to happen after
+ // those for drag-drop, so schedule them to happen asynchronously here.
+ GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] handleDragLeaveLater", [this, droppingContext]() {
+ auto it = m_droppingContexts.find(droppingContext->gdkContext);
+ if (it == m_droppingContexts.end())
+ return;
+
+ // If the view doesn't know about the drag yet (there are still pending data requests),
+ // don't update it with information about the drag.
+ if (droppingContext->pendingDataRequests)
+ return;
+
+ if (!droppingContext->dropHappened) {
+ // Don't call dragExited if we have just received a drag-drop signal. This
+ // happens in the case of a successful drop onto the view.
+ const IntPoint& position = droppingContext->lastMotionPosition;
+ DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), DragOperationNone);
+ m_page.dragExited(dragData);
+ m_page.resetCurrentDragInformation();
+ }
+
+ m_droppingContexts.remove(it);
+ });
+}
+
+bool DragAndDropHandler::drop(GdkDragContext* context, const IntPoint& position, unsigned time)
+{
+ DroppingContext* droppingContext = m_droppingContexts.get(context);
+ if (!droppingContext)
+ return false;
+
+ droppingContext->dropHappened = true;
+
+ DataObjectGtk* dataObject = droppingContext->dataObject.get();
+ if (!dataObject)
+ return false;
+
+ DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
+ SandboxExtension::Handle handle;
+ SandboxExtension::HandleArray sandboxExtensionForUpload;
+ m_page.performDragOperation(dragData, String(), handle, sandboxExtensionForUpload);
+ gtk_drag_finish(context, TRUE, FALSE, time);
+ return true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(DRAG_SUPPORT)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkDragAndDropHandlerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h (0 => 174868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h        2014-10-19 07:33:19 UTC (rev 174868)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DragAndDropHandler_h
+#define DragAndDropHandler_h
+
+#if ENABLE(DRAG_SUPPORT)
+
+#include <WebCore/DataObjectGtk.h>
+#include <WebCore/DragIcon.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+
+typedef struct _GdkDragContext GdkDragContext;
+typedef struct _GtkSelectionData GtkSelectionData;
+
+namespace WebCore {
+class DragData;
+class IntPoint;
+}
+
+namespace WebKit {
+
+class ShareableBitmap;
+class WebPageProxy;
+
+class DragAndDropHandler {
+ WTF_MAKE_NONCOPYABLE(DragAndDropHandler);
+public:
+ static std::unique_ptr<DragAndDropHandler> create(WebPageProxy&);
+
+ void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+ void fillDragData(GdkDragContext*, GtkSelectionData*, unsigned info);
+ void finishDrag(GdkDragContext*);
+
+ void dragEntered(GdkDragContext*, GtkSelectionData*, unsigned info, unsigned time);
+ void dragMotion(GdkDragContext*, const WebCore::IntPoint& position, unsigned time);
+ void dragLeave(GdkDragContext*);
+ bool drop(GdkDragContext*, const WebCore::IntPoint& position, unsigned time);
+
+private:
+ struct DroppingContext {
+ DroppingContext(GdkDragContext*, const WebCore::IntPoint& position);
+
+ GdkDragContext* gdkContext;
+ RefPtr<WebCore::DataObjectGtk> dataObject;
+ WebCore::IntPoint lastMotionPosition;
+ unsigned pendingDataRequests;
+ bool dropHappened;
+ };
+
+ DragAndDropHandler(WebPageProxy&);
+
+ WebCore::DataObjectGtk* dataObjectForDropData(GdkDragContext*, GtkSelectionData*, unsigned info, WebCore::IntPoint& position);
+ WebCore::DataObjectGtk* requestDragData(GdkDragContext*, const WebCore::IntPoint& position, unsigned time);
+
+ WebPageProxy& m_page;
+ WebCore::DragIcon m_dragIcon;
+ HashMap<GdkDragContext*, std::unique_ptr<DroppingContext>> m_droppingContexts;
+ HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk>> m_draggingDataObjects;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(DRAG_SUPPORT)
+
+#endif // DragAndDropHandler_h
</ins></span></pre>
</div>
</div>
</body>
</html>