chrome-devtools-frontend 1.0.1621678 → 1.0.1622369

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.
@@ -10,6 +10,7 @@ import * as Host from '../../core/host/host.js';
10
10
  import * as i18n from '../../core/i18n/i18n.js';
11
11
  import * as Platform from '../../core/platform/platform.js';
12
12
  import * as EmulationModel from '../../models/emulation/emulation.js';
13
+ import * as Buttons from '../../ui/components/buttons/buttons.js';
13
14
  import * as uiI18n from '../../ui/i18n/i18n.js';
14
15
  import * as UI from '../../ui/legacy/legacy.js';
15
16
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
@@ -194,9 +195,13 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
194
195
  * than in the DevTools panel itself. Therefore, we need to fall back to using the
195
196
  * built-in tooltip by setting the title attribute on the button's element.
196
197
  */
197
- function setTitleForButton(button: UI.Toolbar.ToolbarButton|UI.Toolbar.ToolbarMenuButton, title: string): void {
198
- button.setTitle(title);
199
- button.element.title = title;
198
+ function setTitleForButton(button: Buttons.Button.Button|UI.Toolbar.ToolbarMenuButton, title: string): void {
199
+ if (button instanceof UI.Toolbar.ToolbarMenuButton) {
200
+ button.setTitle(title);
201
+ button.element.title = title;
202
+ } else {
203
+ button.title = title;
204
+ }
200
205
  }
201
206
 
202
207
  export class DeviceModeToolbar {
@@ -211,19 +216,19 @@ export class DeviceModeToolbar {
211
216
  readonly #element: HTMLDivElement;
212
217
  private readonly emulatedDevicesList: EmulationModel.EmulatedDevices.EmulatedDevicesList;
213
218
  private readonly persistenceSetting: Common.Settings.Setting<{device: string, orientation: string, mode: string}>;
214
- private spanButton!: UI.Toolbar.ToolbarButton;
215
- private postureItem!: UI.Toolbar.ToolbarComboBox;
216
- private modeButton!: UI.Toolbar.ToolbarButton;
219
+ private spanButton!: Buttons.Button.Button;
220
+ private postureItem!: HTMLSelectElement;
221
+ private modeButton!: Buttons.Button.Button;
217
222
  private widthInput: EmulationComponents.DeviceSizeInputElement.SizeInputElement;
218
223
  private heightInput: EmulationComponents.DeviceSizeInputElement.SizeInputElement;
219
- private deviceScaleItem!: UI.Toolbar.ToolbarComboBox;
220
- private deviceScaleItems: UI.Toolbar.ToolbarItem[] = [];
221
- private deviceSelectItem!: UI.Toolbar.ToolbarComboBox;
222
- private scaleItem!: UI.Toolbar.ToolbarComboBox;
223
- private uaItem!: UI.Toolbar.ToolbarComboBox;
224
+ private deviceScaleItem!: HTMLSelectElement;
225
+ private deviceScaleItems: HTMLElement[] = [];
226
+ private deviceSelectItem!: HTMLSelectElement;
227
+ private scaleItem!: HTMLSelectElement;
228
+ private uaItem!: HTMLSelectElement;
224
229
  private cachedDeviceScale!: number|null;
225
230
  private cachedUaType!: string|null;
226
- private xItem?: UI.Toolbar.ToolbarItem;
231
+ private xItem?: HTMLElement;
227
232
  private cachedModelType?: EmulationModel.DeviceModeModel.Type;
228
233
  private cachedScale?: number;
229
234
  private cachedModelDevice?: EmulationModel.EmulatedDevices.EmulatedDevice|null;
@@ -287,6 +292,14 @@ export class DeviceModeToolbar {
287
292
  }
288
293
  }
289
294
 
295
+ private appendOption(parentElement: HTMLElement, title: string, value: string, jslogContext: string): void {
296
+ const option = document.createElement('option');
297
+ option.text = title;
298
+ option.value = value;
299
+ option.setAttribute('jslog', `${VisualLogging.item(jslogContext).track({click: true})}`);
300
+ parentElement.appendChild(option);
301
+ }
302
+
290
303
  private createEmptyToolbarElement(): HTMLDivElement {
291
304
  const element = document.createElement('div');
292
305
  element.classList.add('device-mode-empty-toolbar-element');
@@ -296,14 +309,16 @@ export class DeviceModeToolbar {
296
309
  private createMainToolbar(): UI.Toolbar.Toolbar {
297
310
  const mainToolbar = this.#element.createChild('devtools-toolbar', 'main-toolbar');
298
311
 
299
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.createEmptyToolbarElement()));
300
- this.deviceSelectItem = new UI.Toolbar.ToolbarComboBox(
301
- this.onDeviceChange.bind(this), i18nString(UIStrings.deviceType), 'dark-text', 'device');
302
- this.deviceSelectItem.turnShrinkable();
303
- const dimensionsSpan =
304
- uiI18n.getFormatLocalizedString(str_, UIStrings.dimensions, {PH1: this.deviceSelectItem.element});
312
+ mainToolbar.append(this.createEmptyToolbarElement());
313
+ this.deviceSelectItem = document.createElement('select');
314
+ this.deviceSelectItem.classList.add('dark-text', 'toolbar-has-dropdown-shrinkable');
315
+ this.deviceSelectItem.title = i18nString(UIStrings.deviceType);
316
+ UI.ARIAUtils.setLabel(this.deviceSelectItem, i18nString(UIStrings.deviceType));
317
+ this.deviceSelectItem.addEventListener('change', this.onDeviceChange.bind(this));
318
+ this.deviceSelectItem.setAttribute('jslog', `${VisualLogging.dropDown().track({change: true}).context('device')}`);
319
+ const dimensionsSpan = uiI18n.getFormatLocalizedString(str_, UIStrings.dimensions, {PH1: this.deviceSelectItem});
305
320
  mainToolbar.append(...dimensionsSpan.childNodes);
306
- mainToolbar.appendToolbarItem(this.deviceSelectItem);
321
+ mainToolbar.append(this.deviceSelectItem);
307
322
 
308
323
  this.widthInput.addEventListener('sizechanged', ({size: width}) => {
309
324
  if (this.autoAdjustScaleSetting.get()) {
@@ -319,43 +334,57 @@ export class DeviceModeToolbar {
319
334
  this.model.setHeight(height);
320
335
  }
321
336
  });
322
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.widthInput));
323
- const xElement = document.createElement('div');
324
- xElement.classList.add('device-mode-x');
325
- xElement.textContent = '×';
326
- this.xItem = new UI.Toolbar.ToolbarItem(xElement);
327
- mainToolbar.appendToolbarItem(this.xItem);
328
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.heightInput));
329
-
330
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.createEmptyToolbarElement()));
331
- this.scaleItem =
332
- new UI.Toolbar.ToolbarComboBox(this.onScaleChange.bind(this), i18nString(UIStrings.zoom), 'dark-text', 'scale');
333
- this.scaleItem.turnShrinkable();
334
- mainToolbar.appendToolbarItem(this.scaleItem);
337
+ mainToolbar.append(this.widthInput);
338
+ this.xItem = document.createElement('div');
339
+ this.xItem.classList.add('device-mode-x');
340
+ this.xItem.textContent = '×';
341
+ mainToolbar.append(this.xItem);
342
+ mainToolbar.append(this.heightInput);
343
+
344
+ mainToolbar.append(this.createEmptyToolbarElement());
345
+ this.scaleItem = document.createElement('select');
346
+ this.scaleItem.classList.add('dark-text', 'toolbar-has-dropdown-shrinkable');
347
+ this.scaleItem.title = i18nString(UIStrings.zoom);
348
+ UI.ARIAUtils.setLabel(this.scaleItem, i18nString(UIStrings.zoom));
349
+ this.scaleItem.addEventListener('change', this.onScaleChange.bind(this));
350
+ this.scaleItem.setAttribute('jslog', `${VisualLogging.dropDown().track({change: true}).context('scale')}`);
351
+ mainToolbar.append(this.scaleItem);
335
352
 
