Bug 452083, drag and drop not working on Windows if effectAllowed isn't set, don't reuse the event for drops on Linux, causes the cancel flag to still be set from the previous event, r=smaug,sr=roc
authorNeil Deakin <neil@mozilla.com>
Mon, 01 Sep 2008 15:51:12 -0400
changeset 18552 0206b8c65827b3f7d05db2670cb592df6f83af0c
parent 18551 e2c3679da76e998c5986a95a0e1e8ef27e0c6b76
child 18553 ad9d3380f03a0013c81497790209fe62646fd5b6
push id1637
push userneil@mozilla.com
push dateMon, 01 Sep 2008 19:51:49 +0000
treeherdermozilla-central@0206b8c65827 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, roc
bugs452083
milestone1.9.1b1pre
Bug 452083, drag and drop not working on Windows if effectAllowed isn't set, don't reuse the event for drops on Linux, causes the cancel flag to still be set from the previous event, r=smaug,sr=roc
content/events/src/nsEventStateManager.cpp
widget/src/gtk2/nsWindow.cpp
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -2202,23 +2202,24 @@ nsEventStateManager::DoDefaultDragStart(
   aDataTransfer->GetDragTarget(getter_AddRefs(dragTargetElement));
   dragTarget = do_QueryInterface(dragTargetElement);
   if (!dragTarget) {
     dragTarget = do_QueryInterface(aDragTarget);
     if (!dragTarget)
       return;
   }
 
-  // check which drag effect should initially be used
-  PRUint32 effectAllowed;
-  aDataTransfer->GetEffectAllowedInt(&effectAllowed);
-
-  PRInt32 action = 0;
-  if (effectAllowed != nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
-    action = effectAllowed;
+  // check which drag effect should initially be used. If the effect was not
+  // set, just use all actions, otherwise Windows won't allow a drop.
+  PRUint32 action;
+  aDataTransfer->GetEffectAllowedInt(&action);
+  if (action == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
+    action = nsIDragService::DRAGDROP_ACTION_COPY |
+             nsIDragService::DRAGDROP_ACTION_MOVE |
+             nsIDragService::DRAGDROP_ACTION_LINK;
 
   // get any custom drag image that was set
   PRInt32 imageX, imageY;
   nsIDOMElement* dragImage = aDataTransfer->GetDragImage(&imageX, &imageY);
 
   // If a selection is being dragged, and no custom drag image was
   // set, get the selection so that the drag region can be created
   // from the selection area. If a custom image was set, it doesn't
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -3060,21 +3060,21 @@ nsWindow::OnDragDropEvent(GtkWidget *aWi
 
     nsEventStatus status;
     innerMostWidget->DispatchEvent(&event, status);
 
     // We need to check innerMostWidget->mIsDestroyed here because the nsRefPtr
     // only protects innerMostWidget from being deleted, it does NOT protect
     // against nsView::~nsView() calling Destroy() on it, bug 378670.
     if (!innerMostWidget->mIsDestroyed) {
-        event.message = NS_DRAGDROP_DROP;
-        event.widget = innerMostWidget;
+        nsDragEvent event(PR_TRUE, NS_DRAGDROP_DROP, innerMostWidget);
         event.refPoint.x = retx;
         event.refPoint.y = rety;
 
+        nsEventStatus status = nsEventStatus_eIgnore;
         innerMostWidget->DispatchEvent(&event, status);
     }
 
     // before we unset the context we need to do a drop_finish
 
     gdk_drop_finish(aDragContext, TRUE, aTime);
 
     // after a drop takes place we need to make sure that the drag