New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bound the target width and height of window when calling SetSize #6363

Merged
merged 2 commits into from Jul 7, 2016

Conversation

Projects
None yet
2 participants
@MarshallOfSound
Member

MarshallOfSound commented Jul 6, 2016

This fixes #6347 by bounding the width and height values by the MinimumSize and MaximumSize bounds of the window.

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Jul 6, 2016

Doing this in atom/browser/native_window_mac.mm should be enough, on Windows and Linux this has been enforced with the UI library of Chromium, doing it in NativeWindow can also avoid adding code to all size related APIs since we only need to check in constructor and SetBounds.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Jul 6, 2016

@zcbenz Was just writing up a comment querying if that would be the case 😆

I'll quickly transpose this into the mac native window file. 👍

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Jul 6, 2016

🎉 Magic 😆

It's now in native window mac 👍

@@ -756,6 +756,17 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
return bounds;
}
void NativeWindowMac::SetSize(const gfx::Size& size, bool animate) {

This comment has been minimized.

@zcbenz

zcbenz Jul 7, 2016

Contributor

All size APIs are directly to the SetBounds method, so we only need to do check there.

gfx::Size minSize = GetMinimumSize();
gfx::Size maxSize = GetMaximumSize();
// Bound the supplied width and height values with max and min sizes
int bWidth = fmax(minSize.width(), size.width());

This comment has been minimized.

@zcbenz
bSize.SetToMax(GetMinimumSize());
gfx::Size maxSize = GetMaximumSize();
maxSize = gfx::Size(maxSize.width() == 0 ? bSize.width() : maxSize.width(),

This comment has been minimized.

@MarshallOfSound

MarshallOfSound Jul 7, 2016

Member

We couldn't use a straight up SetToMin call here as for some reason Electron's default maximumSize is [0, 0]. This means we need these nasty ternary operatorst

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Jul 7, 2016

🎉 Magic 😆

It's now in SetBounds 👍

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Jul 7, 2016

👍

@zcbenz zcbenz merged commit 43e9f30 into electron:master Jul 7, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment