chrome-devtools-frontend 1.0.1578729 → 1.0.1579812

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 (72) hide show
  1. package/docs/cookbook/devtools_on_devtools.md +2 -2
  2. package/docs/feature-specs/elements-gutter-decorators.md +40 -0
  3. package/docs/feature-specs/elements-tree-selection-and-hover.md +31 -0
  4. package/docs/feature-specs/images/elements-gutter-decorators-multiple.png +0 -0
  5. package/docs/get_the_code.md +3 -3
  6. package/front_end/generated/ARIAProperties.js +0 -6
  7. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  8. package/front_end/generated/protocol.ts +1 -0
  9. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +30 -0
  10. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +79 -0
  11. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -0
  12. package/front_end/panels/accessibility/AXBreadcrumbsPane.ts +5 -3
  13. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +18 -4
  14. package/front_end/panels/ai_assistance/components/ChatInput.ts +38 -18
  15. package/front_end/panels/ai_assistance/components/ChatMessage.ts +7 -4
  16. package/front_end/panels/ai_assistance/components/ChatView.ts +2 -0
  17. package/front_end/panels/ai_assistance/components/chatInput.css +10 -3
  18. package/front_end/panels/animation/AnimationGroupPreviewUI.ts +1 -1
  19. package/front_end/panels/application/DeviceBoundSessionsView.ts +51 -76
  20. package/front_end/panels/application/ServiceWorkerUpdateCycleView.ts +1 -0
  21. package/front_end/panels/application/components/BackForwardCacheView.ts +4 -2
  22. package/front_end/panels/autofill/AutofillView.ts +1 -1
  23. package/front_end/panels/browser_debugger/XHRBreakpointsSidebarPane.ts +1 -0
  24. package/front_end/panels/common/AiCodeGenerationTeaser.ts +2 -2
  25. package/front_end/panels/common/AiCodeGenerationUpgradeDialog.ts +4 -4
  26. package/front_end/panels/console/ConsoleViewMessage.ts +1 -0
  27. package/front_end/panels/elements/AdoptedStyleSheetTreeElement.ts +78 -0
  28. package/front_end/panels/elements/ElementsTreeElement.ts +93 -121
  29. package/front_end/panels/elements/ElementsTreeOutline.ts +1 -0
  30. package/front_end/panels/elements/LayoutPane.ts +8 -7
  31. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +1 -1
  32. package/front_end/panels/elements/components/StylePropertyEditor.ts +2 -1
  33. package/front_end/panels/elements/elements.ts +3 -0
  34. package/front_end/panels/elements/elementsTreeOutline.css +16 -5
  35. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +1 -1
  36. package/front_end/panels/lighthouse/LighthouseStartView.ts +1 -1
  37. package/front_end/panels/lighthouse/lighthouseStartView.css +6 -0
  38. package/front_end/panels/linear_memory_inspector/components/LinearMemoryValueInterpreter.ts +1 -1
  39. package/front_end/panels/linear_memory_inspector/components/ValueInterpreterDisplay.ts +1 -1
  40. package/front_end/panels/media/PlayerListView.ts +1 -1
  41. package/front_end/panels/network/NetworkLogView.ts +2 -5
  42. package/front_end/panels/network/NetworkLogViewColumns.ts +2 -1
  43. package/front_end/panels/network/components/RequestHeaderSection.ts +1 -1
  44. package/front_end/panels/protocol_monitor/JSONEditor.ts +1 -1
  45. package/front_end/panels/recorder/components/RecordingListView.ts +1 -1
  46. package/front_end/panels/recorder/components/StepEditor.ts +3 -3
  47. package/front_end/panels/settings/EditFileSystemView.ts +8 -8
  48. package/front_end/panels/settings/KeybindsSettingsTab.ts +2 -1
  49. package/front_end/panels/settings/SettingsScreen.ts +4 -4
  50. package/front_end/panels/sources/components/HeadersView.ts +2 -2
  51. package/front_end/panels/timeline/components/BreadcrumbsUI.ts +1 -1
  52. package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +1 -1
  53. package/front_end/panels/timeline/overlays/OverlaysImpl.ts +47 -26
  54. package/front_end/panels/timeline/overlays/components/TimespanBreakdownOverlay.ts +121 -39
  55. package/front_end/panels/timeline/overlays/components/timespanBreakdownOverlay.css +106 -101
  56. package/front_end/third_party/chromium/README.chromium +1 -1
  57. package/front_end/ui/components/suggestion_input/SuggestionInput.ts +7 -12
  58. package/front_end/ui/components/tree_outline/TreeOutline.ts +1 -1
  59. package/front_end/ui/legacy/InplaceEditor.ts +1 -1
  60. package/front_end/ui/legacy/ListControl.ts +2 -1
  61. package/front_end/ui/legacy/ListWidget.ts +1 -1
  62. package/front_end/ui/legacy/SoftContextMenu.ts +2 -1
  63. package/front_end/ui/legacy/Treeoutline.ts +1 -0
  64. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +4 -2
  65. package/front_end/ui/legacy/components/data_grid/SortableDataGrid.ts +59 -9
  66. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +28 -15
  67. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +2 -2
  68. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +1 -1
  69. package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +3 -3
  70. package/front_end/ui/legacy/components/source_frame/JSONView.ts +2 -3
  71. package/front_end/ui/visual_logging/Debugging.ts +1 -1
  72. package/package.json +1 -1
