mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
* Reduce use of explicit `any` type (#274723) * fix ci
This commit is contained in:
@@ -7,6 +7,14 @@ import { getWindowId, onDidUnregisterWindow } from './dom.js';
|
||||
import { Emitter, Event } from '../common/event.js';
|
||||
import { Disposable, markAsSingleton } from '../common/lifecycle.js';
|
||||
|
||||
type BackingStoreContext = CanvasRenderingContext2D & {
|
||||
webkitBackingStorePixelRatio?: number;
|
||||
mozBackingStorePixelRatio?: number;
|
||||
msBackingStorePixelRatio?: number;
|
||||
oBackingStorePixelRatio?: number;
|
||||
backingStorePixelRatio?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio#monitoring_screen_resolution_or_zoom_level_changes
|
||||
*/
|
||||
@@ -67,13 +75,13 @@ class PixelRatioMonitorImpl extends Disposable implements IPixelRatioMonitor {
|
||||
}
|
||||
|
||||
private _getPixelRatio(targetWindow: Window): number {
|
||||
const ctx: any = document.createElement('canvas').getContext('2d');
|
||||
const ctx = document.createElement('canvas').getContext('2d') as BackingStoreContext | null;
|
||||
const dpr = targetWindow.devicePixelRatio || 1;
|
||||
const bsr = ctx.webkitBackingStorePixelRatio ||
|
||||
ctx.mozBackingStorePixelRatio ||
|
||||
ctx.msBackingStorePixelRatio ||
|
||||
ctx.oBackingStorePixelRatio ||
|
||||
ctx.backingStorePixelRatio || 1;
|
||||
const bsr = ctx?.webkitBackingStorePixelRatio ||
|
||||
ctx?.mozBackingStorePixelRatio ||
|
||||
ctx?.msBackingStorePixelRatio ||
|
||||
ctx?.oBackingStorePixelRatio ||
|
||||
ctx?.backingStorePixelRatio || 1;
|
||||
return dpr / bsr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user