Skip to content

Commit b4d9140

Browse files
authored
Revert "Fix theme not being synchronized with external windows on firefox" (#260252)
Revert "Fix theme not being synchronized with external windows on firefox (#2…" This reverts commit 5a03ce4.
1 parent d5e0905 commit b4d9140

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

src/vs/base/browser/domStylesheets.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { DisposableStore, toDisposable, IDisposable } from '../common/lifecycle.js';
77
import { autorun, IObservable } from '../common/observable.js';
8-
import { isFirefox } from './browser.js';
98
import { getWindows, sharedMutationObserver } from './dom.js';
109
import { mainWindow } from './window.js';
1110

@@ -98,15 +97,7 @@ function cloneGlobalStyleSheet(globalStylesheet: HTMLStyleElement, globalStylesh
9897
clone.sheet?.insertRule(rule.cssText, clone.sheet?.cssRules.length);
9998
}
10099

101-
let observeInit: MutationObserverInit = { childList: true };
102-
if (isFirefox) {
103-
// Firefox doesn't support observing style tag contents
104-
// As a workaround, also observe the data-version attribute
105-
// that is updated when the content is updated
106-
observeInit = { ...observeInit, attributes: true, attributeFilter: ['data-version'] };
107-
}
108-
109-
disposables.add(sharedMutationObserver.observe(globalStylesheet, disposables, observeInit)(() => {
100+
disposables.add(sharedMutationObserver.observe(globalStylesheet, disposables, { childList: true })(() => {
110101
clone.textContent = globalStylesheet.textContent;
111102
}));
112103

src/vs/workbench/services/themes/browser/workbenchThemeService.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { updateColorThemeConfigurationSchemas, updateFileIconThemeConfigurationS
3333
import { ProductIconThemeData, DEFAULT_PRODUCT_ICON_THEME_ID } from './productIconThemeData.js';
3434
import { registerProductIconThemeSchemas } from '../common/productIconThemeSchema.js';
3535
import { ILogService } from '../../../../platform/log/common/log.js';
36-
import { isFirefox, isWeb } from '../../../../base/common/platform.js';
36+
import { isWeb } from '../../../../base/common/platform.js';
3737
import { ColorScheme, ThemeTypeSelector } from '../../../../platform/theme/common/theme.js';
3838
import { IHostColorSchemeService } from '../common/hostColorSchemeService.js';
3939
import { RunOnceScheduler, Sequencer } from '../../../../base/common/async.js';
@@ -42,7 +42,6 @@ import { getIconsStyleSheet } from '../../../../platform/theme/browser/iconsStyl
4242
import { asCssVariableName, getColorRegistry } from '../../../../platform/theme/common/colorRegistry.js';
4343
import { ILanguageService } from '../../../../editor/common/languages/language.js';
4444
import { mainWindow } from '../../../../base/browser/window.js';
45-
import { generateUuid } from '../../../../base/common/uuid.js';
4645

4746
// implementation
4847

@@ -794,21 +793,13 @@ class ThemeFileWatcher {
794793
}
795794

796795
function _applyRules(styleSheetContent: string, rulesClassName: string) {
797-
let themeStyle = mainWindow.document.head.getElementsByClassName(rulesClassName).item(0);
798-
if (!themeStyle) {
799-
themeStyle = createStyleSheet();
800-
themeStyle.className = rulesClassName;
801-
}
802-
803-
if (themeStyle.textContent !== styleSheetContent) {
804-
themeStyle.textContent = styleSheetContent;
805-
806-
if (isFirefox) {
807-
// Firefox doesn't support observing style tag contents
808-
// As a workaround, also update the data-version attribute
809-
// when it changes so it can be observed
810-
themeStyle.setAttribute('data-version', generateUuid());
811-
}
796+
const themeStyles = mainWindow.document.head.getElementsByClassName(rulesClassName);
797+
if (themeStyles.length === 0) {
798+
const elStyle = createStyleSheet();
799+
elStyle.className = rulesClassName;
800+
elStyle.textContent = styleSheetContent;
801+
} else {
802+
(<HTMLStyleElement>themeStyles[0]).textContent = styleSheetContent;
812803
}
813804
}
814805

0 commit comments

Comments
 (0)