Bug 1445519 - Use frameRectForContentRect:styleMask: for nsCocoaWindow::ClientToWindowSize. r?mstange
MozReview-Commit-ID: 6p97SXWfchA
--- 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()
{