chrome-devtools-frontend 1.0.1590494 → 1.0.1592129

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 (79) hide show
  1. package/docs/ui_engineering.md +34 -1
  2. package/front_end/core/common/Gzip.ts +17 -2
  3. package/front_end/core/host/AidaClient.ts +38 -15
  4. package/front_end/core/host/DispatchHttpRequestClient.ts +7 -4
  5. package/front_end/core/host/InspectorFrontendHostAPI.ts +2 -0
  6. package/front_end/core/host/UserMetrics.ts +2 -1
  7. package/front_end/core/root/ExperimentNames.ts +1 -0
  8. package/front_end/core/root/Runtime.ts +5 -0
  9. package/front_end/core/sdk/CSSMetadata.ts +18 -0
  10. package/front_end/core/sdk/EmulationModel.ts +6 -1
  11. package/front_end/core/sdk/NetworkManager.ts +49 -2
  12. package/front_end/core/sdk/NetworkRequest.ts +4 -0
  13. package/front_end/core/sdk/RuntimeModel.ts +2 -1
  14. package/front_end/core/sdk/sdk-meta.ts +26 -0
  15. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +34 -5
  16. package/front_end/entrypoints/main/MainImpl.ts +8 -0
  17. package/front_end/generated/InspectorBackendCommands.ts +1 -0
  18. package/front_end/generated/protocol-mapping.d.ts +10 -0
  19. package/front_end/generated/protocol-proxy-api.d.ts +8 -0
  20. package/front_end/generated/protocol.ts +6 -2
  21. package/front_end/models/ai_assistance/AiConversation.ts +9 -0
  22. package/front_end/models/ai_assistance/AiHistoryStorage.ts +1 -0
  23. package/front_end/models/ai_assistance/agents/AiAgent.ts +6 -1
  24. package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgent.ts +722 -0
  25. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +1 -1
  26. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  27. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +12 -12
  28. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +7 -7
  29. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +7 -7
  30. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +1 -1
  31. package/front_end/models/greendev/Prototypes.ts +7 -1
  32. package/front_end/models/javascript_metadata/NativeFunctions.js +5 -1
  33. package/front_end/models/trace/handlers/NetworkRequestsHandler.ts +3 -3
  34. package/front_end/models/trace/helpers/Network.ts +1 -1
  35. package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -1
  36. package/front_end/models/trace/insights/RenderBlocking.ts +5 -5
  37. package/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +6 -6
  38. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +63 -0
  39. package/front_end/panels/ai_assistance/README.md +14 -0
  40. package/front_end/panels/ai_assistance/components/ChatInput.ts +1 -4
  41. package/front_end/panels/ai_assistance/components/ChatMessage.ts +45 -27
  42. package/front_end/panels/ai_assistance/components/chatInput.css +0 -8
  43. package/front_end/panels/ai_assistance/components/chatMessage.css +6 -0
  44. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +25 -46
  45. package/front_end/panels/common/AiCodeGenerationTeaser.ts +9 -4
  46. package/front_end/panels/console/ConsoleViewMessage.ts +100 -4
  47. package/front_end/panels/elements/ComputedStyleWidget.ts +46 -18
  48. package/front_end/panels/elements/ElementsPanel.ts +2 -2
  49. package/front_end/panels/elements/StyleEditorWidget.ts +10 -2
  50. package/front_end/panels/elements/StylePropertyTreeElement.ts +1 -1
  51. package/front_end/panels/elements/StylesContainer.ts +2 -0
  52. package/front_end/panels/elements/StylesSidebarPane.ts +8 -0
  53. package/front_end/panels/network/NetworkDataGridNode.ts +1 -1
  54. package/front_end/panels/network/NetworkLogViewColumns.ts +1 -1
  55. package/front_end/panels/network/RequestPayloadView.ts +7 -6
  56. package/front_end/panels/network/RequestTimingView.ts +3 -3
  57. package/front_end/panels/search/SearchResultsPane.ts +2 -1
  58. package/front_end/panels/settings/SettingsScreen.ts +3 -2
  59. package/front_end/panels/settings/WorkspaceSettingsTab.ts +1 -1
  60. package/front_end/panels/sources/BreakpointsView.ts +1 -1
  61. package/front_end/panels/sources/CallStackSidebarPane.ts +1 -1
  62. package/front_end/panels/timeline/NetworkTrackAppender.ts +1 -1
  63. package/front_end/panels/timeline/components/IgnoreListSetting.ts +0 -1
  64. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +4 -4
  65. package/front_end/panels/timeline/components/NetworkRequestTooltip.ts +2 -2
  66. package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +4 -4
  67. package/front_end/third_party/chromium/README.chromium +4 -2
  68. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +5 -1
  69. package/front_end/third_party/lighthouse/locales/en-GB.json +2 -2
  70. package/front_end/third_party/lighthouse/locales/en-US.json +2 -2
  71. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +1 -1
  72. package/front_end/ui/legacy/Treeoutline.ts +39 -0
  73. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +31 -8
  74. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +10 -3
  75. package/front_end/ui/legacy/components/source_frame/XMLView.ts +20 -5
  76. package/front_end/ui/visual_logging/Debugging.ts +51 -34
  77. package/front_end/ui/visual_logging/KnownContextValues.ts +7 -1
  78. package/front_end/ui/visual_logging/LoggingEvents.ts +5 -2
  79. package/package.json +1 -1
@@ -1404,6 +1404,14 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
1404
1404
  }
1405
1405
  }
1406
1406
 
