chrome-devtools-frontend 1.0.1732418 → 1.0.1733843

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 (146) hide show
  1. package/docs/get_the_code.md +1 -73
  2. package/front_end/Tests.js +0 -5
  3. package/front_end/core/host/AidaClientTypes.ts +24 -3
  4. package/front_end/core/host/AidaGcaTranslation.ts +29 -1
  5. package/front_end/core/platform/browser/HostRuntime.ts +5 -1
  6. package/front_end/core/sdk/DOMModel.ts +8 -3
  7. package/front_end/design_system_tokens.css +5 -0
  8. package/front_end/entrypoints/formatter_worker/ScopeParser.ts +2 -2
  9. package/front_end/generated/InspectorBackendCommands.ts +5 -5
  10. package/front_end/generated/SupportedCSSProperties.ts +8 -2
  11. package/front_end/generated/protocol.ts +29 -7
  12. package/front_end/models/ai-utils/debug.ts +127 -22
  13. package/front_end/models/ai_assistance/AiConversation.ts +1 -0
  14. package/front_end/models/ai_assistance/README.md +1 -1
  15. package/front_end/models/ai_assistance/agents/AiAgent.ts +69 -11
  16. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +2 -1
  17. package/front_end/models/ai_assistance/contexts/DOMNodeContext.ts +4 -3
  18. package/front_end/models/ai_assistance/contexts/LighthouseContext.snapshot.txt +4 -2
  19. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +6 -0
  20. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +2 -0
  21. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +1 -1
  22. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +26 -26
  23. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +2 -1
  24. package/front_end/models/ai_code_completion/ai_code_completion.ts +11 -2
  25. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +2 -1
  26. package/front_end/models/ai_code_generation/ai_code_generation.ts +11 -2
  27. package/front_end/models/trace/LanternComputationData.ts +4 -0
  28. package/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +126 -1
  29. package/front_end/models/trace/lantern/types/Lantern.ts +3 -0
  30. package/front_end/models/web_mcp/WebMCPModel.ts +1 -1
  31. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +65 -15
  32. package/front_end/panels/ai_assistance/ExternalHandler.ts +1 -1
  33. package/front_end/panels/ai_assistance/components/PermissionPrompt.ts +4 -4
  34. package/front_end/panels/ai_assistance/components/chatMessage.css +4 -5
  35. package/front_end/panels/ai_assistance/components/exploreWidget.css +3 -3
  36. package/front_end/panels/application/backgroundServiceView.css +2 -2
  37. package/front_end/panels/application/components/reportsGrid.css +1 -1
  38. package/front_end/panels/application/components/serviceWorkerRouterView.css +2 -2
  39. package/front_end/panels/application/components/trustTokensView.css +1 -1
  40. package/front_end/panels/application/deviceBoundSessionsView.css +1 -1
  41. package/front_end/panels/application/frameDetailsReportView.css +0 -4
  42. package/front_end/panels/application/indexedDBViews.css +0 -4
  43. package/front_end/panels/application/resourcesPanel.css +0 -13
  44. package/front_end/panels/application/serviceWorkerUpdateCycleView.css +3 -3
  45. package/front_end/panels/application/serviceWorkersView.css +3 -2
  46. package/front_end/panels/browser_debugger/XHRBreakpointsSidebarPane.ts +346 -286
  47. package/front_end/panels/comments/CommentsPane.ts +2 -11
  48. package/front_end/panels/common/CommentThreadWidget.ts +11 -3
  49. package/front_end/panels/common/CommentsOverlayWidget.ts +3 -2
  50. package/front_end/panels/console/consoleContextSelector.css +1 -1
  51. package/front_end/panels/console/consolePinPane.css +1 -1
  52. package/front_end/panels/console/consolePrompt.css +4 -2
  53. package/front_end/panels/console/consoleView.css +1 -1
  54. package/front_end/panels/elements/ComputedStyleWidget.ts +8 -19
  55. package/front_end/panels/elements/PropertyRenderer.ts +7 -27
  56. package/front_end/panels/elements/StylePropertyTreeElement.ts +61 -72
  57. package/front_end/panels/elements/components/cssPropertyDocsView.css +1 -1
  58. package/front_end/panels/elements/components/elementsBreadcrumbs.css +1 -1
  59. package/front_end/panels/elements/components/stylePropertyEditor.css +1 -5
  60. package/front_end/panels/elements/layoutPane.css +1 -1
  61. package/front_end/panels/elements/metricsSidebarPane.css +2 -2
  62. package/front_end/panels/elements/propertiesWidget.css +0 -5
  63. package/front_end/panels/elements/stylesSidebarPane.css +3 -2
  64. package/front_end/panels/emulation/deviceModeView.css +3 -3
  65. package/front_end/panels/event_listeners/eventListenersView.css +1 -1
  66. package/front_end/panels/explain/components/consoleInsight.css +2 -2
  67. package/front_end/panels/issues/issuesTree.css +10 -7
  68. package/front_end/panels/layer_viewer/layerTreeOutline.css +1 -1
  69. package/front_end/panels/lighthouse/LighthousePanel.ts +16 -1
  70. package/front_end/panels/lighthouse/lighthousePanel.css +1 -1
  71. package/front_end/panels/linear_memory_inspector/components/LinearMemoryHighlightChipList.ts +10 -6
  72. package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +1 -26
  73. package/front_end/panels/linear_memory_inspector/components/valueInterpreterDisplay.css +1 -1
  74. package/front_end/panels/media/playerListView.css +11 -8
  75. package/front_end/panels/media/playerMessagesView.css +9 -5
  76. package/front_end/panels/network/NetworkWaterfallColumn.ts +92 -55
  77. package/front_end/panels/network/networkConfigView.css +3 -3
  78. package/front_end/panels/network/networkLogView.css +5 -4
  79. package/front_end/panels/network/networkManageCustomHeadersView.css +1 -1
  80. package/front_end/panels/network/networkTimingTable.css +4 -8
  81. package/front_end/panels/network/requestPayloadView.css +1 -1
  82. package/front_end/panels/performance_monitor/performanceMonitor.css +1 -1
  83. package/front_end/panels/profiler/ModuleUIStrings.ts +12 -0
  84. package/front_end/panels/profiler/ProfileFlameChartDataProvider.ts +114 -18
  85. package/front_end/panels/protocol_monitor/JSONEditor.css +4 -3
  86. package/front_end/panels/recorder/createRecordingView.css +2 -2
  87. package/front_end/panels/recorder/stepEditor.css +1 -1
  88. package/front_end/panels/recorder/stepView.css +0 -7
  89. package/front_end/panels/recorder/timelineSection.css +1 -1
  90. package/front_end/panels/screencast/screencastView.css +1 -1
  91. package/front_end/panels/search/searchResultsPane.css +1 -1
  92. package/front_end/panels/security/mainView.css +2 -2
  93. package/front_end/panels/security/originView.css +1 -1
  94. package/front_end/panels/settings/AISettingsTab.ts +1 -0
  95. package/front_end/panels/sources/NavigatorView.ts +120 -49
  96. package/front_end/panels/sources/breakpointsView.css +3 -3
  97. package/front_end/panels/sources/components/HeadersView.css +2 -2
  98. package/front_end/panels/sources/watchExpressionsSidebarPane.css +2 -1
  99. package/front_end/panels/timeline/CompatibilityTracksAppender.ts +30 -10
  100. package/front_end/panels/timeline/TimelinePanel.ts +24 -3
  101. package/front_end/panels/timeline/components/metricCard.css +1 -1
  102. package/front_end/panels/timeline/components/networkRequestTooltip.css +2 -2
  103. package/front_end/panels/timeline/components/relatedInsightChips.css +1 -1
  104. package/front_end/panels/timeline/timelineFlameChartView.css +4 -4
  105. package/front_end/panels/timeline/timelineFlamechartPopover.css +2 -2
  106. package/front_end/panels/timeline/timelineMiniMap.css +3 -2
  107. package/front_end/panels/web_audio/WebAudioModel.ts +14 -5
  108. package/front_end/panels/web_audio/WebAudioView.ts +34 -1
  109. package/front_end/panels/web_audio/webAudio.css +17 -3
  110. package/front_end/panels/webauthn/webauthnPane.css +2 -4
  111. package/front_end/panels/whats_new/ReleaseNoteText.ts +19 -1
  112. package/front_end/panels/whats_new/ReleaseNoteView.ts +15 -1
  113. package/front_end/panels/whats_new/releaseNoteView.css +49 -0
  114. package/front_end/third_party/chromium/README.chromium +1 -1
  115. package/front_end/third_party/puppeteer-replay/README.chromium +9 -1
  116. package/front_end/third_party/puppeteer-replay/package/lib/main.d.ts +2 -2
  117. package/front_end/ui/components/buttons/button.css +0 -1
  118. package/front_end/ui/components/diff_view/diffView.css +1 -1
  119. package/front_end/ui/components/markdown_view/codeBlock.css +4 -4
  120. package/front_end/ui/components/markdown_view/markdownView.css +3 -7
  121. package/front_end/ui/components/panel_feedback/panelFeedback.css +3 -2
  122. package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +1 -1
  123. package/front_end/ui/components/suggestion_input/suggestionInput.css +2 -2
  124. package/front_end/ui/components/switch/switch.css +2 -1
  125. package/front_end/ui/legacy/TabbedPane.ts +1 -1
  126. package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +10 -3
  127. package/front_end/ui/legacy/components/inline_editor/colorSwatch.css +1 -2
  128. package/front_end/ui/legacy/components/perf_ui/chartViewport.css +1 -1
  129. package/front_end/ui/legacy/components/perf_ui/filmStripView.css +1 -1
  130. package/front_end/ui/legacy/components/perf_ui/flameChart.css +5 -3
  131. package/front_end/ui/legacy/components/perf_ui/overviewGrid.css +7 -4
  132. package/front_end/ui/legacy/components/perf_ui/pieChart.css +0 -1
  133. package/front_end/ui/legacy/components/utils/imagePreview.css +1 -1
  134. package/front_end/ui/legacy/inspectorCommon.css +11 -27
  135. package/front_end/ui/legacy/listWidget.css +1 -1
  136. package/front_end/ui/legacy/progressIndicator.css +1 -2
  137. package/front_end/ui/legacy/reportView.css +5 -2
  138. package/front_end/ui/legacy/searchableView.css +3 -2
  139. package/front_end/ui/legacy/suggestBox.css +2 -1
  140. package/front_end/ui/legacy/tabbedPane.css +8 -5
  141. package/front_end/ui/legacy/treeoutline.css +1 -1
  142. package/front_end/ui/legacy/viewContainers.css +1 -1
  143. package/front_end/ui/visual_logging/KnownContextValues.ts +11 -0
  144. package/package.json +1 -1
  145. package/front_end/models/ai_code_completion/debug.ts +0 -33
  146. package/front_end/models/ai_code_generation/debug.ts +0 -33
@@ -1,7 +1,6 @@
1
1
  // Copyright 2015 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-imperative-dom-api */
5
4
 
6
5
  import * as i18n from '../../core/i18n/i18n.js';
7
6
  import * as Platform from '../../core/platform/platform.js';
@@ -9,12 +8,12 @@ import * as SDK from '../../core/sdk/sdk.js';
9
8
  import * as Protocol from '../../generated/protocol.js';
10
9
  import * as Buttons from '../../ui/components/buttons/buttons.js';
11
10
  import * as UI from '../../ui/legacy/legacy.js';
12
- import {Directives, html, render, type TemplateResult} from '../../ui/lit/lit.js';
11
+ import {Directives, html, nothing, render, type TemplateResult} from '../../ui/lit/lit.js';
13
12
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
14
13
 
15
14
  import xhrBreakpointsSidebarPaneStyles from './xhrBreakpointsSidebarPane.css.js';
16
15
 
17
- const {classMap, ifDefined, ref} = Directives;
16
+ const {classMap, ifDefined, repeat} = Directives;
18
17
 
19
18
  const UIStrings = {
20
19
  /**
@@ -65,292 +64,261 @@ const UIStrings = {
65
64
  } as const;
66
65
  const str_ = i18n.i18n.registerUIStrings('panels/browser_debugger/XHRBreakpointsSidebarPane.ts', UIStrings);
67
66
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
68
- const containerToBreakpointEntry = new WeakMap<Element, HTMLElement>();
69
67
 
70
- let xhrBreakpointsSidebarPaneInstance: XHRBreakpointsSidebarPane|null = null;
71
-
72
- export class XHRBreakpointsSidebarPane extends UI.Widget.VBox implements UI.ContextFlavorListener.ContextFlavorListener,
73
- UI.Toolbar.ItemsProvider,
74
- UI.ListControl.ListDelegate<string> {
75
- readonly #breakpoints: UI.ListModel.ListModel<string>;
76
- #list: UI.ListControl.ListControl<string>;
77
- readonly #emptyElement: HTMLElement;
78
- readonly #breakpointElements: Map<string, Element>;
79
- readonly #addButton: UI.Toolbar.ToolbarButton;
80
- #hitBreakpoint?: string;
81
- #editingBreakpoint: string|null = null;
82
-
83
- private constructor() {
84
- super({
85
- jslog: `${VisualLogging.section('source.xhr-breakpoints')}`,
86
- useShadowDom: true,
87
- });
88
- this.registerRequiredCSS(xhrBreakpointsSidebarPaneStyles);
89
-
90
- this.#breakpoints = new UI.ListModel.ListModel();
91
- this.#list = new UI.ListControl.ListControl(this.#breakpoints, this, UI.ListControl.ListMode.NonViewport);
92
- this.contentElement.appendChild(this.#list.element);
93
- this.#list.element.classList.add('breakpoint-list', 'hidden');
94
- UI.ARIAUtils.markAsList(this.#list.element);
95
- UI.ARIAUtils.setLabel(this.#list.element, i18nString(UIStrings.xhrfetchBreakpoints));
96
- this.#emptyElement = this.contentElement.createChild('div', 'gray-info-message');
97
- this.#emptyElement.textContent = i18nString(UIStrings.noBreakpoints);
98
-
99
- this.#breakpointElements = new Map();
100
-
101
- this.#addButton = new UI.Toolbar.ToolbarButton(
102
- i18nString(UIStrings.addXhrfetchBreakpoint), 'plus', undefined, 'sources.add-xhr-fetch-breakpoint');
103
- this.#addButton.setSize(Buttons.Button.Size.SMALL);
104
- this.#addButton.addEventListener(UI.Toolbar.ToolbarButton.Events.CLICK, () => {
105
- void this.addButtonClicked();
106
- });
107
-
108
- this.#emptyElement.addEventListener('contextmenu', this.emptyElementContextMenu.bind(this), true);
109
- this.#emptyElement.tabIndex = -1;
110
- this.restoreBreakpoints();
111
- this.update();
112
- }
113
-
114
- static instance(): XHRBreakpointsSidebarPane {
115
- if (!xhrBreakpointsSidebarPaneInstance) {
116
- xhrBreakpointsSidebarPaneInstance = new XHRBreakpointsSidebarPane();
117
- }
118
- return xhrBreakpointsSidebarPaneInstance;
119
- }
120
-
121
- static removeInstance(): void {
122
- xhrBreakpointsSidebarPaneInstance = null;
123
- }
124
-
125
- toolbarItems(): TemplateResult {
126
- return html`${this.#addButton.element}`;
127
- }
128
-
129
- get addButtonForTest(): UI.Toolbar.ToolbarButton {
130
- return this.#addButton;
131
- }
68
+ export interface BreakpointItem {
69
+ url: string;
70
+ enabled: boolean;
71
+ title: string;
72
+ isHit: boolean;
73
+ isFocused: boolean;
74
+ isEditing: boolean;
75
+ }
132
76
 
133
- private emptyElementContextMenu(event: Event): void {
134
- const contextMenu = new UI.ContextMenu.ContextMenu(event);
135
- contextMenu.defaultSection().appendItem(
136
- i18nString(UIStrings.addBreakpoint), this.addButtonClicked.bind(this),
137
- {jslogContext: 'sources.add-xhr-fetch-breakpoint'});
138
- void contextMenu.show();
139
- }
77
+ export interface ViewInput {
78
+ isAdding: boolean;
79
+ breakpoints: BreakpointItem[];
80
+ onAddCommit: (newUrl: string) => void;
81
+ onAddCancel: () => void;
82
+ onBreakpointClick: (url: string) => void;
83
+ onBreakpointCheckboxChange: (url: string) => void;
84
+ onBreakpointContextMenu: (url: string, event: Event) => void;
85
+ onBreakpointNavigate: (url: string, direction: 'ArrowUp'|'ArrowDown'|'Home'|'End') => void;
86
+ onStartEditing: (url: string) => void;
87
+ onEditCommit: (oldUrl: string, newUrl: string) => void;
88
+ onEditCancel: (url: string) => void;
89
+ onEmptyContextMenu: (event: Event) => void;
90
+ }
140
91
 
141
- private async addButtonClicked(): Promise<void> {
142
- await UI.ViewManager.ViewManager.instance().showView('sources.xhr-breakpoints');
92
+ export type View = (input: ViewInput, output: undefined, target: HTMLElement|DocumentFragment) => void;
143
93
 
144
- const inputElementContainer = document.createElement('p');
145
- inputElementContainer.classList.add('breakpoint-condition');
146
- inputElementContainer.setAttribute('jslog', `${VisualLogging.value('condition').track({change: true})}`);
147
- this.addListElement(inputElementContainer, this.#list.element.firstChild as Element | null);
94
+ // clang-format off
95
+ export const DEFAULT_VIEW: View =
96
+ (input: ViewInput, _output: undefined, target: HTMLElement|DocumentFragment): void => {
97
+ const isEmpty = input.breakpoints.length === 0 && !input.isAdding;
148
98
 
99
+ const renderBreakpointItem = (item: BreakpointItem): TemplateResult => {
100
+ const isEditing = item.isEditing;
101
+ const isHit = item.isHit;
149
102
  const commit = (e: UI.TextPrompt.TextPromptElement.CommitEvent): void => {
150
- const newText = e.detail;
151
- this.removeListElement(inputElementContainer);
152
- SDK.DOMDebuggerModel.DOMDebuggerManager.instance().addXHRBreakpoint(newText, true);
153
- this.setBreakpoint(newText);
154
- this.update();
103
+ input.onEditCommit(item.url, e.detail);
155
104
  };
156
-
157
105
  const cancel = (): void => {
158
- this.removeListElement(inputElementContainer);
159
- this.update();
106
+ input.onEditCancel(item.url);
160
107
  };
161
-
162
- // clang-format off
163
- /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
164
- render(
165
- html`
166
- ${i18nString(UIStrings.breakWhenUrlContains)}
167
- <devtools-prompt
168
- value=""
169
- render-as-block
170
- ?editing=${true}
171
- aria-label=${i18nString(UIStrings.urlBreakpoint)}
172
- class="breakpoint-condition-input"
173
- @commit=${commit}
174
- @cancel=${cancel}>
175
- </devtools-prompt>
176
- `,
177
- inputElementContainer,
178
- );
179
- // clang-format on
180
- }
181
-
182
- heightForItem(_item: string): number {
183
- return 0;
184
- }
185
-
186
- isItemSelectable(_item: string): boolean {
187
- return true;
188
- }
189
-
190
- private setBreakpoint(breakKeyword: string): void {
191
- if (this.#breakpoints.indexOf(breakKeyword) !== -1) {
192
- this.#list.refreshItem(breakKeyword);
193
- } else {
194
- this.#breakpoints.insertWithComparator(breakKeyword, Platform.ArrayUtilities.DEFAULT_COMPARATOR);
195
- }
196
- if (!this.#list.selectedItem() || !this.hasFocus()) {
197
- this.#list.selectItem(this.#breakpoints.at(0));
198
- }
199
- }
200
-
201
- createElementForItem(item: string): Element {
202
- const listItemElement = document.createElement('div');
203
- UI.ARIAUtils.markAsListitem(listItemElement);
204
- const enabled = SDK.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints().get(item) || false;
205
- const title = item ? i18nString(UIStrings.urlContainsS, {PH1: item}) : i18nString(UIStrings.anyXhrOrFetch);
206
-
207
- const commit = (e: UI.TextPrompt.TextPromptElement.CommitEvent): void => {
208
- if (this.#editingBreakpoint !== item) {
209
- return;
108
+ const onKeyDown = (event: KeyboardEvent): void => {
109
+ let handled = false;
110
+ if (event.key === ' ') {
111
+ input.onBreakpointCheckboxChange(item.url);
112
+ handled = true;
113
+ } else if ((event.key === 'Enter' && !event.isComposing) || event.key === 'F2') {
114
+ input.onStartEditing(item.url);
115
+ handled = true;
116
+ } else if (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'Home' || event.key === 'End') {
117
+ input.onBreakpointNavigate(item.url, event.key);
118
+ handled = true;
210
119
  }
211
- const newText = e.detail;
212
- this.#editingBreakpoint = null;
213
- this.#removeBreakpoint(item);
214
- this.#addBreakpoint(newText, enabled);
215
- this.#list.selectItem(newText);
216
- this.focus();
217
- };
218
-
219
- const cancel = (): void => {
220
- if (this.#editingBreakpoint !== item) {
221
- return;
120
+ if (handled) {
121
+ event.consume(true);
222
122
  }
223
- this.#editingBreakpoint = null;
224
- this.#list.refreshItem(item);
225
- this.focus();
226
123
  };
227
124
 
228
- // clang-format off
229
- /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
230
- render(
231
- html`
232
- <div class=${classMap({'breakpoint-entry': true, 'breakpoint-hit': item === this.#hitBreakpoint})}
125
+ return html`
126
+ <div role="listitem"
127
+ jslog=${VisualLogging.item().track({
128
+ click: true,
129
+ dblclick: true,
130
+ resize: true,
131
+ keydown: 'ArrowUp|ArrowDown|PageUp|PageDown|Enter|Space',
132
+ })}>
133
+ <div class=${classMap({'breakpoint-entry': true, 'breakpoint-hit': isHit})}
233
134
  role="checkbox"
234
- aria-checked=${enabled ? 'true' : 'false'}
235
- aria-label=${title}
236
- aria-description=${ifDefined(item === this.#hitBreakpoint ? i18nString(UIStrings.breakpointHit) : undefined)}
237
- tabindex=${item === this.#list.selectedItem() ? '0' : '-1'}
238
- ?autofocus=${item === this.#list.selectedItem()}
239
- ${ref((el?: Element) => {
240
- if (el instanceof HTMLElement) {
241
- containerToBreakpointEntry.set(listItemElement, el);
242
- this.#breakpointElements.set(item, listItemElement);
243
- }
244
- })}
245
- @click=${(event: Event) => {
135
+ aria-checked=${item.enabled ? 'true' : 'false'}
136
+ aria-label=${item.title}
137
+ aria-description=${ifDefined(isHit ? i18nString(UIStrings.breakpointHit) : undefined)}
138
+ tabindex=${item.isFocused && !isEditing ? '0' : '-1'}
139
+ ?autofocus=${item.isFocused && !isEditing && !input.isAdding}
140
+ @click=${(event: MouseEvent) => {
246
141
  if (event.target === event.currentTarget) {
247
- this.checkboxClicked(item, enabled);
142
+ input.onBreakpointClick(item.url);
248
143
  }
249
144
  }}
250
- @contextmenu=${(e: Event) => this.contextMenu(item, e)}
251
- @keydown=${(event: KeyboardEvent) => {
252
- let handled = false;
253
- if (event.key === ' ') {
254
- this.checkboxClicked(item, enabled);
255
- handled = true;
256
- } else if (event.key === 'Enter') {
257
- this.#startEditing(item);
258
- handled = true;
259
- }
260
- if (handled) {
261
- event.consume(true);
262
- }
263
- }}>
145
+ @contextmenu=${(event: Event) => input.onBreakpointContextMenu(item.url, event)}
146
+ @keydown=${onKeyDown}>
264
147
  <devtools-checkbox
265
148
  class="cursor-auto"
266
149
  aria-hidden="true"
267
- .checked=${enabled}
150
+ .checked=${item.enabled}
268
151
  .small=${true}
269
- .title=${title}
152
+ .title=${item.title}
270
153
  @click=${(e: Event) => e.stopPropagation()}
271
- @change=${() => this.checkboxClicked(item, enabled)}
272
- @dblclick=${() => this.#startEditing(item)}
154
+ @change=${() => input.onBreakpointCheckboxChange(item.url)}
155
+ @dblclick=${() => input.onStartEditing(item.url)}
273
156
  tabindex="-1"
274
157
  jslog=${VisualLogging.toggle().track({click: true})}>
275
158
  <devtools-prompt
276
- value=${item}
159
+ value=${item.url}
277
160
  render-as-block
278
- ?editing=${item === this.#editingBreakpoint}
279
- aria-label=${title}
280
- class=${classMap({'breakpoint-condition-input': item === this.#editingBreakpoint})}
161
+ ?editing=${isEditing}
162
+ ?autofocus=${isEditing}
163
+ aria-label=${item.url ? i18nString(UIStrings.urlBreakpoint) : i18nString(UIStrings.anyXhrOrFetch)}
164
+ class=${classMap({'breakpoint-condition-input': isEditing})}
281
165
  jslog=${VisualLogging.value('condition').track({change: true})}
282
166
  @commit=${commit}
283
167
  @cancel=${cancel}>
284
- ${title}
168
+ ${item.title}
285
169
  </devtools-prompt>
286
170
  </devtools-checkbox>
287
171
  </div>
288
- `,
289
- listItemElement,
290
- );
172
+ </div>
173
+ `;
174
+ };
175
+
176
+ render(
177
+ html`
178
+ <style>${xhrBreakpointsSidebarPaneStyles}</style>
179
+ <div class="breakpoint-list"
180
+ role="list"
181
+ aria-label=${i18nString(UIStrings.xhrfetchBreakpoints)}
182
+ ?hidden=${isEmpty}>
183
+ ${input.isAdding ? html`
184
+ <p class="breakpoint-condition" jslog=${VisualLogging.value('condition').track({change: true})}>
185
+ ${i18nString(UIStrings.breakWhenUrlContains)}
186
+ <devtools-prompt
187
+ value=""
188
+ render-as-block
189
+ ?editing=${true}
190
+ ?autofocus=${true}
191
+ aria-label=${i18nString(UIStrings.urlBreakpoint)}
192
+ class="breakpoint-condition-input"
193
+ @commit=${(e: UI.TextPrompt.TextPromptElement.CommitEvent) => input.onAddCommit(e.detail)}
194
+ @cancel=${input.onAddCancel}>
195
+ </devtools-prompt>
196
+ </p>
197
+ ` : nothing}
198
+ ${repeat(input.breakpoints, item => item.url, renderBreakpointItem)}
199
+ </div>
200
+ <div class="gray-info-message"
201
+ tabindex="-1"
202
+ ?autofocus=${isEmpty}
203
+ @contextmenu=${input.onEmptyContextMenu}
204
+ ?hidden=${!isEmpty}>
205
+ ${i18nString(UIStrings.noBreakpoints)}
206
+ </div>
207
+ `,
208
+ target,
209
+ {
210
+ container: {
211
+ attributes: {
212
+ jslog: `${VisualLogging.section('source.xhr-breakpoints')}`,
213
+ },
214
+ },
215
+ },
216
+ );
217
+ };
218
+ // clang-format on
219
+
220
+ let xhrBreakpointsSidebarPaneInstance: XHRBreakpointsSidebarPane|null = null;
221
+
222
+ export class XHRBreakpointsSidebarPane extends UI.Widget.VBox<ShadowRoot> implements
223
+ UI.ContextFlavorListener.ContextFlavorListener, UI.Toolbar.ItemsProvider {
224
+ readonly #breakpoints: string[] = [];
225
+ readonly #view: View;
226
+ #hitBreakpoint?: string;
227
+ #editingBreakpoint: string|null = null;
228
+ #focusedBreakpoint: string|null = null;
229
+ #isAddingBreakpoint = false;
230
+
231
+ constructor(view: View = DEFAULT_VIEW) {
232
+ super({
233
+ useShadowDom: 'pure',
234
+ delegatesFocus: true,
235
+ });
236
+ this.#view = view;
237
+
238
+ this.#restoreBreakpoints();
239
+ this.update();
240
+ this.performUpdate();
241
+ }
242
+
243
+ static instance(opts: {forceNew: boolean|null, view?: View} = {forceNew: null}): XHRBreakpointsSidebarPane {
244
+ const {forceNew, view} = opts;
245
+ if (!xhrBreakpointsSidebarPaneInstance || forceNew) {
246
+ xhrBreakpointsSidebarPaneInstance = new XHRBreakpointsSidebarPane(view);
247
+ }
248
+ return xhrBreakpointsSidebarPaneInstance;
249
+ }
250
+
251
+ static removeInstance(): void {
252
+ xhrBreakpointsSidebarPaneInstance = null;
253
+ }
254
+
255
+ toolbarItems(): TemplateResult {
256
+ // clang-format off
257
+ return html`
258
+ <devtools-button .data=${{
259
+ variant: Buttons.Button.Variant.TOOLBAR,
260
+ iconName: 'plus',
261
+ size: Buttons.Button.Size.SMALL,
262
+ title: i18nString(UIStrings.addXhrfetchBreakpoint),
263
+ jslogContext: 'sources.add-xhr-fetch-breakpoint',
264
+ } as Buttons.Button.ButtonData}
265
+ @click=${() => {
266
+ void this.addButtonClicked();
267
+ }}></devtools-button>
268
+ `;
291
269
  // clang-format on
270
+ }
292
271
 
293
- listItemElement.setAttribute('jslog', `${VisualLogging.item().track({
294
- click: true,
295
- dblclick: true,
296
- resize: true,
297
- keydown: 'ArrowUp|ArrowDown|PageUp|PageDown|Enter|Space',
298
- })}`);
299
- return listItemElement;
272
+ async addButtonClicked(): Promise<void> {
273
+ this.#isAddingBreakpoint = true;
274
+ this.performUpdate();
275
+ await UI.ViewManager.ViewManager.instance().showView('sources.xhr-breakpoints');
300
276
  }
301
277
 
302
- selectedItemChanged(_from: string|null, _to: string|null, fromElement: HTMLElement|null, toElement: HTMLElement|null):
303
- void {
304
- if (fromElement) {
305
- const breakpointEntryElement = containerToBreakpointEntry.get(fromElement);
306
- if (!breakpointEntryElement) {
307
- throw new Error('Expected breakpoint entry to be found for an element');
308
- }
309
- breakpointEntryElement.tabIndex = -1;
278
+ setBreakpoint(breakKeyword: string, enabled?: boolean): void {
279
+ if (enabled !== undefined) {
280
+ SDK.DOMDebuggerModel.DOMDebuggerManager.instance().addXHRBreakpoint(breakKeyword, enabled);
310
281
  }
311
- if (toElement) {
312
- const breakpointEntryElement = containerToBreakpointEntry.get(toElement);
313
- if (!breakpointEntryElement) {
314
- throw new Error('Expected breakpoint entry to be found for an element');
315
- }
316
- const prompt =
317
- _to === this.#editingBreakpoint ? toElement.querySelector('devtools-prompt') as HTMLElement | null : null;
318
- this.setDefaultFocusedElement(prompt || breakpointEntryElement);
319
- breakpointEntryElement.tabIndex = 0;
320
- if (this.hasFocus()) {
321
- if (prompt) {
322
- prompt.focus();
323
- return;
324
- }
325
- breakpointEntryElement.focus();
326
- }
282
+ if (!this.#breakpoints.includes(breakKeyword)) {
283
+ this.#breakpoints.push(breakKeyword);
284
+ this.#breakpoints.sort(Platform.ArrayUtilities.DEFAULT_COMPARATOR);
327
285
  }
286
+ this.#synchronizeFocusedBreakpoint();
287
+ this.performUpdate();
328
288
  }
329
289
 
330
- updateSelectedItemARIA(_fromElement: Element|null, _toElement: Element|null): boolean {
331
- return true;
290
+ #restoreBreakpoints(): void {
291
+ const breakpoints = SDK.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints();
292
+ for (const url of breakpoints.keys()) {
293
+ if (!this.#breakpoints.includes(url)) {
294
+ this.#breakpoints.push(url);
295
+ }
296
+ }
297
+ this.#breakpoints.sort(Platform.ArrayUtilities.DEFAULT_COMPARATOR);
298
+ this.#synchronizeFocusedBreakpoint();
332
299
  }
333
300
 
334
- private removeBreakpoint(breakKeyword: string): void {
335
- const index = this.#breakpoints.indexOf(breakKeyword);
336
- if (index >= 0) {
337
- this.#breakpoints.remove(index);
338
- }
339
- this.#breakpointElements.delete(breakKeyword);
340
- this.update();
301
+ get focusedBreakpoint(): string|null {
302
+ return this.#focusedBreakpoint;
341
303
  }
342
304
 
343
- private addListElement(element: Element, beforeNode: Node|null): void {
344
- this.#list.element.insertBefore(element, beforeNode);
345
- this.#emptyElement.classList.add('hidden');
346
- this.#list.element.classList.remove('hidden');
305
+ set focusedBreakpoint(url: string|null) {
306
+ if (this.#focusedBreakpoint === url) {
307
+ return;
308
+ }
309
+ this.#focusedBreakpoint = url;
310
+ this.#synchronizeFocusedBreakpoint();
311
+ this.requestUpdate();
347
312
  }
348
313
 
349
- private removeListElement(element: Element): void {
350
- this.#list.element.removeChild(element);
351
- if (!this.#list.element.firstElementChild) {
352
- this.#emptyElement.classList.remove('hidden');
353
- this.#list.element.classList.add('hidden');
314
+ #synchronizeFocusedBreakpoint(): void {
315
+ if (this.#focusedBreakpoint && !this.#breakpoints.includes(this.#focusedBreakpoint)) {
316
+ this.#focusedBreakpoint = null;
317
+ }
318
+ if (!this.#focusedBreakpoint && this.#breakpoints.length > 0) {
319
+ this.#focusedBreakpoint = (this.#hitBreakpoint && this.#breakpoints.includes(this.#hitBreakpoint)) ?
320
+ this.#hitBreakpoint :
321
+ this.#breakpoints[0];
354
322
  }
355
323
  }
356
324
 
@@ -361,83 +329,175 @@ export class XHRBreakpointsSidebarPane extends UI.Widget.VBox implements UI.Cont
361
329
 
362
330
  #removeBreakpoint(url: string): void {
363
331
  SDK.DOMDebuggerModel.DOMDebuggerManager.instance().removeXHRBreakpoint(url);
364
- this.removeBreakpoint(url);
332
+ const index = this.#breakpoints.indexOf(url);
333
+ if (index >= 0) {
334
+ this.#breakpoints.splice(index, 1);
335
+ }
336
+ this.#synchronizeFocusedBreakpoint();
337
+ this.performUpdate();
365
338
  }
366
339
 
367
340
  #removeAllBreakpoints(): void {
368
- for (const url of this.#breakpointElements.keys()) {
341
+ for (const url of [...this.#breakpoints]) {
369
342
  this.#removeBreakpoint(url);
370
343
  }
371
- this.update();
372
344
  }
373
345
 
374
- #toggleBreakpoint(url: string, checked: boolean): void {
375
- SDK.DOMDebuggerModel.DOMDebuggerManager.instance().toggleXHRBreakpoint(url, checked);
376
- this.#list.refreshItem(url);
377
- this.#list.selectItem(url);
346
+ #toggleBreakpoint(url: string): void {
347
+ const hadFocus = this.hasFocus();
348
+ const current = SDK.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints().get(url) ?? false;
349
+ SDK.DOMDebuggerModel.DOMDebuggerManager.instance().toggleXHRBreakpoint(url, !current);
350
+ this.#focusedBreakpoint = url;
351
+ this.performUpdate();
352
+ if (hadFocus) {
353
+ this.focus();
354
+ }
355
+ }
356
+
357
+ #startEditing(url: string): void {
358
+ this.#editingBreakpoint = url;
359
+ this.#focusedBreakpoint = url;
360
+ this.performUpdate();
361
+ }
362
+
363
+ #onBreakpointNavigate(url: string, direction: 'ArrowUp'|'ArrowDown'|'Home'|'End'): void {
364
+ const index = this.#breakpoints.indexOf(url);
365
+ let newIndex = index;
366
+ if (direction === 'ArrowUp') {
367
+ newIndex = Math.max(0, index - 1);
368
+ } else if (direction === 'ArrowDown') {
369
+ newIndex = Math.min(this.#breakpoints.length - 1, index + 1);
370
+ } else if (direction === 'Home') {
371
+ newIndex = 0;
372
+ } else if (direction === 'End') {
373
+ newIndex = this.#breakpoints.length - 1;
374
+ }
375
+ if (newIndex >= 0 && newIndex < this.#breakpoints.length) {
376
+ this.focusedBreakpoint = this.#breakpoints[newIndex];
377
+ void this.updateComplete.then(() => {
378
+ const entry = this.contentElement.querySelectorAll<HTMLElement>('.breakpoint-entry')[newIndex];
379
+ entry?.focus();
380
+ entry?.scrollIntoView({block: 'nearest'});
381
+ });
382
+ }
378
383
  }
379
384
 
380
- private contextMenu(breakKeyword: string, event: Event): void {
385
+ #onBreakpointContextMenu(url: string, event: Event): void {
386
+ this.#focusedBreakpoint = url;
381
387
  const contextMenu = new UI.ContextMenu.ContextMenu(event);
382
388
  const removeAllTitle = i18nString(UIStrings.removeAllBreakpoints);
383
389
 
384
- contextMenu.defaultSection().appendItem(
385
- i18nString(UIStrings.addBreakpoint), this.addButtonClicked.bind(this),
386
- {jslogContext: 'sources.add-xhr-fetch-breakpoint'});
387
- contextMenu.defaultSection().appendItem(i18nString(UIStrings.removeBreakpoint),
388
- this.#removeBreakpoint.bind(this, breakKeyword),
389
- {jslogContext: 'sources.remove-xhr-fetch-breakpoint'});
390
- contextMenu.defaultSection().appendItem(removeAllTitle, this.#removeAllBreakpoints.bind(this),
391
- {jslogContext: 'sources.remove-all-xhr-fetch-breakpoints'});
390
+ contextMenu.defaultSection().appendItem(i18nString(UIStrings.addBreakpoint), () => {
391
+ void this.addButtonClicked();
392
+ }, {jslogContext: 'sources.add-xhr-fetch-breakpoint'});
393
+ contextMenu.defaultSection().appendItem(i18nString(UIStrings.removeBreakpoint), () => {
394
+ this.#removeBreakpoint(url);
395
+ }, {jslogContext: 'sources.remove-xhr-fetch-breakpoint'});
396
+ contextMenu.defaultSection().appendItem(removeAllTitle, () => {
397
+ this.#removeAllBreakpoints();
398
+ }, {jslogContext: 'sources.remove-all-xhr-fetch-breakpoints'});
392
399
  void contextMenu.show();
393
400
  }
394
401
 
395
- private checkboxClicked(breakKeyword: string, checked: boolean): void {
396
- const hadFocus = this.hasFocus();
397
- this.#toggleBreakpoint(breakKeyword, !checked);
398
- if (hadFocus) {
399
- this.focus();
400
- }
402
+ #onEmptyContextMenu(event: Event): void {
403
+ const contextMenu = new UI.ContextMenu.ContextMenu(event);
404
+ contextMenu.defaultSection().appendItem(i18nString(UIStrings.addBreakpoint), () => {
405
+ void this.addButtonClicked();
406
+ }, {jslogContext: 'sources.add-xhr-fetch-breakpoint'});
407
+ void contextMenu.show();
401
408
  }
402
409
 
403
- #startEditing(item: string): void {
404
- this.#editingBreakpoint = item;
405
- this.#list.refreshItem(item);
410
+ flavorChanged(_object: Object|null): void {
411
+ this.update();
406
412
  }
407
413
 
408
- flavorChanged(_object: Object|null): void {
414
+ override wasShown(): void {
415
+ super.wasShown();
409
416
  this.update();
417
+ this.performUpdate();
410
418
  }
411
419
 
412
420
  update(): void {
413
- const isEmpty = this.#breakpoints.length === 0;
414
- this.#list.element.classList.toggle('hidden', isEmpty);
415
- this.#emptyElement.classList.toggle('hidden', !isEmpty);
416
-
417
421
  const details = UI.Context.Context.instance().flavor(SDK.DebuggerModel.DebuggerPausedDetails);
418
422
  if (!details || details.reason !== Protocol.Debugger.PausedEventReason.XHR) {
419
423
  if (this.#hitBreakpoint) {
420
- const oldHitBreakpoint = this.#hitBreakpoint;
421
424
  this.#hitBreakpoint = undefined;
422
- if (this.#breakpoints.indexOf(oldHitBreakpoint) >= 0) {
423
- this.#list.refreshItem(oldHitBreakpoint);
424
- }
425
+ this.performUpdate();
425
426
  }
426
427
  return;
427
428
  }
428
429
  const url = details.auxData?.['breakpointURL'];
429
430
  this.#hitBreakpoint = url;
430
- if (this.#breakpoints.indexOf(url) < 0) {
431
- return;
431
+ if (this.#breakpoints.includes(url)) {
432
+ void UI.ViewManager.ViewManager.instance().showView('sources.xhr-breakpoints');
432
433
  }
433
- this.#list.refreshItem(url);
434
- void UI.ViewManager.ViewManager.instance().showView('sources.xhr-breakpoints');
434
+ this.performUpdate();
435
435
  }
436
436
 
437
- private restoreBreakpoints(): void {
438
- const breakpoints = SDK.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints();
439
- for (const url of breakpoints.keys()) {
440
- this.setBreakpoint(url);
441
- }
437
+ override performUpdate(): void {
438
+ this.#synchronizeFocusedBreakpoint();
439
+ const xhrBreakpoints = SDK.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints();
440
+ const breakpointItems: BreakpointItem[] = this.#breakpoints.map(url => {
441
+ const enabled = xhrBreakpoints.get(url) ?? false;
442
+ const title = url ? i18nString(UIStrings.urlContainsS, {PH1: url}) : i18nString(UIStrings.anyXhrOrFetch);
443
+ return {
444
+ url,
445
+ enabled,
446
+ title,
447
+ isHit: url === this.#hitBreakpoint,
448
+ isFocused: url === this.#focusedBreakpoint,
449
+ isEditing: url === this.#editingBreakpoint,
450
+ };
451
+ });
452
+
453
+ const viewInput: ViewInput = {
454
+ isAdding: this.#isAddingBreakpoint,
455
+ breakpoints: breakpointItems,
456
+ onAddCommit: (newUrl: string) => {
457
+ this.#isAddingBreakpoint = false;
458
+ this.#addBreakpoint(newUrl, true);
459
+ this.focusedBreakpoint = newUrl;
460
+ this.performUpdate();
461
+ },
462
+ onAddCancel: () => {
463
+ this.#isAddingBreakpoint = false;
464
+ this.performUpdate();
465
+ },
466
+ onBreakpointClick: (url: string) => {
467
+ this.focusedBreakpoint = url;
468
+ this.#toggleBreakpoint(url);
469
+ },
470
+ onBreakpointCheckboxChange: (url: string) => {
471
+ this.#toggleBreakpoint(url);
472
+ },
473
+ onBreakpointContextMenu: (url: string, event: Event) => {
474
+ this.#onBreakpointContextMenu(url, event);
475
+ },
476
+ onBreakpointNavigate: (url: string, direction: 'ArrowUp'|'ArrowDown'|'Home'|'End') => {
477
+ this.#onBreakpointNavigate(url, direction);
478
+ },
479
+ onStartEditing: (url: string) => {
480
+ this.#startEditing(url);
481
+ },
482
+ onEditCommit: (oldUrl: string, newUrl: string) => {
483
+ this.#editingBreakpoint = null;
484
+ const enabled = SDK.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints().get(oldUrl) ?? true;
485
+ this.#removeBreakpoint(oldUrl);
486
+ this.#addBreakpoint(newUrl, enabled);
487
+ this.#focusedBreakpoint = newUrl;
488
+ this.performUpdate();
489
+ this.focus();
490
+ },
491
+ onEditCancel: (_url: string) => {
492
+ this.#editingBreakpoint = null;
493
+ this.performUpdate();
494
+ this.focus();
495
+ },
496
+ onEmptyContextMenu: (event: Event) => {
497
+ this.#onEmptyContextMenu(event);
498
+ },
499
+ };
500
+
501
+ this.#view(viewInput, undefined, this.contentElement);
442
502
  }
443
503
  }