chrome-devtools-frontend 1.0.1601661 → 1.0.1602348

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.
Files changed (60) hide show
  1. package/.agents/skills/version-control/SKILL.md +71 -0
  2. package/front_end/core/host/InspectorFrontendHostStub.ts +0 -5
  3. package/front_end/core/root/Runtime.ts +0 -8
  4. package/front_end/core/sdk/DOMModel.ts +5 -4
  5. package/front_end/entrypoints/inspector_main/InspectorMain.ts +1 -1
  6. package/front_end/entrypoints/main/GlobalAiButton.ts +1 -1
  7. package/front_end/generated/InspectorBackendCommands.ts +6 -5
  8. package/front_end/generated/protocol.ts +36 -3
  9. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +167 -9
  10. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -0
  11. package/front_end/models/live-metrics/LiveMetrics.ts +51 -31
  12. package/front_end/panels/accessibility/ARIAAttributesView.ts +2 -2
  13. package/front_end/panels/ai_assistance/components/ChatInput.ts +3 -2
  14. package/front_end/panels/ai_assistance/components/ChatMessage.ts +15 -19
  15. package/front_end/panels/application/KeyValueStorageItemsView.ts +4 -4
  16. package/front_end/panels/common/AiCodeCompletionSummaryToolbar.ts +2 -1
  17. package/front_end/panels/console_counters/WarningErrorCounter.ts +7 -14
  18. package/front_end/panels/elements/NodeStackTraceWidget.ts +2 -1
  19. package/front_end/panels/elements/StylePropertyTreeElement.ts +2 -1
  20. package/front_end/panels/network/RequestPayloadView.ts +2 -2
  21. package/front_end/panels/recorder/RecorderController.ts +4 -3
  22. package/front_end/panels/recorder/components/CreateRecordingView.ts +2 -1
  23. package/front_end/panels/recorder/components/RecordingView.ts +2 -2
  24. package/front_end/panels/recorder/models/RecordingPlayer.ts +3 -0
  25. package/front_end/panels/security/SecurityPanel.ts +3 -3
  26. package/front_end/panels/sensors/SensorsView.ts +131 -88
  27. package/front_end/panels/timeline/TimelineDetailsView.ts +6 -37
  28. package/front_end/panels/timeline/TimelineUIUtils.ts +0 -118
  29. package/front_end/panels/timeline/components/IgnoreListSetting.ts +1 -1
  30. package/front_end/panels/timeline/components/SidebarInsightsTab.ts +2 -2
  31. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +162 -9
  32. package/front_end/panels/timeline/components/timelineRangeSummaryView.css +20 -8
  33. package/front_end/panels/whats_new/ReleaseNoteText.ts +10 -10
  34. package/front_end/panels/whats_new/resources/WNDT.md +6 -6
  35. package/front_end/third_party/chromium/README.chromium +1 -1
  36. package/front_end/third_party/puppeteer/README.chromium +2 -2
  37. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  38. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +4 -0
  39. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  40. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  41. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  42. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
  43. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  44. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  45. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +3 -3
  46. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  47. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +4 -0
  48. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  49. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  50. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  51. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
  52. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  53. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  54. package/front_end/third_party/puppeteer/package/package.json +1 -1
  55. package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +8 -0
  56. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  57. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  58. package/front_end/ui/legacy/Toolbar.ts +25 -3
  59. package/front_end/ui/legacy/Widget.ts +35 -40
  60. package/package.json +1 -1
@@ -329,8 +329,8 @@ export class SensorsView extends UI.Widget.VBox {
329
329
  }
330
330
  })}
331
331
  >
332
- <!-- @ts-ignore -->
333
332
  <div class="latlong-group">
333
+ <!-- @ts-ignore -->
334
334
  <input
335
335
  id="latitude-input"
336
336
  type="number"
