提交 ddab4d65 编写于 作者: M Matt Bierner

Don't take parent in webview ctor

上级 bb1f0f04
......@@ -426,7 +426,8 @@ export class ExtensionEditor extends BaseEditor {
.then<void>(body => {
const allowedBadgeProviders = this.extensionsWorkbenchService.allowedBadgeProviders;
const webViewOptions = allowedBadgeProviders.length > 0 ? { allowScripts: false, allowSvgs: false, svgWhiteList: allowedBadgeProviders } : {};
this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions);
this.activeWebview = new Webview(this.partService.getContainer(Parts.EDITOR_PART), this.themeService, this.environmentService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions);
this.activeWebview.mountTo(this.content);
const removeLayoutParticipant = arrays.insert(this.layoutParticipants, this.activeWebview);
this.contentDisposables.push(toDisposable(removeLayoutParticipant));
this.activeWebview.contents = body;
......
......@@ -93,7 +93,6 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
}
this._webview = new Webview(
this.content,
this.partService.getContainer(Parts.EDITOR_PART),
this.themeService,
this._environmentService,
......@@ -104,6 +103,7 @@ export class HtmlPreviewPart extends BaseWebviewEditor {
...webviewOptions,
useSameOriginForRoot: true
});
this._webview.mountTo(this.content);
if (this.input && this.input instanceof HtmlInput) {
const state = this.loadViewState(this.input.getResource());
......
......@@ -37,7 +37,6 @@ export class Webview {
private _contents: string = '';
constructor(
private readonly parent: HTMLElement,
private readonly _styleElement: Element,
private readonly _themeService: IThemeService,
private readonly _environmentService: IEnvironmentService,
......@@ -180,11 +179,11 @@ export class Webview {
this.style(this._themeService.getTheme());
this._themeService.onThemeChange(this.style, this, this._disposables);
}
if (parent) {
parent.appendChild(this._webviewFindWidget.getDomNode());
parent.appendChild(this._webview);
}
public mountTo(parent: HTMLElement) {
parent.appendChild(this._webviewFindWidget.getDomNode());
parent.appendChild(this._webview);
}
public notifyFindWidgetFocusChanged(isFocused: boolean) {
......@@ -293,9 +292,12 @@ export class Webview {
}
contents.setZoomFactor(factor);
if (!this._webview || !this._webview.parentElement) {
return;
}
const width = this.parent.clientWidth;
const height = this.parent.clientHeight;
const width = this._webview.parentElement.clientWidth;
const height = this._webview.parentElement.clientHeight;
contents.setSize({
normal: {
width: Math.floor(width * factor),
......
......@@ -191,7 +191,6 @@ export class WebviewEditor extends BaseWebviewEditor {
this.findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(this._contextKeyService);
this._webview = new Webview(
this.webviewContent,
this._partService.getContainer(Parts.EDITOR_PART),
this.themeService,
this._environmentService,
......@@ -202,6 +201,7 @@ export class WebviewEditor extends BaseWebviewEditor {
enableWrappedPostMessage: true,
useSameOriginForRoot: false
});
this._webview.mountTo(this.webviewContent);
input.webview = this._webview;
if (input.options.tryRestoreScrollPosition) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册