Changeset 269620 in webkit


Ignore:
Timestamp:
Nov 10, 2020 1:03:04 AM (3 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Crash in WebKit::DropTarget::drop
https://bugs.webkit.org/show_bug.cgi?id=217482

Reviewed by Michael Catanzaro.

If we don't have selection data when drop is called, just return early to let leave continue. Also change
accept() to receive the drop context and position to be set after leaving any previous operation.

  • UIProcess/API/gtk/DropTarget.h:
  • UIProcess/API/gtk/DropTargetGtk3.cpp:

(WebKit::DropTarget::DropTarget):
(WebKit::DropTarget::accept):
(WebKit::DropTarget::drop):

  • UIProcess/API/gtk/DropTargetGtk4.cpp:

(WebKit::DropTarget::DropTarget):
(WebKit::DropTarget::accept):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r269618 r269620  
     12020-11-10  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Crash in WebKit::DropTarget::drop
     4        https://bugs.webkit.org/show_bug.cgi?id=217482
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        If we don't have selection data when drop is called, just return early to let leave continue. Also change
     9        accept() to receive the drop context and position to be set after leaving any previous operation.
     10
     11        * UIProcess/API/gtk/DropTarget.h:
     12        * UIProcess/API/gtk/DropTargetGtk3.cpp:
     13        (WebKit::DropTarget::DropTarget):
     14        (WebKit::DropTarget::accept):
     15        (WebKit::DropTarget::drop):
     16        * UIProcess/API/gtk/DropTargetGtk4.cpp:
     17        (WebKit::DropTarget::DropTarget):
     18        (WebKit::DropTarget::accept):
     19
    1202020-11-10  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Source/WebKit/UIProcess/API/gtk/DropTarget.h

    r262680 r269620  
    4040#if USE(GTK4)
    4141typedef struct _GdkDrop GdkDrop;
     42using PlatformDropContext = GdkDrop;
    4243#else
    4344typedef struct _GdkDragContext GdkDragContext;
    4445typedef struct _GtkSelectionData GtkSelectionData;
     46using PlatformDropContext = GdkDragContext;
    4547#endif
    4648
     
    5860
    5961private:
    60     void accept(unsigned = 0);
     62    void accept(PlatformDropContext*, Optional<WebCore::IntPoint> = WTF::nullopt, unsigned = 0);
    6163    void enter(WebCore::IntPoint&&, unsigned = 0);
    6264    void update(WebCore::IntPoint&&, unsigned = 0);
  • trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk3.cpp

    r269505 r269620  
    6060        auto& drop = *static_cast<DropTarget*>(userData);
    6161        if (drop.m_drop != context) {
    62             drop.m_drop = context;
    63             drop.m_position = IntPoint(x, y);
    64             drop.accept(time);
     62            drop.accept(context, IntPoint(x, y), time);
    6563        } else if (drop.m_drop == context)
    6664            drop.update({ x, y }, time);
     
    9896}
    9997
    100 void DropTarget::accept(unsigned time)
     98void DropTarget::accept(GdkDragContext* drop, Optional<WebCore::IntPoint> position, unsigned time)
    10199{
    102100    if (m_leaveTimer.isActive()) {
     
    105103    }
    106104
     105    m_drop = drop;
     106    m_position = position;
    107107    m_dataRequestCount = 0;
    108108    m_selectionData = WTF::nullopt;
     
    260260void DropTarget::drop(IntPoint&& position, unsigned time)
    261261{
     262    // If we don't have data at this point, allow the leave timer to fire, ending the drop operation.
     263    if (!m_selectionData)
     264        return;
     265
    262266    if (m_leaveTimer.isActive())
    263267        m_leaveTimer.stop();
  • trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk4.cpp

    r265650 r269620  
    5555    g_signal_connect(target, "accept", G_CALLBACK(+[](GtkDropTargetAsync*, GdkDrop* gdkDrop, gpointer userData) -> gboolean {
    5656        auto& drop = *static_cast<DropTarget*>(userData);
    57         drop.m_drop = gdkDrop;
    58         drop.accept();
     57        drop.accept(gdkDrop);
    5958        return TRUE;
    6059    }), this);
     
    103102}
    104103
    105 void DropTarget::accept(unsigned)
    106 {
    107     m_position = WTF::nullopt;
     104void DropTarget::accept(GdkDrop* drop, Optional<WebCore::IntPoint> position, unsigned)
     105{
     106    m_drop = drop;
     107    m_position = position;
    108108    m_selectionData = SelectionData();
    109109    m_dataRequestCount = 0;
Note: See TracChangeset for help on using the changeset viewer.