summaryrefslogtreecommitdiff
path: root/mozilla-1463753.patch
blob: 4e83fd41e2c96ca0a006044b576cbf8ad69949c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

# HG changeset patch
# User Martin Stransky <stransky@redhat.com>
# Date 1527155477 -7200
# Node ID 172827af80fa02953e0c7723c0dee915c411c286
# Parent  a5c04fe7278db916b3efd5f06a5f2a9da0d64ad2
Bug 1463753 - [DragAndDrop] Update mTarget(Wayland)DragContext unconditionally and check its validity after that, r=jhorak

MozReview-Commit-ID: KiNaPDDVvLu

diff --git a/widget/gtk/nsDragService.cpp b/widget/gtk/nsDragService.cpp
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -1043,21 +1043,21 @@ nsDragService::IsDataFlavorSupported(con
     }
 
     // check the target context vs. this flavor, one at a time
     GList *tmp = nullptr;
     if (mTargetDragContext) {
         tmp = gdk_drag_context_list_targets(mTargetDragContext);
     }
 #ifdef MOZ_WAYLAND
-    else {
+    else if (mTargetWaylandDragContext) {
         tmp = mTargetWaylandDragContext->GetTargets();
     }
+    GList *tmp_head = tmp;
 #endif
-    GList *tmp_head = tmp;
 
     for (; tmp; tmp = tmp->next) {
         /* Bug 331198 */
         GdkAtom atom = GDK_POINTER_TO_ATOM(tmp->data);
         gchar *name = nullptr;
         name = gdk_atom_name(atom);
         MOZ_LOG(sDragLm, LogLevel::Debug,
                ("checking %s against %s\n", name, aDataFlavor));
@@ -1095,21 +1095,23 @@ nsDragService::IsDataFlavorSupported(con
             MOZ_LOG(sDragLm, LogLevel::Debug,
                    ("good! ( it's text plain and we're checking \
                    against text/unicode or application/x-moz-file)\n"));
             *_retval = true;
         }
         g_free(name);
     }
 
+#ifdef MOZ_WAYLAND
     // mTargetWaylandDragContext->GetTargets allocates the list
     // so we need to free it here.
-    if (!mTargetDragContext) {
+    if (!mTargetDragContext && tmp_head) {
         g_list_free(tmp_head);
     }
+#endif
 
     return NS_OK;
 }
 
 void
 nsDragService::ReplyToDragMotion(GdkDragContext* aDragContext)
 {
     MOZ_LOG(sDragLm, LogLevel::Debug,
@@ -2007,23 +2009,19 @@ nsDragService::RunScheduledTask()
     // This may be the start of a destination drag session.
     StartDragSession();
 
     // mTargetWidget may be nullptr if the window has been destroyed.
     // (The leave event is not scheduled if a drop task is still scheduled.)
     // We still reply appropriately to indicate that the drop will or didn't
     // succeeed.
     mTargetWidget = mTargetWindow->GetMozContainerWidget();
-    if (mTargetDragContext) {
-        mTargetDragContext.steal(mPendingDragContext);
-    }
+    mTargetDragContext.steal(mPendingDragContext);
 #ifdef MOZ_WAYLAND
-    else {
-        mTargetWaylandDragContext = mPendingWaylandDragContext.forget();
-    }
+    mTargetWaylandDragContext = mPendingWaylandDragContext.forget();
 #endif
     mTargetTime = mPendingTime;
 
     // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#drag-and-drop-processing-model
     // (as at 27 December 2010) indicates that a "drop" event should only be
     // fired (at the current target element) if the current drag operation is
     // not none.  The current drag operation will only be set to a non-none
     // value during a "dragover" event.
@@ -2056,17 +2054,17 @@ nsDragService::RunScheduledTask()
 #endif
           } else {
               // Reply to tell the source whether we can drop and what
               // action would be taken.
               if (mTargetDragContext) {
                   ReplyToDragMotion(mTargetDragContext);
               }
 #ifdef MOZ_WAYLAND
-              else {
+              else if (mTargetWaylandDragContext) {
                   ReplyToDragMotion(mTargetWaylandDragContext);
               }
 #endif
           }
         }
     }
 
     if (task == eDragTaskDrop) {
@@ -2123,17 +2121,17 @@ nsDragService::UpdateDragAction()
 
     // default is to do nothing
     int action = nsIDragService::DRAGDROP_ACTION_NONE;
     GdkDragAction gdkAction = GDK_ACTION_DEFAULT;
     if (mTargetDragContext) {
         gdkAction = gdk_drag_context_get_actions(mTargetDragContext);
     }
 #ifdef MOZ_WAYLAND
-    else {
+    else if (mTargetWaylandDragContext) {
         // We got the selected D&D action from compositor on Wayland.
         gdkAction = mTargetWaylandDragContext->GetSelectedDragAction();
     }
 #endif
 
     // set the default just in case nothing matches below
     if (gdkAction & GDK_ACTION_DEFAULT)
         action = nsIDragService::DRAGDROP_ACTION_MOVE;

bgstack15