diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index b398e04ac0c6..3a8284e1bee0 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -737,21 +737,18 @@ bool NativeWindowMac::IsFullscreen() const { } void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) { - gfx::Size bSize = gfx::Size(bounds.width(), bounds.height()); - bSize.SetToMax(GetMinimumSize()); + // Check size constraints since setFrame does not check it. + gfx::Size size = bounds.size(); + size.SetToMax(GetMinimumSize()); + gfx::Size max_size = GetMaximumSize(); + if (!max_size.IsEmpty()) + size.SetToMin(max_size); - gfx::Size maxSize = GetMaximumSize(); - maxSize = gfx::Size(maxSize.width() == 0 ? bSize.width() : maxSize.width(), - maxSize.height() == 0 ? bSize.height() : maxSize.height()); - bSize.SetToMin(maxSize); - - NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, - bSize.width(), - bSize.height()); + NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, size.width(), size.height()); // Flip coordinates based on the primary screen. NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; cocoa_bounds.origin.y = - NSHeight([screen frame]) - bSize.height() - bounds.y(); + NSHeight([screen frame]) - size.height() - bounds.y(); [window_ setFrame:cocoa_bounds display:YES animate:animate]; }