diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index d775c635bc2d..469d9cd01ac5 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -354,10 +354,14 @@ void NativeWindow::SetContentSizeConstraints( size_constraints_.reset(); } +// Windows/Linux: // The return value of GetContentSizeConstraints will be passed to Chromium // to set min/max sizes of window. Note that we are returning content size // instead of window size because that is what Chromium expects, see the // comment of |WidgetSizeIsClientSize| in Chromium's codebase to learn more. +// +// macOS: +// The min/max sizes are set directly by calling NSWindow's methods. extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const { if (content_size_constraints_) return *content_size_constraints_; diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index 9b089c52640f..a1c70ba2a0f2 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -58,6 +58,8 @@ class NativeWindowMac : public NativeWindow, gfx::Rect GetBounds() override; bool IsNormal() override; gfx::Rect GetNormalBounds() override; + void SetSizeConstraints( + const extensions::SizeConstraints& window_constraints) override; void SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) override; void SetResizable(bool resizable) override; diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 805ab87b2df3..be27cd8a5821 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -761,6 +761,16 @@ gfx::Rect NativeWindowMac::GetNormalBounds() { // return widget()->GetRestoredBounds(); } +void NativeWindowMac::SetSizeConstraints( + const extensions::SizeConstraints& window_constraints) { + // Apply the size constraints to NSWindow. + if (window_constraints.HasMinimumSize()) + [window_ setMinSize:window_constraints.GetMinimumSize().ToCGSize()]; + if (window_constraints.HasMaximumSize()) + [window_ setMaxSize:window_constraints.GetMaximumSize().ToCGSize()]; + NativeWindow::SetSizeConstraints(window_constraints); +} + void NativeWindowMac::SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) { auto convertSize = [this](const gfx::Size& size) { @@ -775,6 +785,7 @@ void NativeWindowMac::SetContentSizeConstraints( } }; + // Apply the size constraints to NSWindow. NSView* content = [window_ contentView]; if (size_constraints.HasMinimumSize()) { NSSize min_size = convertSize(size_constraints.GetMinimumSize());