Repository: electron/electron (language: cpp)

Issue:
[Bug]: BrowserView.setBounds is not appliead immediately on first calls.
### 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

28, 27, 26 and older

### What operating system are you using?

Windows

### Operating System Version

Windows 10

### What arch are you using?

x64

### Last Known Working Electron version

Probably never

### Expected Behavior

setBounds applied immediately, BrowserView painted in new position.

### Actual Behavior

setBounds sets the data but view is still being painted with old bounds even though getBounds returns new bounds.

### Testcase Gist URL

https://gist.github.com/2e8b6adb97bf44893828212a79b06b22

### Additional Information

Setting same bounds twice will make BrowserView paint correctly. This is because same calling setBounds with same rect immediately triggers layout call on Views (https://source.chromium.org/chromium/chromium/src/+/ba15ffd71335c75897f4bd8501b3c8ed00a284da:ui/views/view.cc;l=386), while different bounds will make it schedule InvalidateLayout call, which is propagated to parent and view is marked as needing layout, expecting to receive it from parent on next layout call . The problem is that BrowserView's view is added as child of InspectableWebContentsViews which does not call setBounds (which triggers layout) on all of it's children when doing it's layout, so it skips propagating Layout call to its children BrowserViews views, even though those were marked as needing layout.


Discussion / hints:

Fix patch:
diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.cc b/shell/browser/ui/views/inspectable_web_contents_view_views.cc
index b294d1461258a..69c40aef8784c 100644
--- a/shell/browser/ui/views/inspectable_web_contents_view_views.cc
+++ b/shell/browser/ui/views/inspectable_web_contents_view_views.cc
@@ -213,6 +213,8 @@ void InspectableWebContentsViewViews::SetTitle(const std::u16string& title) {
 void InspectableWebContentsViewViews::Layout() {
   if (!devtools_web_view_->GetVisible()) {
     contents_web_view_->SetBoundsRect(GetContentsBounds());
+    // Propagate layout call to all children, for example browser views.
+    View::Layout();
     return;
   }
 
@@ -230,6 +232,9 @@ void InspectableWebContentsViewViews::Layout() {
   devtools_web_view_->SetBoundsRect(new_devtools_bounds);
   contents_web_view_->SetBoundsRect(new_contents_bounds);
 
+  // Propagate layout call to all children, for example browser views.
+  View::Layout();
+
   if (GetDelegate())
     GetDelegate()->DevToolsResized();
 }


Test patch: