osx: Fix converting size for frameless window

This commit is contained in:
Cheng Zhao 2015-10-05 19:32:23 +08:00
parent a76ea00249
commit 279407f7a3

View file

@ -789,12 +789,18 @@ void NativeWindowMac::HandleKeyboardEvent(
} }
gfx::Size NativeWindowMac::ContentSizeToWindowSize(const gfx::Size& size) { gfx::Size NativeWindowMac::ContentSizeToWindowSize(const gfx::Size& size) {
if (!has_frame())
return size;
NSRect content = NSMakeRect(0, 0, size.width(), size.height()); NSRect content = NSMakeRect(0, 0, size.width(), size.height());
NSRect frame = [window_ frameRectForContentRect:content]; NSRect frame = [window_ frameRectForContentRect:content];
return gfx::Size(frame.size); return gfx::Size(frame.size);
} }
gfx::Size NativeWindowMac::WindowSizeToContentSize(const gfx::Size& size) { gfx::Size NativeWindowMac::WindowSizeToContentSize(const gfx::Size& size) {
if (!has_frame())
return size;
NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
NSRect content = [window_ contentRectForFrameRect:frame]; NSRect content = [window_ contentRectForFrameRect:frame];
return gfx::Size(content.size); return gfx::Size(content.size);