chrome-devtools-frontend 1.0.929965 → 1.0.930993
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/gni/devtools_grd_files.gni +2 -1
- package/front_end/core/host/InspectorFrontendHost.ts +8 -1
- package/front_end/core/host/InspectorFrontendHostAPI.ts +12 -0
- package/front_end/core/i18n/locales/en-US.json +3 -0
- package/front_end/core/i18n/locales/en-XL.json +3 -0
- package/front_end/core/protocol_client/InspectorBackend.ts +71 -71
- package/front_end/core/sdk/NetworkManager.ts +6 -2
- package/front_end/devtools_compatibility.js +8 -0
- package/front_end/legacy_test_runner/sources_test_runner/DebuggerTestRunner.js +2 -2
- package/front_end/legacy_test_runner/test_runner/TestRunner.js +2 -3
- package/front_end/models/bindings/BreakpointManager.ts +158 -154
- package/front_end/models/bindings/CSSWorkspaceBinding.ts +64 -56
- package/front_end/models/bindings/CompilerScriptMapping.ts +70 -70
- package/front_end/models/bindings/ContentProviderBasedProject.ts +20 -20
- package/front_end/models/bindings/DebuggerLanguagePlugins.ts +132 -132
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +73 -72
- package/front_end/models/bindings/DefaultScriptMapping.ts +22 -22
- package/front_end/models/bindings/FileUtils.ts +81 -81
- package/front_end/models/bindings/IgnoreListManager.ts +17 -17
- package/front_end/models/bindings/LiveLocation.ts +21 -21
- package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +28 -28
- package/front_end/models/bindings/ResourceMapping.ts +50 -50
- package/front_end/models/bindings/ResourceScriptMapping.ts +71 -71
- package/front_end/models/bindings/SASSSourceMapping.ts +32 -32
- package/front_end/models/bindings/StylesSourceMapping.ts +57 -57
- package/front_end/models/bindings/TempFile.ts +34 -34
- package/front_end/models/emulation/DeviceModeModel.ts +208 -203
- package/front_end/models/emulation/EmulatedDevices.ts +34 -34
- package/front_end/panels/console/ConsoleView.ts +2 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +3 -3
- package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +133 -133
- package/front_end/panels/css_overview/CSSOverviewModel.ts +16 -16
- package/front_end/panels/css_overview/CSSOverviewPanel.ts +77 -77
- package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +5 -5
- package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +4 -4
- package/front_end/panels/elements/ElementsTreeElement.ts +6 -10
- package/front_end/panels/elements/ElementsTreeOutline.ts +3 -1
- package/front_end/panels/elements/components/LayoutPane.ts +6 -0
- package/front_end/panels/elements/elementsPanel.css +0 -1
- package/front_end/panels/elements/elementsTreeOutline.css +0 -4
- package/front_end/panels/lighthouse/LighthouseController.ts +18 -9
- package/front_end/panels/lighthouse/LighthousePanel.ts +2 -2
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +7 -2
- package/front_end/panels/network/BlockedURLsPane.ts +8 -5
- package/front_end/panels/network/blockedURLsPane.css +0 -1
- package/front_end/panels/search/SearchView.ts +0 -2
- package/front_end/panels/sources/BreakpointEditDialog.ts +98 -81
- package/front_end/panels/sources/DebuggerPlugin.ts +15 -14
- package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +18 -2
- package/front_end/ui/components/text_editor/config.ts +6 -0
- package/front_end/ui/components/text_editor/cursor_tooltip.ts +70 -0
- package/front_end/ui/components/text_editor/javascript.ts +590 -0
- package/front_end/ui/components/text_editor/text_editor.ts +1 -0
- package/front_end/ui/components/text_editor/theme.ts +11 -0
- package/front_end/ui/components/tree_outline/TreeOutline.ts +3 -1
- package/front_end/ui/legacy/ARIAUtils.ts +24 -8
- package/front_end/ui/legacy/components/text_editor/cmdevtools.css +1 -0
- package/front_end/ui/legacy/components/text_editor/text_editor-legacy.ts +0 -3
- package/front_end/ui/legacy/components/text_editor/text_editor.ts +0 -2
- package/package.json +1 -1
- package/scripts/migration/class-fields/migrate.js +15 -2
- package/scripts/migration/class-fields/migrate.sh +10 -0
- package/front_end/ui/legacy/components/text_editor/SyntaxHighlighter.ts +0 -62
|
@@ -73,96 +73,96 @@ let deviceModeModelInstance: DeviceModeModel;
|
|
|
73
73
|
|
|
74
74
|
export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTypes> implements
|
|
75
75
|
SDK.TargetManager.SDKModelObserver<SDK.EmulationModel.EmulationModel> {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
76
|
+
#screenRectInternal: Rect;
|
|
77
|
+
#visiblePageRectInternal: Rect;
|
|
78
|
+
#availableSize: UI.Geometry.Size;
|
|
79
|
+
#preferredSize: UI.Geometry.Size;
|
|
80
|
+
#initialized: boolean;
|
|
81
|
+
#appliedDeviceSizeInternal: UI.Geometry.Size;
|
|
82
|
+
#appliedDeviceScaleFactorInternal: number;
|
|
83
|
+
#appliedUserAgentTypeInternal: UA;
|
|
84
|
+
readonly #experimentDualScreenSupport: boolean;
|
|
85
|
+
readonly #webPlatformExperimentalFeaturesEnabledInternal: boolean;
|
|
86
|
+
readonly #scaleSettingInternal: Common.Settings.Setting<number>;
|
|
87
|
+
#scaleInternal: number;
|
|
88
|
+
#widthSetting: Common.Settings.Setting<number>;
|
|
89
|
+
#heightSetting: Common.Settings.Setting<number>;
|
|
90
|
+
#uaSettingInternal: Common.Settings.Setting<UA>;
|
|
91
|
+
readonly #deviceScaleFactorSettingInternal: Common.Settings.Setting<number>;
|
|
92
|
+
readonly #deviceOutlineSettingInternal: Common.Settings.Setting<boolean>;
|
|
93
|
+
readonly #toolbarControlsEnabledSettingInternal: Common.Settings.Setting<boolean>;
|
|
94
|
+
#typeInternal: Type;
|
|
95
|
+
#deviceInternal: EmulatedDevice|null;
|
|
96
|
+
#modeInternal: Mode|null;
|
|
97
|
+
#fitScaleInternal: number;
|
|
98
|
+
#touchEnabled: boolean;
|
|
99
|
+
#touchMobile: boolean;
|
|
100
|
+
#emulationModel: SDK.EmulationModel.EmulationModel|null;
|
|
101
|
+
#onModelAvailable: (() => void)|null;
|
|
102
|
+
#emulatedPageSize?: UI.Geometry.Size;
|
|
103
|
+
#outlineRectInternal?: Rect;
|
|
104
104
|
|
|
105
105
|
private constructor() {
|
|
106
106
|
super();
|
|
107
|
-
this
|
|
108
|
-
this
|
|
109
|
-
this
|
|
110
|
-
this
|
|
111
|
-
this
|
|
112
|
-
this
|
|
113
|
-
this
|
|
114
|
-
this
|
|
115
|
-
this
|
|
116
|
-
this
|
|
117
|
-
|
|
118
|
-
this
|
|
107
|
+
this.#screenRectInternal = new Rect(0, 0, 1, 1);
|
|
108
|
+
this.#visiblePageRectInternal = new Rect(0, 0, 1, 1);
|
|
109
|
+
this.#availableSize = new UI.Geometry.Size(1, 1);
|
|
110
|
+
this.#preferredSize = new UI.Geometry.Size(1, 1);
|
|
111
|
+
this.#initialized = false;
|
|
112
|
+
this.#appliedDeviceSizeInternal = new UI.Geometry.Size(1, 1);
|
|
113
|
+
this.#appliedDeviceScaleFactorInternal = window.devicePixelRatio;
|
|
114
|
+
this.#appliedUserAgentTypeInternal = UA.Desktop;
|
|
115
|
+
this.#experimentDualScreenSupport = Root.Runtime.experiments.isEnabled('dualScreenSupport');
|
|
116
|
+
this.#webPlatformExperimentalFeaturesEnabledInternal = Boolean(eval('"segments" in window.visualViewport'));
|
|
117
|
+
|
|
118
|
+
this.#scaleSettingInternal = Common.Settings.Settings.instance().createSetting('emulation.deviceScale', 1);
|
|
119
119
|
// We've used to allow zero before.
|
|
120
|
-
if (!this
|
|
121
|
-
this
|
|
120
|
+
if (!this.#scaleSettingInternal.get()) {
|
|
121
|
+
this.#scaleSettingInternal.set(1);
|
|
122
122
|
}
|
|
123
|
-
this
|
|
124
|
-
this
|
|
123
|
+
this.#scaleSettingInternal.addChangeListener(this.scaleSettingChanged, this);
|
|
124
|
+
this.#scaleInternal = 1;
|
|
125
125
|
|
|
126
|
-
this
|
|
127
|
-
if (this
|
|
128
|
-
this
|
|
126
|
+
this.#widthSetting = Common.Settings.Settings.instance().createSetting('emulation.deviceWidth', 400);
|
|
127
|
+
if (this.#widthSetting.get() < MinDeviceSize) {
|
|
128
|
+
this.#widthSetting.set(MinDeviceSize);
|
|
129
129
|
}
|
|
130
|
-
if (this
|
|
131
|
-
this
|
|
130
|
+
if (this.#widthSetting.get() > MaxDeviceSize) {
|
|
131
|
+
this.#widthSetting.set(MaxDeviceSize);
|
|
132
132
|
}
|
|
133
|
-
this
|
|
133
|
+
this.#widthSetting.addChangeListener(this.widthSettingChanged, this);
|
|
134
134
|
|
|
135
|
-
this
|
|
136
|
-
if (this
|
|
137
|
-
this
|
|
135
|
+
this.#heightSetting = Common.Settings.Settings.instance().createSetting('emulation.deviceHeight', 0);
|
|
136
|
+
if (this.#heightSetting.get() && this.#heightSetting.get() < MinDeviceSize) {
|
|
137
|
+
this.#heightSetting.set(MinDeviceSize);
|
|
138
138
|
}
|
|
139
|
-
if (this
|
|
140
|
-
this
|
|
139
|
+
if (this.#heightSetting.get() > MaxDeviceSize) {
|
|
140
|
+
this.#heightSetting.set(MaxDeviceSize);
|
|
141
141
|
}
|
|
142
|
-
this
|
|
142
|
+
this.#heightSetting.addChangeListener(this.heightSettingChanged, this);
|
|
143
143
|
|
|
144
|
-
this
|
|
145
|
-
this
|
|
146
|
-
this
|
|
144
|
+
this.#uaSettingInternal = Common.Settings.Settings.instance().createSetting('emulation.deviceUA', UA.Mobile);
|
|
145
|
+
this.#uaSettingInternal.addChangeListener(this.uaSettingChanged, this);
|
|
146
|
+
this.#deviceScaleFactorSettingInternal =
|
|
147
147
|
Common.Settings.Settings.instance().createSetting('emulation.deviceScaleFactor', 0);
|
|
148
|
-
this
|
|
148
|
+
this.#deviceScaleFactorSettingInternal.addChangeListener(this.deviceScaleFactorSettingChanged, this);
|
|
149
149
|
|
|
150
|
-
this
|
|
150
|
+
this.#deviceOutlineSettingInternal =
|
|
151
151
|
Common.Settings.Settings.instance().moduleSetting('emulation.showDeviceOutline');
|
|
152
|
-
this
|
|
152
|
+
this.#deviceOutlineSettingInternal.addChangeListener(this.deviceOutlineSettingChanged, this);
|
|
153
153
|
|
|
154
|
-
this
|
|
154
|
+
this.#toolbarControlsEnabledSettingInternal = Common.Settings.Settings.instance().createSetting(
|
|
155
155
|
'emulation.toolbarControlsEnabled', true, Common.Settings.SettingStorageType.Session);
|
|
156
156
|
|
|
157
|
-
this
|
|
158
|
-
this
|
|
159
|
-
this
|
|
160
|
-
this
|
|
161
|
-
this
|
|
162
|
-
this
|
|
157
|
+
this.#typeInternal = Type.None;
|
|
158
|
+
this.#deviceInternal = null;
|
|
159
|
+
this.#modeInternal = null;
|
|
160
|
+
this.#fitScaleInternal = 1;
|
|
161
|
+
this.#touchEnabled = false;
|
|
162
|
+
this.#touchMobile = false;
|
|
163
163
|
|
|
164
|
-
this
|
|
165
|
-
this
|
|
164
|
+
this.#emulationModel = null;
|
|
165
|
+
this.#onModelAvailable = null;
|
|
166
166
|
SDK.TargetManager.TargetManager.instance().observeModels(SDK.EmulationModel.EmulationModel, this);
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -239,31 +239,35 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
239
239
|
return {valid, errorMessage};
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
get scaleSettingInternal(): Common.Settings.Setting<number> {
|
|
243
|
+
return this.#scaleSettingInternal;
|
|
244
|
+
}
|
|
245
|
+
|
|
242
246
|
setAvailableSize(availableSize: UI.Geometry.Size, preferredSize: UI.Geometry.Size): void {
|
|
243
|
-
this
|
|
244
|
-
this
|
|
245
|
-
this
|
|
247
|
+
this.#availableSize = availableSize;
|
|
248
|
+
this.#preferredSize = preferredSize;
|
|
249
|
+
this.#initialized = true;
|
|
246
250
|
this.calculateAndEmulate(false);
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
emulate(type: Type, device: EmulatedDevice|null, mode: Mode|null, scale?: number): void {
|
|
250
254
|
const resetPageScaleFactor =
|
|
251
|
-
this
|
|
252
|
-
this
|
|
255
|
+
this.#typeInternal !== type || this.#deviceInternal !== device || this.#modeInternal !== mode;
|
|
256
|
+
this.#typeInternal = type;
|
|
253
257
|
|
|
254
258
|
if (type === Type.Device && device && mode) {
|
|
255
259
|
console.assert(Boolean(device) && Boolean(mode), 'Must pass device and mode for device emulation');
|
|
256
|
-
this
|
|
257
|
-
this
|
|
258
|
-
if (this
|
|
260
|
+
this.#modeInternal = mode;
|
|
261
|
+
this.#deviceInternal = device;
|
|
262
|
+
if (this.#initialized) {
|
|
259
263
|
const orientation = device.orientationByName(mode.orientation);
|
|
260
|
-
this
|
|
264
|
+
this.#scaleSettingInternal.set(
|
|
261
265
|
scale ||
|
|
262
266
|
this.calculateFitScale(orientation.width, orientation.height, this.currentOutline(), this.currentInsets()));
|
|
263
267
|
}
|
|
264
268
|
} else {
|
|
265
|
-
this
|
|
266
|
-
this
|
|
269
|
+
this.#deviceInternal = null;
|
|
270
|
+
this.#modeInternal = null;
|
|
267
271
|
}
|
|
268
272
|
|
|
269
273
|
if (type !== Type.None) {
|
|
@@ -275,13 +279,13 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
275
279
|
setWidth(width: number): void {
|
|
276
280
|
const max = Math.min(MaxDeviceSize, this.preferredScaledWidth());
|
|
277
281
|
width = Math.max(Math.min(width, max), 1);
|
|
278
|
-
this
|
|
282
|
+
this.#widthSetting.set(width);
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
setWidthAndScaleToFit(width: number): void {
|
|
282
286
|
width = Math.max(Math.min(width, MaxDeviceSize), 1);
|
|
283
|
-
this
|
|
284
|
-
this
|
|
287
|
+
this.#scaleSettingInternal.set(this.calculateFitScale(width, this.#heightSetting.get()));
|
|
288
|
+
this.#widthSetting.set(width);
|
|
285
289
|
}
|
|
286
290
|
|
|
287
291
|
setHeight(height: number): void {
|
|
@@ -290,85 +294,85 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
290
294
|
if (height === this.preferredScaledHeight()) {
|
|
291
295
|
height = 0;
|
|
292
296
|
}
|
|
293
|
-
this
|
|
297
|
+
this.#heightSetting.set(height);
|
|
294
298
|
}
|
|
295
299
|
|
|
296
300
|
setHeightAndScaleToFit(height: number): void {
|
|
297
301
|
height = Math.max(Math.min(height, MaxDeviceSize), 0);
|
|
298
|
-
this
|
|
299
|
-
this
|
|
302
|
+
this.#scaleSettingInternal.set(this.calculateFitScale(this.#widthSetting.get(), height));
|
|
303
|
+
this.#heightSetting.set(height);
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
setScale(scale: number): void {
|
|
303
|
-
this
|
|
307
|
+
this.#scaleSettingInternal.set(scale);
|
|
304
308
|
}
|
|
305
309
|
|
|
306
310
|
device(): EmulatedDevice|null {
|
|
307
|
-
return this
|
|
311
|
+
return this.#deviceInternal;
|
|
308
312
|
}
|
|
309
313
|
|
|
310
314
|
mode(): Mode|null {
|
|
311
|
-
return this
|
|
315
|
+
return this.#modeInternal;
|
|
312
316
|
}
|
|
313
317
|
|
|
314
318
|
type(): Type {
|
|
315
|
-
return this
|
|
319
|
+
return this.#typeInternal;
|
|
316
320
|
}
|
|
317
321
|
|
|
318
322
|
screenImage(): string {
|
|
319
|
-
return (this
|
|
323
|
+
return (this.#deviceInternal && this.#modeInternal) ? this.#deviceInternal.modeImage(this.#modeInternal) : '';
|
|
320
324
|
}
|
|
321
325
|
|
|
322
326
|
outlineImage(): string {
|
|
323
|
-
return (this
|
|
324
|
-
this
|
|
327
|
+
return (this.#deviceInternal && this.#modeInternal && this.#deviceOutlineSettingInternal.get()) ?
|
|
328
|
+
this.#deviceInternal.outlineImage(this.#modeInternal) :
|
|
325
329
|
'';
|
|
326
330
|
}
|
|
327
331
|
|
|
328
332
|
outlineRect(): Rect|null {
|
|
329
|
-
return this
|
|
333
|
+
return this.#outlineRectInternal || null;
|
|
330
334
|
}
|
|
331
335
|
|
|
332
336
|
screenRect(): Rect {
|
|
333
|
-
return this
|
|
337
|
+
return this.#screenRectInternal;
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
visiblePageRect(): Rect {
|
|
337
|
-
return this
|
|
341
|
+
return this.#visiblePageRectInternal;
|
|
338
342
|
}
|
|
339
343
|
|
|
340
344
|
scale(): number {
|
|
341
|
-
return this
|
|
345
|
+
return this.#scaleInternal;
|
|
342
346
|
}
|
|
343
347
|
|
|
344
348
|
fitScale(): number {
|
|
345
|
-
return this
|
|
349
|
+
return this.#fitScaleInternal;
|
|
346
350
|
}
|
|
347
351
|
|
|
348
352
|
appliedDeviceSize(): UI.Geometry.Size {
|
|
349
|
-
return this
|
|
353
|
+
return this.#appliedDeviceSizeInternal;
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
appliedDeviceScaleFactor(): number {
|
|
353
|
-
return this
|
|
357
|
+
return this.#appliedDeviceScaleFactorInternal;
|
|
354
358
|
}
|
|
355
359
|
|
|
356
360
|
appliedUserAgentType(): UA {
|
|
357
|
-
return this
|
|
361
|
+
return this.#appliedUserAgentTypeInternal;
|
|
358
362
|
}
|
|
359
363
|
|
|
360
364
|
isFullHeight(): boolean {
|
|
361
|
-
return !this
|
|
365
|
+
return !this.#heightSetting.get();
|
|
362
366
|
}
|
|
363
367
|
|
|
364
368
|
private isMobile(): boolean {
|
|
365
|
-
switch (this
|
|
369
|
+
switch (this.#typeInternal) {
|
|
366
370
|
case Type.Device:
|
|
367
|
-
return this
|
|
371
|
+
return this.#deviceInternal ? this.#deviceInternal.mobile() : false;
|
|
368
372
|
case Type.None:
|
|
369
373
|
return false;
|
|
370
374
|
case Type.Responsive:
|
|
371
|
-
return this
|
|
375
|
+
return this.#uaSettingInternal.get() === UA.Mobile || this.#uaSettingInternal.get() === UA.MobileNoTouch;
|
|
372
376
|
}
|
|
373
377
|
return false;
|
|
374
378
|
}
|
|
@@ -378,39 +382,39 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
378
382
|
}
|
|
379
383
|
|
|
380
384
|
scaleSetting(): Common.Settings.Setting<number> {
|
|
381
|
-
return this
|
|
385
|
+
return this.#scaleSettingInternal;
|
|
382
386
|
}
|
|
383
387
|
|
|
384
388
|
uaSetting(): Common.Settings.Setting<UA> {
|
|
385
|
-
return this
|
|
389
|
+
return this.#uaSettingInternal;
|
|
386
390
|
}
|
|
387
391
|
|
|
388
392
|
deviceScaleFactorSetting(): Common.Settings.Setting<number> {
|
|
389
|
-
return this
|
|
393
|
+
return this.#deviceScaleFactorSettingInternal;
|
|
390
394
|
}
|
|
391
395
|
|
|
392
396
|
deviceOutlineSetting(): Common.Settings.Setting<boolean> {
|
|
393
|
-
return this
|
|
397
|
+
return this.#deviceOutlineSettingInternal;
|
|
394
398
|
}
|
|
395
399
|
|
|
396
400
|
toolbarControlsEnabledSetting(): Common.Settings.Setting<boolean> {
|
|
397
|
-
return this
|
|
401
|
+
return this.#toolbarControlsEnabledSettingInternal;
|
|
398
402
|
}
|
|
399
403
|
|
|
400
404
|
reset(): void {
|
|
401
|
-
this
|
|
402
|
-
this
|
|
405
|
+
this.#deviceScaleFactorSettingInternal.set(0);
|
|
406
|
+
this.#scaleSettingInternal.set(1);
|
|
403
407
|
this.setWidth(400);
|
|
404
408
|
this.setHeight(0);
|
|
405
|
-
this
|
|
409
|
+
this.#uaSettingInternal.set(UA.Mobile);
|
|
406
410
|
}
|
|
407
411
|
|
|
408
412
|
modelAdded(emulationModel: SDK.EmulationModel.EmulationModel): void {
|
|
409
|
-
if (!this
|
|
410
|
-
this
|
|
411
|
-
if (this
|
|
412
|
-
const callback = this
|
|
413
|
-
this
|
|
413
|
+
if (!this.#emulationModel && emulationModel.supportsDeviceEmulation()) {
|
|
414
|
+
this.#emulationModel = emulationModel;
|
|
415
|
+
if (this.#onModelAvailable) {
|
|
416
|
+
const callback = this.#onModelAvailable;
|
|
417
|
+
this.#onModelAvailable = null;
|
|
414
418
|
callback();
|
|
415
419
|
}
|
|
416
420
|
const resourceTreeModel = emulationModel.target().model(SDK.ResourceTreeModel.ResourceTreeModel);
|
|
@@ -419,22 +423,22 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
419
423
|
resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameNavigated, this.onFrameChange, this);
|
|
420
424
|
}
|
|
421
425
|
} else {
|
|
422
|
-
emulationModel.emulateTouch(this
|
|
426
|
+
emulationModel.emulateTouch(this.#touchEnabled, this.#touchMobile);
|
|
423
427
|
}
|
|
424
428
|
}
|
|
425
429
|
|
|
426
430
|
modelRemoved(emulationModel: SDK.EmulationModel.EmulationModel): void {
|
|
427
|
-
if (this
|
|
428
|
-
this
|
|
431
|
+
if (this.#emulationModel === emulationModel) {
|
|
432
|
+
this.#emulationModel = null;
|
|
429
433
|
}
|
|
430
434
|
}
|
|
431
435
|
|
|
432
436
|
inspectedURL(): string|null {
|
|
433
|
-
return this
|
|
437
|
+
return this.#emulationModel ? this.#emulationModel.target().inspectedURL() : null;
|
|
434
438
|
}
|
|
435
439
|
|
|
436
440
|
private onFrameChange(): void {
|
|
437
|
-
const overlayModel = this
|
|
441
|
+
const overlayModel = this.#emulationModel ? this.#emulationModel.overlayModel() : null;
|
|
438
442
|
if (!overlayModel) {
|
|
439
443
|
return;
|
|
440
444
|
}
|
|
@@ -467,37 +471,37 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
467
471
|
}
|
|
468
472
|
|
|
469
473
|
private preferredScaledWidth(): number {
|
|
470
|
-
return Math.floor(this
|
|
474
|
+
return Math.floor(this.#preferredSize.width / (this.#scaleSettingInternal.get() || 1));
|
|
471
475
|
}
|
|
472
476
|
|
|
473
477
|
private preferredScaledHeight(): number {
|
|
474
|
-
return Math.floor(this
|
|
478
|
+
return Math.floor(this.#preferredSize.height / (this.#scaleSettingInternal.get() || 1));
|
|
475
479
|
}
|
|
476
480
|
|
|
477
481
|
private currentOutline(): Insets {
|
|
478
482
|
let outline: Insets = new Insets(0, 0, 0, 0);
|
|
479
|
-
if (this
|
|
483
|
+
if (this.#typeInternal !== Type.Device || !this.#deviceInternal || !this.#modeInternal) {
|
|
480
484
|
return outline;
|
|
481
485
|
}
|
|
482
|
-
const orientation = this
|
|
483
|
-
if (this
|
|
486
|
+
const orientation = this.#deviceInternal.orientationByName(this.#modeInternal.orientation);
|
|
487
|
+
if (this.#deviceOutlineSettingInternal.get()) {
|
|
484
488
|
outline = orientation.outlineInsets || outline;
|
|
485
489
|
}
|
|
486
490
|
return outline;
|
|
487
491
|
}
|
|
488
492
|
|
|
489
493
|
private currentInsets(): Insets {
|
|
490
|
-
if (this
|
|
494
|
+
if (this.#typeInternal !== Type.Device || !this.#modeInternal) {
|
|
491
495
|
return new Insets(0, 0, 0, 0);
|
|
492
496
|
}
|
|
493
|
-
return this
|
|
497
|
+
return this.#modeInternal.insets;
|
|
494
498
|
}
|
|
495
499
|
|
|
496
500
|
private getScreenOrientationType(): Protocol.Emulation.ScreenOrientationType {
|
|
497
|
-
if (!this
|
|
501
|
+
if (!this.#modeInternal) {
|
|
498
502
|
throw new Error('Mode required to get orientation type.');
|
|
499
503
|
}
|
|
500
|
-
switch (this
|
|
504
|
+
switch (this.#modeInternal.orientation) {
|
|
501
505
|
case VerticalSpanned:
|
|
502
506
|
case Vertical:
|
|
503
507
|
return Protocol.Emulation.ScreenOrientationType.PortraitPrimary;
|
|
@@ -509,64 +513,65 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
509
513
|
}
|
|
510
514
|
|
|
511
515
|
private calculateAndEmulate(resetPageScaleFactor: boolean): void {
|
|
512
|
-
if (!this
|
|
513
|
-
this
|
|
516
|
+
if (!this.#emulationModel) {
|
|
517
|
+
this.#onModelAvailable = this.calculateAndEmulate.bind(this, resetPageScaleFactor);
|
|
514
518
|
}
|
|
515
519
|
const mobile = this.isMobile();
|
|
516
|
-
const overlayModel = this
|
|
520
|
+
const overlayModel = this.#emulationModel ? this.#emulationModel.overlayModel() : null;
|
|
517
521
|
if (overlayModel) {
|
|
518
522
|
this.showHingeIfApplicable(overlayModel);
|
|
519
523
|
}
|
|
520
|
-
if (this
|
|
521
|
-
const orientation = this
|
|
524
|
+
if (this.#typeInternal === Type.Device && this.#deviceInternal && this.#modeInternal) {
|
|
525
|
+
const orientation = this.#deviceInternal.orientationByName(this.#modeInternal.orientation);
|
|
522
526
|
const outline = this.currentOutline();
|
|
523
527
|
const insets = this.currentInsets();
|
|
524
|
-
this
|
|
528
|
+
this.#fitScaleInternal = this.calculateFitScale(orientation.width, orientation.height, outline, insets);
|
|
525
529
|
if (mobile) {
|
|
526
|
-
this
|
|
530
|
+
this.#appliedUserAgentTypeInternal = this.#deviceInternal.touch() ? UA.Mobile : UA.MobileNoTouch;
|
|
527
531
|
} else {
|
|
528
|
-
this
|
|
532
|
+
this.#appliedUserAgentTypeInternal = this.#deviceInternal.touch() ? UA.DesktopTouch : UA.Desktop;
|
|
529
533
|
}
|
|
530
534
|
this.applyDeviceMetrics(
|
|
531
|
-
new UI.Geometry.Size(orientation.width, orientation.height), insets, outline,
|
|
532
|
-
this.deviceInternal.deviceScaleFactor, mobile,
|
|
533
|
-
this.webPlatformExperimentalFeaturesEnabledInternal);
|
|
534
|
-
this.applyUserAgent(this
|
|
535
|
-
this.applyTouch(this
|
|
536
|
-
} else if (this
|
|
537
|
-
this
|
|
538
|
-
this
|
|
535
|
+
new UI.Geometry.Size(orientation.width, orientation.height), insets, outline,
|
|
536
|
+
this.#scaleSettingInternal.get(), this.#deviceInternal.deviceScaleFactor, mobile,
|
|
537
|
+
this.getScreenOrientationType(), resetPageScaleFactor, this.#webPlatformExperimentalFeaturesEnabledInternal);
|
|
538
|
+
this.applyUserAgent(this.#deviceInternal.userAgent, this.#deviceInternal.userAgentMetadata);
|
|
539
|
+
this.applyTouch(this.#deviceInternal.touch(), mobile);
|
|
540
|
+
} else if (this.#typeInternal === Type.None) {
|
|
541
|
+
this.#fitScaleInternal = this.calculateFitScale(this.#availableSize.width, this.#availableSize.height);
|
|
542
|
+
this.#appliedUserAgentTypeInternal = UA.Desktop;
|
|
539
543
|
this.applyDeviceMetrics(
|
|
540
|
-
this
|
|
544
|
+
this.#availableSize, new Insets(0, 0, 0, 0), new Insets(0, 0, 0, 0), 1, 0, mobile, null,
|
|
545
|
+
resetPageScaleFactor);
|
|
541
546
|
this.applyUserAgent('', null);
|
|
542
547
|
this.applyTouch(false, false);
|
|
543
|
-
} else if (this
|
|
544
|
-
let screenWidth = this
|
|
548
|
+
} else if (this.#typeInternal === Type.Responsive) {
|
|
549
|
+
let screenWidth = this.#widthSetting.get();
|
|
545
550
|
if (!screenWidth || screenWidth > this.preferredScaledWidth()) {
|
|
546
551
|
screenWidth = this.preferredScaledWidth();
|
|
547
552
|
}
|
|
548
|
-
let screenHeight = this
|
|
553
|
+
let screenHeight = this.#heightSetting.get();
|
|
549
554
|
if (!screenHeight || screenHeight > this.preferredScaledHeight()) {
|
|
550
555
|
screenHeight = this.preferredScaledHeight();
|
|
551
556
|
}
|
|
552
557
|
const defaultDeviceScaleFactor = mobile ? defaultMobileScaleFactor : 0;
|
|
553
|
-
this
|
|
554
|
-
this
|
|
558
|
+
this.#fitScaleInternal = this.calculateFitScale(this.#widthSetting.get(), this.#heightSetting.get());
|
|
559
|
+
this.#appliedUserAgentTypeInternal = this.#uaSettingInternal.get();
|
|
555
560
|
this.applyDeviceMetrics(
|
|
556
561
|
new UI.Geometry.Size(screenWidth, screenHeight), new Insets(0, 0, 0, 0), new Insets(0, 0, 0, 0),
|
|
557
|
-
this
|
|
562
|
+
this.#scaleSettingInternal.get(), this.#deviceScaleFactorSettingInternal.get() || defaultDeviceScaleFactor,
|
|
558
563
|
mobile,
|
|
559
564
|
screenHeight >= screenWidth ? Protocol.Emulation.ScreenOrientationType.PortraitPrimary :
|
|
560
565
|
Protocol.Emulation.ScreenOrientationType.LandscapePrimary,
|
|
561
566
|
resetPageScaleFactor);
|
|
562
567
|
this.applyUserAgent(mobile ? defaultMobileUserAgent : '', mobile ? defaultMobileUserAgentMetadata : null);
|
|
563
568
|
this.applyTouch(
|
|
564
|
-
this
|
|
565
|
-
this
|
|
569
|
+
this.#uaSettingInternal.get() === UA.DesktopTouch || this.#uaSettingInternal.get() === UA.Mobile,
|
|
570
|
+
this.#uaSettingInternal.get() === UA.Mobile);
|
|
566
571
|
}
|
|
567
572
|
|
|
568
573
|
if (overlayModel) {
|
|
569
|
-
overlayModel.setShowViewportSizeOnResize(this
|
|
574
|
+
overlayModel.setShowViewportSizeOnResize(this.#typeInternal === Type.None);
|
|
570
575
|
}
|
|
571
576
|
this.dispatchEventToListeners(Events.Updated);
|
|
572
577
|
}
|
|
@@ -577,8 +582,8 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
577
582
|
const insetsWidth = insets ? insets.left + insets.right : 0;
|
|
578
583
|
const insetsHeight = insets ? insets.top + insets.bottom : 0;
|
|
579
584
|
let scale = Math.min(
|
|
580
|
-
screenWidth ? this
|
|
581
|
-
screenHeight ? this
|
|
585
|
+
screenWidth ? this.#preferredSize.width / (screenWidth + outlineWidth) : 1,
|
|
586
|
+
screenHeight ? this.#preferredSize.height / (screenHeight + outlineHeight) : 1);
|
|
582
587
|
scale = Math.min(Math.floor(scale * 100), 100);
|
|
583
588
|
|
|
584
589
|
let sharpScale = scale;
|
|
@@ -599,7 +604,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
599
604
|
}
|
|
600
605
|
|
|
601
606
|
setSizeAndScaleToFit(width: number, height: number): void {
|
|
602
|
-
this
|
|
607
|
+
this.#scaleSettingInternal.set(this.calculateFitScale(width, height));
|
|
603
608
|
this.setWidth(width);
|
|
604
609
|
this.setHeight(height);
|
|
605
610
|
}
|
|
@@ -617,37 +622,37 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
617
622
|
|
|
618
623
|
let pageWidth: 0|number = screenSize.width - insets.left - insets.right;
|
|
619
624
|
let pageHeight: 0|number = screenSize.height - insets.top - insets.bottom;
|
|
620
|
-
this
|
|
625
|
+
this.#emulatedPageSize = new UI.Geometry.Size(pageWidth, pageHeight);
|
|
621
626
|
|
|
622
627
|
const positionX = insets.left;
|
|
623
628
|
const positionY = insets.top;
|
|
624
629
|
const screenOrientationAngle =
|
|
625
630
|
screenOrientation === Protocol.Emulation.ScreenOrientationType.LandscapePrimary ? 90 : 0;
|
|
626
631
|
|
|
627
|
-
this
|
|
628
|
-
this
|
|
629
|
-
this
|
|
630
|
-
Math.max(0, (this
|
|
632
|
+
this.#appliedDeviceSizeInternal = screenSize;
|
|
633
|
+
this.#appliedDeviceScaleFactorInternal = deviceScaleFactor || window.devicePixelRatio;
|
|
634
|
+
this.#screenRectInternal = new Rect(
|
|
635
|
+
Math.max(0, (this.#availableSize.width - screenSize.width * scale) / 2), outline.top * scale,
|
|
631
636
|
screenSize.width * scale, screenSize.height * scale);
|
|
632
|
-
this
|
|
633
|
-
this
|
|
637
|
+
this.#outlineRectInternal = new Rect(
|
|
638
|
+
this.#screenRectInternal.left - outline.left * scale, 0,
|
|
634
639
|
(outline.left + screenSize.width + outline.right) * scale,
|
|
635
640
|
(outline.top + screenSize.height + outline.bottom) * scale);
|
|
636
|
-
this
|
|
641
|
+
this.#visiblePageRectInternal = new Rect(
|
|
637
642
|
positionX * scale, positionY * scale,
|
|
638
|
-
Math.min(pageWidth * scale, this
|
|
639
|
-
Math.min(pageHeight * scale, this
|
|
640
|
-
this
|
|
643
|
+
Math.min(pageWidth * scale, this.#availableSize.width - this.#screenRectInternal.left - positionX * scale),
|
|
644
|
+
Math.min(pageHeight * scale, this.#availableSize.height - this.#screenRectInternal.top - positionY * scale));
|
|
645
|
+
this.#scaleInternal = scale;
|
|
641
646
|
if (!forceMetricsOverride) {
|
|
642
647
|
// When sending displayFeature, we cannot use the optimization below due to backend restrictions.
|
|
643
|
-
if (scale === 1 && this
|
|
644
|
-
this
|
|
648
|
+
if (scale === 1 && this.#availableSize.width >= screenSize.width &&
|
|
649
|
+
this.#availableSize.height >= screenSize.height) {
|
|
645
650
|
// When we have enough space, no page size override is required. This will speed things up and remove lag.
|
|
646
651
|
pageWidth = 0;
|
|
647
652
|
pageHeight = 0;
|
|
648
653
|
}
|
|
649
|
-
if (this
|
|
650
|
-
this
|
|
654
|
+
if (this.#visiblePageRectInternal.width === pageWidth * scale &&
|
|
655
|
+
this.#visiblePageRectInternal.height === pageHeight * scale && Number.isInteger(pageWidth * scale) &&
|
|
651
656
|
Number.isInteger(pageHeight * scale)) {
|
|
652
657
|
// When we only have to apply scale, do not resize the page. This will speed things up and remove lag.
|
|
653
658
|
pageWidth = 0;
|
|
@@ -655,12 +660,12 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
655
660
|
}
|
|
656
661
|
}
|
|
657
662
|
|
|
658
|
-
if (!this
|
|
663
|
+
if (!this.#emulationModel) {
|
|
659
664
|
return;
|
|
660
665
|
}
|
|
661
666
|
|
|
662
667
|
if (resetPageScaleFactor) {
|
|
663
|
-
this
|
|
668
|
+
this.#emulationModel.resetPageScaleFactor();
|
|
664
669
|
}
|
|
665
670
|
if (pageWidth || pageHeight || mobile || deviceScaleFactor || scale !== 1 || screenOrientation ||
|
|
666
671
|
forceMetricsOverride) {
|
|
@@ -685,35 +690,35 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
685
690
|
if (screenOrientation) {
|
|
686
691
|
metrics.screenOrientation = {type: screenOrientation, angle: screenOrientationAngle};
|
|
687
692
|
}
|
|
688
|
-
this
|
|
693
|
+
this.#emulationModel.emulateDevice(metrics);
|
|
689
694
|
} else {
|
|
690
|
-
this
|
|
695
|
+
this.#emulationModel.emulateDevice(null);
|
|
691
696
|
}
|
|
692
697
|
}
|
|
693
698
|
|
|
694
699
|
exitHingeMode(): void {
|
|
695
|
-
const overlayModel = this
|
|
700
|
+
const overlayModel = this.#emulationModel ? this.#emulationModel.overlayModel() : null;
|
|
696
701
|
if (overlayModel) {
|
|
697
702
|
overlayModel.showHingeForDualScreen(null);
|
|
698
703
|
}
|
|
699
704
|
}
|
|
700
705
|
|
|
701
706
|
webPlatformExperimentalFeaturesEnabled(): boolean {
|
|
702
|
-
return this
|
|
707
|
+
return this.#webPlatformExperimentalFeaturesEnabledInternal;
|
|
703
708
|
}
|
|
704
709
|
|
|
705
710
|
shouldReportDisplayFeature(): boolean {
|
|
706
|
-
return this
|
|
711
|
+
return this.#webPlatformExperimentalFeaturesEnabledInternal && this.#experimentDualScreenSupport;
|
|
707
712
|
}
|
|
708
713
|
|
|
709
714
|
async captureScreenshot(fullSize: boolean, clip?: Protocol.Page.Viewport): Promise<string|null> {
|
|
710
715
|
const screenCaptureModel =
|
|
711
|
-
this
|
|
716
|
+
this.#emulationModel ? this.#emulationModel.target().model(SDK.ScreenCaptureModel.ScreenCaptureModel) : null;
|
|
712
717
|
if (!screenCaptureModel) {
|
|
713
718
|
return null;
|
|
714
719
|
}
|
|
715
720
|
|
|
716
|
-
const overlayModel = this
|
|
721
|
+
const overlayModel = this.#emulationModel ? this.#emulationModel.overlayModel() : null;
|
|
717
722
|
if (overlayModel) {
|
|
718
723
|
overlayModel.setShowViewportSizeOnResize(false);
|
|
719
724
|
}
|
|
@@ -738,9 +743,9 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
738
743
|
deviceScaleFactor: 0,
|
|
739
744
|
mobile: false,
|
|
740
745
|
};
|
|
741
|
-
if (fullSize && this
|
|
742
|
-
if (this
|
|
743
|
-
const orientation = this
|
|
746
|
+
if (fullSize && this.#emulationModel) {
|
|
747
|
+
if (this.#deviceInternal && this.#modeInternal) {
|
|
748
|
+
const orientation = this.#deviceInternal.orientationByName(this.#modeInternal.orientation);
|
|
744
749
|
deviceMetrics.width = orientation.width;
|
|
745
750
|
deviceMetrics.height = orientation.height;
|
|
746
751
|
const dispFeature = this.getDisplayFeature();
|
|
@@ -754,25 +759,25 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
754
759
|
deviceMetrics.width = 0;
|
|
755
760
|
deviceMetrics.height = 0;
|
|
756
761
|
}
|
|
757
|
-
await this
|
|
762
|
+
await this.#emulationModel.emulateDevice(deviceMetrics);
|
|
758
763
|
}
|
|
759
764
|
this.calculateAndEmulate(false);
|
|
760
765
|
return screenshot;
|
|
761
766
|
}
|
|
762
767
|
|
|
763
768
|
private applyTouch(touchEnabled: boolean, mobile: boolean): void {
|
|
764
|
-
this
|
|
765
|
-
this
|
|
769
|
+
this.#touchEnabled = touchEnabled;
|
|
770
|
+
this.#touchMobile = mobile;
|
|
766
771
|
for (const emulationModel of SDK.TargetManager.TargetManager.instance().models(SDK.EmulationModel.EmulationModel)) {
|
|
767
772
|
emulationModel.emulateTouch(touchEnabled, mobile);
|
|
768
773
|
}
|
|
769
774
|
}
|
|
770
775
|
|
|
771
776
|
private showHingeIfApplicable(overlayModel: SDK.OverlayModel.OverlayModel): void {
|
|
772
|
-
const orientation = (this
|
|
773
|
-
this
|
|
777
|
+
const orientation = (this.#deviceInternal && this.#modeInternal) ?
|
|
778
|
+
this.#deviceInternal.orientationByName(this.#modeInternal.orientation) :
|
|
774
779
|
null;
|
|
775
|
-
if (this
|
|
780
|
+
if (this.#experimentDualScreenSupport && orientation && orientation.hinge) {
|
|
776
781
|
overlayModel.showHingeForDualScreen(orientation.hinge);
|
|
777
782
|
return;
|
|
778
783
|
}
|
|
@@ -781,10 +786,10 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
781
786
|
}
|
|
782
787
|
|
|
783
788
|
private getDisplayFeatureOrientation(): Protocol.Emulation.DisplayFeatureOrientation {
|
|
784
|
-
if (!this
|
|
789
|
+
if (!this.#modeInternal) {
|
|
785
790
|
throw new Error('Mode required to get display feature orientation.');
|
|
786
791
|
}
|
|
787
|
-
switch (this
|
|
792
|
+
switch (this.#modeInternal.orientation) {
|
|
788
793
|
case VerticalSpanned:
|
|
789
794
|
case Vertical:
|
|
790
795
|
return Protocol.Emulation.DisplayFeatureOrientation.Vertical;
|
|
@@ -800,12 +805,12 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
800
805
|
return null;
|
|
801
806
|
}
|
|
802
807
|
|
|
803
|
-
if (!this
|
|
804
|
-
(this
|
|
808
|
+
if (!this.#deviceInternal || !this.#modeInternal ||
|
|
809
|
+
(this.#modeInternal.orientation !== VerticalSpanned && this.#modeInternal.orientation !== HorizontalSpanned)) {
|
|
805
810
|
return null;
|
|
806
811
|
}
|
|
807
812
|
|
|
808
|
-
const orientation = this
|
|
813
|
+
const orientation = this.#deviceInternal.orientationByName(this.#modeInternal.orientation);
|
|
809
814
|
if (!orientation || !orientation.hinge) {
|
|
810
815
|
return null;
|
|
811
816
|
}
|
|
@@ -813,8 +818,8 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
813
818
|
const hinge = orientation.hinge;
|
|
814
819
|
return {
|
|
815
820
|
orientation: this.getDisplayFeatureOrientation(),
|
|
816
|
-
offset: (this
|
|
817
|
-
maskLength: (this
|
|
821
|
+
offset: (this.#modeInternal.orientation === VerticalSpanned) ? hinge.x : hinge.y,
|
|
822
|
+
maskLength: (this.#modeInternal.orientation === VerticalSpanned) ? hinge.width : hinge.height,
|
|
818
823
|
};
|
|
819
824
|
}
|
|
820
825
|
}
|