Bug 1070038 - Make window dragging work correctly on Mac OS 10.10. r=smichaud
authorMarkus Stange <mstange@themasta.com>
Mon, 22 Sep 2014 13:45:48 -0400
changeset 206576 8f7dcbde58db4e92716d5e79cceebb6806dd2f10
parent 206543 15aebfcdbde50a9f20fe7865236ca85e6f07e617
child 206577 77995516ba17d01f6db4e3d4d59f9266161724de
push id27532
push userkwierso@gmail.com
push dateTue, 23 Sep 2014 01:57:26 +0000
treeherdermozilla-central@790f41c631cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs1070038
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1070038 - Make window dragging work correctly on Mac OS 10.10. r=smichaud
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -220,16 +220,17 @@ static uint32_t gNumberOfWidgetsNeedingE
 @end
 
 @interface NSView(NSThemeFrameCornerRadius)
 - (float)roundedCornerRadius;
 @end
 
 @interface NSView(DraggableRegion)
 - (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect forMove:(BOOL)aForMove;
+- (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect forMove:(BOOL)aForMove forUnderTitlebar:(BOOL)aForUnderTitlebar;
 @end
 
 // Starting with 10.7 the bottom corners of all windows are rounded.
 // Unfortunately, the standard rounding that OS X applies to OpenGL views
 // does not use anti-aliasing and looks very crude. Since we want a smooth,
 // anti-aliased curve, we'll draw it ourselves.
 // Additionally, we need to turn off the OS-supplied rounding because it
 // eats into our corner's curve. We do that by overriding an NSSurface method.
@@ -4953,16 +4954,33 @@ NewCGSRegionFromRegion(const nsIntRegion
   nsIntRegion opaqueRegion;
   opaqueRegion.Sub(boundingRect, mGeckoChild->GetDraggableRegion());
 
   return NewCGSRegionFromRegion(opaqueRegion, ^(const nsIntRect& r) {
     return [self convertToFlippedWindowCoordinates:mGeckoChild->DevPixelsToCocoaPoints(r)];
   });
 }
 
+// Starting with 10.10, in addition to the traditional
+// -[NSView _regionForOpaqueDescendants:forMove:] method, there's a new form with
+// an additional forUnderTitlebar argument, which is sometimes called instead of
+// the old form. We need to override the new variant as well.
+- (CGSRegionObj)_regionForOpaqueDescendants:(NSRect)aRect
+                                    forMove:(BOOL)aForMove
+                           forUnderTitlebar:(BOOL)aForUnderTitlebar
+{
+  if (!aForMove || !mGeckoChild) {
+    return [super _regionForOpaqueDescendants:aRect
+                                      forMove:aForMove
+                             forUnderTitlebar:aForUnderTitlebar];
+  }
+
+  return [self _regionForOpaqueDescendants:aRect forMove:aForMove];
+}
+
 - (void)handleMouseMoved:(NSEvent*)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mGeckoChild)
     return;
 
   WidgetMouseEvent geckoEvent(true, NS_MOUSE_MOVE, mGeckoChild,