1407
+ addStyleUpdateListener(listener: () => void): void {
1408
+ this.addEventListener(Events.STYLES_UPDATE_COMPLETED, listener);
1409
+ }
1410
+
1411
+ removeStyleUpdateListener(listener: () => void): void {
1412
+ this.removeEventListener(Events.STYLES_UPDATE_COMPLETED, listener);
1413
+ }
1414
+
1407
1415
  private startToolbarPaneAnimation(widget: UI.Widget.Widget|null): void {
1408
1416
  if (widget === this.currentToolbarPane) {
1409
1417
  return;
@@ -324,7 +324,7 @@ const UIStrings = {
324
324
  */
325
325
  initialPriorityToolTip: '{PH1}, Initial priority: {PH2}',
326
326
  /**
327
- * @description Text in Network Data Grid Node of the Network panel. Noun. Refers to a render blocking resource.
327
+ * @description Text in Network Data Grid Node of the Network panel. Noun. Refers to a render-blocking resource.
328
328
  */
329
329
  blocking: 'Blocking',
330
330
  /**
@@ -156,7 +156,7 @@ const UIStrings = {
156
156
  /**
157
157
  * @description Text in Network Log View Columns of the Network panel
158
158
  */
159
- renderBlocking: 'Render Blocking',
159
+ renderBlocking: 'Render-blocking',
160
160
  } as const;
161
161
  const str_ = i18n.i18n.registerUIStrings('panels/network/NetworkLogViewColumns.ts', UIStrings);
162
162
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -52,6 +52,7 @@ import {ShowMoreDetailsWidget} from './ShowMoreDetailsWidget.js';
52
52
 
53
53
  const {classMap} = Directives;
54
54
  const {widgetConfig} = UI.Widget;
55
+ const {ifExpanded} = UI.TreeOutline;
55
56
  const UIStrings = {
56
57
  /**
57
58
  * @description A context menu item Payload View of the Network panel to copy a parsed value.
@@ -239,8 +240,8 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
239
240
  ${input.decodeRequestParameters ? i18nString(UIStrings.viewUrlEncoded) : i18nString(UIStrings.viewDecoded)}
240
241
  </devtools-button>
241
242
  <ul role=group>
242
- ${input.viewQueryParamSource ? createSourceText(input.queryString ?? '')
243
- : createParsedParams(input.queryParameters ?? [])}
243
+ ${ifExpanded(input.viewQueryParamSource ? createSourceText(input.queryString ?? '')
244
+ : createParsedParams(input.queryParameters ?? []))}
244
245
  </ul>
245
246
  </li>
246
247
  <li
@@ -263,8 +264,8 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
263
264
  ${input.decodeRequestParameters ? i18nString(UIStrings.viewUrlEncoded) : i18nString(UIStrings.viewDecoded)}
264
265
  </devtools-button>
265
266
  <ul role=group>
266
- ${input.viewFormParamSource ? createSourceText(input.formData ?? '')
267
- : createParsedParams(input.formParameters ?? [])}
267
+ ${ifExpanded(input.viewFormParamSource ? createSourceText(input.formData ?? '')
268
+ : createParsedParams(input.formParameters ?? []))}
268
269
  </ul>
269
270
  </li>
270
271
  <li
@@ -280,8 +281,8 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
280
281
  <div class="selection fill"></div>${i18nString(UIStrings.requestPayload)}${
281
282
  createViewSourceToggle(input.viewJSONPayloadSource, input.setViewJSONPayloadSource)}
282
283
  <ul role=group>
283
- ${!parsedFormData || input.viewJSONPayloadSource ? createSourceText(input.formData ?? '')
284
- : createPayload(parsedFormData)}
284
+ ${ifExpanded(!parsedFormData || input.viewJSONPayloadSource ? createSourceText(input.formData ?? '')
285
+ : createPayload(parsedFormData))}
285
286
  </ul>
286
287
  </li>
287
288
  </ul>
@@ -416,9 +416,9 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
416
416
  resize: true
417
417
  })}>
418
418
  <colgroup>
419
- <col class=labels></col>
420
- <col class=bars> </col>
421
- <col class=duration></col>
419
+ <col class=labels>
420
+ <col class=bars>
421
+ <col class=duration>
422
422
  </colgroup>
423
423
  <thead class=network-timing-start>
424
424
  <tr>
@@ -31,6 +31,7 @@ const UIStrings = {
31
31
  } as const;
32
32
  const str_ = i18n.i18n.registerUIStrings('panels/search/SearchResultsPane.ts', UIStrings);
33
33
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
34
+ const {ifExpanded} = UI.TreeOutline;
34
35
 
35
36
  interface SearchMatch {
36
37
  lineContent: string;
@@ -74,7 +75,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
74
75
  <style>${searchResultsPaneStyles}</style>
75
76
  ${renderSearchResult(searchResult)}
76
77
  <ul role="group">
77
- ${renderSearchMatches(searchResult, matches, onSelectMatch, onShowMoreMatches)}
78
+ ${ifExpanded(renderSearchMatches(searchResult, matches, onSelectMatch, onShowMoreMatches))}
78
79
  </ul>
79
80
  </li>`)}
80
81
  </ul>
@@ -636,7 +636,7 @@ const GREENDEV_VIEW: View = (input, _output, target) => {
636
636
  <span>${i18nString(UIStrings.greenDevUnstable)}</span>
637
637
  </div>
638
638
  <div class="settings-experiments-block">
639
- ${renderPrototypeCheckboxes(input.settings, ['aiAnnotations', 'copyToGemini'])}
639
+ ${renderPrototypeCheckboxes(input.settings, ['aiAnnotations', 'copyToGemini', 'breakpointDebuggerAgent'])}
640
640
  </div>
641
641
  </devtools-card>
642
642
  </div>
@@ -646,7 +646,8 @@ const GREENDEV_VIEW: View = (input, _output, target) => {
646
646
 
647
647
  const GREENDEV_PROTOTYPE_NAMES: Record<keyof GreenDev.GreenDevSettings, string> = {
648
648
  aiAnnotations: 'AI auto-annotations',
649
- copyToGemini: 'Copy changes to AI Prompt'
649
+ copyToGemini: 'Copy changes to AI Prompt',
650
+ breakpointDebuggerAgent: 'Breakpoint Debugger Agent'
650
651
  };
651
652
 
652
653
  function renderPrototypeCheckboxes(
@@ -62,7 +62,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
62
62
  class="harmony-input"
63
63
  jslog=${VisualLogging.textField().track({keydown: 'Enter', change: true}).context(input.excludePatternSetting.name)}
64
64
  ${UI.UIUtils.bindToSetting(input.excludePatternSetting, {jslog: false})}
65
- id="workspace-setting-folder-exclude-pattern"></input>
65
+ id="workspace-setting-folder-exclude-pattern">
66
66
  </div>
67
67
  <div class="mappings-info">${i18nString(UIStrings.mappingsAreInferredAutomatically)}</div>
68
68
  </devtools-card>
@@ -594,7 +594,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
594
594
  .checked=${group.breakpointItems.some(item => item.status === BreakpointStatus.ENABLED)}
595
595
  @change=${input.groupCheckboxToggled.bind(undefined, group)}
596
596
  tabindex=-1
597
- jslog=${VisualLogging.toggle('breakpoint-group').track({change: true,})}></input>
597
+ jslog=${VisualLogging.toggle('breakpoint-group').track({change: true,})}>
598
598
  </span>
599
599
  <span class='group-header-title' title=${group.url}>
600
600
  ${group.name}
@@ -165,7 +165,7 @@ export class CallStackSidebarPane extends UI.View.SimpleView implements UI.Conte
165
165
  <div class='ignore-listed-message' ${ref(ignoreListMessageRef)}>
166
166
  <label class='ignore-listed-message-label'>
167
167
  <input type='checkbox' tabindex=0 class='ignore-listed-checkbox'
168
- @change=${ignoreListCheckboxChanged} ${ref(ignoreListCheckboxRef)}></input>
168
+ @change=${ignoreListCheckboxChanged} ${ref(ignoreListCheckboxRef)} />
169
169
  ${i18nString(UIStrings.showIgnorelistedFrames)}
170
170
  </label>
171
171
  </div>
@@ -122,7 +122,7 @@ export class NetworkTrackAppender implements TrackAppender {
122
122
  for (let i = 0; i < events.length; ++i) {
123
123
  const event = events[i];
124
124
  this.#appendEventAtLevel(event, trackStartLevel);
125
- // Decorate render blocking
125
+ // Decorate render-blocking
126
126
  if (Trace.Types.Events.isSyntheticNetworkRequest(event) &&
127
127
  Trace.Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(event)) {
128
128
  addDecorationToEvent(this.#flameChartData, i, {
@@ -157,7 +157,6 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
157
157
  placeholder='/framework\\.js$'
158
158
  .value=${live(newRegexValue)}
159
159
  .jslogContext=${'timeline.ignore-list-new-regex.text'}>
160
- </input>
161
160
  </div>
162
161
  </div>
163
162
  </devtools-button-dialog>
@@ -88,13 +88,13 @@ const UIStrings = {
88
88
  */
89
89
  blocking: 'Blocking',
90
90
  /**
91
- * @description Text that refers to if the network request is in-body parser render blocking
91
+ * @description Text that refers to if the network request is in-body parser render-blocking
92
92
  */
93
93
  inBodyParserBlocking: 'In-body parser blocking',
94
94
  /**
95
- * @description Text that refers to if the network request is render blocking
95
+ * @description Text that refers to if the network request is render-blocking
96
96
  */
97
- renderBlocking: 'Render blocking',
97
+ renderBlocking: 'Render-blocking',
98
98
  /**
99
99
  * @description Text to refer to a 3rd Party entity.
100
100
  */
@@ -376,7 +376,7 @@ function renderBlockingRow(request: Trace.Types.Events.SyntheticNetworkRequest):
376
376
  break;
377
377
  default:
378
378
  // Shouldn't fall to this block, if so, this network request is not
379
- // render blocking, so return null.
379
+ // render-blocking, so return null.
380
380
  return Lit.nothing;
381
381
  }
382
382
  return renderRow(i18nString(UIStrings.blocking), renderBlockingText);
@@ -46,9 +46,9 @@ const UIStrings = {
46
46
  */
47
47
  waitingOnMainThread: 'Waiting on main thread',
48
48
  /**
49
- * @description Text that refers to a network request is render blocking
49
+ * @description Text that refers to a network request is render-blocking
50
50
  */
51
- renderBlocking: 'Render blocking',
51
+ renderBlocking: 'Render-blocking',
52
52
  /**
53
53
  * @description Text to refer to the list of redirects.
54
54
  */
@@ -384,22 +384,22 @@ function renderTutorial(): Lit.LitTemplate {
384
384
  return html`<div class="annotation-tutorial-container">
385
385
  ${i18nString(UIStrings.annotationGetStarted)}
386
386
  <div class="tutorial-card">
387
- <div class="tutorial-image"><img src=${entryLabelImageUrl}></img></div>
387
+ <div class="tutorial-image"><img src=${entryLabelImageUrl}></div>
388
388
  <div class="tutorial-title">${i18nString(UIStrings.entryLabelTutorialTitle)}</div>
389
389
  <div class="tutorial-description">${i18nString(UIStrings.entryLabelTutorialDescription)}</div>
390
390
  </div>
391
391
  <div class="tutorial-card">
392
- <div class="tutorial-image"><img src=${diagramImageUrl}></img></div>
392
+ <div class="tutorial-image"><img src=${diagramImageUrl}></div>
393
393
  <div class="tutorial-title">${i18nString(UIStrings.entryLinkTutorialTitle)}</div>
394
394
  <div class="tutorial-description">${i18nString(UIStrings.entryLinkTutorialDescription)}</div>
395
395
  </div>
396
396
  <div class="tutorial-card">
397
- <div class="tutorial-image"><img src=${timeRangeImageUrl}></img></div>
397
+ <div class="tutorial-image"><img src=${timeRangeImageUrl}></div>
398
398
  <div class="tutorial-title">${i18nString(UIStrings.timeRangeTutorialTitle)}</div>
399
399
  <div class="tutorial-description">${i18nString(UIStrings.timeRangeTutorialDescription)}</div>
400
400
  </div>
401
401
  <div class="tutorial-card">
402
- <div class="tutorial-image"><img src=${deleteAnnotationImageUrl}></img></div>
402
+ <div class="tutorial-image"><img src=${deleteAnnotationImageUrl}></div>
403
403
  <div class="tutorial-title">${i18nString(UIStrings.deleteAnnotationTutorialTitle)}</div>
404
404
  <div class="tutorial-description">${i18nString(UIStrings.deleteAnnotationTutorialDescription)}</div>
405
405
  </div>
@@ -1,7 +1,7 @@
1
1
  Name: Dependencies sourced from the upstream `chromium` repository
2
- URL: https://chromium.googlesource.com/chromium/src
2
+ URL: Internal
3
3
  Version: N/A
4
- Revision: 070c55b60dd29061a93f753a77d49c7a1a9688d6
4
+ Revision: 34d76fab4749ed03ad2a80ed0b2770700ad0cfbc
5
5
  Update Mechanism: Manual (https://crbug.com/428069060)
6
6
  License: BSD-3-Clause
7
7
  License File: LICENSE
@@ -11,6 +11,8 @@ License Android Compatible: yes
11
11
 
12
12
  Description:
13
13
  This subdirectory is reserved for dependencies that are part of the upstream `chromium` repository.
14
+ Sourced from https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/devtools/.
15
+ The Revision is the chromium revision these have been taken from.
14
16
 
15
17
  To update these dependencies, run this from the root of the `devtools-frontend` repository:
16
18
 
@@ -958,7 +958,11 @@ return n=r.indexOf("?"),n<0?r:r.substr(0,n)}static completeURL(t,n){if(n.startsW
958
958
  !!s),!s)return{url:t,lineNumber:0,columnNumber:0};typeof s[1]=="string"&&(c=parseInt(s[1],10),c=isNaN(c)?void 0:c-1),typeof s[2]=="string"&&(l=parseInt(s[2],10),l=isNaN(l)?void 0:l-1);let u=r+a.substring(0,a.length-s[0].length);if(s[1]===void 0&&s[2]===void 0){let p=/wasm-function\[\d+\]:0x([a-z0-9]+)$/g.exec(a);p&&typeof p[1]=="string"&&(u=e.removeWasmFunctionInfoFromURL(u),l=parseInt(p[1],16),l=isNaN(l)?void 0:l)}return{url:u,lineNumber:c,columnNumber:l}}static removeWasmFunctionInfoFromURL(t){let n=/:wasm-function\[\d+\]/,r=t.search(n);return r===-1?t:e.substring(t,0,r)}static beginsWithWindowsDriveLetter(t){return/^[A-Za-z]:/.test(t)}static beginsWithScheme(t){return/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)}static isRelativeURL(t){return!this.beginsWithScheme(t)||this.beginsWithWindowsDriveLetter(t)}isAboutBlank(){return this.url==="about:blank"}isDataURL(){return this.scheme==="data"}extractDataUrlMimeType(){let t=/^data:((?<type>\w+)\/(?<subtype>\w+))?(;base64)?,/,n=this.url.match(t);return{
959
959
  type:n?.groups?.type,subtype:n?.groups?.subtype}}isBlobURL(){return this.url.startsWith("blob:")}lastPathComponentWithFragment(){return this.lastPathComponent+(this.fragment?"#"+this.fragment:"")}domain(){return this.isDataURL()?"data:":this.host+(this.port?":"+this.port:"")}securityOrigin(){return this.isDataURL()?"data:":(this.isBlobURL()?this.blobInnerScheme:this.scheme)+"://"+this.domain()}urlWithoutScheme(){return this.scheme&&this.url.startsWith(this.scheme+"://")?this.url.substring(this.scheme.length+3):this.url}static urlRegexInstance=null}});var ZE={};x(ZE,{UIStrings:()=>qa,createOverlayForRequest:()=>V5,createOverlays:()=>Fle,generateInsight:()=>Lle,i18nString:()=>JE,isRenderBlockingInsight:()=>Dle});function Dle(e){return e.insightKey==="RenderBlocking"}function Nle(e){let t=new Map;for(let[n,r]of e)n.type==="network"&&t.set(n.request.requestId,{node:n,nodeTiming:r});return t}function Mle(e,t){let n=t.simulator,r=t.metrics.firstContentfulPaint.optimisticGraph,{nodeTimings:a}=t.simulator.simulate(r),o=new Map(a),s=0,c=r.cloneWithRelationships(f=>!e.has(f.id));if(c.type!=="network")throw new Error("minimalFCPGraph not a NetworkNode");let l=Math.max(...Array.from(Array.from(o).map(f=>f[1].endTime))),u=c.request.transferSize,m=u||0;c.request.transferSize=m+s;let p=n.simulate(c).timeInMs;return c.request.transferSize=u,Math.round(Math.max(l-p,0))}function Ole(e,t){return e.LargestImagePaint.lcpRequestByNavigationId.has(t.navigationId)}function Ple(e,t,n){if(!t.lantern)return;let r=Nle(t.lantern.metrics.firstContentfulPaint.optimisticEstimate.
960
960
  nodeTimings),a={FCP:0,LCP:0},o=new Map,s=new Set;for(let c of n){let l=r.get(c.args.data.requestId);if(!l)continue;let{node:u,nodeTiming:m}=l;u.traverse(f=>s.add(f.id));let p=Math.round(m.duration);p<Ale||o.set(u.id,p)}return o.size&&(a.FCP=Mle(s,t.lantern),Ole(e,t)||(a.LCP=a.FCP)),{metricSavings:a,requestIdToWastedMs:o}}function XE(e){return{insightKey:ce.RENDER_BLOCKING,strings:qa,title:JE(qa.title),description:JE(qa.description),docs:"https://developer.chrome.com/docs/performance/insights/render-blocking",category:qe.LCP,state:e.renderBlockingRequests.length>0?"fail":"pass",...e}}function Lle(e,t){if(!t.navigation)return XE({renderBlockingRequests:[]});let n=e.PageLoadMetrics.metricScoresByFrameId.get(t.frameId)?.get(t.navigationId)?.get(dt.PageLoadMetrics.MetricName.FP)?.event?.ts;if(!n)return XE({renderBlockingRequests:[],warnings:[Bn.NO_FP]});let r=[];for(let o of e.NetworkRequests.byTime){if(o.args.data.frame!==t.frameId||!_n.isSyntheticNetworkRequestEventRenderBlocking(o)||o.args.
961
- data.syntheticData.finishTime>n)continue;if(o.args.data.renderBlocking==="in_body_parser_blocking"){let c=o.args.data.priority,u=o.args.data.resourceType==="Script"&&c==="High";if(c!=="VeryHigh"&&!u)continue}re.getNavigationForTraceEvent(o,t.frameId,e.Meta.navigationsByFrameId)===t.navigation&&r.push(o)}let a=Ple(e,t,r);return r=r.sort((o,s)=>s.dur-o.dur),XE({relatedEvents:r,renderBlockingRequests:r,...a})}function V5(e){return{type:"ENTRY_OUTLINE",entry:e,outlineReason:"ERROR"}}function Fle(e){return e.renderBlockingRequests.map(t=>V5(t))}var qa,JE,Ale,QE=g(()=>{d();tn();Se();$t();qa={title:"Render blocking requests",description:"Requests are blocking the page's initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.",renderBlockingRequest:"Request",duration:"Duration",noRenderBlocking:"No render blocking requests for this navigation"},JE=i((e,t)=>({i18nId:e,
961
+ data.syntheticData.finishTime > n) continue; if (o.args.data.renderBlocking === "in_body_parser_blocking") { let c = o.args.data.priority, u = o.args.data.resourceType === "Script" && c === "High"; if (c !== "VeryHigh" && !u) continue } re.getNavigationForTraceEvent(o, t.frameId, e.Meta.navigationsByFrameId) === t.navigation && r.push(o)
962
+ } let a = Ple(e, t, r); return r = r.sort((o, s) => s.dur - o.dur), XE({ relatedEvents: r, renderBlockingRequests: r, ...a })
963
+ } function V5(e) { return { type: "ENTRY_OUTLINE", entry: e, outlineReason: "ERROR" } } function Fle(e) { return e.renderBlockingRequests.map(t => V5(t)) } var qa, JE, Ale, QE = g(() => {
964
+ d(); tn(); Se(); $t(); qa = { title: "Render-blocking requests", description: "Requests are blocking the page's initial render, which may delay LCP. [Deferring or inlining](https://developer.chrome.com/docs/performance/insights/render-blocking) can move these network requests out of the critical path.", renderBlockingRequest: "Request", duration: "Duration", noRenderBlocking: "No render-blocking requests for this navigation" }, JE = i((e, t) => ({
965
+ i18nId: e,
962
966
  values:t}),"i18nString");i(Dle,"isRenderBlockingInsight");Ale=50;i(Nle,"getNodesAndTimingByRequestId");i(Mle,"estimateSavingsWithGraphs");i(Ole,"hasImageLCP");i(Ple,"computeSavings");i(XE,"finalize");i(Lle,"generateInsight");i(V5,"createOverlayForRequest");i(Fle,"createOverlays")});var tT={};x(tT,{UIStrings:()=>za,createOverlays:()=>zle,generateInsight:()=>qle,i18nString:()=>eT,isSlowCSSSelectorInsight:()=>Hle});function Ble(e,t){let n=new Map;for(let[r,a]of e.dataForRecalcStyleEvent)if(r.args.beginData?.frame===t.frameId&&j.eventIsInBounds(r,t.bounds))for(let o of a.timings){let s=o[zt.Selector]+"_"+o[zt.StyleSheetId],c=n.get(s);c!==void 0?(c[zt.Elapsed]+=o[zt.Elapsed],c[zt.FastRejectCount]+=o[zt.FastRejectCount],c[zt.MatchAttempts]+=o[zt.MatchAttempts],c[zt.MatchCount]+=o[zt.MatchCount]):n.set(s,{...o})}return[...n.values()]}function jle(e){return{insightKey:ce.SLOW_CSS_SELECTOR,strings:za,title:eT(za.title),description:eT(za.description),docs:"https://developer.chrome.com/docs/performance/insights/slow-css-selector",category:qe.ALL,state:e.topSelectorElapsedMs&&e.topSelectorMatchAttempts?"informative":"pass",...e}}function Hle(e){return e.insightKey===ce.SLOW_CSS_SELECTOR}function qle(e,t){let n=e.SelectorStats;if(!n)throw new Error("no selector stats data");let r=Ble(
963
967
  n,t),a=0,o=0,s=0;r.map(u=>{a+=u[zt.Elapsed],o+=u[zt.MatchAttempts],s+=u[zt.MatchCount]});let c=null,l=null;return r.length>0&&(c=r.reduce((u,m)=>u[zt.Elapsed]>m[zt.Elapsed]?u:m),c&&c[zt.Elapsed]<Ule&&(c=null),l=r.reduce((u,m)=>u[zt.MatchAttempts]>m[zt.MatchAttempts]?u:m)),jle({relatedEvents:[],totalElapsedMs:I.Milli(a/1e3),totalMatchAttempts:o,totalMatchCount:s,topSelectorElapsedMs:c,topSelectorMatchAttempts:l})}function zle(e){return[]}var za,eT,Ule,nT=g(()=>{d();Se();kf();ie();$t();za={title:"CSS Selector costs",description:"If Recalculate Style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.",matchAttempts:"Match attempts",matchCount:"Match count",elapsed:"Elapsed time",topSelectors:"Top selectors",total:"Total",enableSelectorData:"\
964
968
  No CSS selector data was found. CSS selector stats need to be enabled in the performance panel settings.",topSelectorElapsedTime:"Top selector elapsed time",topSelectorMatchAttempt:"Top selector match attempt"},eT=i((e,t)=>({i18nId:e,values:t}),"i18nString"),Ule=500;i(Ble,"aggregateSelectorStats");i(jle,"finalize");i(Hle,"isSlowCSSSelectorInsight");i(qle,"generateInsight");i(zle,"createOverlays")});var aT={};x(aT,{UIStrings:()=>xr,createOverlays:()=>Yle,createOverlaysForSummary:()=>$5,generateInsight:()=>$le,i18nString:()=>rT,isThirdPartyInsight:()=>Vle});function Gle(e,t){let n=[];for(let r of e)r.entity!==t&&n.push(...r.relatedEvents);return n}function Wle(e){return{insightKey:ce.THIRD_PARTIES,strings:xr,title:rT(xr.title),description:rT(xr.description),docs:"https://developer.chrome.com/docs/performance/insights/third-parties",category:qe.ALL,state:e.entitySummaries.find(t=>t.entity!==e.firstPartyEntity)?"informative":"pass",...e}}function Vle(e){return e.insightKey===ce.THIRD_PARTIES}function $le(e,t){let n=jh.summarizeByThirdParty(e,t.bounds),r=t.navigation?.args.data?.documentLoaderURL??e.Meta.mainFrameURL,a=Js.default.getEntity(r)||vr.makeUpEntity(e.Renderer.entityMappings.createdEntityCache,r);return Wle({relatedEvents:Gle(n,a),firstPartyEntity:a,entitySummaries:n})}function $5(e){let t=[];for(let n of e.relatedEvents){if(n.dur===void 0||n.dur<1e3)continue;let r={type:"EN\
@@ -2370,13 +2370,13 @@
2370
2370
  "message": "Duration"
2371
2371
  },
2372
2372
  "node_modules/@paulirish/trace_engine/models/trace/insights/RenderBlocking.js | noRenderBlocking": {
2373
- "message": "No render blocking requests for this navigation"
2373
+ "message": "No render-blocking requests for this navigation"
2374
2374
  },
2375
2375
  "node_modules/@paulirish/trace_engine/models/trace/insights/RenderBlocking.js | renderBlockingRequest": {
2376
2376
  "message": "Request"
2377
2377
  },
2378
2378
  "node_modules/@paulirish/trace_engine/models/trace/insights/RenderBlocking.js | title": {
2379
- "message": "Render blocking requests"
2379
+ "message": "Render-blocking requests"
2380
2380
  },
2381
2381
  "node_modules/@paulirish/trace_engine/models/trace/insights/SlowCSSSelector.js | description": {
2382
2382
  "message": "If Recalculate Style costs remain high, selector optimisation can reduce them. [Optimise the selectors](https://developer.chrome.com/docs/devtools/performance/selector-stats) with both a high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM and a shallower DOM will all reduce matching costs."
@@ -2370,13 +2370,13 @@
2370
2370
  "message": "Duration"
2371
2371
  },
2372
2372
  "node_modules/@paulirish/trace_engine/models/trace/insights/RenderBlocking.js | noRenderBlocking": {
2373
- "message": "No render blocking requests for this navigation"
2373
+ "message": "No render-blocking requests for this navigation"
2374
2374
  },
2375
2375
  "node_modules/@paulirish/trace_engine/models/trace/insights/RenderBlocking.js | renderBlockingRequest": {
2376
2376
  "message": "Request"
2377
2377
  },
2378
2378
  "node_modules/@paulirish/trace_engine/models/trace/insights/RenderBlocking.js | title": {
2379
- "message": "Render blocking requests"
2379
+ "message": "Render-blocking requests"
2380
2380
  },
2381
2381
  "node_modules/@paulirish/trace_engine/models/trace/insights/SlowCSSSelector.js | description": {
2382
2382
  "message": "If Recalculate Style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/performance/insights/slow-css-selector) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs."
@@ -294,7 +294,7 @@ export class AiCodeGenerationProvider {
294
294
  PanelCommon.AiCodeGenerationTeaser.AiCodeGenerationTeaserDisplayState.GENERATED) {
295
295
  update.view.dispatch({effects: setAiAutoCompleteSuggestion.of(null)});
296
296
  this.#generationTeaser.displayState =
297
- PanelCommon.AiCodeGenerationTeaser.AiCodeGenerationTeaserDisplayState.TRIGGER;
297
+ PanelCommon.AiCodeGenerationTeaser.AiCodeGenerationTeaserDisplayState.DISCOVERY;
298
298
  return;
299
299
  }
300
300
  }
@@ -1927,6 +1927,45 @@ export namespace TreeViewElement {
1927
1927
  }
1928
1928
  }
1929
1929
 
1930
+ export const ifExpanded = Lit.Directive.directive(class extends Lit.Directive.Directive {
1931
+ #partInfo: {type: Lit.Directive.PartType, startNode: Node};
1932
+ constructor(partInfo: Lit.Directive.PartInfo) {
1933
+ if (partInfo.type !== Lit.Directive.PartType.CHILD) {
1934
+ throw new Error('ifExpanded directive must be used in a child node');
1935
+ }
1936
+ super(partInfo);
1937
+ this.#partInfo = partInfo as {type: Lit.Directive.PartType, startNode: Node};
1938
+ }
1939
+
1940
+ render(content: Lit.LitTemplate|Iterable<Lit.LitTemplate>): Lit.LitTemplate|Iterable<Lit.LitTemplate> {
1941
+ return this.#isInExpandedRow(this.#partInfo.startNode) ? content : Lit.nothing;
1942
+ }
1943
+
1944
+ #isInExpandedRow(element: Node|null|undefined): boolean {
1945
+ if (!element) {
1946
+ return false;
1947
+ }
1948
+ if (!(element instanceof HTMLElement)) {
1949
+ element = element.parentNode;
1950
+ }
1951
+ if (!(element instanceof HTMLElement)) {
1952
+ return false;
1953
+ }
1954
+ element = element.closest('li[role="treeitem"]') ?? undefined;
1955
+ if (!(element instanceof HTMLLIElement)) {
1956
+ return false;
1957
+ }
1958
+ if (hasBooleanAttribute(element, 'open')) {
1959
+ return true;
1960
+ }
1961
+ const node = TreeViewTreeElement.get(element);
1962
+ if (!node) {
1963
+ return false;
1964
+ }
1965
+ return node.expanded;
1966
+ }
1967
+ });
1968
+
1930
1969
  export class TreeElementWrapper extends HTMLElement {
1931
1970
  #treeElement?: TreeElement;
1932
1971
  set treeElement(treeElement: TreeElement) {
@@ -148,7 +148,7 @@ interface NodeChildren {
148
148
  accessors?: ObjectTreeNode[];
149
149
  }
150
150
 
151
- abstract class ObjectTreeNodeBase extends Common.ObjectWrapper.ObjectWrapper<ObjectTreeNodeBase.EventTypes> {
151
+ export abstract class ObjectTreeNodeBase extends Common.ObjectWrapper.ObjectWrapper<ObjectTreeNodeBase.EventTypes> {
152
152
  #children?: NodeChildren;
153
153
  protected filter: {includeNullOrUndefinedValues: boolean, regex: RegExp|null}|null = null;
154
154
  protected extraProperties: ObjectTreeNode[] = [];
@@ -160,6 +160,14 @@ abstract class ObjectTreeNodeBase extends Common.ObjectWrapper.ObjectWrapper<Obj
160
160
  this.filter = parent?.filter ?? null;
161
161
  }
162
162
 
163
+ get includeNullOrUndefinedValues(): boolean {
164
+ return this.filter?.includeNullOrUndefinedValues ?? true;
165
+ }
166
+
167
+ set includeNullOrUndefinedValues(value: boolean) {
168
+ this.setFilter({includeNullOrUndefinedValues: value, regex: this.filter?.regex ?? null});
169
+ }
170
+
163
171
  // Performs a pre-order tree traversal over the populated children. If any children need to be populated, callers must
164
172
  // do that while walking (pre-order visitation enables that).
165
173
  * #walk(maxDepth = -1): Generator<ObjectTreeNodeBase> {
@@ -326,7 +334,7 @@ abstract class ObjectTreeNodeBase extends Common.ObjectWrapper.ObjectWrapper<Obj
326
334
  }
327
335
  }
328
336
 
329
- namespace ObjectTreeNodeBase {
337
+ export namespace ObjectTreeNodeBase {
330
338
  export const enum Events {
331
339
  VALUE_CHANGED = 'value-changed',
332
340
  CHILDREN_CHANGED = 'children-changed',
@@ -513,11 +521,12 @@ export const getObjectPropertiesSectionFrom = (element: Element): ObjectProperti
513
521
  };
514
522
 
515
523
  export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow {
516
- private readonly root: ObjectTree;
524
+ readonly root: ObjectTree;
517
525
  readonly editable: boolean;
518
526
  readonly #objectTreeElement: RootElement;
519
527
  titleElement: Element;
520
528
  skipProtoInternal?: boolean;
529
+
521
530
  constructor(
522
531
  object: SDK.RemoteObject.RemoteObject, title?: string|Element|null, linkifier?: Components.Linkifier.Linkifier,
523
532
  showOverflow?: boolean, editable = true) {
@@ -721,14 +730,15 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
721
730
 
722
731
  static createPropertyValueWithCustomSupport(
723
732
  value: SDK.RemoteObject.RemoteObject, wasThrown: boolean, showPreview: boolean,
724
- linkifier?: Components.Linkifier.Linkifier, isSyntheticProperty?: boolean, variableName?: string): HTMLElement {
733
+ linkifier?: Components.Linkifier.Linkifier, isSyntheticProperty?: boolean, variableName?: string,
734
+ includeNullOrUndefined?: boolean): HTMLElement {
725
735
  if (value.customPreview()) {
726
736
  const result = (new CustomPreviewComponent(value)).element;
727
737
  result.classList.add('object-properties-section-custom-section');
728
738
  return result;
729
739
  }
730
740
  return ObjectPropertiesSection.createPropertyValue(
731
- value, wasThrown, showPreview, linkifier, isSyntheticProperty, variableName);
741
+ value, wasThrown, showPreview, linkifier, isSyntheticProperty, variableName, includeNullOrUndefined);
732
742
  }
733
743
 
734
744
  static getMemoryIcon(object: SDK.RemoteObject.RemoteObject, expression?: string): LitTemplate {
@@ -757,7 +767,8 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
757
767
 
758
768
  static createPropertyValue(
759
769
  value: SDK.RemoteObject.RemoteObject, wasThrown: boolean, showPreview: boolean,
760
- linkifier?: Components.Linkifier.Linkifier, isSyntheticProperty = false, variableName?: string): HTMLElement {
770
+ linkifier?: Components.Linkifier.Linkifier, isSyntheticProperty = false, variableName?: string,
771
+ includeNullOrUndefined?: boolean): HTMLElement {
761
772
  const propertyValue = document.createDocumentFragment();
762
773
  const type = value.type;
763
774
  const subtype = value.subtype;
@@ -809,7 +820,7 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
809
820
  }
810
821
  const hasPreview = value.preview && showPreview;
811
822
  return html`<span class="value object-value-${subtype || type}" title=${description}>${
812
- hasPreview ? new RemoteObjectPreviewFormatter().renderObjectPreview(value.preview) :
823
+ hasPreview ? new RemoteObjectPreviewFormatter().renderObjectPreview(value.preview, includeNullOrUndefined) :
813
824
  description}${isSyntheticProperty ? nothing : this.getMemoryIcon(value, variableName)}</span>`;
814
825
  };
815
826
 
@@ -989,6 +1000,9 @@ export class RootElement extends UI.TreeOutline.TreeElement {
989
1000
  {jslogContext: 'expand-recursively'});
990
1001
  contextMenu.viewSection().appendItem(
991
1002
  i18nString(UIStrings.collapseChildren), this.collapseChildren.bind(this), {jslogContext: 'collapse-children'});
1003
+ contextMenu.viewSection().appendCheckboxItem(i18n.i18n.lockedString('Show all'), () => {
1004
+ this.object.includeNullOrUndefinedValues = !this.object.includeNullOrUndefinedValues;
1005
+ }, {checked: this.object.includeNullOrUndefinedValues, jslogContext: 'show-all'});
992
1006
  void contextMenu.show();
993
1007
  }
994
1008
 
@@ -1059,7 +1073,7 @@ export const OBJECT_PROPERTY_DEFAULT_VIEW: ObjectPropertyView = (input, output,
1059
1073
  const showPreview = property.name !== '[[Prototype]]';
1060
1074
  const value = ObjectPropertiesSection.createPropertyValueWithCustomSupport(
1061
1075
  property.value, property.wasThrown, showPreview, input.linkifier, property.synthetic,
1062
- input.node.path /* variableName */);
1076
+ input.node.path /* variableName */, input.node.includeNullOrUndefinedValues);
1063
1077
  output.valueElement = value;
1064
1078
  return value;
1065
1079
  }
@@ -1150,10 +1164,12 @@ export class ObjectPropertyWidget extends UI.Widget.Widget {
1150
1164
  if (this.#property) {
1151
1165
  this.#property.removeEventListener(ObjectTreeNodeBase.Events.VALUE_CHANGED, this.requestUpdate, this);
1152
1166
  this.#property.removeEventListener(ObjectTreeNodeBase.Events.CHILDREN_CHANGED, this.requestUpdate, this);
1167
+ this.#property.removeEventListener(ObjectTreeNodeBase.Events.FILTER_CHANGED, this.requestUpdate, this);
1153
1168
  }
1154
1169
  this.#property = property;
1155
1170
  this.#property.addEventListener(ObjectTreeNodeBase.Events.VALUE_CHANGED, this.requestUpdate, this);
1156
1171
  this.#property.addEventListener(ObjectTreeNodeBase.Events.CHILDREN_CHANGED, this.requestUpdate, this);
1172
+ this.#property.addEventListener(ObjectTreeNodeBase.Events.FILTER_CHANGED, this.requestUpdate, this);
1157
1173
  this.requestUpdate();
1158
1174
  }
1159
1175
 
@@ -1515,6 +1531,13 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
1515
1531
  i18nString(UIStrings.collapseChildren), this.collapseChildren.bind(this),
1516
1532
  {jslogContext: 'collapse-children'});
1517
1533
  }
1534
+ let root: ObjectTreeNodeBase = this.property;
1535
+ while (root.parent) {
1536
+ root = root.parent;
1537
+ }
1538
+ contextMenu.viewSection().appendCheckboxItem(i18n.i18n.lockedString('Show all'), () => {
1539
+ root.includeNullOrUndefinedValues = !root.includeNullOrUndefinedValues;
1540
+ }, {checked: root.includeNullOrUndefinedValues, jslogContext: 'show-all'});
1518
1541
  return contextMenu;
1519
1542
  }
1520
1543
 
@@ -63,7 +63,7 @@ export class RemoteObjectPreviewFormatter {
63
63
  }
64
64
  }
65
65
 
66
- renderObjectPreview(preview: Protocol.Runtime.ObjectPreview): LitTemplate {
66
+ renderObjectPreview(preview: Protocol.Runtime.ObjectPreview, includeNullOrUndefined = true): LitTemplate {
67
67
  const description = preview.description;
68
68
  const subTypesWithoutValuePreview = new Set<Protocol.Runtime.ObjectPreviewSubtype|'internal#entry'|'trustedtype'>([
69
69
  Protocol.Runtime.ObjectPreviewSubtype.Arraybuffer,
@@ -97,7 +97,7 @@ export class RemoteObjectPreviewFormatter {
97
97
  const items = Array.from(
98
98
  preview.entries ? this.renderEntries(preview) :
99
99
  isArrayOrTypedArray ? this.renderArrayProperties(preview) :
100
- this.renderObjectProperties(preview));
100
+ this.renderObjectProperties(preview, includeNullOrUndefined));
101
101
 
102
102
  // clang-format off
103
103
  const renderName = (name: string): LitTemplate => html`<span class=name>${
@@ -130,12 +130,19 @@ export class RemoteObjectPreviewFormatter {
130
130
  ${isArrayOrTypedArray ? ']' : '}'}</span>`;
131
131
  }
132
132
 
133
- private * renderObjectProperties(preview: Protocol.Runtime.ObjectPreview): Generator<PropertyPreviewValue> {
133
+ private *
134
+ renderObjectProperties(preview: Protocol.Runtime.ObjectPreview, includeNullOrUndefined: boolean):
135
+ Generator<PropertyPreviewValue> {
134
136
  const properties = preview.properties.filter(p => p.type !== 'accessor')
135
137
  .sort(RemoteObjectPreviewFormatter.objectPropertyComparator);
136
138
  for (let i = 0; i < properties.length; ++i) {
137
139
  const property = properties[i];
138
140
  const name = property.name;
141
+ if (!includeNullOrUndefined &&
142
+ (property.type === 'undefined' || (property.type === 'object' && property.subtype === 'null'))) {
143
+ continue;
144
+ }
145
+
139
146
  // Internal properties are given special formatting, e.g. Promises `<rejected>: 123`.
140
147
  if (preview.subtype === Protocol.Runtime.ObjectPreviewSubtype.Promise && name === InternalName.PROMISE_STATE) {
141
148
  const promiseResult =
@@ -19,9 +19,12 @@ const UIStrings = {
19
19
  */
20
20
  find: 'Find',
21
21
  } as const;
22
+
22
23
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/source_frame/XMLView.ts', UIStrings);
23
24
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
24
25
  const {render, html} = Lit;
26
+ const {ifExpanded} = UI.TreeOutline;
27
+
25
28
  function* attributes(element: Element): Generator<Attr> {
26
29
  for (let i = 0; i < element.attributes.length; ++i) {
27
30
  const attributeNode = element.attributes.item(i);
@@ -135,23 +138,35 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
135
138
  return {highlights, selected};
136
139
  }
137
140
 
138
- function layOutNode(node: XMLTreeViewNode, populateSubtrees = false): Lit.LitTemplate {
141
+ function layOutNode(node: XMLTreeViewNode): Lit.LitTemplate {
139
142
  const onExpand = (event: UI.TreeOutline.TreeViewElement.ExpandEvent): void =>
140
143
  input.onExpand(node, event.detail.expanded);
141
144
  const {highlights, selected} = highlight(node, /* closeTag=*/ false);
142
145
 
146
+ const containsSearchResult = (node: XMLTreeViewNode): boolean => {
147
+ if (node === input.jumpToNextSearchResult?.node) {
148
+ return true;
149
+ }
150
+ for (const child of node.children()) {
151
+ if (containsSearchResult(child)) {
152
+ return true;
153
+ }
154
+ }
155
+ return false;
156
+ };
157
+
143
158
  // clang-format off
144
159
  return html`
145
160
  <li role="treeitem"
146
161
  ?selected=${input.jumpToNextSearchResult?.node === node}
147
162
  @expand=${onExpand}
148
- ?open=${node.expanded || input.jumpToNextSearchResult?.node === node}>
163
+ ?open=${containsSearchResult(node)}>
149
164
  <devtools-highlight ranges=${highlights} current-range=${selected}>
150
165
  ${htmlView(node)}
151
166
  </devtools-highlight>
152
167
  ${node.children().length ? html`
153
168
  <ul role="group">
154
- ${populateSubtrees || input.search ? subtree(node) : Lit.nothing}
169
+ ${ifExpanded(subtree(node))}
155
170
  </ul>` : Lit.nothing}
156
171
  </li>`;
157
172
  // clang-format on
@@ -165,7 +180,7 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
165
180
  const {highlights, selected} = highlight(treeNode, /* closeTag=*/ true);
166
181
  // clang-format off
167
182
  return html`
168
- ${children.map(child => layOutNode(child, treeNode.expanded))}
183
+ ${children.map(child => layOutNode(child))}
169
184
  ${treeNode.node instanceof Element ? html`
170
185
  <li role="treeitem">
171
186
  <devtools-highlight ranges=${highlights} current-range=${selected}>
@@ -184,7 +199,7 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
184
199
  class="shadow-xml-view source-code"
185
200
  .template=${html`
186
201
  <ul role="tree">
187
- ${input.xml.children().map(node => layOutNode(node, /* populateSubtrees=*/ true))}
202
+ ${input.xml.children().map(node => layOutNode(node))}
188
203
  </ul>`}
189
204
  ></devtools-tree>`,
190
205
  // clang-format on