chore: cleanup dead <webview> related code (#29039)
This commit is contained in:
parent
dab9a88413
commit
cbba602eae
4 changed files with 4 additions and 18 deletions
|
@ -34,12 +34,12 @@ const createGuest = function (embedder: Electron.WebContents, params: Record<str
|
||||||
const guest = (webContents as typeof ElectronInternal.WebContents).create({
|
const guest = (webContents as typeof ElectronInternal.WebContents).create({
|
||||||
type: 'webview',
|
type: 'webview',
|
||||||
partition: params.partition,
|
partition: params.partition,
|
||||||
embedder: embedder
|
embedder
|
||||||
});
|
});
|
||||||
const guestInstanceId = guest.id;
|
const guestInstanceId = guest.id;
|
||||||
guestInstances.set(guestInstanceId, {
|
guestInstances.set(guestInstanceId, {
|
||||||
guest: guest,
|
guest,
|
||||||
embedder: embedder
|
embedder
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear the guest from map when it is destroyed.
|
// Clear the guest from map when it is destroyed.
|
||||||
|
@ -165,7 +165,7 @@ const attachGuest = function (event: Electron.IpcMainInvokeEvent,
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const webPreferences: Electron.WebPreferences = {
|
const webPreferences: Electron.WebPreferences = {
|
||||||
guestInstanceId: guestInstanceId,
|
guestInstanceId,
|
||||||
nodeIntegration: params.nodeintegration != null ? params.nodeintegration : false,
|
nodeIntegration: params.nodeintegration != null ? params.nodeintegration : false,
|
||||||
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes != null ? params.nodeintegrationinsubframes : false,
|
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes != null ? params.nodeintegrationinsubframes : false,
|
||||||
plugins: params.plugins,
|
plugins: params.plugins,
|
||||||
|
|
|
@ -17,7 +17,6 @@ export const enum WEB_VIEW_CONSTANTS {
|
||||||
|
|
||||||
// Error messages.
|
// Error messages.
|
||||||
ERROR_MSG_ALREADY_NAVIGATED = 'The object has already navigated, so its partition cannot be changed.',
|
ERROR_MSG_ALREADY_NAVIGATED = 'The object has already navigated, so its partition cannot be changed.',
|
||||||
ERROR_MSG_CANNOT_INJECT_SCRIPT = '<webview> = ' + 'Script cannot be injected into content until the page has loaded.',
|
|
||||||
ERROR_MSG_INVALID_PARTITION_ATTRIBUTE = 'Invalid partition attribute.',
|
ERROR_MSG_INVALID_PARTITION_ATTRIBUTE = 'Invalid partition attribute.',
|
||||||
ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE = 'Only "file:" protocol is supported in "preload" attribute.'
|
ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE = 'Only "file:" protocol is supported in "preload" attribute.'
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ type IWebViewImpl = webViewImplModule.WebViewImpl;
|
||||||
const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof webViewImplModule) => {
|
const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof webViewImplModule) => {
|
||||||
const { guestViewInternal, WebViewImpl } = webViewImpl;
|
const { guestViewInternal, WebViewImpl } = webViewImpl;
|
||||||
return class WebViewElement extends HTMLElement {
|
return class WebViewElement extends HTMLElement {
|
||||||
public internalInstanceId?: number;
|
|
||||||
|
|
||||||
static get observedAttributes () {
|
static get observedAttributes () {
|
||||||
return [
|
return [
|
||||||
WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION,
|
WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION,
|
||||||
|
@ -78,7 +76,6 @@ const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof
|
||||||
guestViewInternal.detachGuest(internal.guestInstanceId);
|
guestViewInternal.detachGuest(internal.guestInstanceId);
|
||||||
}
|
}
|
||||||
internal.elementAttached = false;
|
internal.elementAttached = false;
|
||||||
this.internalInstanceId = 0;
|
|
||||||
internal.reset();
|
internal.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
10
typings/internal-electron.d.ts
vendored
10
typings/internal-electron.d.ts
vendored
|
@ -285,16 +285,6 @@ declare namespace ElectronInternal {
|
||||||
loader: ModuleLoader;
|
loader: ModuleLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WebFrameResizeEvent extends WebViewEvent {
|
|
||||||
newWidth: number;
|
|
||||||
newHeight: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WebViewEvent extends Event {
|
|
||||||
url: string;
|
|
||||||
isMainFrame: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
class WebViewElement extends HTMLElement {
|
class WebViewElement extends HTMLElement {
|
||||||
static observedAttributes: Array<string>;
|
static observedAttributes: Array<string>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue