fix: remove cyclic references of BrowserWindow (#22006)
* fix: remove cyclic references in BrowserWindow * fix: prevent TopLevelWindow from garbage collection * test: garbage collection of BrowserWindow * chore: createIDWeakMap is used in tests
This commit is contained in:
parent
9942149f3c
commit
9ad6f06831
9 changed files with 76 additions and 32 deletions
|
@ -25,26 +25,6 @@ BrowserWindow.prototype._init = function () {
|
|||
nativeSetBounds.call(this, bounds, ...opts)
|
||||
}
|
||||
|
||||
// window.resizeTo(...)
|
||||
// window.moveTo(...)
|
||||
this.webContents.on('move', (event, size) => {
|
||||
this.setBounds(size)
|
||||
})
|
||||
|
||||
// Hide the auto-hide menu when webContents is focused.
|
||||
this.webContents.on('activate', () => {
|
||||
if (process.platform !== 'darwin' && this.autoHideMenuBar && this.isMenuBarVisible()) {
|
||||
this.setMenuBarVisibility(false)
|
||||
}
|
||||
})
|
||||
|
||||
// Change window title to page title.
|
||||
this.webContents.on('page-title-updated', (event, title, ...args) => {
|
||||
// Route the event to BrowserWindow.
|
||||
this.emit('page-title-updated', event, title, ...args)
|
||||
if (!this.isDestroyed() && !event.defaultPrevented) this.setTitle(title)
|
||||
})
|
||||
|
||||
// Sometimes the webContents doesn't get focus when window is shown, so we
|
||||
// have to force focusing on webContents in this case. The safest way is to
|
||||
// focus it when we first start to load URL, if we do it earlier it won't
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue