chrome-devtools-frontend 1.0.1583146 → 1.0.1585664

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 (119) hide show
  1. package/front_end/core/host/InspectorFrontendHostAPI.ts +1 -0
  2. package/front_end/core/host/InspectorFrontendHostStub.ts +2 -0
  3. package/front_end/core/root/Runtime.ts +12 -6
  4. package/front_end/core/sdk/CSSMatchedStyles.ts +3 -0
  5. package/front_end/core/sdk/CSSMetadata.ts +3 -0
  6. package/front_end/entrypoints/main/MainImpl.ts +1 -0
  7. package/front_end/generated/Deprecation.ts +21 -0
  8. package/front_end/generated/InspectorBackendCommands.ts +5 -3
  9. package/front_end/generated/SupportedCSSProperties.js +10 -4
  10. package/front_end/generated/protocol-mapping.d.ts +2 -1
  11. package/front_end/generated/protocol-proxy-api.d.ts +2 -1
  12. package/front_end/generated/protocol.ts +14 -0
  13. package/front_end/models/ai_assistance/AiConversation.ts +34 -2
  14. package/front_end/models/ai_assistance/BuiltInAi.ts +1 -2
  15. package/front_end/models/ai_assistance/agents/AiAgent.ts +3 -10
  16. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +1 -1
  17. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +17 -9
  18. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +0 -24
  19. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +12 -0
  20. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -0
  21. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +16 -8
  22. package/front_end/models/computed_style/ComputedStyleModel.ts +20 -15
  23. package/front_end/models/greendev/Prototypes.ts +1 -5
  24. package/front_end/models/issues_manager/CorsIssue.ts +2 -9
  25. package/front_end/models/issues_manager/descriptions/corsLocalNetworkAccessPermissionDenied.md +2 -2
  26. package/front_end/models/javascript_metadata/NativeFunctions.js +20 -0
  27. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +13 -36
  28. package/front_end/panels/ai_assistance/components/ChatInput.ts +73 -95
  29. package/front_end/panels/ai_assistance/components/ChatView.ts +13 -2
  30. package/front_end/panels/application/FrameDetailsView.ts +4 -9
  31. package/front_end/panels/common/AiCodeGenerationTeaser.ts +10 -0
  32. package/front_end/panels/console/ConsoleView.ts +1 -2
  33. package/front_end/panels/console/ConsoleViewMessage.ts +19 -12
  34. package/front_end/panels/elements/ComputedStyleWidget.ts +41 -21
  35. package/front_end/panels/elements/ElementsPanel.ts +18 -5
  36. package/front_end/panels/elements/ElementsTreeElement.ts +173 -169
  37. package/front_end/panels/elements/NodeStackTraceWidget.ts +3 -13
  38. package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +69 -0
  39. package/front_end/panels/elements/computedStyleWidget.css +1 -6
  40. package/front_end/panels/elements/elements.ts +3 -1
  41. package/front_end/panels/issues/AffectedResourcesView.ts +1 -2
  42. package/front_end/panels/network/NetworkDataGridNode.ts +0 -8
  43. package/front_end/panels/network/RequestConditionsDrawer.ts +138 -112
  44. package/front_end/panels/network/RequestInitiatorView.ts +2 -10
  45. package/front_end/panels/settings/SettingsScreen.ts +12 -4
  46. package/front_end/panels/snippets/SnippetsQuickOpen.ts +6 -9
  47. package/front_end/panels/sources/CallStackSidebarPane.ts +4 -6
  48. package/front_end/panels/sources/DebuggerPlugin.ts +2 -1
  49. package/front_end/panels/sources/GoToLineQuickOpen.ts +0 -4
  50. package/front_end/panels/sources/OpenFileQuickOpen.ts +0 -4
  51. package/front_end/panels/sources/OutlineQuickOpen.ts +0 -4
  52. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +3 -1
  53. package/front_end/panels/sources/sources-meta.ts +9 -6
  54. package/front_end/panels/timeline/TimelineFlameChartView.ts +0 -12
  55. package/front_end/panels/timeline/TimelinePanel.ts +35 -15
  56. package/front_end/panels/timeline/TimelineUIUtils.ts +2 -6
  57. package/front_end/panels/timeline/components/Sidebar.ts +21 -0
  58. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +1 -20
  59. package/front_end/panels/timeline/components/insights/InsightRenderer.ts +0 -1
  60. package/front_end/third_party/chromium/README.chromium +1 -1
  61. package/front_end/third_party/puppeteer/README.chromium +2 -2
  62. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts +1 -1
  63. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  64. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +1 -1
  65. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  66. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +2 -3
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.d.ts.map +1 -1
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.js +5 -3
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.js.map +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  75. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  76. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +8 -6
  77. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts +1 -1
  78. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  79. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  82. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +2 -3
  83. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  85. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  86. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.d.ts.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.js +5 -3
  88. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.js.map +1 -1
  89. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  91. package/front_end/third_party/puppeteer/package/package.json +4 -4
  92. package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +1 -1
  93. package/front_end/third_party/puppeteer/package/src/bidi/core/BrowsingContext.ts +2 -2
  94. package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +4 -3
  95. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  96. package/front_end/third_party/puppeteer/package/src/util/encoding.ts +5 -3
  97. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  98. package/front_end/ui/components/linkifier/LinkifierImpl.ts +3 -0
  99. package/front_end/ui/components/linkifier/LinkifierUtils.ts +3 -0
  100. package/front_end/ui/components/text_editor/AiCodeGenerationParser.ts +29 -7
  101. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +34 -18
  102. package/front_end/ui/legacy/InspectorView.ts +41 -15
  103. package/front_end/ui/legacy/UIUtils.ts +30 -6
  104. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +4 -3
  105. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +2 -1
  106. package/front_end/ui/legacy/components/quick_open/HelpQuickOpen.ts +8 -2
  107. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +8 -8
  108. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +20 -150
  109. package/front_end/ui/legacy/components/utils/Linkifier.ts +120 -87
  110. package/front_end/ui/legacy/components/utils/jsUtils.css +0 -9
  111. package/front_end/ui/legacy/legacy.ts +0 -2
  112. package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
  113. package/mcp/HostBindings.ts +3 -0
  114. package/package.json +1 -1
  115. package/front_end/models/issues_manager/descriptions/corsInsecurePrivateNetwork.md +0 -10
  116. package/front_end/models/issues_manager/descriptions/corsPreflightAllowPrivateNetworkError.md +0 -10
  117. package/front_end/models/issues_manager/descriptions/corsPrivateNetworkPermissionDenied.md +0 -10
  118. package/front_end/ui/legacy/Floaty.ts +0 -438
  119. package/front_end/ui/legacy/floaty.css +0 -77