@@ -61,9 +61,8 @@ export interface EditFileSystemViewInput {
61
61
  fileSystemPath: Platform.DevToolsPath.UrlString;
62
62
  excludedFolderPaths: PathWithStatus[];
63
63
  onCreate: (event: CustomEvent<{url?: string}>) => void;
64
- onEdit:
65
- (event: CustomEvent<{node: HTMLElement, columnId: string, valueBeforeEditing: string, newText: string}>) => void;
66
- onDelete: (event: CustomEvent<HTMLElement>) => void;
64
+ onEdit: (event: CustomEvent<{columnId: string, valueBeforeEditing: string, newText: string}>) => void;
65
+ onDelete: (event: CustomEvent) => void;
67
66
  }
68
67
 
69
68
  export type View = (input: EditFileSystemViewInput, output: object, target: HTMLElement) => void;
@@ -77,8 +76,6 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
77
76
  <span class="excluded-folder-url">${input.fileSystemPath}</span>
78
77
  <devtools-data-grid
79
78
  @create=${input.onCreate}
80
- @edit=${input.onEdit}
81
- @delete=${input.onDelete}
82
79
  class="exclude-subfolders-table"
83
80
  parts="excluded-folder-row-with-error"
84
81
  inline striped>
@@ -90,7 +87,9 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
90
87
  </thead>
91
88
  <tbody>
92
89
  ${input.excludedFolderPaths.map((path, index) => html`
93
- <tr data-url=${path.path} data-index=${index}>
90
+ <tr data-url=${path.path} data-index=${index}
91
+ @edit=${input.onEdit}
92
+ @delete=${input.onDelete}>
94
93
  <td style=${styleMap({backgroundColor: path.status !== ExcludedFolderStatus.VALID ? 'var(--sys-color-error-container)' : undefined})}>${path.path}</td>
95
94
  </tr>
96
95
  `)}
@@ -139,8 +138,9 @@ export class EditFileSystemView extends UI.Widget.VBox {
139
138
  fileSystemPath: this.#fileSystem?.path() ?? Platform.DevToolsPath.urlString``,
140
139
  excludedFolderPaths: this.#excludedFolderPaths,
141
140
  onCreate: e => this.#onCreate(e.detail.url),
142
- onEdit: e => this.#onEdit(e.detail.node.dataset.index ?? '-1', e.detail.valueBeforeEditing, e.detail.newText),
143
- onDelete: e => this.#onDelete(e.detail.dataset.index ?? '-1'),
141
+ onEdit: e => this.#onEdit(
142
+ (e.currentTarget as HTMLElement).dataset.index ?? '-1', e.detail.valueBeforeEditing, e.detail.newText),
143
+ onDelete: e => this.#onDelete((e.currentTarget as HTMLElement).dataset.index ?? '-1'),
144
144
  };
145
145
  this.#view(input, {}, this.contentElement);
146
146
  }