336
353
  const autoAdjustScaleButton = new UI.Toolbar.ToolbarSettingToggle(
337
354
  this.autoAdjustScaleSetting, 'center-focus-weak', i18nString(UIStrings.autoadjustZoom));
338
355
  mainToolbar.appendToolbarItem(autoAdjustScaleButton);
339
356
 
340
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.createEmptyToolbarElement()));
357
+ mainToolbar.append(this.createEmptyToolbarElement());
341
358
 
342
- this.deviceScaleItem = new UI.Toolbar.ToolbarComboBox(
343
- this.onDeviceScaleChange.bind(this), i18nString(UIStrings.devicePixelRatio), 'dark-text', 'device-pixel-ratio');
344
- this.deviceScaleItem.turnShrinkable();
345
- const deviceScaleSpan = uiI18n.getFormatLocalizedString(str_, UIStrings.dpr, {PH1: this.deviceScaleItem.element});
359
+ this.deviceScaleItem = document.createElement('select');
360
+ this.deviceScaleItem.classList.add('dark-text', 'toolbar-has-dropdown-shrinkable');
361
+ this.deviceScaleItem.title = i18nString(UIStrings.devicePixelRatio);
362
+ UI.ARIAUtils.setLabel(this.deviceScaleItem, i18nString(UIStrings.devicePixelRatio));
363
+ this.deviceScaleItem.addEventListener('change', this.onDeviceScaleChange.bind(this));
364
+ this.deviceScaleItem.setAttribute(
365
+ 'jslog', `${VisualLogging.dropDown().track({change: true}).context('device-pixel-ratio')}`);
366
+ const deviceScaleSpan = uiI18n.getFormatLocalizedString(str_, UIStrings.dpr, {PH1: this.deviceScaleItem});
346
367
  for (const node of Array.from(deviceScaleSpan.childNodes)) {
347
- const item = node === this.deviceScaleItem.element ? this.deviceScaleItem :
348
- new UI.Toolbar.ToolbarText(node.textContent || '');
349
- item.setVisible(this.showDeviceScaleFactorSetting.get());
350
- this.deviceScaleItems.push(item);
351
- mainToolbar.appendToolbarItem(item);
368
+ if (node === this.deviceScaleItem) {
369
+ this.deviceScaleItem.classList.toggle('hidden', !this.showDeviceScaleFactorSetting.get());
370
+ this.deviceScaleItems.push(this.deviceScaleItem);
371
+ mainToolbar.append(this.deviceScaleItem);
372
+ } else {
373
+ const item = new UI.Toolbar.ToolbarText(node.textContent || '');
374
+ item.setVisible(this.showDeviceScaleFactorSetting.get());
375
+ this.deviceScaleItems.push(item.element);
376
+ mainToolbar.appendToolbarItem(item);
377
+ }
352
378
  }
353
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.createEmptyToolbarElement()));
354
- this.uaItem = new UI.Toolbar.ToolbarComboBox(
355
- this.onUAChange.bind(this), i18nString(UIStrings.deviceType), 'dark-text', 'device-type');
356
- this.uaItem.turnShrinkable();
357
- this.uaItem.setVisible(this.showUserAgentTypeSetting.get());
358
- mainToolbar.appendToolbarItem(this.uaItem);
379
+ mainToolbar.append(this.createEmptyToolbarElement());
380
+ this.uaItem = document.createElement('select');
381
+ this.uaItem.classList.add('dark-text', 'toolbar-has-dropdown-shrinkable');
382
+ this.uaItem.title = i18nString(UIStrings.deviceType);
383
+ UI.ARIAUtils.setLabel(this.uaItem, i18nString(UIStrings.deviceType));
384
+ this.uaItem.addEventListener('change', this.onUAChange.bind(this));
385
+ this.uaItem.setAttribute('jslog', `${VisualLogging.dropDown().track({change: true}).context('device-type')}`);
386
+ this.uaItem.classList.toggle('hidden', !this.showUserAgentTypeSetting.get());
387
+ mainToolbar.append(this.uaItem);
359
388
 
360
389
  MobileThrottling.NetworkThrottlingSelector.NetworkThrottlingSelect.createForGlobalConditions(
361
390
  mainToolbar, i18nString(UIStrings.throttling));
@@ -363,22 +392,32 @@ export class DeviceModeToolbar {
363
392
  saveDataItem.turnShrinkable();
364
393
  mainToolbar.appendToolbarItem(saveDataItem);
365
394
 
366
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.createEmptyToolbarElement()));
367
- this.modeButton = new UI.Toolbar.ToolbarButton('', 'screen-rotation', undefined, 'screen-rotation');
368
- this.modeButton.addEventListener(UI.Toolbar.ToolbarButton.Events.CLICK, this.modeMenuClicked, this);
369
- mainToolbar.appendToolbarItem(this.modeButton);
395
+ mainToolbar.append(this.createEmptyToolbarElement());
396
+ this.modeButton = new Buttons.Button.Button();
397
+ this.modeButton.classList.add('toolbar-button');
398
+ this.modeButton.data = {variant: Buttons.Button.Variant.ICON, iconName: 'screen-rotation'};
399
+ this.modeButton.setAttribute('jslog', `${VisualLogging.action('screen-rotation').track({click: true})}`);
400
+ this.modeButton.addEventListener('click', this.modeMenuClicked.bind(this));
401
+ mainToolbar.append(this.modeButton);
370
402
 
371
403
  // Show dual screen toolbar.
372
- this.spanButton = new UI.Toolbar.ToolbarButton('', 'device-fold', undefined, 'device-fold');
373
- this.spanButton.addEventListener(UI.Toolbar.ToolbarButton.Events.CLICK, this.spanClicked, this);
374
- mainToolbar.appendToolbarItem(this.spanButton);
404
+ this.spanButton = new Buttons.Button.Button();
405
+ this.spanButton.classList.add('toolbar-button');
406
+ this.spanButton.data = {variant: Buttons.Button.Variant.ICON, iconName: 'device-fold'};
407
+ this.spanButton.setAttribute('jslog', `${VisualLogging.action('device-fold').track({click: true})}`);
408
+ this.spanButton.addEventListener('click', this.spanClicked.bind(this));
409
+ mainToolbar.append(this.spanButton);
375
410
 
376
411
  // Show posture toolbar menu for foldable devices.
377
- mainToolbar.appendToolbarItem(new UI.Toolbar.ToolbarItem(this.createEmptyToolbarElement()));
378
- this.postureItem = new UI.Toolbar.ToolbarComboBox(
379
- this.onPostureChange.bind(this), i18nString(UIStrings.devicePosture), 'dark-text', 'device-posture');
380
- this.postureItem.turnShrinkable();
381
- mainToolbar.appendToolbarItem(this.postureItem);
412
+ mainToolbar.append(this.createEmptyToolbarElement());
413
+ this.postureItem = document.createElement('select');
414
+ this.postureItem.classList.add('dark-text', 'toolbar-has-dropdown-shrinkable');
415
+ this.postureItem.title = i18nString(UIStrings.devicePosture);
416
+ UI.ARIAUtils.setLabel(this.postureItem, i18nString(UIStrings.devicePosture));
417
+ this.postureItem.addEventListener('change', this.onPostureChange.bind(this));
418
+ this.postureItem.setAttribute(
419
+ 'jslog', `${VisualLogging.dropDown().track({change: true}).context('device-posture')}`);
420
+ mainToolbar.append(this.postureItem);
382
421
 
383
422
  return mainToolbar;
384
423
  }
@@ -400,19 +439,19 @@ export class DeviceModeToolbar {
400
439
  }
401
440
 