@@ -697,19 +697,42 @@ export class ElementFocusRestorer {
697
697
  export function runCSSAnimationOnce(element: Element, className: string): void {
698
698
  function animationEndCallback(): void {
699
699
  element.classList.remove(className);
700
- element.removeEventListener('webkitAnimationEnd', animationEndCallback, false);
700
+ element.removeEventListener('animationend', animationEndCallback, false);
701
701
  element.removeEventListener('animationcancel', animationEndCallback, false);
702
702
  }
703
703
 
704
- if (element.classList.contains(className)) {
705
- element.classList.remove(className);
706
- }
707
-
708
- element.addEventListener('webkitAnimationEnd', animationEndCallback, false);
704
+ // Remove class if it exists.
705
+ element.classList.toggle(className, /* force=*/ false);
706
+ element.addEventListener('animationend', animationEndCallback, false);
709
707
  element.addEventListener('animationcancel', animationEndCallback, false);
710
708
  element.classList.add(className);
711
709
  }
712
710
 
711
+ class AnimateOnDirective extends Lit.Directive.Directive {
712
+ #previousValue = false;
713
+
714
+ render(_condition: boolean, _className: string): void {
715
+ return undefined; // Directives don't have to render HTML
716
+ }
717
+
718
+ override update(part: Lit.Directive.ElementPart, [condition, className]: [boolean, string]): void {
719
+ const el = part.element as HTMLElement;
720
+
721
+ // Only trigger if the condition transitioned from false -> true
722
+ if (condition && !this.#previousValue) {
723
+ this.#animate(el, className);
724
+ }
725
+
726
+ this.#previousValue = condition;
727
+ }
728
+
729
+ #animate(el: HTMLElement, className: string): void {
730
+ runCSSAnimationOnce(el, className);
731
+ }
732
+ }
733
+
734
+ export const animateOn = Lit.Directive.directive(AnimateOnDirective);
735
+
713
736
  export function measurePreferredSize(element: Element, containerElement?: Element|null): Geometry.Size {
714
737
  const oldParent = element.parentElement;
715
738
  const oldNextSibling = element.nextSibling;
@@ -1530,6 +1553,7 @@ export function createFileSelectorElement(callback: (arg0: File) => void, accept
1530
1553
  }
1531
1554
 
1532
1555
  export const MaxLengthForDisplayedURLs = 150;
1556
+ export const MaxLengthForDisplayedURLsInConsole = 40;
1533
1557
 
1534
1558
  export class MessageDialog {
1535
1559
  static async show(header: string, message: string, where?: Element|Document, jslogContext?: string): Promise<void> {
@@ -275,8 +275,8 @@ export const enum PanelOrDrawer {
275
275
  export class CommandMenuProvider extends Provider {
276
276
  private commands: Command[];
277
277
 
278
- constructor(commandsForTest: Command[] = []) {
279
- super('command');
278
+ constructor(jslogContext: string, commandsForTest: Command[] = []) {
279
+ super(jslogContext);
280
280
  this.commands = commandsForTest;
281
281
  }
282
282
 
@@ -455,8 +455,9 @@ export class ShowActionDelegate implements UI.ActionRegistration.ActionDelegate
455
455
  registerProvider({
456
456
  prefix: '>',
457
457
  iconName: 'chevron-right',
458
- provider: () => Promise.resolve(new CommandMenuProvider()),
458
+ provider: (jslogContext: string) => Promise.resolve(new CommandMenuProvider(jslogContext)),
459
459
  helpTitle: () => i18nString(UIStrings.runCommand),
460
460
  titlePrefix: () => i18nString(UIStrings.run),
461
461
  titleSuggestion: () => i18nString(UIStrings.command),
462
+ jslogContext: 'command',
462
463
  });
@@ -657,8 +657,9 @@ export function getRegisteredProviders(): ProviderRegistration[] {
657
657
  export interface ProviderRegistration {
658
658
  prefix: string;
659
659
  iconName: string;
660
- provider: () => Promise<Provider>;
660
+ provider: (jslogContext: string) => Promise<Provider>;
661
661
  helpTitle: (() => string);
662
662
  titlePrefix: (() => string);
663
663
  titleSuggestion?: (() => string);
664
+ jslogContext: string;
664
665
  }
@@ -24,11 +24,16 @@ export class HelpQuickOpen extends Provider {
24
24
  }
25
25
 
26
26
  private async addProvider(extension: ProviderRegistration): Promise<void> {
27
+ // We want to exclude Help menu as we are already in it.
28
+ if (extension.prefix === '?') {
29
+ return;
30
+ }
31
+
27
32
  this.providers.push({
28
33
  prefix: extension.prefix || '',
29
34
  iconName: extension.iconName,
30
35
  title: extension.helpTitle(),
31
- jslogContext: (await extension.provider()).jslogContext,
36
+ jslogContext: extension.jslogContext,
32
37
  });
33
38
  }
34
39
 
@@ -69,8 +74,9 @@ export class HelpQuickOpen extends Provider {
69
74
  registerProvider({
70
75
  prefix: '?',
71
76
  iconName: 'help',
72
- provider: () => Promise.resolve(new HelpQuickOpen('help')),
77
+ provider: jslogContext => Promise.resolve(new HelpQuickOpen(jslogContext)),
73
78
  helpTitle: () => 'Help',
74
79
  titlePrefix: () => 'Help',
75
80
  titleSuggestion: undefined,
81
+ jslogContext: 'help'
76
82
  });
@@ -5,7 +5,12 @@
5
5
  import * as i18n from '../../../../core/i18n/i18n.js';
6
6
  import type * as UI from '../../legacy.js';
7
7
 
8
- import {FilteredListWidget, getRegisteredProviders, type Provider} from './FilteredListWidget.js';
8
+ import {
9
+ FilteredListWidget,
10
+ getRegisteredProviders,
11
+ type Provider,
12
+ type ProviderRegistration
13
+ } from './FilteredListWidget.js';
9
14
 
10
15
  const UIStrings = {
11
16
  /**
@@ -42,19 +47,14 @@ export class QuickOpenImpl {
42
47
  filteredListWidget.setQuery(query);
43
48
  }
44
49
 
45
- private addProvider(extension: {
46
- prefix: string,
47
- provider: () => Promise<Provider>,
48
- titlePrefix: () => string,
49
- titleSuggestion?: (() => string),
50
- }): void {
50
+ private addProvider(extension: ProviderRegistration): void {
51
51
  const prefix = extension.prefix;
52
52
  if (prefix === null) {
53
53
  return;
54
54
  }
55
55
  this.prefixes.push(prefix);
56
56
  this.providers.set(prefix, {
57
- provider: extension.provider,
57
+ provider: () => extension.provider(extension.jslogContext),
58
58
  titlePrefix: extension.titlePrefix,
59
59
  titleSuggestion: extension.titleSuggestion,
60
60
  });
@@ -34,17 +34,15 @@
34
34
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
35
  */
36
36
 
37
- import * as Common from '../../../../core/common/common.js';
38
37
  import * as i18n from '../../../../core/i18n/i18n.js';
39
38
  import * as SDK from '../../../../core/sdk/sdk.js';
40
- import type * as Protocol from '../../../../generated/protocol.js';
41
39
  import * as StackTrace from '../../../../models/stack_trace/stack_trace.js';
42
40
  import * as Workspace from '../../../../models/workspace/workspace.js';
43
41
  import * as VisualLogging from '../../../visual_logging/visual_logging.js';
44
42
  import * as UI from '../../legacy.js';
45
43
 
46
44
  import jsUtilsStyles from './jsUtils.css.js';
47
- import {Events as LinkifierEvents, Linkifier} from './Linkifier.js';
45
+ import {Linkifier} from './Linkifier.js';
48
46
 
49
47
  const UIStrings = {
50
48
  /**
@@ -63,10 +61,6 @@ const UIStrings = {
63
61
  * @description A link to rehide frames that are by default hidden.
64
62
  */
65
63
  showLess: 'Show less',
66
- /**
67
- * @description Text indicating that source url of a link is currently unknown
68
- */
69
- unknownSource: 'unknown',
70
64
  } as const;
71
65
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/utils/JSPresentationUtils.ts', UIStrings);
72
66
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -95,74 +89,8 @@ function populateContextMenu(link: Element, event: Event): void {
95
89
  void contextMenu.show();
96
90
  }
97
91
 
98
- // TODO(crbug.com/456517732): remove when all usages of runtimeStackTrace are migrated.
99
- function buildStackTraceRowsForLegacyRuntimeStackTrace(
100
- stackTrace: Protocol.Runtime.StackTrace,
101
- target: SDK.Target.Target|null,
102
- linkifier: Linkifier,
103
- tabStops: boolean|undefined,
104
- updateCallback?: (arg0: Array<StackTraceRegularRow|StackTraceAsyncRow>) => void,
105
- showColumnNumber?: boolean,
106
- ): Array<StackTraceRegularRow|StackTraceAsyncRow> {
107
- const stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow> = [];
108
-
109
- if (updateCallback) {
110
- const throttler = new Common.Throttler.Throttler(100);
111
- linkifier.addEventListener(LinkifierEvents.LIVE_LOCATION_UPDATED, () => {
112
- void throttler.schedule(async () => updateCallback(stackTraceRows));
113
- });
114
- }
115
-
116
- function buildStackTraceRowsHelper(
117
- stackTrace: Protocol.Runtime.StackTrace,
118
- previousCallFrames: Protocol.Runtime.CallFrame[]|undefined = undefined): void {
119
- let asyncRow: StackTraceAsyncRow|null = null;
120
- if (previousCallFrames) {
121
- asyncRow = {
122
- asyncDescription: UI.UIUtils.asyncStackTraceLabel(stackTrace.description, previousCallFrames),
123
- };
124
- stackTraceRows.push(asyncRow);
125
- }
126
- let previousStackFrameWasBreakpointCondition = false;
127
- for (const stackFrame of stackTrace.callFrames) {
128
- const functionName = UI.UIUtils.beautifyFunctionName(stackFrame.functionName);
129
- const link = linkifier.maybeLinkifyConsoleCallFrame(target, stackFrame, {
130
- showColumnNumber,
131
- tabStop: Boolean(tabStops),
132
- inlineFrameIndex: 0,
133
- revealBreakpoint: previousStackFrameWasBreakpointCondition,
134
- });
135
- if (link) {
136
- link.setAttribute('jslog', `${VisualLogging.link('stack-trace').track({click: true})}`);
137
- link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
138
-
139
- if (!link.textContent) {
140
- link.textContent = i18nString(UIStrings.unknownSource);
141
- }
142
- }
143
- stackTraceRows.push({functionName, link});
144
- previousStackFrameWasBreakpointCondition = [
145
- SDK.DebuggerModel.COND_BREAKPOINT_SOURCE_URL,
146
- SDK.DebuggerModel.LOGPOINT_SOURCE_URL,
147
- ].includes(stackFrame.url);
148
- }
149
- }
150
-
151
- buildStackTraceRowsHelper(stackTrace);
152
- let previousCallFrames = stackTrace.callFrames;
153
- for (let asyncStackTrace = stackTrace.parent; asyncStackTrace; asyncStackTrace = asyncStackTrace.parent) {
154
- if (asyncStackTrace.callFrames.length) {
155
- buildStackTraceRowsHelper(asyncStackTrace, previousCallFrames);
156
- }
157
- previousCallFrames = asyncStackTrace.callFrames;
158
- }
159
- return stackTraceRows;
160
- }
161
-
162
92
  function buildStackTraceRows(
163
93
  stackTrace: StackTrace.StackTrace.StackTrace,
164
- target: SDK.Target.Target|null,
165
- linkifier: Linkifier,
166
94
  tabStops: boolean|undefined,
167
95
  showColumnNumber?: boolean,
168
96
  ): Array<StackTraceRegularRow|StackTraceAsyncRow> {
@@ -183,11 +111,12 @@ function buildStackTraceRows(
183
111
  let previousStackFrameWasBreakpointCondition = false;
184
112
  for (const frame of fragment.frames) {
185
113
  const functionName = UI.UIUtils.beautifyFunctionName(frame.name ?? '');
186
- const link = linkifier.maybeLinkifyStackTraceFrame(target, frame, {
114
+ const link = Linkifier.linkifyStackTraceFrame(frame, {
187
115
  showColumnNumber,
188
116
  tabStop: Boolean(tabStops),
189
117
  inlineFrameIndex: 0,
190
118
  revealBreakpoint: previousStackFrameWasBreakpointCondition,
119
+ maxLength: UI.UIUtils.MaxLengthForDisplayedURLsInConsole,
191
120
  });
192
121
  link.setAttribute('jslog', `${VisualLogging.link('stack-trace').track({click: true})}`);
193
122
  link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
@@ -213,9 +142,8 @@ function buildStackTraceRows(
213
142
 
214
143
  function renderStackTraceTable(
215
144
  container: Element, parent: Element, expandable: boolean,
216
- stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow>): HTMLElement[] {
145
+ stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow>): void {
217
146
  container.removeChildren();
218
- const links: HTMLElement[] = [];
219
147
 
220
148
  // The tableSection groups one or more synchronous call frames together.
221
149
  // Wherever there is an asynchronous call, a new section is created.
@@ -249,10 +177,7 @@ function renderStackTraceTable(
249
177
  } else {
250
178
  row.createChild('td', 'function-name').textContent = item.functionName;
251
179
  row.createChild('td').textContent = ' @ ';
252
- if (item.link) {
253
- row.createChild('td', 'link').appendChild(item.link);
254
- links.push(item.link);
255
- }
180
+ row.createChild('td', 'link').appendChild(item.link);
256
181
  }
257
182
  }
258
183
 
@@ -285,13 +210,9 @@ function renderStackTraceTable(
285
210
  // If we are in a popup, this will trigger a re-layout
286
211
  UI.GlassPane.GlassPane.containerMoved(container);
287
212
  }, false);
288
-
289
- return links;
290
213
  }
291
214
 
292
215
  export interface Options {
293
- // TODO(crbug.com/456517732): remove when all usages of runtimeStackTrace are migrated.
294
- runtimeStackTrace?: Protocol.Runtime.StackTrace;
295
216
  tabStops?: boolean;
296
217
  // Whether the width of stack trace preview
297
218
  // is constrained to its container or whether
@@ -303,7 +224,7 @@ export interface Options {
303
224
 
304
225
  interface StackTraceRegularRow {
305
226
  functionName: string;
306
- link: HTMLElement|null;
227
+ link: HTMLElement;
307
228
  }
308
229
 
309
230
  interface StackTraceAsyncRow {
@@ -312,90 +233,43 @@ interface StackTraceAsyncRow {
312
233
 
313
234
  export class StackTracePreviewContent extends UI.Widget.Widget {
314
235
  #stackTrace?: StackTrace.StackTrace.StackTrace;
315
- #target?: SDK.Target.Target;
316
- #linkifier?: Linkifier;
317
- #ownedLinkifier?: Linkifier;
318
- #options: Options;
319
- #links: HTMLElement[] = [];
236
+ #options: Options = {};
320
237
 
321
238
  readonly #table: HTMLElement;
322
- /**
323
- * Updated when we update to define if we have any rows for the StackTrace;
324
- * allowing the caller to know if this element is empty or not.
325
- */
326
- #hasRows = false;
327
-
328
- constructor(element?: HTMLElement, target?: SDK.Target.Target, linkifier?: Linkifier, options?: Options) {
329
- super(element, {useShadowDom: true});
330
-
331
- this.#target = target;
332
- this.#linkifier = linkifier;
333
- if (!this.#linkifier) {
334
- this.#ownedLinkifier = new Linkifier();
335
- this.#linkifier = this.#ownedLinkifier;
336
- }
337
- this.#options = options || {
338
- widthConstrained: false,
339
- };
340
239
 
341
- this.element.classList.add('monospace');
342
- this.element.classList.add('stack-preview-container');
343
- this.element.classList.toggle('width-constrained', this.#options.widthConstrained ?? false);
344
- this.element.style.display = 'inline-block';
240
+ constructor(element?: HTMLElement) {
241
+ super(element, {useShadowDom: true, classes: ['monospace', 'stack-preview-container']});
345
242
 
346
243
  UI.DOMUtilities.appendStyle(this.element.shadowRoot as ShadowRoot, jsUtilsStyles);
347
244
 
348
245
  this.#table = this.contentElement.createChild('table', 'stack-preview-container');
349
- this.#table.classList.toggle('width-constrained', this.#options.widthConstrained ?? false);
350
-
351
- this.performUpdate();
352
246
  }
353
247
 
354
248
  hasContent(): boolean {
355
- return this.#hasRows;
249
+ if (!this.#stackTrace) {
250
+ return false;
251
+ }
252
+ const {syncFragment, asyncFragments} = this.#stackTrace;
253
+ return syncFragment.frames.length > 0 || asyncFragments.some(f => f.frames.length > 0);
356
254
  }
357
255
 
358
256
  override performUpdate(): void {
359
- if (!this.#linkifier) {
257
+ if (!this.#stackTrace) {
360
258
  return;
361
259
  }
362
260
 
363
- const {runtimeStackTrace, tabStops} = this.#options;
364
-
365
- if (this.#stackTrace) {
366
- const stackTraceRows = buildStackTraceRows(
367
- this.#stackTrace, this.#target ?? null, this.#linkifier, tabStops, this.#options.showColumnNumber);
368
- this.#hasRows = stackTraceRows.length > 0;
369
- this.#links = renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
370
- return;
371
- }
372
-
373
- // TODO(crbug.com/456517732): remove when all usages of runtimeStackTrace are migrated.
374
- const updateCallback =
375
- renderStackTraceTable.bind(null, this.#table, this.element, this.#options.expandable ?? false);
376
- const stackTraceRows = buildStackTraceRowsForLegacyRuntimeStackTrace(
377
- runtimeStackTrace ?? {callFrames: []}, this.#target ?? null, this.#linkifier, tabStops, updateCallback,
378
- this.#options.showColumnNumber);
379
- this.#hasRows = stackTraceRows.length > 0;
380
- this.#links = renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
261
+ const stackTraceRows =
262
+ buildStackTraceRows(this.#stackTrace, this.#options.tabStops, this.#options.showColumnNumber);
263
+ renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
381
264
  }
382
265
 
383
266
  get linkElements(): readonly HTMLElement[] {
384
- return this.#links;
385
- }
386
-
387
- set target(target: SDK.Target.Target|undefined) {
388
- this.#target = target;
389
- this.requestUpdate();
390
- }
391
-
392
- set linkifier(linkifier: Linkifier) {
393
- this.#linkifier = linkifier;
394
- this.requestUpdate();
267
+ return [...this.contentElement.querySelectorAll<HTMLElement>('td.link > .devtools-link')];
395
268
  }
396
269
 
397
270
  set options(options: Options) {
398
271
  this.#options = options;
272
+ this.#table.classList.toggle('width-constrained', this.#options.widthConstrained ?? false);
399
273
  this.requestUpdate();
400
274
  }
401
275
 
@@ -407,8 +281,4 @@ export class StackTracePreviewContent extends UI.Widget.Widget {
407
281
  this.#stackTrace.addEventListener(StackTrace.StackTrace.Events.UPDATED, this.requestUpdate, this);
408
282
  this.requestUpdate();
409
283
  }
410
-
411
- override onDetach(): void {
412
- this.#ownedLinkifier?.dispose();
413
- }
414
284
  }