Skip to content

Commit

Permalink
Prefer using layout dimensions for sizing webview
Browse files Browse the repository at this point in the history
Fixes #80077
  • Loading branch information
mjbvz committed Aug 29, 2019
1 parent 58e6e86 commit 3fd4410
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/vs/workbench/contrib/webview/browser/webviewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export class WebviewEditor extends BaseEditor {
this.withWebview(webview => webview.reload());
}

public layout(_dimension: DOM.Dimension): void {
public layout(dimension: DOM.Dimension): void {
if (this.input && this.input instanceof WebviewEditorInput) {
this.synchronizeWebviewContainerDimensions(this.input.webview);
this.synchronizeWebviewContainerDimensions(this.input.webview, dimension);
this.input.webview.layout();
}
}
Expand Down Expand Up @@ -170,17 +170,16 @@ export class WebviewEditor extends BaseEditor {
this.trackFocus(input.webview);
}

private synchronizeWebviewContainerDimensions(webview: WebviewEditorOverlay) {
private synchronizeWebviewContainerDimensions(webview: WebviewEditorOverlay, dimension?: DOM.Dimension) {
const webviewContainer = webview.container;
if (webviewContainer && webviewContainer.parentElement && this._editorFrame) {
const frameRect = this._editorFrame.getBoundingClientRect();
const containerRect = webviewContainer.parentElement.getBoundingClientRect();

webviewContainer.style.position = 'absolute';
webviewContainer.style.top = `${frameRect.top - containerRect.top}px`;
webviewContainer.style.left = `${frameRect.left - containerRect.left}px`;
webviewContainer.style.width = `${frameRect.width}px`;
webviewContainer.style.height = `${frameRect.height}px`;
webviewContainer.style.width = `${dimension ? dimension.width : frameRect.width}px`;
webviewContainer.style.height = `${dimension ? dimension.height : frameRect.height}px`;
}
}

Expand Down

0 comments on commit 3fd4410

Please sign in to comment.