Skip to content

Commit 79d5ce4

Browse files
author
Loïc Mangeonjean
committed
fix: properly inject global style into auxiliary windows
1 parent 9c177b2 commit 79d5ce4

4 files changed

+48
-20
lines changed

vscode-patches/0022-feat-only-apply-style-on-specific-class.patch

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ Date: Mon, 11 Mar 2024 17:51:04 +0100
44
Subject: [PATCH] feat: only apply style on specific class
55

66
---
7-
src/vs/workbench/browser/media/style.css | 182 +++++++++++------------
8-
src/vs/workbench/browser/style.ts | 10 +-
9-
2 files changed, 90 insertions(+), 102 deletions(-)
7+
src/vs/workbench/browser/media/style.css | 182 ++++++++----------
8+
src/vs/workbench/browser/style.ts | 10 +-
9+
.../browser/auxiliaryWindowService.ts | 16 ++
10+
3 files changed, 106 insertions(+), 102 deletions(-)
1011

1112
diff --git a/src/vs/workbench/browser/media/style.css b/src/vs/workbench/browser/media/style.css
1213
index 13ff7948e88..2970ec6e57f 100644
@@ -392,3 +393,30 @@ index 9250ef3f280..b3cde1a1e14 100644
392393
+ collector.addRule(`.monaco-workbench-part { background-color: ${workbenchBackground}; }`);
393394
}
394395
});
396+
diff --git a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
397+
index 53bfb067b4e..6e201931269 100644
398+
--- a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
399+
+++ b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
400+
@@ -429,6 +429,22 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
401+
private applyCSS(auxiliaryWindow: CodeWindow, disposables: DisposableStore) {
402+
mark('code/auxiliaryWindow/willApplyCSS');
403+
404+
+ const globalStyle = new auxiliaryWindow.CSSStyleSheet();
405+
+ globalStyle.insertRule(`body {
406+
+ height: 100%;
407+
+ width: 100%;
408+
+ margin: 0;
409+
+ padding: 0;
410+
+ overflow: hidden;
411+
+ font-size: 11px;
412+
+ user-select: none;
413+
+ -webkit-user-select: none;
414+
+}`);
415+
+ auxiliaryWindow.document.adoptedStyleSheets = [
416+
+ ...auxiliaryWindow.document.adoptedStyleSheets,
417+
+ globalStyle,
418+
+ ];
419+
+
420+
const mapOriginalToClone = new Map<Node /* original */, Node /* clone */>();
421+
422+
const stylesLoaded = new Barrier();

vscode-patches/0024-cleanup-remove-some-checks-and-warnings.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ index 7585cf01c22..b4a16a03b59 100644
5454
if (this.element && this._messagePort) {
5555
this._messagePort.postMessage({ channel, args: data }, transferable);
5656
diff --git a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
57-
index 53bfb067b4e..5f385e07a71 100644
57+
index 6e201931269..15b221bafb8 100644
5858
--- a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
5959
+++ b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
6060
@@ -387,13 +387,6 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili

vscode-patches/0062-feat-support-adoptedStyleSheets-for-aux-windows.patch

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Date: Fri, 9 May 2025 19:46:58 +0200
44
Subject: [PATCH] feat: support adoptedStyleSheets for aux windows
55

66
---
7-
.../auxiliaryWindow/browser/auxiliaryWindowService.ts | 10 +++++++++-
8-
1 file changed, 9 insertions(+), 1 deletion(-)
7+
.../auxiliaryWindow/browser/auxiliaryWindowService.ts | 10 ++++++++--
8+
1 file changed, 8 insertions(+), 2 deletions(-)
99

1010
diff --git a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
11-
index 5f385e07a71..c91907ed1e3 100644
11+
index 15b221bafb8..3adc42984d0 100644
1212
--- a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
1313
+++ b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
1414
@@ -5,7 +5,7 @@
@@ -20,18 +20,18 @@ index 5f385e07a71..c91907ed1e3 100644
2020
import { CodeWindow, ensureCodeWindow, mainWindow } from '../../../../base/browser/window.js';
2121
import { coalesce } from '../../../../base/common/arrays.js';
2222
import { Barrier } from '../../../../base/common/async.js';
23-
@@ -422,6 +422,14 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
24-
private applyCSS(auxiliaryWindow: CodeWindow, disposables: DisposableStore) {
25-
mark('code/auxiliaryWindow/willApplyCSS');
23+
@@ -436,7 +436,13 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
24+
auxiliaryWindow.document.adoptedStyleSheets = [
25+
...auxiliaryWindow.document.adoptedStyleSheets,
26+
globalStyle,
27+
- ];
28+
+ ...(shadowRootContainer ?? mainWindow.document).adoptedStyleSheets.map(ss => {
29+
+ const newss = new auxiliaryWindow.CSSStyleSheet();
30+
+ for (const rule of ss.cssRules) {
31+
+ newss.insertRule(rule.cssText);
32+
+ }
33+
+ return newss;
34+
+ })];
2635

27-
+ auxiliaryWindow.document.adoptedStyleSheets = [...auxiliaryWindow.document.adoptedStyleSheets, ...(shadowRootContainer ?? mainWindow.document).adoptedStyleSheets.map(ss => {
28-
+ const newss = new auxiliaryWindow.CSSStyleSheet();
29-
+ for (const rule of ss.cssRules) {
30-
+ newss.insertRule(rule.cssText);
31-
+ }
32-
+ return newss;
33-
+ })];
34-
+
3536
const mapOriginalToClone = new Map<Node /* original */, Node /* clone */>();
3637

37-
const stylesLoaded = new Barrier();

vscode-patches/0071-fix-close-auxiliary-window-when-the-context-is-unloa.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Subject: [PATCH] fix: close auxiliary window when the context is unloaded
88
1 file changed, 6 insertions(+)
99

1010
diff --git a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
11-
index c91907ed1e3..0e9a11a29fc 100644
11+
index 3adc42984d0..412c22ccf9e 100644
1212
--- a/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
1313
+++ b/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.ts
1414
@@ -154,6 +154,12 @@ export class AuxiliaryWindow extends BaseWindow implements IAuxiliaryWindow {

0 commit comments

Comments
 (0)