Bug 466379, add screen coordinates to dragend event, r=josh,sr=roc

This commit is contained in:
Neil Deakin 2009-04-13 09:00:29 -04:00
Родитель 8ca0fb931d
Коммит 783c76f429
4 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -6228,6 +6228,12 @@ static BOOL keyUpAlreadySentKeyDown = NO;
}
if (mDragService) {
// set the dragend point from the current mouse location
nsDragService* dragService = static_cast<nsDragService *>(mDragService);
NSPoint pnt = [NSEvent mouseLocation];
FlipCocoaScreenCoordinate(pnt);
dragService->SetDragEndPoint(nsPoint(NSToIntRound(pnt.x), NSToIntRound(pnt.y)));
mDragService->EndDragSession(PR_TRUE);
NS_RELEASE(mDragService);
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsIContent> content = do_QueryInterface(mSourceNode);
return presShell->HandleDOMEventWithTarget(content, &event, &status);

Просмотреть файл

@ -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;
};