@@ -347,8 +347,8 @@ export class SensorsView extends UI.Widget.VBox {
347
347
  >
348
348
  <label class="latlong-title" for="latitude-input">${i18nString(UIStrings.latitude)}</label>
349
349
  </div>
350
- <!-- @ts-ignore -->
351
350
  <div class="latlong-group">
351
+ <!-- @ts-ignore -->
352
352
  <input
353
353
  id="longitude-input"
354
354
  type="number"
@@ -397,8 +397,8 @@ export class SensorsView extends UI.Widget.VBox {
397
397
  <label class="locale-title" for="locale-input">${i18nString(UIStrings.locale)}</label>
398
398
  <div class="locale-error" ${Directives.ref((el: Element | undefined) => { if (el) { this.localeError = el as HTMLElement; } })}></div>
399
399
  </div>
400
- <!-- @ts-ignore -->
401
400
  <div class="latlong-group">
401
+ <!-- @ts-ignore -->
402
402
  <input
403
403
  id="accuracy-input"
404
404
  type="number"
@@ -593,10 +593,6 @@ export class SensorsView extends UI.Widget.VBox {
593
593
  private createDeviceOrientationSection(): void {
594
594
  const orientationGroup = this.contentElement.createChild('section', 'sensors-group');
595
595
  orientationGroup.setAttribute('jslog', `${VisualLogging.section('device-orientation')}`);
596
- const orientationTitle = UI.UIUtils.createLabel(i18nString(UIStrings.orientation), 'sensors-group-title');
597
- orientationGroup.appendChild(orientationTitle);
598
- const orientationContent = orientationGroup.createChild('div', 'orientation-content');
599
- const fields = orientationContent.createChild('div', 'orientation-fields');
600
596
 
601
597
  const orientationOffOption = {
602
598
  title: i18nString(UIStrings.off),
@@ -622,46 +618,136 @@ export class SensorsView extends UI.Widget.VBox {
622
618
  {title: i18nString(UIStrings.displayDown), orientation: '[0, -180, 0]', jslogContext: 'displayUp-down'},
623
619
  ],
624
620
  }];
625
- this.orientationSelectElement = this.contentElement.createChild('select');
626
- this.orientationSelectElement.setAttribute('jslog', `${VisualLogging.dropDown().track({change: true})}`);
627
- UI.ARIAUtils.bindLabelToControl(orientationTitle, this.orientationSelectElement);
628
- this.orientationSelectElement.appendChild(UI.UIUtils.createOption(
629
- orientationOffOption.title, orientationOffOption.orientation, orientationOffOption.jslogContext));
630
- this.orientationSelectElement.appendChild(
631
- UI.UIUtils.createOption(customOrientationOption.title, customOrientationOption.orientation, 'custom'));
632
-
633
- for (let i = 0; i < orientationGroups.length; ++i) {
634
- const groupElement = this.orientationSelectElement.createChild('optgroup');
635
- groupElement.label = orientationGroups[i].title;
636
- const group = orientationGroups[i].value;
637
- for (let j = 0; j < group.length; ++j) {
638
- groupElement.appendChild(UI.UIUtils.createOption(group[j].title, group[j].orientation, group[j].jslogContext));
639
- }
640
- }
641
- this.orientationSelectElement.selectedIndex = 0;
642
- fields.appendChild(this.orientationSelectElement);
643
- this.orientationSelectElement.addEventListener('change', this.orientationSelectChanged.bind(this));
644
-
645
- this.deviceOrientationFieldset = this.createDeviceOrientationOverrideElement(this.deviceOrientation);
646
- this.stageElement = orientationContent.createChild('div', 'orientation-stage');
647
- this.stageElement.setAttribute('jslog', `${VisualLogging.preview().track({drag: true})}`);
648
- this.orientationLayer = this.stageElement.createChild('div', 'orientation-layer');
649
- this.boxElement = this.orientationLayer.createChild('section', 'orientation-box orientation-element');
650
-
651
- this.boxElement.createChild('section', 'orientation-front orientation-element');
652
- this.boxElement.createChild('section', 'orientation-top orientation-element');
653
- this.boxElement.createChild('section', 'orientation-back orientation-element');
654
- this.boxElement.createChild('section', 'orientation-left orientation-element');
655
- this.boxElement.createChild('section', 'orientation-right orientation-element');
656
- this.boxElement.createChild('section', 'orientation-bottom orientation-element');
657
-
658
- UI.UIUtils.installDragHandle(this.stageElement, this.onBoxDragStart.bind(this), event => {
659
- this.onBoxDrag(event);
660
- }, null, '-webkit-grabbing', '-webkit-grab');
661
-
662
- fields.appendChild(this.deviceOrientationFieldset);
621
+
622
+ // clang-format off
623
+ // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
624
+ render(
625
+ html`
626
+ <label class="sensors-group-title" for="orientation-select">${i18nString(UIStrings.orientation)}</label>
627
+ <div class="orientation-content">
628
+ <div class="orientation-fields">
629
+ <select
630
+ id="orientation-select"
631
+ ${Directives.ref((el: Element | undefined) => {
632
+ if (el) {
633
+ this.orientationSelectElement = el as HTMLSelectElement;
634
+ }
635
+ })}
636
+ @change=${this.orientationSelectChanged.bind(this)}
637
+ jslog=${VisualLogging.dropDown().track({change: true})}
638
+ >
639
+ <option value=${orientationOffOption.orientation} jslog=${VisualLogging.item(orientationOffOption.jslogContext)}>${orientationOffOption.title}</option>
640
+ <option value=${customOrientationOption.orientation} jslog=${VisualLogging.item('custom')}>${customOrientationOption.title}</option>
641
+ ${orientationGroups.map(group => html`
642
+ <optgroup label=${group.title}>
643
+ ${group.value.map(preset => html`
644
+ <option value=${preset.orientation} jslog=${VisualLogging.item(preset.jslogContext)}>${preset.title}</option>
645
+ `)}
646
+ </optgroup>
647
+ `)}
648
+ </select>
649
+ <fieldset
650
+ class="device-orientation-override-section"
651
+ ${Directives.ref((el: Element | undefined) => {
652
+ if (el) {
653
+ this.deviceOrientationFieldset = el as HTMLFieldSetElement;
654
+ }
655
+ })}
656
+ >
657
+ <div class="orientation-inputs-cell">
658
+ <div class="orientation-axis-input-container">
659
+ <!-- @ts-ignore -->
660
+ <input
661
+ id="alpha-input"
662
+ type="number"
663
+ step="any"
664
+ ${Directives.ref((el: Element | undefined) => { if (el) { this.alphaElement = el as HTMLInputElement; } })}
665
+ @change=${this.#onOrientationChange.bind(this)}
666
+ @input=${this.#onOrientationInput.bind(this)}
667
+ @keydown=${this.#onOrientationKeyDown.bind(this)}
668
+ @focus=${this.#onOrientationFocus.bind(this)}
669
+ >
670
+ <label for="alpha-input">${i18nString(UIStrings.alpha)}</label>
671
+ </div>
672
+ <div class="orientation-axis-input-container">
673
+ <!-- @ts-ignore -->
674
+ <input
675
+ id="beta-input"
676
+ type="number"
677
+ step="any"
678
+ ${Directives.ref((el: Element | undefined) => { if (el) { this.betaElement = el as HTMLInputElement; } })}
679
+ @change=${this.#onOrientationChange.bind(this)}
680
+ @input=${this.#onOrientationInput.bind(this)}
681
+ @keydown=${this.#onOrientationKeyDown.bind(this)}
682
+ @focus=${this.#onOrientationFocus.bind(this)}
683
+ >
684
+ <label for="beta-input">${i18nString(UIStrings.beta)}</label>
685
+ </div>
686
+ <div class="orientation-axis-input-container">
687
+ <!-- @ts-ignore -->
688
+ <input
689
+ id="gamma-input"
690
+ type="number"
691
+ step="any"
692
+ ${Directives.ref((el: Element | undefined) => { if (el) { this.gammaElement = el as HTMLInputElement; } })}
693
+ @change=${this.#onOrientationChange.bind(this)}
694
+ @input=${this.#onOrientationInput.bind(this)}
695
+ @keydown=${this.#onOrientationKeyDown.bind(this)}
696
+ @focus=${this.#onOrientationFocus.bind(this)}
697
+ >
698
+ <label for="gamma-input">${i18nString(UIStrings.gamma)}</label>
699
+ </div>
700
+ <devtools-button
701
+ .variant=${Buttons.Button.Variant.OUTLINED}
702
+ class="orientation-reset-button"
703
+ type="reset"
704
+ aria-label=${i18nString(UIStrings.resetDeviceOrientation)}
705
+ @click=${this.resetDeviceOrientation.bind(this)}
706
+ jslog=${VisualLogging.action('sensors.reset-device-orientiation').track({click: true})}
707
+ >
708
+ ${i18nString(UIStrings.reset)}
709
+ </devtools-button>
710
+ </div>
711
+ </fieldset>
712
+ </div>
713
+ <div
714
+ class="orientation-stage"
715
+ jslog=${VisualLogging.preview().track({drag: true})}
716
+ ${Directives.ref((el: Element | undefined) => {
717
+ if (el && !this.stageElement) {
718
+ this.stageElement = el as HTMLElement;
719
+ UI.UIUtils.installDragHandle(this.stageElement, this.onBoxDragStart.bind(this), event => {
720
+ this.onBoxDrag(event);
721
+ }, null, '-webkit-grabbing', '-webkit-grab');
722
+ }
723
+ })}
724
+ >
725
+ <div class="orientation-layer" ${Directives.ref((el: Element | undefined) => { if (el) { this.orientationLayer = el as HTMLDivElement; } })}>
726
+ <section
727
+ class="orientation-box orientation-element"
728
+ ${Directives.ref((el: Element | undefined) => { if (el) { this.boxElement = el as HTMLElement; } })}
729
+ >
730
+ <section class="orientation-front orientation-element"></section>
731
+ <section class="orientation-top orientation-element"></section>
732
+ <section class="orientation-back orientation-element"></section>
733
+ <section class="orientation-left orientation-element"></section>
734
+ <section class="orientation-right orientation-element"></section>
735
+ <section class="orientation-bottom orientation-element"></section>
736
+ </section>
737
+ </div>
738
+ </div>
739
+ </div>
740
+ `,
741
+ orientationGroup
742
+ );
743
+ // clang-format on
744
+
663
745
  this.enableOrientationFields(true);
664
746
  this.setBoxOrientation(this.deviceOrientation, false);
747
+
748
+ this.#setOrientationInputValue(this.alphaElement, String(this.deviceOrientation.alpha));
749
+ this.#setOrientationInputValue(this.betaElement, String(this.deviceOrientation.beta));
750
+ this.#setOrientationInputValue(this.gammaElement, String(this.deviceOrientation.gamma));
665
751
  }
666
752
 
667
753
  private createPressureSection(): void {
@@ -824,54 +910,11 @@ export class SensorsView extends UI.Widget.VBox {
824
910
  }
825
911
 
826
912
  #setOrientationInputValue(input: HTMLInputElement, value: string): void {
827
- if (input.value === value) {
828
- return;
829
- }
830
913
  input.value = value;
831
914
  const valid = this.#validateOrientationInput(input, value);
832
915
  input.classList.toggle('error-input', !valid);
833
916
  }
834
917
 
835
- private createDeviceOrientationOverrideElement(deviceOrientation: SDK.EmulationModel.DeviceOrientation):
836
- HTMLFieldSetElement {
837
- const fieldsetElement = document.createElement('fieldset');
838
- fieldsetElement.classList.add('device-orientation-override-section');
839
- const cellElement = fieldsetElement.createChild('td', 'orientation-inputs-cell');
840
-
841
- this.alphaElement = UI.UIUtils.createInput('', 'number', 'alpha');
842
- this.alphaElement.setAttribute('step', 'any');
843
- this.#setupAxisInput(cellElement, this.alphaElement, i18nString(UIStrings.alpha));
844
- this.#setOrientationInputValue(this.alphaElement, String(deviceOrientation.alpha));
845
-
846
- this.betaElement = UI.UIUtils.createInput('', 'number', 'beta');
847
- this.betaElement.setAttribute('step', 'any');
848
- this.#setupAxisInput(cellElement, this.betaElement, i18nString(UIStrings.beta));
849
- this.#setOrientationInputValue(this.betaElement, String(deviceOrientation.beta));
850
-
851
- this.gammaElement = UI.UIUtils.createInput('', 'number', 'gamma');
852
- this.gammaElement.setAttribute('step', 'any');
853
- this.#setupAxisInput(cellElement, this.gammaElement, i18nString(UIStrings.gamma));
854
- this.#setOrientationInputValue(this.gammaElement, String(deviceOrientation.gamma));
855
-
856
- const resetButton = UI.UIUtils.createTextButton(
857
- i18nString(UIStrings.reset), this.resetDeviceOrientation.bind(this),
858
- {className: 'orientation-reset-button', jslogContext: 'sensors.reset-device-orientiation'});
859
- UI.ARIAUtils.setLabel(resetButton, i18nString(UIStrings.resetDeviceOrientation));
860
- resetButton.setAttribute('type', 'reset');
861
- cellElement.appendChild(resetButton);
862
- return fieldsetElement;
863
- }
864
-
865
- #setupAxisInput(parentElement: Element, input: HTMLInputElement, label: string): void {
866
- const div = parentElement.createChild('div', 'orientation-axis-input-container');
867
- div.appendChild(input);
868
- div.appendChild(UI.UIUtils.createLabel(label, /* className */ '', input));
869
- input.addEventListener('change', this.#onOrientationChange.bind(this), false);
870
- input.addEventListener('input', this.#onOrientationInput.bind(this), false);
871
- input.addEventListener('keydown', this.#onOrientationKeyDown.bind(this), false);
872
- input.addEventListener('focus', this.#onOrientationFocus.bind(this), false);
873
- }
874
-
875
918
  private setBoxOrientation(deviceOrientation: SDK.EmulationModel.DeviceOrientation, animate: boolean): void {
876
919
  if (animate) {
877
920
  this.stageElement.classList.add('is-animating');
@@ -657,48 +657,17 @@ class SummaryView extends UI.Widget.Widget {
657
657
  }
658
658
 
659
659
  function generateRangeSummaryDetails(input: SummaryViewInput): LitTemplate {
660
- const {parsedTrace, selectedRange} = input;
661
-
662
- if (!selectedRange || !parsedTrace) {
663
- return nothing;
664
- }
665
-
666
- const minBoundsMilli = Trace.Helpers.Timing.microToMilli(parsedTrace.data.Meta.traceBounds.min);
667
- const {events, startTime, endTime, thirdPartyTree} = selectedRange;
668
- const aggregatedStats = TimelineUIUtils.statsForTimeRange(events, startTime, endTime);
669
- const startOffset = startTime - minBoundsMilli;
670
- const endOffset = endTime - minBoundsMilli;
671
-
672
- let total = 0;
673
- for (const categoryName in aggregatedStats) {
674
- total += aggregatedStats[categoryName];
675
- }
676
-
677
- const categories: TimelineComponents.TimelineSummary.CategoryData[] = [];
678
- for (const categoryName in Trace.Styles.getCategoryStyles()) {
679
- const category = Trace.Styles.getCategoryStyles()[categoryName as keyof Trace.Styles.CategoryPalette];
680
- if (category.name === Trace.Styles.EventCategory.IDLE) {
681
- continue;
682
- }
683
- const value = aggregatedStats[category.name];
684
- if (!value) {
685
- continue;
686
- }
687
- categories.push({value, color: category.getCSSValue(), title: category.title});
688
- }
689
- categories.sort((a, b) => b.value - a.value);
690
-
691
660
  // clang-format off
692
661
  return html`
693
662
  <devtools-widget
694
663
  ${widget(TimelineComponents.TimelineRangeSummaryView.TimelineRangeSummaryView, {
695
664
  data: {
696
- rangeStart: startOffset,
697
- rangeEnd: endOffset,
698
- total,
699
- categories,
700
- thirdPartyTreeTemplate: html`<devtools-performance-third-party-tree-view
701
- .treeView=${thirdPartyTree}></devtools-performance-third-party-tree-view>`,
665
+ parsedTrace: input.parsedTrace,
666
+ events: input.selectedRange?.events,
667
+ startTime: input.selectedRange?.startTime,
668
+ endTime: input.selectedRange?.endTime,
669
+ thirdPartyTreeTemplate: input.selectedRange?.thirdPartyTree ? html`<devtools-performance-third-party-tree-view
670
+ .treeView=${input.selectedRange?.thirdPartyTree}></devtools-performance-third-party-tree-view>` : nothing,
702
671
  } as TimelineComponents.TimelineRangeSummaryView.TimelineRangeSummaryViewData,
703
672
  })}
704
673
  ></devtools-widget>`;
@@ -1541,124 +1541,6 @@ export class TimelineUIUtils {
1541
1541
  return contentHelper.fragment;
1542
1542
  }
1543
1543
 
1544
- static statsForTimeRange(
1545
- events: Trace.Types.Events.Event[], startTime: Trace.Types.Timing.Milli,
1546
- endTime: Trace.Types.Timing.Milli): TimeRangeCategoryStats {
1547
- if (!events.length) {
1548
- return {idle: endTime - startTime};
1549
- }
1550
-
1551
- buildRangeStatsCacheIfNeeded(events);
1552
- const aggregatedStats = subtractStats(aggregatedStatsAtTime(endTime), aggregatedStatsAtTime(startTime));
1553
- const aggregatedTotal = Object.values(aggregatedStats).reduce((a, b) => a + b, 0);
1554
- aggregatedStats['idle'] = Math.max(0, endTime - startTime - aggregatedTotal);
1555
- return aggregatedStats;
1556
-
1557
- function aggregatedStatsAtTime(time: number): TimeRangeCategoryStats {
1558
- const stats: TimeRangeCategoryStats = {};
1559
- // @ts-expect-error TODO(crbug.com/1011811): Remove symbol usage.
1560
- const cache = events[categoryBreakdownCacheSymbol];
1561
- for (const category in cache) {
1562
- const categoryCache = cache[category];
1563
- const index =
1564
- Platform.ArrayUtilities.upperBound(categoryCache.time, time, Platform.ArrayUtilities.DEFAULT_COMPARATOR);
1565
- let value;
1566
- if (index === 0) {
1567
- value = 0;
1568
- } else if (index === categoryCache.time.length) {
1569
- value = categoryCache.value[categoryCache.value.length - 1];
1570
- } else {
1571
- const t0 = categoryCache.time[index - 1];
1572
- const t1 = categoryCache.time[index];
1573
- const v0 = categoryCache.value[index - 1];
1574
- const v1 = categoryCache.value[index];
1575
- value = v0 + (v1 - v0) * (time - t0) / (t1 - t0);
1576
- }
1577
- stats[category] = value;
1578
- }
1579
- return stats;
1580
- }
1581
-
1582
- function subtractStats(a: TimeRangeCategoryStats, b: TimeRangeCategoryStats): TimeRangeCategoryStats {
1583
- const result = Object.assign({}, a);
1584
- for (const key in b) {
1585
- result[key] -= b[key];
1586
- }
1587
- return result;
1588
- }
1589
-
1590
- function buildRangeStatsCacheIfNeeded(events: Trace.Types.Events.Event[]): void {
1591
- // @ts-expect-error TODO(crbug.com/1011811): Remove symbol usage.
1592
- if (events[categoryBreakdownCacheSymbol]) {
1593
- return;
1594
- }
1595
-
1596
- // aggregatedStats is a map by categories. For each category there's an array
1597
- // containing sorted time points which records accumulated value of the category.
1598
- const aggregatedStats: Record<string, {
1599
- time: number[],
1600
- value: number[],
1601
- }> = {};
1602
- const categoryStack: string[] = [];
1603
- let lastTime = 0;
1604
- Trace.Helpers.Trace.forEachEvent(events, {
1605
- onStartEvent,
1606
- onEndEvent,
1607
- });
1608
-
1609
- function updateCategory(category: string, time: number): void {
1610
- let statsArrays: {
1611
- time: number[],
1612
- value: number[],
1613
- } = aggregatedStats[category];
1614
- if (!statsArrays) {
1615
- statsArrays = {time: [], value: []};
1616
- aggregatedStats[category] = statsArrays;
1617
- }
1618
- if (statsArrays.time.length && statsArrays.time[statsArrays.time.length - 1] === time || lastTime > time) {
1619
- return;
1620
- }
1621
- const lastValue = statsArrays.value.length > 0 ? statsArrays.value[statsArrays.value.length - 1] : 0;
1622
- statsArrays.value.push(lastValue + time - lastTime);
1623
- statsArrays.time.push(time);
1624
- }
1625
-
1626
- function categoryChange(from: string|null, to: string|null, time: number): void {
1627
- if (from) {
1628
- updateCategory(from, time);
1629
- }
1630
- lastTime = time;
1631
- if (to) {
1632
- updateCategory(to, time);
1633
- }
1634
- }
1635
-
1636
- function onStartEvent(e: Trace.Types.Events.Event): void {
1637
- const {startTime} = Trace.Helpers.Timing.eventTimingsMilliSeconds(e);
1638
- const category = Trace.Styles.getEventStyle(e.name as Trace.Types.Events.Name)?.category.name ||
1639
- Trace.Styles.getCategoryStyles().other.name;
1640
- const parentCategory = categoryStack.length ? categoryStack[categoryStack.length - 1] : null;
1641
- if (category !== parentCategory) {
1642
- categoryChange(parentCategory || null, category, startTime);
1643
- }
1644
- categoryStack.push(category);
1645
- }
1646
-
1647
- function onEndEvent(e: Trace.Types.Events.Event): void {
1648
- const {endTime} = Trace.Helpers.Timing.eventTimingsMilliSeconds(e);
1649
- const category = categoryStack.pop();
1650
- const parentCategory = categoryStack.length ? categoryStack[categoryStack.length - 1] : null;
1651
- if (category !== parentCategory) {
1652
- categoryChange(category || null, parentCategory || null, endTime || 0);
1653
- }
1654
- }
1655
-
1656
- const obj = (events as Object);
1657
- // @ts-expect-error TODO(crbug.com/1011811): Remove symbol usage.
1658
- obj[categoryBreakdownCacheSymbol] = aggregatedStats;
1659
- }
1660
- }
1661
-
1662
1544
  private static renderEventJson(event: Trace.Types.Events.Event, contentHelper: TimelineDetailsContentHelper): void {
1663
1545
  contentHelper.addSection(i18nString(UIStrings.traceEvent));
1664
1546
 
@@ -167,7 +167,7 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
167
167
  export class IgnoreListSetting extends UI.Widget.Widget {
168
168
  static createWidgetElement(): UI.Widget.WidgetElement<IgnoreListSetting> {
169
169
  const widgetElement = document.createElement('devtools-widget') as UI.Widget.WidgetElement<IgnoreListSetting>;
170
- widgetElement.widgetConfig = UI.Widget.widgetConfig(IgnoreListSetting);
170
+ new IgnoreListSetting(widgetElement);
171
171
  return widgetElement;
172
172
  }
173
173
 
@@ -14,7 +14,7 @@ import sidebarInsightsTabStyles from './sidebarInsightsTab.css.js';
14
14
  import {SidebarSingleInsightSet, type SidebarSingleInsightSetData} from './SidebarSingleInsightSet.js';
15
15
 
16
16
  const {html} = Lit;
17
- const {widgetConfig} = UI.Widget;
17
+ const {widget} = UI.Widget;
18
18
 
19
19
  interface ViewInput {
20
20
  parsedTrace: Trace.TraceModel.ParsedTrace;
@@ -67,7 +67,7 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
67
67
  const contents = html`
68
68
  <devtools-widget
69
69
  data-insight-set-key=${id}
70
- .widgetConfig=${widgetConfig(SidebarSingleInsightSet, {data})}
70
+ ${widget(SidebarSingleInsightSet, {data})}
71
71
  ></devtools-widget>
72
72
  `;
73
73