Repository: electron/electron (language: cpp)

Issue:
[Bug]: minWidth no longer working
### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

17.0.0-beta.7

### What operating system are you using?

Windows

### Operating System Version

Windows 10 19042.985

### What arch are you using?

x64

### Last Known Working Electron version

16

### Expected Behavior

Setting minWidth for a browserWindow during creation should work

### Actual Behavior

minWidth does not work (minHeight does)

```
const { app, BrowserWindow } = require("electron");

function init() {
	let browserWindow1 = new BrowserWindow({
		show: true,
		minWidth: 500,
		minHeight: 500,
	});
}

app.on("ready", () => {
	init();
});
```

Note: It works when using browserWindow1.setMinimumSize(500, 500);

### Testcase Gist URL

_No response_

### Additional Information

_No response_


Discussion / hints:
Looks like this regressed in https://github.com/electron/electron/compare/v17.0.0-alpha.3...v17.0.0-alpha.4 and within that, https://github.com/electron/electron/commit/b6f8a1686fcaa758a93b7d37b695e38bd5111eae seems like the likely culprit - cc @CezaryKulakowski 
My changes are in method `HWNDMessageHandler::SizeWindowToAspectRatio` which is called only when aspect ratio is set on the `BrowserWindow`. As test case from this bug doesn't set it I'd suspect that some change in the chromium intake causes the problem. I'll take a look at a later time.
I can confirm that it's definitely not caused by https://github.com/electron/electron/commit/b6f8a1686fcaa758a93b7d37b695e38bd5111eae. My change modifies file `ui/views/win/hwnd_message_handler.cc` which is being compiled only on Windows and the regression with `minWidth` can be observed also on macOS.
lol found it, it's this:

![image](https://user-images.githubusercontent.com/172800/151062401-1b1e3c0c-984e-4ac7-ba39-47c7472190b3.png)

`||` short-circuits, `|` does not.

Fix patch:
diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc
index 55fec650ce812..7bb0d1e88f1c0 100644
--- a/shell/browser/native_window.cc
+++ b/shell/browser/native_window.cc
@@ -144,16 +144,16 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
   // On Linux and Window we may already have maximum size defined.
   extensions::SizeConstraints size_constraints(
       use_content_size ? GetContentSizeConstraints() : GetSizeConstraints());
-  int min_height = 0, min_width = 0;
-  if (options.Get(options::kMinHeight, &min_height) ||
-      options.Get(options::kMinWidth, &min_width)) {
-    size_constraints.set_minimum_size(gfx::Size(min_width, min_height));
-  }
-  int max_height = INT_MAX, max_width = INT_MAX;
-  if (options.Get(options::kMaxHeight, &max_height) ||
-      options.Get(options::kMaxWidth, &max_width)) {
-    size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
-  }
+  int min_width = size_constraints.GetMinimumSize().width();
+  int min_height = size_constraints.GetMinimumSize().height();
+  options.Get(options::kMinWidth, &min_width);
+  options.Get(options::kMinHeight, &min_height);
+  size_constraints.set_minimum_size(gfx::Size(min_width, min_height));
+  int max_width = size_constraints.GetMaximumSize().width();
+  int max_height = size_constraints.GetMaximumSize().height();
+  options.Get(options::kMaxWidth, &max_width);
+  options.Get(options::kMaxHeight, &max_height);
+  size_constraints.set_maximum_size(gfx::Size(max_width, max_height));
   if (use_content_size) {
     SetContentSizeConstraints(size_constraints);
   } else {


Test patch: