diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index c370cca0724e..87b75a734e38 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -6228,6 +6228,12 @@ static BOOL keyUpAlreadySentKeyDown = NO; } if (mDragService) { + // set the dragend point from the current mouse location + nsDragService* dragService = static_cast(mDragService); + NSPoint pnt = [NSEvent mouseLocation]; + FlipCocoaScreenCoordinate(pnt); + dragService->SetDragEndPoint(nsPoint(NSToIntRound(pnt.x), NSToIntRound(pnt.y))); + mDragService->EndDragSession(PR_TRUE); NS_RELEASE(mDragService); } diff --git a/widget/src/windows/nsDragService.cpp b/widget/src/windows/nsDragService.cpp index d73b74b278f7..8ce2b405746e 100644 --- a/widget/src/windows/nsDragService.cpp +++ b/widget/src/windows/nsDragService.cpp @@ -355,7 +355,10 @@ nsDragService::StartInvokingDragSession(IDataObject * aDataObj, mUserCancelled = nativeDragSource->UserCancelled(); - // We're done dragging + // We're done dragging, get the cursor position and end the drag + POINT pos; + GetCursorPos(&pos); + SetDragEndPoint(nsPoint(pos.x, pos.y)); EndDragSession(PR_TRUE); // For some drag/drop interactions, IDataObject::SetData doesn't get diff --git a/widget/src/xpwidgets/nsBaseDragService.cpp b/widget/src/xpwidgets/nsBaseDragService.cpp index c2a139b6d50a..449c9e0ec15e 100644 --- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -224,6 +224,7 @@ nsBaseDragService::InvokeDragSession(nsIDOMNode *aDOMNode, // stash the document of the dom node aDOMNode->GetOwnerDocument(getter_AddRefs(mSourceDocument)); mSourceNode = aDOMNode; + mEndDragPoint = nsPoint(0, 0); // When the mouse goes down, the selection code starts a mouse // capture. However, this gets in the way of determining drag @@ -374,7 +375,11 @@ nsBaseDragService::FireDragEventAtSource(PRUint32 aMsg) if (presShell) { nsEventStatus status = nsEventStatus_eIgnore; nsDragEvent event(PR_TRUE, aMsg, nsnull); - event.userCancelled = (aMsg == NS_DRAGDROP_END && mUserCancelled); + if (aMsg == NS_DRAGDROP_END) { + event.refPoint.x = mEndDragPoint.x; + event.refPoint.y = mEndDragPoint.y; + event.userCancelled = mUserCancelled; + } nsCOMPtr content = do_QueryInterface(mSourceNode); return presShell->HandleDOMEventWithTarget(content, &event, &status); diff --git a/widget/src/xpwidgets/nsBaseDragService.h b/widget/src/xpwidgets/nsBaseDragService.h index 1d891ace3034..3bfc26861ca0 100644 --- a/widget/src/xpwidgets/nsBaseDragService.h +++ b/widget/src/xpwidgets/nsBaseDragService.h @@ -77,6 +77,8 @@ public: NS_DECL_NSIDRAGSERVICE NS_DECL_NSIDRAGSESSION + void SetDragEndPoint(nsPoint aEndDragPoint) { mEndDragPoint = aEndDragPoint; } + protected: /** @@ -154,6 +156,9 @@ protected: PRInt32 mScreenX; PRInt32 mScreenY; + // the screen position where the drag ended + nsPoint mEndDragPoint; + PRUint32 mSuppressLevel; };