Bound the target width and height of window when calling SetSize
This commit is contained in:
parent
92b97d3576
commit
6bd343b112
2 changed files with 12 additions and 0 deletions
|
@ -46,6 +46,7 @@ class NativeWindowMac : public NativeWindow {
|
|||
bool IsFullscreen() const override;
|
||||
void SetBounds(const gfx::Rect& bounds, bool animate = false) override;
|
||||
gfx::Rect GetBounds() override;
|
||||
void SetSize(const gfx::Size& size, bool animate = false) override;
|
||||
void SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) override;
|
||||
void SetResizable(bool resizable) override;
|
||||
|
|
|
@ -756,6 +756,17 @@ gfx::Rect NativeWindowMac::GetBounds() {
|
|||
return bounds;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetSize(const gfx::Size& size, bool animate) {
|
||||
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());
|
||||
bWidth = maxSize.width() == 0 ? bWidth : fmin(maxSize.width(), bWidth);
|
||||
int bHeight = fmax(minSize.height(), size.height());
|
||||
bHeight = maxSize.height() == 0 ? bHeight : fmin(maxSize.height(), bHeight);
|
||||
SetBounds(gfx::Rect(GetPosition(), gfx::Size(bWidth, bHeight)), animate);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetContentSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints) {
|
||||
auto convertSize = [this](const gfx::Size& size) {
|
||||
|
|
Loading…
Reference in a new issue