402
441
  private updateDevicePostureItems(): void {
403
- this.postureItem.removeOptions();
442
+ this.postureItem.replaceChildren();
404
443
  for (const option of this.getDevicePostureOptions()) {
405
- this.postureItem.createOption(option.title, option.value, option.title.toLowerCase());
444
+ this.appendOption(this.postureItem, option.title, option.value, option.title.toLowerCase());
406
445
  }
407
446
  const currentPosture = this.currentDevicePosture();
408
- if (this.postureItem.element.value !== currentPosture) {
409
- this.postureItem.element.value = currentPosture;
447
+ if (this.postureItem.value !== currentPosture) {
448
+ this.postureItem.value = currentPosture;
410
449
  }
411
450
  this.resizeItem(this.postureItem);
412
451
  }
413
452
 
414
453
  private onPostureChange(): void {
415
- const value = this.postureItem.element.value;
454
+ const value = this.postureItem.value;
416
455
  if (value !== this.currentDevicePosture()) {
417
456
  this.spanClicked();
418
457
  }
@@ -461,20 +500,20 @@ export class DeviceModeToolbar {
461
500
  }
462
501
 
463
502
  private updateScaleMenuItems(): void {
464
- this.scaleItem.removeOptions();
503
+ this.scaleItem.replaceChildren();
465
504
  const options = this.getScaleOptions();
466
505
  for (const option of options) {
467
- this.scaleItem.createOption(option.title, String(option.value), option.jslogContext);
506
+ this.appendOption(this.scaleItem, option.title, String(option.value), option.jslogContext);
468
507
  }
469
508
  const selected = options.find(o => o.selected);
470
509
  if (selected) {
471
- this.scaleItem.element.value = String(selected.value);
510
+ this.scaleItem.value = String(selected.value);
472
511
  }
473
512
  this.resizeItem(this.scaleItem, true);
474
513
  }
475
514
 
476
515
  private onScaleChange(): void {
477
- const value = Number(this.scaleItem.selectedOption()?.value);
516
+ const value = Number(this.scaleItem.value);
478
517
  this.model.scaleSetting().set(value);
479
518
  }
480
519
 
@@ -509,20 +548,20 @@ export class DeviceModeToolbar {
509
548
  }
510
549
 
511
550
  private updateDeviceScaleMenuItems(): void {
512
- this.deviceScaleItem.removeOptions();
551
+ this.deviceScaleItem.replaceChildren();
513
552
  const options = this.getDeviceScaleFactorOptions();
514
553
  for (const option of options) {
515
- this.deviceScaleItem.createOption(option.title, String(option.value), option.jslogContext);
554
+ this.appendOption(this.deviceScaleItem, option.title, String(option.value), option.jslogContext);
516
555
  }
517
556
  const selected = options.find(o => o.selected);
518
557
  if (selected) {
519
- this.deviceScaleItem.element.value = String(selected.value);
558
+ this.deviceScaleItem.value = String(selected.value);
520
559
  }
521
560
  this.resizeItem(this.deviceScaleItem, true);
522
561
  }
523
562
 
524
563
  private onDeviceScaleChange(): void {
525
- const value = Number(this.deviceScaleItem.selectedOption()?.value);
564
+ const value = Number(this.deviceScaleItem.value);
526
565
  this.model.deviceScaleFactorSetting().set(value);
527
566
  }
528
567
 
@@ -544,20 +583,20 @@ export class DeviceModeToolbar {
544
583
  }
545
584
 
546
585
  private updateUserAgentMenuItems(): void {
547
- this.uaItem.removeOptions();
586
+ this.uaItem.replaceChildren();
548
587
  const options = this.getUserAgentOptions();
549
588
  for (const option of options) {
550
- this.uaItem.createOption(option.title, option.value, option.jslogContext);
589
+ this.appendOption(this.uaItem, option.title, option.value, option.jslogContext);
551
590
  }
552
591
  const selected = options.find(o => o.selected);
553
592
  if (selected) {
554
- this.uaItem.element.value = selected.value;
593
+ this.uaItem.value = selected.value;
555
594
  }
556
595
  this.resizeItem(this.uaItem);
557
596
  }
558
597
 
559
598
  private onUAChange(): void {
560
- const value = this.uaItem.selectedOption()?.value as EmulationModel.DeviceModeModel.UA;
599
+ const value = this.uaItem.value as EmulationModel.DeviceModeModel.UA;
561
600
  this.model.uaSetting().set(value);
562
601
  this.resizeItem(this.uaItem);
563
602
  }
@@ -685,15 +724,15 @@ export class DeviceModeToolbar {
685
724
  }
686
725
 
687
726
  private updateDeviceMenuItems(): void {
688
- this.deviceSelectItem.removeOptions();
727
+ this.deviceSelectItem.replaceChildren();
689
728
  const options = this.getDeviceModeOptions();
690
729
 
691
- this.deviceSelectItem.createOption(options.responsive.title, 'Responsive', options.responsive.jslogContext);
730
+ this.appendOption(this.deviceSelectItem, options.responsive.title, 'Responsive', options.responsive.jslogContext);
692
731
 
693
732
  appendGroup.call(this, options.standard, 'Standard');
694
733
  appendGroup.call(this, options.custom, 'Custom');
695
734
 
696
- this.deviceSelectItem.createOption(options.edit.title, 'Edit', options.edit.jslogContext);
735
+ this.appendOption(this.deviceSelectItem, options.edit.title, 'Edit', options.edit.jslogContext);
697
736
 
698
737
  this.updateDeviceSelection();
699
738
 
@@ -705,28 +744,24 @@ export class DeviceModeToolbar {
705
744
  const optGroup = document.createElement('optgroup');
706
745
  optGroup.label = label;
707
746
  for (const item of group) {
708
- const option = document.createElement('option');
709
- option.value = item.title;
710
- option.text = item.title;
711
- option.setAttribute('jslog', `${VisualLogging.item(item.jslogContext).track({click: true})}`);
712
- optGroup.appendChild(option);
747
+ this.appendOption(optGroup, item.title, item.title, item.jslogContext);
713
748
  }
714
- this.deviceSelectItem.addOption(optGroup);
749
+ this.deviceSelectItem.appendChild(optGroup);
715
750
  }
716
751
  }
717
752
 
718
753
  private updateDeviceSelection(): void {
719
754
  const device = this.model.device();
720
755
  if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
721
- this.deviceSelectItem.element.value = 'Responsive';
756
+ this.deviceSelectItem.value = 'Responsive';
722
757
  } else if (device) {
723
- this.deviceSelectItem.element.value = device.title;
758
+ this.deviceSelectItem.value = device.title;
724
759
  }
725
760
  this.resizeItem(this.deviceSelectItem);
726
761
  }
727
762
 
728
763
  private onDeviceChange(): void {
729
- const value = this.deviceSelectItem.selectedOption()?.value;
764
+ const value = this.deviceSelectItem.value;
730
765
  if (value === 'Edit') {
731
766
  this.emulatedDevicesList.revealCustomSetting();
732
767
  this.updateDeviceSelection();
@@ -764,9 +799,9 @@ export class DeviceModeToolbar {
764
799
  private updateDeviceScaleFactorVisibility(): void {
765
800
  if (this.deviceScaleItem) {
766
801
  const visible = this.showDeviceScaleFactorSetting.get();
767
- this.deviceScaleItem.setVisible(visible);
802
+ this.deviceScaleItem.classList.toggle('hidden', !visible);
768
803
  for (const item of this.deviceScaleItems) {
769
- item.setVisible(visible);
804
+ item.classList.toggle('hidden', !visible);
770
805
  }
771
806
  }
772
807
  }
@@ -774,7 +809,7 @@ export class DeviceModeToolbar {
774
809
  private updateUserAgentTypeVisibility(): void {
775
810
  if (this.uaItem) {
776
811
  const visible = this.showUserAgentTypeSetting.get();
777
- this.uaItem.setVisible(visible);
812
+ this.uaItem.classList.toggle('hidden', !visible);
778
813
  if (visible) {
779
814
  this.resizeItem(this.uaItem);
780
815
  }
@@ -802,9 +837,7 @@ export class DeviceModeToolbar {
802
837
  return;
803
838
  }
804
839
 
805
- private modeMenuClicked(event: {
806
- data: Event,
807
- }): void {
840
+ private modeMenuClicked(event: Event): void {
808
841
  if (this.model.isScreenOrientationLocked()) {
809
842
  return;
810
843
  }
@@ -847,9 +880,9 @@ export class DeviceModeToolbar {
847
880
  return;
848
881
  }
849
882
 
850
- const contextMenu = new UI.ContextMenu.ContextMenu(event.data, {
851
- x: this.modeButton.element.getBoundingClientRect().left,
852
- y: this.modeButton.element.getBoundingClientRect().top + (this.modeButton.element as HTMLElement).offsetHeight,
883
+ const contextMenu = new UI.ContextMenu.ContextMenu(event, {
884
+ x: this.modeButton.getBoundingClientRect().left,
885
+ y: this.modeButton.getBoundingClientRect().top + this.modeButton.offsetHeight,
853
886
  });
854
887
  addOrientation(EmulationModel.EmulatedDevices.Vertical, i18nString(UIStrings.portrait));
855
888
  addOrientation(EmulationModel.EmulatedDevices.Horizontal, i18nString(UIStrings.landscape));
@@ -902,14 +935,14 @@ export class DeviceModeToolbar {
902
935
  this.widthInput.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
903
936
 
904
937
  this.heightInput.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
905
- this.deviceScaleItem.setEnabled(this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive);
906
- this.uaItem.setEnabled(this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive);
938
+ this.deviceScaleItem.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
939
+ this.uaItem.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
907
940
 
908
941
  if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
909
- this.modeButton.setEnabled(true);
942
+ this.modeButton.disabled = false;
910
943
  setTitleForButton(this.modeButton, i18nString(UIStrings.rotate));
911
944
  } else {
912
- this.modeButton.setEnabled(false);
945
+ this.modeButton.disabled = true;
913
946
  }
914
947
  }
915
948
 
@@ -928,14 +961,14 @@ export class DeviceModeToolbar {
928
961
 
929
962
  const deviceScale = this.model.appliedDeviceScaleFactor();
930
963
  if (deviceScale !== this.cachedDeviceScale) {
931
- this.deviceScaleItem.element.value = String(deviceScale);
964
+ this.deviceScaleItem.value = String(deviceScale);
932
965
  this.cachedDeviceScale = deviceScale;
933
966
  this.resizeItem(this.deviceScaleItem, true);
934
967
  }
935
968
 
936
969
  const uaType = this.model.appliedUserAgentType();
937
970
  if (uaType !== this.cachedUaType) {
938
- this.uaItem.element.value = uaType;
971
+ this.uaItem.value = uaType;
939
972
  this.cachedUaType = uaType;
940
973
  this.updateDeviceScaleMenuItems();
941
974
  this.resizeItem(this.uaItem);
@@ -948,7 +981,7 @@ export class DeviceModeToolbar {
948
981
  const device = this.model.device();
949
982
  if (device) {
950
983
  const modeCount = device ? device.modes.length : 0;
951
- this.modeButton.setEnabled(modeCount >= 2);
984
+ this.modeButton.disabled = modeCount < 2;
952
985
  setTitleForButton(
953
986
  this.modeButton,
954
987
  modeCount === 2 ? i18nString(UIStrings.rotate) : i18nString(UIStrings.screenOrientationOptions));
@@ -957,15 +990,15 @@ export class DeviceModeToolbar {
957
990
  }
958
991
 
959
992
  if (device?.isDualScreen) {
960
- this.spanButton.setVisible(true);
961
- this.postureItem.setVisible(false);
993
+ this.spanButton.classList.toggle('hidden', false);
994
+ this.postureItem.classList.toggle('hidden', true);
962
995
  } else if (device?.isFoldableScreen) {
963
- this.spanButton.setVisible(false);
964
- this.postureItem.setVisible(true);
996
+ this.spanButton.classList.toggle('hidden', true);
997
+ this.postureItem.classList.toggle('hidden', false);
965
998
  this.updateDevicePostureItems();
966
999
  } else {
967
- this.spanButton.setVisible(false);
968
- this.postureItem.setVisible(false);
1000
+ this.spanButton.classList.toggle('hidden', true);
1001
+ this.postureItem.classList.toggle('hidden', true);
969
1002
  }
970
1003
  setTitleForButton(this.spanButton, i18nString(UIStrings.toggleDualscreenMode));
971
1004
 
@@ -996,16 +1029,16 @@ export class DeviceModeToolbar {
996
1029
  // disable the rotate button to prevent user-initiated rotation.
997
1030
  // When unlocked, restore the button to its normal state.
998
1031
  if (this.model.isScreenOrientationLocked()) {
999
- this.modeButton.setEnabled(false);
1032
+ this.modeButton.disabled = true;
1000
1033
  setTitleForButton(this.modeButton, i18nString(UIStrings.screenOrientationLocked));
1001
1034
  } else if (this.cachedModelDevice) {
1002
1035
  const modeCount = this.cachedModelDevice.modes.length;
1003
- this.modeButton.setEnabled(modeCount >= 2);
1036
+ this.modeButton.disabled = modeCount < 2;
1004
1037
  setTitleForButton(
1005
1038
  this.modeButton,
1006
1039
  modeCount === 2 ? i18nString(UIStrings.rotate) : i18nString(UIStrings.screenOrientationOptions));
1007
1040
  } else if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
1008
- this.modeButton.setEnabled(true);
1041
+ this.modeButton.disabled = false;
1009
1042
  setTitleForButton(this.modeButton, i18nString(UIStrings.rotate));
1010
1043
  }
1011
1044
  }
@@ -1027,13 +1060,13 @@ export class DeviceModeToolbar {
1027
1060
  this.model.emulate(EmulationModel.DeviceModeModel.Type.Responsive, null, null);
1028
1061
  }
1029
1062
 
1030
- private resizeItem(item: UI.Toolbar.ToolbarComboBox, stripParens = false): void {
1031
- const selectedOption = item.selectedOption();
1063
+ private resizeItem(item: HTMLSelectElement, stripParens = false): void {
1064
+ const selectedOption = item.options[item.selectedIndex];
1032
1065
  if (!selectedOption) {
1033
1066
  return;
1034
1067
  }
1035
1068
 
1036
- const dummySelect = item.element.cloneNode(false) as HTMLSelectElement;
1069
+ const dummySelect = item.cloneNode(false) as HTMLSelectElement;
1037
1070
  const dummyOption = selectedOption.cloneNode(true) as HTMLOptionElement;
1038
1071
 
1039
1072
  if (stripParens) {
@@ -1049,8 +1082,8 @@ export class DeviceModeToolbar {
1049
1082
  dummySelect.style.visibility = 'hidden';
1050
1083
  dummySelect.style.pointerEvents = 'none';
1051
1084
 
1052
- item.element.parentElement?.appendChild(dummySelect);
1053
- item.element.style.width = dummySelect.offsetWidth + 'px';
1085
+ item.parentElement?.appendChild(dummySelect);
1086
+ item.style.width = dummySelect.offsetWidth + 'px';
1054
1087
  dummySelect.remove();
1055
1088
  }
1056
1089
  }
@@ -107,7 +107,7 @@ export class WatchExpressionsSidebarPane extends UI.Widget.VBox implements
107
107
  private readonly treeOutline: ObjectUI.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline;
108
108
  private readonly expandController: ObjectUI.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController;
109
109
  private readonly linkifier: Components.Linkifier.Linkifier;
110
- private constructor() {
110
+ constructor() {
111
111
  super({useShadowDom: true});
112
112
  this.registerRequiredCSS(watchExpressionsSidebarPaneStyles, objectValueStyles);
113
113
 
@@ -209,6 +209,7 @@ export class WatchExpressionsSidebarPane extends UI.Widget.VBox implements
209
209
 
210
210
  this.createWatchExpression(expression);
211
211
  }
212
+ await Promise.all(this.#watchExpressions.map(we => we.updateComplete));
212
213
  }
213
214
 
214
215
  private createWatchExpression(expression: string|null): WatchExpression {
@@ -332,6 +333,7 @@ export class WatchExpression extends Common.ObjectWrapper.ObjectWrapper<EventTyp
332
333
  private textPrompt?: ObjectPropertyPrompt;
333
334
  private result?: SDK.RemoteObject.RemoteObject|null;
334
335
  private preventClickTimeout?: number;
336
+ #updateComplete: Promise<void> = Promise.resolve();
335
337
  constructor(
336
338
  expression: string|null,
337
339
  expandController: ObjectUI.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController,
@@ -350,6 +352,10 @@ export class WatchExpression extends Common.ObjectWrapper.ObjectWrapper<EventTyp
350
352
  this.update();
351
353
  }
352
354
 
355
+ get updateComplete(): Promise<void> {
356
+ return this.#updateComplete;
357
+ }
358
+
353
359
  treeElement(): UI.TreeOutline.TreeElement {
354
360
  return this.#treeElement;
355
361
  }
@@ -386,7 +392,7 @@ export class WatchExpression extends Common.ObjectWrapper.ObjectWrapper<EventTyp
386
392
  update(): void {
387
393
  const currentExecutionContext = UI.Context.Context.instance().flavor(SDK.RuntimeModel.ExecutionContext);
388
394
  if (currentExecutionContext && this.#expression) {
389
- void this.#evaluateExpression(currentExecutionContext, this.#expression).then(result => {
395
+ this.#updateComplete = this.#evaluateExpression(currentExecutionContext, this.#expression).then(result => {
390
396
  if ('object' in result) {
391
397
  this.createWatchExpression(result.object, result.exceptionDetails);
392
398
  } else {
@@ -395,6 +401,7 @@ export class WatchExpression extends Common.ObjectWrapper.ObjectWrapper<EventTyp
395
401
  });
396
402
  } else {
397
403
  this.createWatchExpression();
404
+ this.#updateComplete = Promise.resolve();
398
405
  }
399
406
  }
400
407
 
@@ -430,8 +437,9 @@ export class WatchExpression extends Common.ObjectWrapper.ObjectWrapper<EventTyp
430
437
  this.#treeElement.setDisableSelectFocus(false);
431
438
  this.#treeElement.listItemElement.classList.remove('watch-expression-editing');
432
439
  if (this.textPrompt) {
440
+ const text = this.textPrompt.text();
433
441
  this.textPrompt.detach();
434
- const newExpression = canceled ? this.#expression : this.textPrompt.text();
442
+ const newExpression = canceled ? this.#expression : text;
435
443
  this.textPrompt = undefined;
436
444
  this.element.removeChildren();
437
445
  this.updateExpression(newExpression);
@@ -445,7 +453,7 @@ export class WatchExpression extends Common.ObjectWrapper.ObjectWrapper<EventTyp
445
453
  }
446
454
  }
447
455
 
448
- private updateExpression(newExpression: string|null): void {
456
+ updateExpression(newExpression: string|null): void {
449
457
  if (this.#expression) {
450
458
  this.expandController.stopWatchSectionsWithId(this.#expression);
451
459
  }
@@ -205,8 +205,8 @@
205
205
  }
206
206
 
207
207
  .interaction-inp-chip {
208
- background-color: var(--sys-color-yellow-bright);
209
- color: var(--sys-color-on-yellow);
208
+ background-color: var(--sys-color-yellow-container);
209
+ color: var(--sys-color-on-yellow-container);
210
210
  padding: 0 2px;
211
211
  }
212
212
 
@@ -1,7 +1,7 @@
1
1
  Name: Dependencies sourced from the upstream `chromium` repository
2
2
  URL: Internal
3
3
  Version: N/A
4
- Revision: b1e55a8961dbd7de8febb16a1bd10f31de63c4c6
4
+ Revision: 1f344c5922432c73b3db8100c1f15163fdf8b530
5
5
  Update Mechanism: Manual (https://crbug.com/428069060)
6
6
  License: BSD-3-Clause
7
7
  License File: LICENSE
@@ -38,7 +38,7 @@
38
38
  // @ts-nocheck This file is not checked by TypeScript Compiler as it has a lot of legacy code.
39
39
  /* eslint-disable @devtools/no-imperative-dom-api */
40
40
 
41
- import * as Platform from '../platform/platform.js';
41
+ import * as Platform from '../../core/platform/platform.js';
42
42
 
43
43
  Node.prototype.traverseNextTextNode = function(stayWithin?: Node): Node|null {
44
44
  let node = this.traverseNextNode(stayWithin);
@@ -29,7 +29,7 @@
29
29
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
30
  */
31
31
 
32
- import '../../core/dom_extension/dom_extension.js';
32
+ import '../dom_extension/dom_extension.js';
33
33
 
34
34
  import * as Platform from '../../core/platform/platform.js';
35
35
  import * as Geometry from '../../models/geometry/geometry.js';