Bug 1445131 - When testing the event's position against the window's draggable region, read the position when it's still in the correct coordinate space. r?spohl draft
authorMarkus Stange <mstange@themasta.com>
Wed, 14 Mar 2018 17:04:49 -0400
changeset 767619 60c2778bc08f0c3f3463f03f1cb3cf6563da7fc5
parent 767618 7e19c43a2cf67969ec5a68d8d65fc0c0292ec03f
push id102651
push userbmo:mstange@themasta.com
push dateWed, 14 Mar 2018 21:08:07 +0000
reviewersspohl
bugs1445131
milestone61.0a1
Bug 1445131 - When testing the event's position against the window's draggable region, read the position when it's still in the correct coordinate space. r?spohl MozReview-Commit-ID: HqnXgIjDWrW
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -4587,22 +4587,25 @@ NSEvent* gLastDragMouseDownEvent = nil;
   WidgetMouseEvent geckoEvent(true, eMouseUp, mGeckoChild,
                               WidgetMouseEvent::eReal);
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
   if ([theEvent modifierFlags] & NSControlKeyMask)
     geckoEvent.button = WidgetMouseEvent::eRightButton;
   else
     geckoEvent.button = WidgetMouseEvent::eLeftButton;
 
+  // Remember the event's position before calling DispatchInputEvent, because
+  // that call can mutate it and convert it into a different coordinate space.
+  LayoutDeviceIntPoint pos = geckoEvent.mRefPoint;
+
   // This might destroy our widget (and null out mGeckoChild).
   bool defaultPrevented =
     (mGeckoChild->DispatchInputEvent(&geckoEvent) == nsEventStatus_eConsumeNoDefault);
 
   // Check to see if we are double-clicking in draggable parts of the window.
-  LayoutDeviceIntPoint pos = geckoEvent.mRefPoint;
   if (!defaultPrevented && [theEvent clickCount] == 2 &&
       !mGeckoChild->GetNonDraggableRegion().Contains(pos.x, pos.y)) {
     if ([self shouldZoomOnDoubleClick]) {
       [[self window] performZoom:nil];
     } else if ([self shouldMinimizeOnTitlebarDoubleClick]) {
       NSButton *minimizeButton = [[self window] standardWindowButton:NSWindowMiniaturizeButton];
       [minimizeButton performClick:self];
     }