Skip to content

Commit

Permalink
Pass Webview into ExtHostWebviewPanel instead of creating it inside t…
Browse files Browse the repository at this point in the history
…he ctor
  • Loading branch information
mjbvz committed Apr 17, 2018
1 parent 5d37bdf commit fbd3a08
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/vs/workbench/api/node/extHostWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ export class ExtHostWebview implements vscode.Webview {
export class ExtHostWebviewPanel implements vscode.WebviewPanel {

private readonly _handle: WebviewPanelHandle;
private readonly _proxy: MainThreadWebviewsShape;
private readonly _viewType: string;
private readonly _options: vscode.WebviewPanelOptions;
private readonly _proxy: MainThreadWebviewsShape;
private readonly _webview: ExtHostWebview;
private _isDisposed: boolean = false;
private _viewColumn: vscode.ViewColumn;
private _visible: boolean = true;
Expand All @@ -105,23 +106,21 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
public readonly onDidChangeViewStateEmitter = new Emitter<vscode.WebviewPanelOnDidChangeViewStateEvent>();
public readonly onDidChangeViewState: Event<vscode.WebviewPanelOnDidChangeViewStateEvent> = this.onDidChangeViewStateEmitter.event;

private _webview: ExtHostWebview;

constructor(
handle: WebviewPanelHandle,
proxy: MainThreadWebviewsShape,
viewType: string,
title: string,
viewColumn: vscode.ViewColumn,
editorOptions: vscode.WebviewPanelOptions,
webviewOptions: vscode.WebviewOptions
webview: ExtHostWebview
) {
this._handle = handle;
this._proxy = proxy;
this._viewType = viewType;
this._options = editorOptions;
this._viewColumn = viewColumn;
this._webview = new ExtHostWebview(handle, proxy, title, webviewOptions);
this._webview = webview;
}

public dispose() {
Expand Down Expand Up @@ -213,7 +212,8 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
const handle = ExtHostWebviews.webviewHandlePool++ + '';
this._proxy.$createWebviewPanel(handle, viewType, title, typeConverters.fromViewColumn(viewColumn), options, extensionFolderPath);

const panel = new ExtHostWebviewPanel(handle, this._proxy, viewType, title, viewColumn, options, options);
const webview = new ExtHostWebview(handle, this._proxy, title, options);
const panel = new ExtHostWebviewPanel(handle, this._proxy, viewType, viewColumn, options, webview);
this._webviewPanels.set(handle, panel);
return panel;
}
Expand Down Expand Up @@ -269,14 +269,15 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
title: string,
state: any,
position: Position,
options: vscode.WebviewOptions
options: vscode.WebviewOptions & vscode.WebviewPanelOptions
): Thenable<void> {
const serializer = this._serializers.get(viewType);
if (!serializer) {
return TPromise.wrapError(new Error(`No serializer found for '${viewType}'`));
}

const revivedPanel = new ExtHostWebviewPanel(webviewHandle, this._proxy, viewType, title, typeConverters.toViewColumn(position), options as vscode.WebviewPanelOptions, options as vscode.WebviewOptions);
const webview = new ExtHostWebview(webviewHandle, this._proxy, title, options);
const revivedPanel = new ExtHostWebviewPanel(webviewHandle, this._proxy, viewType, typeConverters.toViewColumn(position), options, webview);
this._webviewPanels.set(webviewHandle, revivedPanel);
return serializer.deserializeWebviewPanel(revivedPanel, state);
}
Expand Down

0 comments on commit fbd3a08

Please sign in to comment.