fix: viewport.deviceScaleFactor can be set to system default (#9911)

This commit is contained in:
Nikolay Vitkov 2023-03-24 10:56:52 +01:00 committed by GitHub
parent c09b1b6948
commit 022c909326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -17,3 +17,7 @@ interface Viewport {
#### Default value: #### Default value:
1 1
## Remarks
Setting this value to `0` will set the deviceScaleFactor to the system default.

View File

@ -34,7 +34,7 @@ export class EmulationManager {
const mobile = viewport.isMobile || false; const mobile = viewport.isMobile || false;
const width = viewport.width; const width = viewport.width;
const height = viewport.height; const height = viewport.height;
const deviceScaleFactor = viewport.deviceScaleFactor || 1; const deviceScaleFactor = viewport.deviceScaleFactor ?? 1;
const screenOrientation: Protocol.Emulation.ScreenOrientation = const screenOrientation: Protocol.Emulation.ScreenOrientation =
viewport.isLandscape viewport.isLandscape
? {angle: 90, type: 'landscapePrimary'} ? {angle: 90, type: 'landscapePrimary'}

View File

@ -30,6 +30,10 @@ export interface Viewport {
/** /**
* Specify device scale factor. * Specify device scale factor.
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info. * See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info.
*
* @remarks
* Setting this value to `0` will set the deviceScaleFactor to the system default.
*
* @defaultValue 1 * @defaultValue 1
*/ */
deviceScaleFactor?: number; deviceScaleFactor?: number;