Bug 1445519 - Use frameRectForContentRect:styleMask: for nsCocoaWindow::ClientToWindowSize. r?mstange draft
authorXidorn Quan <me@upsuper.org>
Wed, 14 Mar 2018 12:59:27 +1100
changeset 767177 2cd5bbb1de7c649ce06e7795d8fbf3d3780e9370
parent 767172 bf39f8df42194c4877ff32e533a206b943836762
push id102528
push userxquan@mozilla.com
push dateWed, 14 Mar 2018 02:02:26 +0000
reviewersmstange
bugs1445519
milestone61.0a1
Bug 1445519 - Use frameRectForContentRect:styleMask: for nsCocoaWindow::ClientToWindowSize. r?mstange MozReview-Commit-ID: 6p97SXWfchA
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2140,17 +2140,22 @@ nsCocoaWindow::ClientToWindowSize(const 
 
   if (!mWindow)
     return LayoutDeviceIntSize(0, 0);
 
   CGFloat backingScale = BackingScaleFactor();
   LayoutDeviceIntRect r(0, 0, aClientSize.width, aClientSize.height);
   NSRect rect = nsCocoaUtils::DevPixelsToCocoaPoints(r, backingScale);
 
-  NSRect inflatedRect = [mWindow frameRectForContentRect:rect];
+  // Ideally, we should just use the instance method frameRectForContentRect:
+  // here. However, when the window hasn't shown yet, that method seems to
+  // just return the rect passed in directly, so we use the type method
+  // frameRectForContentRect:styleMask: here instead.
+  unsigned int features = [mWindow styleMask];
+  NSRect inflatedRect = [NSWindow frameRectForContentRect:rect styleMask:features];
   r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(inflatedRect, backingScale);
   return r.Size();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntSize(0,0));
 }
 
 nsMenuBarX* nsCocoaWindow::GetMenuBar()
 {