Changeset 195811 in webkit


Ignore:
Timestamp:
Jan 29, 2016 8:26:23 AM (8 years ago)
Author:
mario@webkit.org
Message:

[GTK] WebProcess crashes when quickly attempting many DnD operations
https://bugs.webkit.org/show_bug.cgi?id=138468

Reviewed by Michael Catanzaro.

Guard all the new DnD-related code under GTK_CHECK_VERSION #if's to
make sure we don't bump the required version of GTK+ up to 3.16, and
it's buildable again with GTK+ >= 3.6.

  • UIProcess/gtk/DragAndDropHandler.cpp:

(WebKit::DragAndDropHandler::DragAndDropHandler):
(WebKit::DragAndDropHandler::startDrag):
(WebKit::DragAndDropHandler::fillDragData):
(WebKit::DragAndDropHandler::finishDrag):

  • UIProcess/gtk/DragAndDropHandler.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r195797 r195811  
     12016-01-29  Mario Sanchez Prada  <mario@endlessm.com>
     2
     3        [GTK] WebProcess crashes when quickly attempting many DnD operations
     4        https://bugs.webkit.org/show_bug.cgi?id=138468
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Guard all the new DnD-related code under GTK_CHECK_VERSION #if's to
     9        make sure we don't bump the required version of GTK+ up to 3.16, and
     10        it's buildable again with GTK+ >= 3.6.
     11
     12        * UIProcess/gtk/DragAndDropHandler.cpp:
     13        (WebKit::DragAndDropHandler::DragAndDropHandler):
     14        (WebKit::DragAndDropHandler::startDrag):
     15        (WebKit::DragAndDropHandler::fillDragData):
     16        (WebKit::DragAndDropHandler::finishDrag):
     17        * UIProcess/gtk/DragAndDropHandler.h:
     18
    1192016-01-28  Antti Koivisto  <antti@apple.com>
    220
  • trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp

    r195586 r195811  
    4545DragAndDropHandler::DragAndDropHandler(WebPageProxy& page)
    4646    : m_page(page)
     47#if GTK_CHECK_VERSION(3, 16, 0)
    4748    , m_dragContext(nullptr)
     49#endif
    4850{
    4951}
     
    112114void DragAndDropHandler::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
    113115{
     116#if GTK_CHECK_VERSION(3, 16, 0)
    114117    m_draggingDataObject = adoptRef(dragData.platformData());
    115 
    116118    GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::singleton().targetListForDataObject(m_draggingDataObject.get()));
     119#else
     120    RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());
     121    GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::singleton().targetListForDataObject(dataObject.get()));
     122#endif
     123
    117124    GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());
    118 
    119125    GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
    120126        GDK_BUTTON_PRIMARY, currentEvent.get());
    121127
     128#if GTK_CHECK_VERSION(3, 16, 0)
    122129    // WebCore::EventHandler does not support more than one DnD operation at the same time for
    123130    // a given page, so we should cancel any previous operation whose context we might have
     
    126133        gtk_drag_cancel(m_dragContext.get());
    127134    m_dragContext = context;
     135#else
     136    // We don't have gtk_drag_cancel() in GTK+ < 3.16, so we use the old code.
     137    // See https://bugs.webkit.org/show_bug.cgi?id=138468
     138    m_draggingDataObjects.set(context, dataObject.get());
     139#endif
    128140
    129141    if (dragImage) {
     
    138150void DragAndDropHandler::fillDragData(GdkDragContext* context, GtkSelectionData* selectionData, unsigned info)
    139151{
     152#if GTK_CHECK_VERSION(3, 16, 0)
    140153    // This can happen when attempting to call finish drag from webkitWebViewBaseDragDataGet()
    141154    // for a obsolete DnD operation that got previously cancelled in startDrag().
     
    145158    ASSERT(m_draggingDataObject);
    146159    PasteboardHelper::singleton().fillSelectionData(selectionData, info, m_draggingDataObject.get());
     160#else
     161    if (DataObjectGtk* dataObject = m_draggingDataObjects.get(context))
     162        PasteboardHelper::singleton().fillSelectionData(selectionData, info, dataObject);
     163#endif
    147164}
    148165
    149166void DragAndDropHandler::finishDrag(GdkDragContext* context)
    150167{
     168#if GTK_CHECK_VERSION(3, 16, 0)
    151169    // This can happen when attempting to call finish drag from webkitWebViewBaseDragEnd()
    152170    // for a obsolete DnD operation that got previously cancelled in startDrag().
     
    159177    m_dragContext = nullptr;
    160178    m_draggingDataObject = nullptr;
     179#else
     180    if (!m_draggingDataObjects.remove(context))
     181        return;
     182#endif
    161183
    162184    GdkDevice* device = gdk_drag_context_get_device(context);
  • trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h

    r195586 r195811  
    3131#include <WebCore/DataObjectGtk.h>
    3232#include <WebCore/IntPoint.h>
     33#include <gtk/gtk.h>
    3334#include <wtf/HashMap.h>
    3435#include <wtf/Noncopyable.h>
     
    7576
    7677    WebPageProxy& m_page;
     78    HashMap<GdkDragContext*, std::unique_ptr<DroppingContext>> m_droppingContexts;
     79
     80#if GTK_CHECK_VERSION(3, 16, 0)
    7781    GRefPtr<GdkDragContext> m_dragContext;
    7882    RefPtr<WebCore::DataObjectGtk> m_draggingDataObject;
    79     HashMap<GdkDragContext*, std::unique_ptr<DroppingContext>> m_droppingContexts;
     83#else
     84    // We don't have gtk_drag_cancel() in GTK+ < 3.16, so we use the old code.
     85    // See https://bugs.webkit.org/show_bug.cgi?id=138468
     86    HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk>> m_draggingDataObjects;
     87#endif
    8088};
    8189
Note: See TracChangeset for help on using the changeset viewer.