Changeset 63058 in webkit


Ignore:
Timestamp:
Jul 11, 2010 10:37:25 AM (14 years ago)
Author:
Martin Robinson
Message:

2010-07-11 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] WebKitWebView should support drops
https://bugs.webkit.org/show_bug.cgi?id=39843

Add support for dropping content onto GTK+ WebViews.

No new tests, as the DRT does not support simulating drops yet.

  • platform/gtk/ClipboardUtilitiesGtk.cpp: (WebCore::dragOperationToGdkDragAction): Added. (WebCore::gdkDragActionToDragOperation): Properly detect DragOperationEvery.
  • platform/gtk/ClipboardUtilitiesGtk.h: Add declaration for dragOperationToGdkDragAction.
  • platform/gtk/PasteboardHelper.cpp: Add new target atom and rename the markup target type to match the others. Add a method which fills a data object from drop data. (WebCore::PasteboardHelper::initializeTargetList): Add support for new atoms. (WebCore::selectionDataToUTF8String): Added this helper. (WebCore::PasteboardHelper::getClipboardContents): Use the selectionDataToUTF8String helper. (WebCore::PasteboardHelper::targetListForDataObject): Change to reflect markup atom rename. (WebCore::PasteboardHelper::fillDataObjectFromDropData): Added. (WebCore::PasteboardHelper::dropAtoms): Added.
  • platform/gtk/PasteboardHelper.h: Add declarations of new methods.

2010-07-11 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] WebKitWebView should support drops
https://bugs.webkit.org/show_bug.cgi?id=39843