@@ -344,7 +344,8 @@ export class ShortcutListItem {
344
344
  this.settingsTab = settingsTab;
345
345
  this.item = item;
346
346
  this.element = document.createElement('div');
347
- this.element.setAttribute('jslog', `${VisualLogging.item().context(item.id()).track({keydown: 'Escape'})}`);
347
+ this.element.setAttribute(
348
+ 'jslog', `${VisualLogging.item().context(item.id()).track({keydown: 'Escape', resize: true})}`);
348
349
  this.editedShortcuts = new Map();
349
350
  this.shortcutInputs = new Map();
350
351
  this.shortcuts = UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction(item.id());
@@ -59,7 +59,7 @@ const UIStrings = {
59
59
  /**
60
60
  * @description Message to display if a setting change requires a reload of DevTools
61
61
  */
62
- oneOrMoreSettingsHaveChanged: 'One or more settings have changed which requires a reload to take effect',
62
+ settingsChangedReloadDevTools: 'Settings changed. To apply, reload DevTools.',
63
63
  /**
64
64
  * @description Warning text shown when the user has entered text to filter the
65
65
  * list of experiments, but no experiments match the filter.
@@ -465,7 +465,7 @@ export class ExperimentsSettingsTab extends UI.Widget.VBox implements SettingsTa
465
465
  experiment.setEnabled(checkbox.checked);
466
466
  Host.userMetrics.experimentChanged(experiment.name, experiment.isEnabled());
467
467
  UI.InspectorView.InspectorView.instance().displayReloadRequiredWarning(
468
- i18nString(UIStrings.oneOrMoreSettingsHaveChanged));
468
+ i18nString(UIStrings.settingsChangedReloadDevTools));
469
469
  }
470
470
  checkbox.addEventListener('click', listener, false);
471
471
 
@@ -675,7 +675,7 @@ function renderWidgetOptions(settings: GreenDev.GreenDevSettings): TemplateResul
675
675
  }
676
676
 
677
677
  UI.InspectorView.InspectorView.instance().displayReloadRequiredWarning(
678
- i18nString(UIStrings.oneOrMoreSettingsHaveChanged));
678
+ i18nString(UIStrings.settingsChangedReloadDevTools));
679
679
  };
680
680
  }
681
681
  // clang-format off
@@ -701,7 +701,7 @@ function renderPrototypeCheckboxes(
701
701
 
702
702
  function showChangeWarning(): void {
703
703
  UI.InspectorView.InspectorView.instance().displayReloadRequiredWarning(
704
- i18nString(UIStrings.oneOrMoreSettingsHaveChanged));
704
+ i18nString(UIStrings.settingsChangedReloadDevTools));
705
705
  }
706
706
  // clang-format off
707
707
  const checkboxes = Object.keys(settings).map(name => {
@@ -404,7 +404,7 @@ export class HeadersViewComponent extends HTMLElement {
404
404
  // clang-format off
405
405
  return html`
406
406
  <div class="row" data-block-index=${blockIndex}
407
- jslog=${VisualLogging.treeItem(pattern === '*' ? pattern : undefined)}>
407
+ jslog=${VisualLogging.treeItem(pattern === '*' ? pattern : undefined).track({resize: true})}>
408
408
  <div>${i18n.i18n.lockedString('Apply to')}</div>
409
409
  <div class="separator">:</div>
410
410
  ${this.#renderEditable(pattern, 'apply-to')}
@@ -427,7 +427,7 @@ export class HeadersViewComponent extends HTMLElement {
427
427
  // clang-format off
428
428
  return html`
429
429
  <div class="row padded" data-block-index=${blockIndex} data-header-index=${headerIndex}
430
- jslog=${VisualLogging.treeItem(header.name).parent('headers-editor-row-parent')}>
430
+ jslog=${VisualLogging.treeItem(header.name).parent('headers-editor-row-parent').track({resize: true})}>
431
431
  ${this.#renderEditable(header.name, 'header-name red', true)}
432
432
  <div class="separator">:</div>
433
433
  ${this.#renderEditable(header.value, 'header-value')}
@@ -111,7 +111,7 @@ export class BreadcrumbsUI extends HTMLElement {
111
111
  // clang-format off
112
112
  return html`
113
113
  <div class="breadcrumb" @contextmenu=${(event: Event) => this.#onContextMenu(event, breadcrumb)} @click=${() => this.#activateBreadcrumb(breadcrumb)}
114
- jslog=${VisualLogging.item('timeline.breadcrumb-select').track({click: true})}>
114
+ jslog=${VisualLogging.item('timeline.breadcrumb-select').track({click: true, resize: true})}>
115
115
  <span class="${(breadcrumb === this.#activeBreadcrumb) ? 'active-breadcrumb' : ''} range">
116
116
  ${(index === 0) ?
117
117
  `Full range (${i18n.TimeUtilities.preciseMillisToString(breadcrumbRange, 2)})` :
@@ -424,7 +424,7 @@ export const DEFAULT_VIEW: (input: SidebarAnnotationsTabViewInput, output: objec
424
424
  @mouseout=${() => (annotation.type === 'ENTRY_LABEL') ? input.onAnnotationHoverOut() : null}
425
425
  aria-label=${label}
426
426
  tabindex="0"
427
- jslog=${VisualLogging.item(`timeline.annotation-sidebar.annotation-${jslogForAnnotation(annotation)}`).track({click: true})}
427
+ jslog=${VisualLogging.item(`timeline.annotation-sidebar.annotation-${jslogForAnnotation(annotation)}`).track({click: true, resize: true})}
428
428
  >
429
429
  <div class="annotation">
430
430
  ${renderAnnotationIdentifier(annotation, input.annotationEntryToColorMap)}
@@ -9,9 +9,11 @@ import * as Platform from '../../../core/platform/platform.js';
9
9
  import * as AIAssistance from '../../../models/ai_assistance/ai_assistance.js';
10
10
  import * as Trace from '../../../models/trace/trace.js';
11
11
  import type * as PerfUI from '../../../ui/legacy/components/perf_ui/perf_ui.js';
12
+ import * as UI from '../../../ui/legacy/legacy.js';
12
13
  import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
13
14
 
14
15
  import * as Components from './components/components.js';
16
+ import type {SectionPosition} from './components/TimespanBreakdownOverlay.js';
15
17
 
16
18
  const UIStrings = {
17
19
  /**
@@ -909,8 +911,13 @@ export class Overlays extends EventTarget {
909
911
  return;
910
912
  }
911
913
 
912
- const component = element.querySelector('devtools-timespan-breakdown-overlay');
913
- const elementSections = component?.renderedSections() ?? [];
914
+ const component = element.querySelector('.devtools-timespan-breakdown-overlay');
915
+
916
+ if (!component) {
917
+ return;
918
+ }
919
+
920
+ const widget = UI.Widget.Widget.get(component) as Components.TimespanBreakdownOverlay.TimespanBreakdownOverlay;
914
921
 
915
922
  // Handle horizontal positioning.
916
923
  const leftEdgePixel = this.#xPixelForMicroSeconds('main', overlay.sections[0].bounds.min);
@@ -921,14 +928,11 @@ export class Overlays extends EventTarget {
921
928
  }
922
929
 
923
930
  const rangeWidth = rightEdgePixel - leftEdgePixel;
924
- element.style.left = `${leftEdgePixel}px`;
925
- element.style.width = `${rangeWidth}px`;
926
931
 
927
- if (elementSections.length === 0) {
928
- return;
929
- }
932
+ widget.left = leftEdgePixel;
933
+ widget.width = rangeWidth;
930
934
 
931
- let count = 0;
935
+ const widths: SectionPosition[] = [];
932
936
  for (const section of overlay.sections) {
933
937
  const leftPixel = this.#xPixelForMicroSeconds('main', section.bounds.min);
934
938
  const rightPixel = this.#xPixelForMicroSeconds('main', section.bounds.max);
@@ -936,18 +940,17 @@ export class Overlays extends EventTarget {
936
940
  return;
937
941
  }
938
942
  const rangeWidth = rightPixel - leftPixel;
939
- const sectionElement = elementSections[count];
940
943
 
941
- sectionElement.style.left = `${leftPixel}px`;
942
- sectionElement.style.width = `${rangeWidth}px`;
943
- count++;
944
+ widths.push({left: leftPixel, width: rangeWidth});
944
945
  }
945
946
 
947
+ widget.widths = widths;
948
+
946
949
  // Handle vertical positioning based on the entry's vertical position.
947
950
  if (overlay.entry && (overlay.renderLocation === 'BELOW_EVENT' || overlay.renderLocation === 'ABOVE_EVENT')) {
948
951
  // Max height for the overlay box when attached to an entry.
949
952
  const MAX_BOX_HEIGHT = 50;
950
- element.style.maxHeight = `${MAX_BOX_HEIGHT}px`;
953
+ widget.maxHeight = MAX_BOX_HEIGHT;
951
954
 
952
955
  const y = this.yPixelForEventOnChart(overlay.entry);
953
956
  if (y === null) {
@@ -960,7 +963,7 @@ export class Overlays extends EventTarget {
960
963
 
961
964
  if (overlay.renderLocation === 'BELOW_EVENT') {
962
965
  const top = y + eventHeight;
963
- element.style.top = `${top}px`;
966
+ widget.top = top;
964
967
  } else {
965
968
  // Some padding so the box hovers just on top.
966
969
  const PADDING = 7;
@@ -974,7 +977,7 @@ export class Overlays extends EventTarget {
974
977
  const height = Math.min(MAX_BOX_HEIGHT, minSpace);
975
978
 
976
979
  const top = bottom - height;
977
- element.style.top = `${top}px`;
980
+ widget.top = top;
978
981
  }
979
982
  }
980
983
  }
@@ -1558,11 +1561,17 @@ export class Overlays extends EventTarget {
1558
1561
  return overlayElement;
1559
1562
  }
1560
1563
  case 'TIMESPAN_BREAKDOWN': {
1561
- const component = new Components.TimespanBreakdownOverlay.TimespanBreakdownOverlay();
1562
- component.sections = overlay.sections;
1563
- component.canvasRect = this.#charts.mainChart.canvasBoundingClientRect();
1564
- component.isBelowEntry = overlay.renderLocation === 'BELOW_EVENT';
1565
- overlayElement.appendChild(component);
1564
+ const widget = document.createElement('devtools-widget') as
1565
+ UI.Widget.WidgetElement<Components.TimespanBreakdownOverlay.TimespanBreakdownOverlay>;
1566
+
1567
+ widget.widgetConfig = UI.Widget.widgetConfig(Components.TimespanBreakdownOverlay.TimespanBreakdownOverlay, {
1568
+ isBelowEntry: overlay.renderLocation === 'BELOW_EVENT',
1569
+ canvasRect: this.#charts.mainChart.canvasBoundingClientRect(),
1570
+ sections: overlay.sections,
1571
+ });
1572
+
1573
+ overlayElement.appendChild(widget);
1574
+
1566
1575
  return overlayElement;
1567
1576
  }
1568
1577
  case 'TIMINGS_MARKER': {
@@ -1685,10 +1694,16 @@ export class Overlays extends EventTarget {
1685
1694
  break;
1686
1695
  }
1687
1696
  case 'TIMESPAN_BREAKDOWN': {
1688
- const component = element.querySelector('devtools-timespan-breakdown-overlay');
1689
- if (component) {
1690
- component.sections = overlay.sections;
1691
- component.canvasRect = this.#charts.mainChart.canvasBoundingClientRect();
1697
+ const component = element.querySelector('.devtools-timespan-breakdown-overlay');
1698
+ if (!component) {
1699
+ return;
1700
+ }
1701
+
1702
+ const widget = UI.Widget.Widget.get(component) as Components.TimespanBreakdownOverlay.TimespanBreakdownOverlay;
1703
+
1704
+ if (widget) {
1705
+ widget.sections = overlay.sections;
1706
+ widget.canvasRect = this.#charts.mainChart.canvasBoundingClientRect();
1692
1707
  }
1693
1708
  break;
1694
1709
  }
@@ -1737,8 +1752,14 @@ export class Overlays extends EventTarget {
1737
1752
  case 'ENTRIES_LINK':
1738
1753
  break;
1739
1754
  case 'TIMESPAN_BREAKDOWN': {
1740
- const component = element.querySelector('devtools-timespan-breakdown-overlay');
1741
- component?.checkSectionLabelPositioning();
1755
+ const component = element.querySelector('.devtools-timespan-breakdown-overlay');
1756
+
1757
+ if (!component) {
1758
+ return;
1759
+ }
1760
+
1761
+ const widget = UI.Widget.Widget.get(component) as Components.TimespanBreakdownOverlay.TimespanBreakdownOverlay;
1762
+ widget?.checkSectionLabelPositioning();
1742
1763
  break;
1743
1764
  }
1744
1765
  case 'TIMESTAMP_MARKER':
@@ -1,23 +1,110 @@
1
1
  // Copyright 2024 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
- /* eslint-disable @devtools/no-lit-render-outside-of-view */
5
4
 
6
5
  import * as i18n from '../../../../core/i18n/i18n.js';
7
6
  import type * as Trace from '../../../../models/trace/trace.js';
8
- import * as Lit from '../../../../ui/lit/lit.js';
7
+ import * as UI from '../../../../ui/legacy/legacy.js';
8
+ import {Directives, html, nothing, render, type TemplateResult} from '../../../../ui/lit/lit.js';
9
9
 
10
10
  import timespanBreakdownOverlayStyles from './timespanBreakdownOverlay.css.js';
11
11
 
12
- const {html} = Lit;
12
+ export interface Input {
13
+ sections: Trace.Types.Overlays.TimespanBreakdownEntryBreakdown[]|null;
14
+ positions: SectionPosition[];
15
+ left: number|null;
16
+ width: number|null;
17
+ maxHeight: number|null;
18
+ top: number|null;
19
+ className: string;
20
+ }
21
+ export interface SectionPosition {
22
+ left: number|null;
23
+ width: number|null;
24
+ }
25
+
26
+ type View = (input: Input, _output: undefined, target: HTMLElement) => void;
27
+
28
+ const renderSection =
29
+ (section: Trace.Types.Overlays.TimespanBreakdownEntryBreakdown, position: SectionPosition): TemplateResult => {
30
+ const style = Directives.styleMap(
31
+ {left: position ? `${position.left}px` : undefined, width: position ? `${position.width}px` : undefined});
32
+
33
+ // clang-format off
34
+ return html`
35
+ <div class="timespan-breakdown-overlay-section" style=${style}>
36
+ <div class="timespan-breakdown-overlay-label">
37
+ ${
38
+ section.showDuration ?
39
+ html`<span class="duration-text">${i18n.TimeUtilities.formatMicroSecondsAsMillisFixed(section.bounds.range)}</span> ` :
40
+ nothing
41
+ }
42
+ <span class="section-label-text">${section.label}</span>
43
+ </div>
44
+ </div>`;
45
+ // clang-format on
46
+ };
47
+
48
+ export const DEFAULT_VIEW = (input: Input, _output: undefined, target: HTMLElement): void => {
49
+ const style = Directives.styleMap({
50
+ left: input.left ? `${input.left}px` : undefined,
51
+ width: input.width ? `${input.width}px` : undefined,
52
+ top: input.top ? `${input.top}px` : undefined,
53
+ maxHeight: input.maxHeight ? `${input.maxHeight}px` : undefined,
54
+ position: 'relative'
55
+ });
56
+ // clang-format off
57
+ render(
58
+ html`
59
+ <style>${timespanBreakdownOverlayStyles}</style>
60
+ <div style=${style} class=${input.className}>
61
+ ${input.sections?.map((curr, index) => {
62
+ return renderSection(curr, input.positions[index]);
63
+ })}
64
+ </div>`,
65
+ target);
66
+ // clang-format off
67
+ };
13
68
 
14
- export class TimespanBreakdownOverlay extends HTMLElement {
15
- readonly #shadow = this.attachShadow({mode: 'open'});
69
+ export class TimespanBreakdownOverlay extends UI.Widget.Widget {
16
70
  #canvasRect: DOMRect|null = null;
17
71
  #sections: Trace.Types.Overlays.TimespanBreakdownEntryBreakdown[]|null = null;
72
+ #sectionsPositions: SectionPosition[] = [];
73
+ #left: number|null = null;
74
+ #width: number|null = null;
75
+ #maxHeight: number|null = null;
76
+ #top: number|null = null;
77
+
78
+ #view: View;
79
+
80
+ constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
81
+ super(element, {classes: ['devtools-timespan-breakdown-overlay']});
82
+ this.#view = view;
83
+ this.requestUpdate();
84
+ }
85
+
86
+ set top(top: number) {
87
+ this.#top = top;
88
+ this.requestUpdate();
89
+ }
90
+
91
+ set maxHeight(maxHeight: number) {
92
+ this.#maxHeight = maxHeight;
93
+ this.requestUpdate();
94
+ }
95
+
96
+ set width(width: number) {
97
+ this.#width = width;
98
+ this.requestUpdate();
99
+ }
100
+
101
+ set left(left: number) {
102
+ this.#left = left;
103
+ this.requestUpdate();
104
+ }
18
105
 
19
106
  set isBelowEntry(isBelow: boolean) {
20
- this.classList.toggle('is-below', isBelow);
107
+ this.element.classList.toggle('is-below', isBelow);
21
108
  }
22
109
 
23
110
  set canvasRect(rect: DOMRect|null) {
@@ -25,7 +112,16 @@ export class TimespanBreakdownOverlay extends HTMLElement {
25
112
  return;
26
113
  }
27
114
  this.#canvasRect = rect;
28
- this.#render();
115
+ this.requestUpdate();
116
+ }
117
+
118
+ set widths(widths: SectionPosition[]) {
119
+ if (widths === this.#sectionsPositions) {
120
+ return;
121
+ }
122
+
123
+ this.#sectionsPositions = widths;
124
+ this.requestUpdate();
29
125
  }
30
126
 
31
127
  set sections(sections: Trace.Types.Overlays.TimespanBreakdownEntryBreakdown[]|null) {
@@ -33,7 +129,7 @@ export class TimespanBreakdownOverlay extends HTMLElement {
33
129
  return;
34
130
  }
35
131
  this.#sections = sections;
36
- this.#render();
132
+ this.requestUpdate();
37
133
  }
38
134
 
39
135
  /**
@@ -43,7 +139,7 @@ export class TimespanBreakdownOverlay extends HTMLElement {
43
139
  * align the text so the label is visible as long as possible.
44
140
  */
45
141
  checkSectionLabelPositioning(): void {
46
- const sections = this.#shadow.querySelectorAll<HTMLElement>('.timespan-breakdown-overlay-section');
142
+ const sections = this.element.querySelectorAll<HTMLElement>('.timespan-breakdown-overlay-section');
47
143
  if (!sections) {
48
144
  return;
49
145
  }
@@ -139,40 +235,26 @@ export class TimespanBreakdownOverlay extends HTMLElement {
139
235
  }
140
236
  }
141
237
 
142
- renderedSections(): HTMLElement[] {
143
- return Array.from(this.#shadow.querySelectorAll('.timespan-breakdown-overlay-section'));
144
- }
145
-
146
- #renderSection(section: Trace.Types.Overlays.TimespanBreakdownEntryBreakdown): Lit.TemplateResult {
147
- // clang-format off
148
- return html`
149
- <div class="timespan-breakdown-overlay-section">
150
- <div class="timespan-breakdown-overlay-label">
151
- ${section.showDuration ?
152
- html`<span class="duration-text">${i18n.TimeUtilities.formatMicroSecondsAsMillisFixed(section.bounds.range)}</span> ` : Lit.nothing}
153
- <span class="section-label-text">${section.label}</span>
154
- </div>
155
- </div>`;
156
- // clang-format on
157
- }
238
+ override performUpdate(): void {
239
+ let className = 'timeline-segment-container';
158
240
 
159
- #render(): void {
160
241
  if (this.#sections) {
161
- this.classList.toggle('odd-number-of-sections', this.#sections.length % 2 === 1);
162
- this.classList.toggle('even-number-of-sections', this.#sections.length % 2 === 0);
242
+ if(this.#sections.length % 2 === 0) {
243
+ className += ' even-number-of-sections';
244
+ } else {
245
+ className += ' odd-number-of-sections';
246
+ }
163
247
  }
164
- Lit.render(
165
- html`<style>${timespanBreakdownOverlayStyles}</style>
166
- ${this.#sections?.map(this.#renderSection)}`,
167
- this.#shadow, {host: this});
168
- this.checkSectionLabelPositioning();
169
- }
170
- }
171
248
 
172
- customElements.define('devtools-timespan-breakdown-overlay', TimespanBreakdownOverlay);
249
+ this.#view({sections: this.#sections,
250
+ positions: this.#sectionsPositions,
251
+ left: this.#left,
252
+ width: this.#width,
253
+ top: this.#top,
254
+ maxHeight: this.#maxHeight,
255
+ className
256
+ }, undefined, this.contentElement);
173
257
 
174
- declare global {
175
- interface HTMLElementTagNameMap {
176
- 'devtools-timespan-breakdown-overlay': TimespanBreakdownOverlay;
258
+ this.checkSectionLabelPositioning();
177
259
  }
178
260
  }