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, a=jcristau
authorMarkus Stange <mstange@themasta.com>
Wed, 14 Mar 2018 17:04:49 -0400
changeset 460339 5f60c50c33cb871516e833ac24ef8d0fcc7d2132
parent 460338 1b2c48ee942a2ed462e09729bc431b4c8c8953b5
child 460340 ea46bb8bb65a6be282be80a9276b9656454fcedd
push id8911
push userryanvm@gmail.com
push dateFri, 23 Mar 2018 16:02:57 +0000
treeherdermozilla-beta@16f5fd01de80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, jcristau
bugs1445131
milestone60.0
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, a=jcristau 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];
     }