提交 2e8b1458 编写于 作者: B Benjamin Pasero

perf - do not access zoom level when DOM nodes have been created

Saw this showing up as triggering a layout in the browser before and we know for a fact that the zoom level cannot change during startup.
上级 a4503c25
......@@ -11,7 +11,6 @@ import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { webFrame } from 'vs/base/parts/sandbox/electron-sandbox/globals';
import { assign } from 'vs/base/common/objects';
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-browser/issue';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
......@@ -49,7 +48,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
};
});
const theme = this.themeService.getColorTheme();
const issueReporterData: IssueReporterData = assign({
const issueReporterData: IssueReporterData = Object.assign({
styles: getIssueReporterStyles(theme),
zoomLevel: webFrame.getZoomLevel(),
enabledExtensions: extensionData,
......
......@@ -230,10 +230,10 @@ export class NativeWindow extends Disposable {
});
// Zoom level changes
this.updateWindowZoomLevel();
this.updateWindowZoomLevel(false);
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('window.zoomLevel')) {
this.updateWindowZoomLevel();
this.updateWindowZoomLevel(true);
} else if (e.affectsConfiguration('keyboard.touchbar.enabled') || e.affectsConfiguration('keyboard.touchbar.ignored')) {
this.updateTouchbarMenu();
}
......@@ -326,28 +326,28 @@ export class NativeWindow extends Disposable {
}
}
private updateWindowZoomLevel(): void {
const windowConfig: IWindowsConfiguration = this.configurationService.getValue<IWindowsConfiguration>();
private updateWindowZoomLevel(fromEvent: boolean): void {
const windowConfig = this.configurationService.getValue<IWindowsConfiguration>();
let newZoomLevel = 0;
let configuredZoomLevel = 0;
if (windowConfig.window && typeof windowConfig.window.zoomLevel === 'number') {
newZoomLevel = windowConfig.window.zoomLevel;
configuredZoomLevel = windowConfig.window.zoomLevel;
// Leave early if the configured zoom level did not change (https://github.com/Microsoft/vscode/issues/1536)
if (this.previousConfiguredZoomLevel === newZoomLevel) {
if (this.previousConfiguredZoomLevel === configuredZoomLevel) {
return;
}
this.previousConfiguredZoomLevel = newZoomLevel;
this.previousConfiguredZoomLevel = configuredZoomLevel;
}
if (webFrame.getZoomLevel() !== newZoomLevel) {
webFrame.setZoomLevel(newZoomLevel);
if (fromEvent && webFrame.getZoomLevel() !== configuredZoomLevel) {
webFrame.setZoomLevel(configuredZoomLevel);
browser.setZoomFactor(webFrame.getZoomFactor());
// See https://github.com/Microsoft/vscode/issues/26151
// Cannot be trusted because the webFrame might take some time
// until it really applies the new zoom level
browser.setZoomLevel(webFrame.getZoomLevel(), /*isTrusted*/false);
// See https://github.com/Microsoft/vscode/issues/26151
browser.setZoomLevel(webFrame.getZoomLevel(), false /* isTrusted */);
}
}
......
......@@ -65,10 +65,10 @@ export abstract class BaseZoomAction extends Action {
const applyZoom = () => {
webFrame.setZoomLevel(level);
browser.setZoomFactor(webFrame.getZoomFactor());
// See https://github.com/Microsoft/vscode/issues/26151
// Cannot be trusted because the webFrame might take some time
// until it really applies the new zoom level
browser.setZoomLevel(webFrame.getZoomLevel(), /*isTrusted*/false);
// See https://github.com/Microsoft/vscode/issues/26151
browser.setZoomLevel(webFrame.getZoomLevel(), false /* isTrusted */);
};
await this.configurationService.updateValue(BaseZoomAction.SETTING_KEY, level);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册