Bug 376071 - When starting a drag, pass the mouse down event that started the drag (instead of the last mouse move event) so that the drag image can be positioned correctly. r=josh

--HG--
extra : rebase_source : e62fc324934c2abe38dce6936d8cab09ee1e2715
This commit is contained in:
Markus Stange 2009-11-06 11:21:41 +01:00
Родитель cfc8100176
Коммит d2bab04fe5
2 изменённых файлов: 14 добавлений и 13 удалений

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

@ -2163,13 +2163,11 @@ nsChildView::GetDocumentAccessible(nsIAccessible** aAccessible)
// occurs in this view.
NSPasteboard* globalDragPboard = nil;
// gLastDragView and gLastDragEvent are only non-null during calls to |mouseDragged:|
// in our native NSView. They are used to communicate information to the drag service
// during drag invocation (starting a drag in from the view). All drag service drag
// invocations happen only while these two global variables are non-null, while |mouseDragged:|
// is on the stack.
// gLastDragView and gLastDragMouseDownEvent are used to communicate information
// to the drag service during drag invocation (starting a drag in from the view).
// gLastDragView is only non-null while mouseDragged is on the call stack.
NSView* gLastDragView = nil;
NSEvent* gLastDragEvent = nil;
NSEvent* gLastDragMouseDownEvent = nil;
+ (void)initialize
{
@ -3012,6 +3010,9 @@ static const PRInt32 sShadowInvalidationInterval = 100;
mLastMouseDownEvent = [theEvent retain];
}
[gLastDragMouseDownEvent release];
gLastDragMouseDownEvent = [theEvent retain];
nsAutoRetainCocoaObject kungFuDeathGrip(self);
if ([self maybeRollup:theEvent] ||
@ -3231,7 +3232,6 @@ static const PRInt32 sShadowInvalidationInterval = 100;
return;
gLastDragView = self;
gLastDragEvent = theEvent;
nsMouseEvent geckoEvent(PR_TRUE, NS_MOUSE_MOVE, nsnull, nsMouseEvent::eReal);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
@ -3268,9 +3268,8 @@ static const PRInt32 sShadowInvalidationInterval = 100;
// Note, sending the above event might have destroyed our widget since we didn't retain.
// Fine so long as we don't access any local variables from here on.
gLastDragView = nil;
gLastDragEvent = nil;
// XXX maybe call markedTextSelectionChanged:client: here?
NS_OBJC_END_TRY_ABORT_BLOCK;
@ -5953,6 +5952,8 @@ static BOOL keyUpAlreadySentKeyDown = NO;
[globalDragPboard release];
globalDragPboard = nil;
[gLastDragMouseDownEvent release];
gLastDragMouseDownEvent = nil;
NS_OBJC_END_TRY_ABORT_BLOCK;
}

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

@ -75,7 +75,7 @@ extern PRLogModuleInfo* sCocoaLog;
extern NSPasteboard* globalDragPboard;
extern NSView* gLastDragView;
extern NSEvent* gLastDragEvent;
extern NSEvent* gLastDragMouseDownEvent;
extern PRBool gUserCancelledDrag;
// This global makes the transferable array available to Cocoa's promised
@ -166,7 +166,7 @@ nsDragService::ConstructDragImage(nsIDOMNode* aDOMNode,
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
NSPoint screenPoint = [[gLastDragView window] convertBaseToScreen:[gLastDragEvent locationInWindow]];
NSPoint screenPoint = [[gLastDragView window] convertBaseToScreen:[gLastDragMouseDownEvent locationInWindow]];
// Y coordinates are bottom to top, so reverse this
if ([[NSScreen screens] count] > 0)
screenPoint.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - screenPoint.y;
@ -303,12 +303,12 @@ nsDragService::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aTransf
// We need to retain the view and the event during the drag in case either gets destroyed.
mNativeDragView = [gLastDragView retain];
mNativeDragEvent = [gLastDragEvent retain];
mNativeDragEvent = [gLastDragMouseDownEvent retain];
gUserCancelledDrag = PR_FALSE;
[mNativeDragView dragImage:image
at:localPoint
offset:NSMakeSize(0,0)
offset:NSZeroSize
event:mNativeDragEvent
pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
source:mNativeDragView