Skip to content

Commit 6afa800

Browse files
authored
aux window - fix web (fix microsoft#199836) (microsoft#199841)
aux window - fix web (microsoft#199836)
1 parent 0df4747 commit 6afa800

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/vs/base/browser/dom.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ export function getComputedStyle(el: HTMLElement): CSSStyleDeclaration {
444444
return getWindow(el).getComputedStyle(el, null);
445445
}
446446

447-
export function getClientArea(element: HTMLElement): Dimension {
448-
const elDocument = element.ownerDocument;
449-
const elWindow = elDocument.defaultView?.window;
447+
export function getClientArea(element: HTMLElement, fallback?: HTMLElement): Dimension {
448+
const elWindow = getWindow(element);
449+
const elDocument = elWindow.document;
450450

451451
// Try with DOM clientWidth / clientHeight
452452
if (element !== elDocument.body) {
@@ -473,6 +473,10 @@ export function getClientArea(element: HTMLElement): Dimension {
473473
return new Dimension(elDocument.documentElement.clientWidth, elDocument.documentElement.clientHeight);
474474
}
475475

476+
if (fallback) {
477+
return getClientArea(fallback);
478+
}
479+
476480
throw new Error('Unable to figure out browser width and height');
477481
}
478482

src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class AuxiliaryWindow extends BaseWindow implements IAuxiliaryWindow {
8383
}));
8484

8585
this._register(addDisposableListener(this.window, EventType.RESIZE, () => {
86-
const dimension = getClientArea(this.window.document.body);
86+
const dimension = getClientArea(this.window.document.body, this.container);
8787
position(this.container, 0, 0, 0, 0, 'relative');
8888
size(this.container, dimension.width, dimension.height);
8989

@@ -116,7 +116,7 @@ export class AuxiliaryWindow extends BaseWindow implements IAuxiliaryWindow {
116116
}
117117

118118
layout(): void {
119-
this._onDidLayout.fire(getClientArea(this.window.document.body));
119+
this._onDidLayout.fire(getClientArea(this.window.document.body, this.container));
120120
}
121121

122122
override dispose(): void {

0 commit comments

Comments
 (0)