mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: ensure BrowserView bounds are always relative to window (#39850)
This commit is contained in:
@@ -769,10 +769,20 @@ void BaseWindow::AddBrowserView(gin::Handle<BrowserView> browser_view) {
|
||||
browser_view->SetOwnerWindow(nullptr);
|
||||
}
|
||||
|
||||
// If the user set the BrowserView's bounds before adding it to the window,
|
||||
// we need to get those initial bounds *before* adding it to the window
|
||||
// so bounds isn't returned relative despite not being correctly positioned
|
||||
// relative to the window.
|
||||
auto bounds = browser_view->GetBounds();
|
||||
|
||||
window_->AddBrowserView(browser_view->view());
|
||||
window_->AddDraggableRegionProvider(browser_view.get());
|
||||
browser_view->SetOwnerWindow(this);
|
||||
browser_views_[browser_view->ID()].Reset(isolate(), browser_view.ToV8());
|
||||
|
||||
// Recalibrate bounds relative to the containing window.
|
||||
if (!bounds.IsEmpty())
|
||||
browser_view->SetBounds(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@ class BrowserView : public gin::Wrappable<BrowserView>,
|
||||
BrowserView(const BrowserView&) = delete;
|
||||
BrowserView& operator=(const BrowserView&) = delete;
|
||||
|
||||
gfx::Rect GetBounds();
|
||||
void SetBounds(const gfx::Rect& bounds);
|
||||
|
||||
protected:
|
||||
BrowserView(gin::Arguments* args, const gin_helper::Dictionary& options);
|
||||
~BrowserView() override;
|
||||
@@ -78,8 +81,6 @@ class BrowserView : public gin::Wrappable<BrowserView>,
|
||||
|
||||
private:
|
||||
void SetAutoResize(AutoResizeFlags flags);
|
||||
void SetBounds(const gfx::Rect& bounds);
|
||||
gfx::Rect GetBounds();
|
||||
void SetBackgroundColor(const std::string& color_name);
|
||||
v8::Local<v8::Value> GetWebContents(v8::Isolate*);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user