Add support for dropping content onto GTK+ WebViews.

  • webkit/webkitprivate.h: Add a DroppingContext struct to keep track of drop data while the drop is in progress. Have WebKitWebView keep a map of GdkDragContexts to DroppingContexts.
  • webkit/webkitwebview.cpp: Add necessary includes and globalPointForClientPoint helper. (webkit_web_view_popup_menu_handler): Use globalPointForClientPoint helper. (webkit_web_view_dispose): Properly clean up droppingContexts member. (webkit_web_view_finalize): Delete droppingContext member. (globalPointForClientPoint): Added. (doDragLeaveLater): Added. (webkit_web_view_drag_leave): Added. (webkit_web_view_drag_motion): Added. (webkit_web_view_drag_data_received): Added. (webkit_web_view_drag_drop): Added. (webkit_web_view_class_init): Connect new drop signal handlers to the widget definition. (webkit_web_view_init): Set up the widget as a drop destination and initialize droppingContexts.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r63057 r63058  
     12010-07-11  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] WebKitWebView should support drops
     6        https://bugs.webkit.org/show_bug.cgi?id=39843
     7
     8        Add support for dropping content onto GTK+ WebViews.
     9
     10        No new tests, as the DRT does not support simulating drops yet.
     11
     12        * platform/gtk/ClipboardUtilitiesGtk.cpp:
     13        (WebCore::dragOperationToGdkDragAction): Added.
     14        (WebCore::gdkDragActionToDragOperation): Properly detect DragOperationEvery.
     15        * platform/gtk/ClipboardUtilitiesGtk.h: Add declaration for dragOperationToGdkDragAction.
     16        * platform/gtk/PasteboardHelper.cpp:
     17        Add new target atom and rename the markup target type to match the others.
     18        Add a method which fills a data object from drop data.
     19        (WebCore::PasteboardHelper::initializeTargetList): Add support for new atoms.
     20        (WebCore::selectionDataToUTF8String): Added this helper.
     21        (WebCore::PasteboardHelper::getClipboardContents): Use the selectionDataToUTF8String helper.
     22        (WebCore::PasteboardHelper::targetListForDataObject): Change to reflect markup atom rename.
     23        (WebCore::PasteboardHelper::fillDataObjectFromDropData): Added.
     24        (WebCore::PasteboardHelper::dropAtoms): Added.
     25        * platform/gtk/PasteboardHelper.h: Add declarations of new methods.
     26
    1272010-07-10  Darin Adler  <darin@apple.com>
    228
  • trunk/WebCore/platform/gtk/ClipboardUtilitiesGtk.cpp

    r60010 r63058  
    4040}
    4141
     42GdkDragAction dragOperationToSingleGdkDragAction(DragOperation coreAction)
     43{
     44    if (coreAction == DragOperationEvery || coreAction & DragOperationCopy)
     45        return GDK_ACTION_COPY;
     46    if (coreAction & DragOperationMove)
     47        return GDK_ACTION_MOVE;
     48    if (coreAction & DragOperationLink)
     49        return GDK_ACTION_LINK;
     50    if (coreAction & DragOperationPrivate)
     51        return GDK_ACTION_PRIVATE;
     52    return static_cast<GdkDragAction>(0);
     53}
     54
    4255DragOperation gdkDragActionToDragOperation(GdkDragAction gdkAction)
    4356{
     57    // We have no good way to detect DragOperationEvery other than
     58    // to use it when all applicable flags are on.
     59    if (gdkAction & GDK_ACTION_COPY && gdkAction & GDK_ACTION_MOVE
     60        && gdkAction & GDK_ACTION_LINK && gdkAction & GDK_ACTION_PRIVATE)
     61        return DragOperationEvery;
     62
    4463    unsigned int action = DragOperationNone;
    4564    if (gdkAction & GDK_ACTION_COPY)
  • trunk/WebCore/platform/gtk/ClipboardUtilitiesGtk.h

    r60010 r63058  
    2626
    2727GdkDragAction dragOperationToGdkDragActions(DragOperation);
     28GdkDragAction dragOperationToSingleGdkDragAction(DragOperation);
    2829DragOperation gdkDragActionToDragOperation(GdkDragAction);
    2930
  • trunk/WebCore/platform/gtk/PasteboardHelper.cpp

    r61881 r63058  
    3535namespace WebCore {
    3636
    37 static GdkAtom gdkMarkupAtom = gdk_atom_intern("text/html", FALSE);
     37static GdkAtom textPlainAtom = gdk_atom_intern("text/plain;charset=utf-8", FALSE);
     38static GdkAtom markupAtom = gdk_atom_intern("text/html", FALSE);
    3839static GdkAtom netscapeURLAtom = gdk_atom_intern("_NETSCAPE_URL", FALSE);
    3940static GdkAtom uriListAtom = gdk_atom_intern("text/uri-list", FALSE);
     
    4950}
    5051
    51 
    5252void PasteboardHelper::initializeTargetList()
    5353{
    5454    gtk_target_list_add_text_targets(m_targetList, getIdForTargetType(TargetTypeText));
    55     gtk_target_list_add(m_targetList, gdkMarkupAtom, 0, getIdForTargetType(TargetTypeMarkup));
     55    gtk_target_list_add(m_targetList, markupAtom, 0, getIdForTargetType(TargetTypeMarkup));
    5656    gtk_target_list_add_uri_targets(m_targetList, getIdForTargetType(TargetTypeURIList));
    5757    gtk_target_list_add(m_targetList, netscapeURLAtom, 0, getIdForTargetType(TargetTypeNetscapeURL));
     58    gtk_target_list_add_image_targets(m_targetList, getIdForTargetType(TargetTypeImage), TRUE);
    5859}
    5960
     
    103104}
    104105
     106static String selectionDataToUTF8String(GtkSelectionData* data)
     107{
     108    // g_strndup guards against selection data that is not null-terminated.
     109    GOwnPtr<gchar> markupString(g_strndup(reinterpret_cast<const char*>(gtk_selection_data_get_data(data)), gtk_selection_data_get_length(data)));
     110    return String::fromUTF8(markupString.get());
     111}
     112
    105113void PasteboardHelper::getClipboardContents(GtkClipboard* clipboard)
    106114{
     
    114122    }
    115123
    116     if (gtk_clipboard_wait_is_target_available(clipboard, gdkMarkupAtom)) {
    117         if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, gdkMarkupAtom)) {
    118             // g_strndup guards against selection data that is not null-terminated.
    119             GOwnPtr<gchar> markupString(g_strndup(reinterpret_cast<const char*>(gtk_selection_data_get_data(data)), gtk_selection_data_get_length(data)));
    120             dataObject->setMarkup(String::fromUTF8(markupString.get()));
     124    if (gtk_clipboard_wait_is_target_available(clipboard, markupAtom)) {
     125        if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, markupAtom)) {
     126            dataObject->setMarkup(selectionDataToUTF8String(data));
    121127            gtk_selection_data_free(data);
    122128        }
     
    142148    else if (info == getIdForTargetType(TargetTypeMarkup)) {
    143149        GOwnPtr<gchar> markup(g_strdup(dataObject->markup().utf8().data()));
    144         gtk_selection_data_set(selectionData, gdkMarkupAtom, 8,
     150        gtk_selection_data_set(selectionData, markupAtom, 8,
    145151            reinterpret_cast<const guchar*>(markup.get()), strlen(markup.get()) + 1);
    146152
     
    180186
    181187    if (dataObject->hasMarkup())
    182         gtk_target_list_add(list, gdkMarkupAtom, 0, getIdForTargetType(TargetTypeMarkup));
     188        gtk_target_list_add(list, markupAtom, 0, getIdForTargetType(TargetTypeMarkup));
    183189
    184190    if (dataObject->hasURIList()) {
     
    191197
    192198    return list;
     199}
     200
     201void PasteboardHelper::fillDataObjectFromDropData(GtkSelectionData* data, guint info, DataObjectGtk* dataObject)
     202{
     203    if (!data->data)
     204        return;
     205
     206    if (data->target == textPlainAtom)
     207        dataObject->setText(selectionDataToUTF8String(data));
     208    else if (data->target == markupAtom)
     209        dataObject->setMarkup(selectionDataToUTF8String(data));
     210    else if (data->target == uriListAtom) {
     211        gchar** uris = gtk_selection_data_get_uris(data);
     212        if (!uris)
     213            return;
     214
     215        Vector<KURL> uriList(urisToKURLVector(uris));
     216        dataObject->setURIList(uriList);
     217        g_strfreev(uris);
     218    } else if (data->target == netscapeURLAtom) {
     219        String urlWithLabel(selectionDataToUTF8String(data));
     220
     221        Vector<String> pieces;
     222        urlWithLabel.split("\n", pieces);
     223
     224        // Give preference to text/uri-list here, as it can hold more
     225        // than one URI but still take  the label if there is one.
     226        if (!dataObject->hasURL()) {
     227            Vector<KURL> uriList;
     228            uriList.append(KURL(KURL(), pieces[0]));
     229            dataObject->setURIList(uriList);
     230        }
     231
     232        if (pieces.size() > 1)
     233            dataObject->setText(pieces[1]);
     234    }
     235}
     236
     237Vector<GdkAtom> PasteboardHelper::dropAtomsForContext(GtkWidget* widget, GdkDragContext* context)
     238{
     239    // Always search for these common atoms.
     240    Vector<GdkAtom> dropAtoms;
     241    dropAtoms.append(textPlainAtom);
     242    dropAtoms.append(markupAtom);
     243    dropAtoms.append(uriListAtom);
     244    dropAtoms.append(netscapeURLAtom);
     245
     246    // For images, try to find the most applicable image type.
     247    GRefPtr<GtkTargetList> list(gtk_target_list_new(0, 0));
     248    gtk_target_list_add_image_targets(list.get(), getIdForTargetType(TargetTypeImage), TRUE);
     249    GdkAtom atom = gtk_drag_dest_find_target(widget, context, list.get());
     250    if (atom != GDK_NONE)
     251        dropAtoms.append(atom);
     252
     253    return dropAtoms;
    193254}
    194255
  • trunk/WebCore/platform/gtk/PasteboardHelper.h

    r58885 r63058  
    3737typedef struct _GtkWidget GtkWidget;
    3838typedef struct _GtkSelectionData GtkSelectionData;
     39typedef struct _GdkDragContext GdkDragContext;
     40typedef struct _GdkAtom* GdkAtom;
    3941
    4042namespace WebCore {
     
    5355    GtkTargetList* targetListForDataObject(DataObjectGtk*);
    5456    void fillSelectionData(GtkSelectionData*, guint, DataObjectGtk*);
     57    void fillDataObjectFromDropData(GtkSelectionData*, guint, DataObjectGtk*);
     58    Vector<GdkAtom> dropAtomsForContext(GtkWidget*, GdkDragContext*);
    5559    void writeClipboardContents(GtkClipboard*, GClosure* closure = 0);
    5660    void getClipboardContents(GtkClipboard*);
  • trunk/WebKit/gtk/ChangeLog

    r62676 r63058  
     12010-07-11  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] WebKitWebView should support drops
     6        https://bugs.webkit.org/show_bug.cgi?id=39843
     7
     8        Add support for dropping content onto GTK+ WebViews.
     9
     10        * webkit/webkitprivate.h:
     11        Add a DroppingContext struct to keep track of drop data while the drop is
     12        in progress. Have WebKitWebView keep a map of GdkDragContexts to DroppingContexts.
     13        * webkit/webkitwebview.cpp: Add necessary includes and globalPointForClientPoint helper.
     14        (webkit_web_view_popup_menu_handler): Use globalPointForClientPoint helper.
     15        (webkit_web_view_dispose): Properly clean up droppingContexts member.
     16        (webkit_web_view_finalize): Delete droppingContext member.
     17        (globalPointForClientPoint): Added.
     18        (doDragLeaveLater): Added.
     19        (webkit_web_view_drag_leave): Added.
     20        (webkit_web_view_drag_motion): Added.
     21        (webkit_web_view_drag_data_received): Added.
     22        (webkit_web_view_drag_drop): Added.
     23        (webkit_web_view_class_init): Connect new drop signal handlers to the widget definition.
     24        (webkit_web_view_init): Set up the widget as a drop destination and initialize droppingContexts.
     25
    1262010-07-07  Sam Weinig  <sam@webkit.org>
    227
  • trunk/WebKit/gtk/webkit/webkitprivate.h

    r62262 r63058  
    4949#include "BackForwardList.h"
    5050#include "DataObjectGtk.h"
    51 #include <enchant.h>
     51#include "DragActions.h"
     52#include "Frame.h"
    5253#include "GOwnPtr.h"
    5354#include "Geolocation.h"
    5455#include "HistoryItem.h"
    55 #include "Settings.h"
    56 #include "Page.h"
    57 #include "Frame.h"
    5856#include "InspectorClientGtk.h"
    5957#include "IntPoint.h"
    6058#include "FrameLoaderClient.h"
     59#include "Page.h"
    6160#include "ResourceHandle.h"
    6261#include "ResourceRequest.h"
     
    6463#include "WindowFeatures.h"
    6564#include "SecurityOrigin.h"
     65#include "Settings.h"
     66#include <enchant.h>
     67#include <wtf/OwnPtr.h>
    6668#include <wtf/text/CString.h>
    6769
     
    104106    WebKitHitTestResult* kit(const WebCore::HitTestResult&);
    105107
    106     WebKit::PasteboardHelperGtk* pasteboardHelperInstance();
     108    PasteboardHelperGtk* pasteboardHelperInstance();
     109
     110    typedef struct DroppingContext_ {
     111        WebKitWebView* webView;
     112        GdkDragContext* gdkContext;
     113        RefPtr<WebCore::DataObjectGtk> dataObject;
     114        WebCore::IntPoint lastMotionPosition;
     115        int pendingDataRequests;
     116        bool dropHappened;
     117    } DroppingContext;
    107118}
    108119
     
    160171
    161172        HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> >* draggingDataObjects;
     173        HashMap<GdkDragContext*, WebKit::DroppingContext*>* droppingContexts;
    162174    };
    163175
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r62676 r63058  
    88 *  Copyright (C) 2008 Nuanti Ltd.
    99 *  Copyright (C) 2008, 2009, 2010 Collabora Ltd.
    10  *  Copyright (C) 2009 Igalia S.L.
     10 *  Copyright (C) 2009, 2010 Igalia S.L.
    1111 *  Copyright (C) 2009 Movial Creative Technologies Inc.
    1212 *  Copyright (C) 2009 Bobby Powers
     
    5353#include "Document.h"
    5454#include "DocumentLoader.h"
     55#include "DragActions.h"
    5556#include "DragClientGtk.h"
     57#include "DragController.h"
     58#include "DragData.h"
    5659#include "EditorClientGtk.h"
    5760#include "Editor.h"
     
    124127static const double defaultDPI = 96.0;
    125128static WebKitCacheModel cacheModel;
     129static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint);
    126130
    127131using namespace WebKit;
     
    371375    }
    372376
    373     int x, y;
    374     gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient())), &x, &y);
    375 
    376377    // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element.
    377378    // Ideally we'd have the position of a context menu event be separate from its target node.
     
    385386    else if (location.x() > view->width())
    386387        location.setX(view->width() - contextMenuMargin);
    387     IntPoint global = location + IntSize(x, y);
     388    IntPoint global(globalPointForClientPoint(gtk_widget_get_window(widget), location));
    388389
    389390    PlatformMouseEvent event(location, global, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
     
    11981199
    11991200    priv->draggingDataObjects->clear();
     1201    HashMap<GdkDragContext*, DroppingContext*>::iterator endDroppingContexts = priv->droppingContexts->end();
     1202    for (HashMap<GdkDragContext*, DroppingContext*>::iterator iter = priv->droppingContexts->begin(); iter != endDroppingContexts; ++iter)
     1203        delete (iter->second);
     1204    priv->droppingContexts->clear();
    12001205
    12011206    G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
     
    12151220    delete priv->previousClickPoint;
    12161221    delete priv->draggingDataObjects;
     1222    delete priv->droppingContexts;
    12171223
    12181224    G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
     
    13101316}
    13111317
     1318static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint)
     1319{
     1320    int x, y;
     1321    gdk_window_get_origin(window, &x, &y);
     1322    return clientPoint + IntSize(x, y);
     1323}
     1324
     1325
    13121326static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
    13131327{
     
    13591373
    13601374    pasteboardHelperInstance()->fillSelectionData(selectionData, info, priv->draggingDataObjects->get(context).get());
     1375}
     1376
     1377static gboolean doDragLeaveLater(DroppingContext* context)
     1378{
     1379    WebKitWebView* webView = context->webView;
     1380    WebKitWebViewPrivate* priv = webView->priv;
     1381
     1382    if (!priv->droppingContexts->contains(context->gdkContext))
     1383        return FALSE;
     1384
     1385    // If the view doesn't know about the drag yet (there are still pending data)
     1386    // requests, don't update it with information about the drag.
     1387    if (context->pendingDataRequests)
     1388        return FALSE;
     1389
     1390    // Don't call dragExited if we have just received a drag-drop signal. This
     1391    // happens in the case of a successful drop onto the view.
     1392    if (!context->dropHappened) {
     1393        const IntPoint& position = context->lastMotionPosition;
     1394        DragData dragData(context->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(GTK_WIDGET(webView)), position), DragOperationNone);
     1395        core(webView)->dragController()->dragExited(&dragData);
     1396    }
     1397
     1398    core(webView)->dragController()->dragEnded();
     1399    priv->droppingContexts->remove(context->gdkContext);
     1400    delete context;
     1401    return FALSE;
     1402}
     1403
     1404static void webkit_web_view_drag_leave(GtkWidget* widget, GdkDragContext* context, guint time)
     1405{
     1406    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
     1407    WebKitWebViewPrivate* priv = webView->priv;
     1408
     1409    if (!priv->droppingContexts->contains(context))
     1410        return;
     1411
     1412    // During a drop GTK+ will fire a drag-leave signal right before firing
     1413    // the drag-drop signal. We want the actions for drag-leave to happen after
     1414    // those for drag-drop, so schedule them to happen asynchronously here.
     1415    g_timeout_add(0, reinterpret_cast<GSourceFunc>(doDragLeaveLater), priv->droppingContexts->get(context));
     1416}
     1417
     1418static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
     1419{
     1420    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
     1421    WebKitWebViewPrivate* priv = webView->priv;
     1422
     1423    DroppingContext* droppingContext = 0;
     1424    IntPoint position = IntPoint(x, y);
     1425    if (!priv->droppingContexts->contains(context)) {
     1426        droppingContext = new DroppingContext;
     1427        droppingContext->webView = webView;
     1428        droppingContext->gdkContext = context;
     1429        droppingContext->dataObject = WebCore::DataObjectGtk::create();
     1430        droppingContext->dropHappened = false;
     1431        droppingContext->lastMotionPosition = position;
     1432        priv->droppingContexts->set(context, droppingContext);
     1433
     1434        Vector<GdkAtom> acceptableTargets(pasteboardHelperInstance()->dropAtomsForContext(widget, context));
     1435        droppingContext->pendingDataRequests = acceptableTargets.size();
     1436        for (size_t i = 0; i < acceptableTargets.size(); i++)
     1437            gtk_drag_get_data(widget, context, acceptableTargets.at(i), time);
     1438    } else {
     1439        droppingContext = priv->droppingContexts->get(context);
     1440        droppingContext->lastMotionPosition = position;
     1441    }
     1442
     1443    // Don't send any drag information to WebCore until we've retrieved all
     1444    // the data for this drag operation. Otherwise we'd have to block to wait
     1445    // for the drag's data.
     1446    ASSERT(droppingContext);
     1447    if (droppingContext->pendingDataRequests > 0)
     1448        return TRUE;
     1449
     1450    DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(context->actions));
     1451    DragOperation operation = core(webView)->dragController()->dragUpdated(&dragData);
     1452    gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
     1453
     1454    return TRUE;
     1455}
     1456
     1457static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time)
     1458{
     1459    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
     1460    WebKitWebViewPrivate* priv = webView->priv;
     1461
     1462    if (!priv->droppingContexts->contains(context))
     1463        return;
     1464
     1465    DroppingContext* droppingContext = priv->droppingContexts->get(context);
     1466    droppingContext->pendingDataRequests--;
     1467    pasteboardHelperInstance()->fillDataObjectFromDropData(selectionData, info, droppingContext->dataObject.get());
     1468
     1469    if (droppingContext->pendingDataRequests)
     1470        return;
     1471
     1472    // The coordinates passed to drag-data-received signal are sometimes
     1473    // inaccurate in DRT, so use the coordinates of the last motion event.
     1474    const IntPoint& position = droppingContext->lastMotionPosition;
     1475
     1476    // If there are no more pending requests, start sending dragging data to WebCore.
     1477    DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(context->actions));
     1478    DragOperation operation = core(webView)->dragController()->dragEntered(&dragData);
     1479    gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
     1480}
     1481
     1482static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
     1483{
     1484    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
     1485    WebKitWebViewPrivate* priv = webView->priv;
     1486
     1487    if (!priv->droppingContexts->contains(context))
     1488        return FALSE;
     1489
     1490    DroppingContext* droppingContext = priv->droppingContexts->get(context);
     1491    droppingContext->dropHappened = true;
     1492
     1493    IntPoint position(x, y);
     1494    DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(context->actions));
     1495    core(webView)->dragController()->performDrag(&dragData);
     1496
     1497    gtk_drag_finish(context, TRUE, FALSE, time);
     1498    return TRUE;
    13611499}
    13621500
     
    23572495    widgetClass->drag_end = webkit_web_view_drag_end;
    23582496    widgetClass->drag_data_get = webkit_web_view_drag_data_get;
     2497    widgetClass->drag_motion = webkit_web_view_drag_motion;
     2498    widgetClass->drag_leave = webkit_web_view_drag_leave;
     2499    widgetClass->drag_drop = webkit_web_view_drag_drop;
     2500    widgetClass->drag_data_received = webkit_web_view_drag_data_received;
    23592501#if GTK_CHECK_VERSION(2, 12, 0)
    23602502    widgetClass->query_tooltip = webkit_web_view_query_tooltip;
     
    29383080
    29393081    priv->draggingDataObjects = new HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> >();
     3082    priv->droppingContexts = new HashMap<GdkDragContext*, DroppingContext*>();
     3083    gtk_drag_dest_set(GTK_WIDGET(webView), static_cast<GtkDestDefaults>(0), 0, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
     3084    gtk_drag_dest_set_target_list(GTK_WIDGET(webView), pasteboardHelperInstance()->targetList());
    29403085}
    29413086
Note: See TracChangeset for help on using the changeset viewer.