perf: only access remote module when <webview>.getWebContents() is called (#20272)
This commit is contained in:
parent
1e0b87732f
commit
d090b0cd2d
1 changed files with 4 additions and 2 deletions
|
@ -1,10 +1,11 @@
|
||||||
import { remote, webFrame } from 'electron'
|
import * as electron from 'electron'
|
||||||
|
|
||||||
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'
|
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'
|
||||||
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
||||||
import * as guestViewInternal from '@electron/internal/renderer/web-view/guest-view-internal'
|
import * as guestViewInternal from '@electron/internal/renderer/web-view/guest-view-internal'
|
||||||
import { WEB_VIEW_CONSTANTS } from '@electron/internal/renderer/web-view/web-view-constants'
|
import { WEB_VIEW_CONSTANTS } from '@electron/internal/renderer/web-view/web-view-constants'
|
||||||
import { syncMethods, asyncMethods } from '@electron/internal/common/web-view-methods'
|
import { syncMethods, asyncMethods } from '@electron/internal/common/web-view-methods'
|
||||||
|
const { webFrame } = electron
|
||||||
|
|
||||||
const v8Util = process.electronBinding('v8_util')
|
const v8Util = process.electronBinding('v8_util')
|
||||||
|
|
||||||
|
@ -225,6 +226,7 @@ export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElem
|
||||||
|
|
||||||
// WebContents associated with this webview.
|
// WebContents associated with this webview.
|
||||||
WebViewElement.prototype.getWebContents = function () {
|
WebViewElement.prototype.getWebContents = function () {
|
||||||
|
const remote = electron.remote as Electron.RemoteInternal
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
throw new Error('getGuestWebContents requires remote, which is not enabled')
|
throw new Error('getGuestWebContents requires remote, which is not enabled')
|
||||||
}
|
}
|
||||||
|
@ -233,7 +235,7 @@ export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElem
|
||||||
internal.createGuestSync()
|
internal.createGuestSync()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (remote as Electron.RemoteInternal).getGuestWebContents(internal.guestInstanceId!)
|
return remote.getGuestWebContents(internal.guestInstanceId!)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Focusing the webview should move page focus to the underlying iframe.
|
// Focusing the webview should move page focus to the underlying iframe.
|
||||||
|
|
Loading…
Reference in a new issue