🍎 Fix 'setAspectRatio(0)' not resetting the default behaviour.

This commit is contained in:
Daniel Pham 2016-05-27 08:56:34 -04:00
parent c1272743b9
commit 0c710fce33

View file

@ -718,14 +718,11 @@ void NativeWindowMac::SetAspectRatio(double aspect_ratio,
const gfx::Size& extra_size) { const gfx::Size& extra_size) {
NativeWindow::SetAspectRatio(aspect_ratio, extra_size); NativeWindow::SetAspectRatio(aspect_ratio, extra_size);
// We can't just pass the aspect ratio to Cocoa, since our API receives // Reset the behaviour to default if aspect_ratio is set to 0 or less.
// it as a float, and Cocoa expects an NSRect with explicit width & height if (aspect_ratio > 0.0)
// arguments. Instead we derive those args ourselves from the given aspect [window_ setAspectRatio:NSMakeSize(aspect_ratio, 1.0)];
// ratio. else
double width = roundf([window_ frame].size.height * aspect_ratio); [window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
double height = roundf(width / aspect_ratio);
[window_ setAspectRatio:NSMakeSize(width, height)];
} }
void NativeWindowMac::SetMovable(bool movable) { void NativeWindowMac::SetMovable(bool movable) {