chrome-devtools-frontend 1.0.1599001 → 1.0.1601661

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 (128) hide show
  1. package/.agents/skills/verification/SKILL.md +1 -1
  2. package/front_end/core/common/Settings.ts +24 -1
  3. package/front_end/core/dom_extension/DOMExtension.ts +1 -0
  4. package/front_end/core/host/AidaClient.ts +5 -2
  5. package/front_end/core/host/AidaGcaTranslation.ts +377 -0
  6. package/front_end/core/host/GcaTypes.ts +3 -1
  7. package/front_end/core/host/UserMetrics.ts +0 -2
  8. package/front_end/core/host/host.ts +2 -0
  9. package/front_end/core/root/ExperimentNames.ts +0 -2
  10. package/front_end/core/sdk/CPUThrottlingManager.ts +12 -9
  11. package/front_end/core/sdk/ResourceTreeModel.ts +1 -1
  12. package/front_end/core/sdk/SourceMap.ts +4 -2
  13. package/front_end/entrypoints/main/MainImpl.ts +1 -10
  14. package/front_end/generated/Deprecation.ts +16 -0
  15. package/front_end/generated/InspectorBackendCommands.ts +5 -7
  16. package/front_end/generated/protocol.ts +47 -79
  17. package/front_end/models/ai_assistance/AiConversation.ts +37 -21
  18. package/front_end/models/ai_assistance/ConversationHandler.ts +8 -9
  19. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +75 -20
  20. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +11 -0
  21. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +38 -0
  22. package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +55 -13
  23. package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +57 -0
  24. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +41 -3
  25. package/front_end/models/ai_assistance/agents/StylingAgent.ts +1 -0
  26. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  27. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +84 -0
  28. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +172 -0
  29. package/front_end/models/breakpoints/BreakpointManager.ts +20 -12
  30. package/front_end/models/issues_manager/SharedDictionaryIssue.ts +5 -15
  31. package/front_end/models/issues_manager/descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
  32. package/front_end/models/javascript_metadata/NativeFunctions.js +52 -0
  33. package/front_end/models/lighthouse/LighthouseReporterTypes.ts +104 -10
  34. package/front_end/models/lighthouse/RunTypes.ts +2 -1
  35. package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +59 -35
  36. package/front_end/models/stack_trace/StackTrace.ts +5 -0
  37. package/front_end/models/stack_trace/StackTraceImpl.ts +7 -1
  38. package/front_end/models/stack_trace/StackTraceModel.ts +2 -1
  39. package/front_end/models/stack_trace/stack_trace.ts +4 -0
  40. package/front_end/panels/accessibility/AccessibilityNodeView.ts +7 -3
  41. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +79 -69
  42. package/front_end/panels/ai_assistance/ExportConversation.ts +25 -0
  43. package/front_end/panels/ai_assistance/ai_assistance.ts +2 -0
  44. package/front_end/panels/ai_assistance/components/ChatMessage.ts +13 -12
  45. package/front_end/panels/ai_assistance/components/ChatView.ts +44 -0
  46. package/front_end/panels/ai_assistance/components/ExportForAgentsDialog.ts +240 -0
  47. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +4 -12
  48. package/front_end/panels/ai_assistance/components/StylingAgentMarkdownRenderer.ts +5 -27
  49. package/front_end/panels/ai_assistance/components/WalkthroughView.ts +115 -17
  50. package/front_end/panels/ai_assistance/components/chatMessage.css +4 -1
  51. package/front_end/panels/ai_assistance/components/chatView.css +8 -0
  52. package/front_end/panels/ai_assistance/components/exportForAgentsDialog.css +82 -0
  53. package/front_end/panels/ai_assistance/components/walkthroughView.css +9 -1
  54. package/front_end/panels/animation/AnimationTimeline.ts +5 -5
  55. package/front_end/panels/application/AppManifestView.ts +13 -7
  56. package/front_end/panels/application/FrameDetailsView.ts +4 -4
  57. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +3 -2
  58. package/front_end/panels/common/DOMLinkifier.ts +10 -8
  59. package/front_end/panels/console/ConsoleView.ts +24 -2
  60. package/front_end/panels/console/ConsoleViewMessage.ts +22 -23
  61. package/front_end/panels/console/console.ts +0 -2
  62. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +5 -5
  63. package/front_end/panels/elements/ElementsTreeElement.ts +2 -3
  64. package/front_end/panels/elements/PropertiesWidget.ts +5 -3
  65. package/front_end/panels/elements/StandaloneStylesContainer.ts +21 -9
  66. package/front_end/panels/elements/StylePropertiesSection.ts +98 -50
  67. package/front_end/panels/elements/StylePropertyTreeElement.ts +38 -4
  68. package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +43 -35
  69. package/front_end/panels/elements/StylesSidebarPane.ts +154 -24
  70. package/front_end/panels/elements/components/ComputedStyleTrace.ts +3 -2
  71. package/front_end/panels/event_listeners/EventListenersView.ts +16 -4
  72. package/front_end/panels/explain/components/ConsoleInsight.ts +6 -9
  73. package/front_end/panels/explain/explain-meta.ts +5 -0
  74. package/front_end/panels/issues/AffectedResourcesView.ts +5 -9
  75. package/front_end/panels/issues/AffectedSelectivePermissionsInterventionView.ts +1 -1
  76. package/front_end/panels/lighthouse/LighthouseController.ts +6 -2
  77. package/front_end/panels/lighthouse/LighthousePanel.ts +3 -2
  78. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +1 -0
  79. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +9 -6
  80. package/front_end/panels/lighthouse/LighthouseStatusView.ts +29 -5
  81. package/front_end/panels/network/NetworkDataGridNode.ts +34 -0
  82. package/front_end/panels/network/NetworkLogViewColumns.ts +10 -0
  83. package/front_end/panels/network/RequestPayloadView.ts +4 -1
  84. package/front_end/panels/network/RequestTimingView.ts +8 -2
  85. package/front_end/panels/performance_monitor/performanceMonitor.css +6 -4
  86. package/front_end/panels/recorder/RecorderController.ts +52 -14
  87. package/front_end/panels/recorder/components/RecordingView.ts +2 -1
  88. package/front_end/panels/recorder/models/RecordingStorage.ts +15 -20
  89. package/front_end/panels/sensors/SensorsView.ts +310 -144
  90. package/front_end/panels/sources/DebuggerPausedMessage.ts +6 -6
  91. package/front_end/panels/sources/FilteredUISourceCodeListProvider.ts +2 -3
  92. package/front_end/panels/sources/NavigatorView.ts +11 -7
  93. package/front_end/panels/sources/ScopeChainSidebarPane.ts +1 -1
  94. package/front_end/panels/sources/SourcesPanel.ts +12 -34
  95. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +5 -1
  96. package/front_end/panels/sources/sources-meta.ts +6 -0
  97. package/front_end/panels/timeline/ThirdPartyTreeView.ts +6 -2
  98. package/front_end/panels/timeline/TimelineDetailsView.ts +35 -3
  99. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +6 -1
  100. package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +9 -4
  101. package/front_end/panels/timeline/TimelinePanel.ts +7 -9
  102. package/front_end/panels/timeline/TimelineTreeView.ts +14 -3
  103. package/front_end/panels/timeline/TimelineUIUtils.ts +5 -57
  104. package/front_end/panels/timeline/components/InteractionBreakdown.ts +2 -1
  105. package/front_end/panels/timeline/components/NetworkRequestTooltip.ts +3 -7
  106. package/front_end/panels/timeline/components/Sidebar.ts +10 -18
  107. package/front_end/panels/timeline/components/SidebarInsightsTab.ts +1 -0
  108. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +66 -0
  109. package/front_end/panels/timeline/components/TimelineSummary.ts +7 -19
  110. package/front_end/panels/timeline/components/components.ts +2 -0
  111. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +2 -0
  112. package/front_end/panels/timeline/components/insights/NodeLink.ts +3 -3
  113. package/front_end/panels/timeline/components/timelineRangeSummaryView.css +20 -0
  114. package/front_end/panels/timeline/overlays/OverlaysImpl.ts +7 -7
  115. package/front_end/panels/timeline/timelineDetailsView.css +0 -9
  116. package/front_end/third_party/chromium/README.chromium +1 -1
  117. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.js +11 -2
  118. package/front_end/third_party/web-vitals/package/src/attribution/onINP.ts +11 -2
  119. package/front_end/third_party/web-vitals/patches/0001-Add-onEachInteraction-to-onINP-options.patch +65 -4
  120. package/front_end/ui/kit/link/link.css +2 -2
  121. package/front_end/ui/legacy/components/object_ui/CustomPreviewComponent.ts +7 -2
  122. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +57 -35
  123. package/front_end/ui/legacy/components/source_frame/PreviewFactory.ts +1 -0
  124. package/front_end/ui/visual_logging/KnownContextValues.ts +5 -0
  125. package/package.json +1 -1
  126. package/front_end/models/issues_manager/descriptions/sharedDictionaryUseErrorNoCorpCrossOriginNoCorsRequest.md +0 -3
  127. package/front_end/models/issues_manager/descriptions/sharedDictionaryWriteErrorNoCorpCossOriginNoCorsRequest.md +0 -3
  128. /package/front_end/{panels/console → models/stack_trace}/ErrorStackParser.ts +0 -0
@@ -2,6 +2,7 @@
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
4
  /* eslint-disable @devtools/no-imperative-dom-api */
5
+ /* eslint-disable @devtools/no-lit-render-outside-of-view */
5
6
 
6
7
  /*
7
8
  * Copyright (C) 2011 Google Inc. All rights reserved.
@@ -46,6 +47,7 @@ import * as Breakpoints from '../../models/breakpoints/breakpoints.js';
46
47
  import * as Greendev from '../../models/greendev/greendev.js';
47
48
  import type * as IssuesManager from '../../models/issues_manager/issues_manager.js';
48
49
  import * as Logs from '../../models/logs/logs.js';
50
+ import * as StackTrace from '../../models/stack_trace/stack_trace.js';
49
51
  import * as TextUtils from '../../models/text_utils/text_utils.js';
50
52
  import * as Workspace from '../../models/workspace/workspace.js';
51
53
  import * as CodeHighlighter from '../../ui/components/code_highlighter/code_highlighter.js';
@@ -59,7 +61,7 @@ import * as ObjectUI from '../../ui/legacy/components/object_ui/object_ui.js';
59
61
  import objectValueStyles from '../../ui/legacy/components/object_ui/objectValue.css.js';
60
62
  import * as Components from '../../ui/legacy/components/utils/utils.js';
61
63
  import * as UI from '../../ui/legacy/legacy.js';
62
- import {render} from '../../ui/lit/lit.js';
64
+ import {type LitTemplate, nothing, render} from '../../ui/lit/lit.js';
63
65
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
64
66
  import * as AiAssistancePanel from '../ai_assistance/ai_assistance.js';
65
67
 
@@ -67,7 +69,6 @@ import {format, updateStyle} from './ConsoleFormat.js';
67
69
  import {ConsoleInsightTeaser} from './ConsoleInsightTeaser.js';
68
70
  import consoleViewStyles from './consoleView.css.js';
69
71
  import type {ConsoleViewportElement} from './ConsoleViewport.js';
70
- import {augmentErrorStackWithScriptIds, parseSourcePositionsFromErrorStack} from './ErrorStackParser.js';
71
72
 
72
73
  const UIStrings = {
73
74
  /**
@@ -374,22 +375,20 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
374
375
  this.consoleGroupInternal = null;
375
376
  }
376
377
 
377
- setInsight(insight: HTMLElement): void {
378
- this.elementInternal?.querySelector('.devtools-console-insight')?.remove();
379
- this.elementInternal?.append(insight);
380
- this.elementInternal?.classList.toggle('has-insight', true);
381
- insight.addEventListener('close', () => {
382
- Host.userMetrics.actionTaken(Host.UserMetrics.Action.InsightClosed);
383
- this.elementInternal?.classList.toggle('has-insight', false);
384
- const widget = UI.Widget.Widget.get(insight);
385
- if (widget) {
386
- widget.detach();
387
- } else {
388
- this.elementInternal?.removeChild(insight);
389
- }
390
- this.#teaser?.setInactive(false);
391
- }, {once: true});
392
- this.#teaser?.setInactive(true);
378
+ setInsight(insight: LitTemplate): void {
379
+ if (this.elementInternal) {
380
+ render(insight, this.elementInternal);
381
+ this.elementInternal.classList.toggle('has-insight', true);
382
+ this.elementInternal.addEventListener('closeinsight', () => {
383
+ Host.userMetrics.actionTaken(Host.UserMetrics.Action.InsightClosed);
384
+ if (this.elementInternal) {
385
+ this.elementInternal.classList.toggle('has-insight', false);
386
+ render(nothing, this.elementInternal);
387
+ }
388
+ this.#teaser?.setInactive(false);
389
+ }, {once: true});
390
+ this.#teaser?.setInactive(true);
391
+ }
393
392
  }
394
393
 
395
394
  element(): HTMLElement {
@@ -870,7 +869,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
870
869
  const renderPreview = (includeNullOrUndefined: boolean): void => {
871
870
  if (obj.preview) {
872
871
  titleElement.classList.add('console-object-preview');
873
- /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
872
+
874
873
  render(this.previewFormatter.renderObjectPreview(obj.preview, includeNullOrUndefined), titleElement);
875
874
  ObjectUI.ObjectPropertiesSection.ObjectPropertiesSection.appendMemoryIcon(titleElement, obj);
876
875
  }
@@ -1043,7 +1042,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
1043
1042
  type: string, subtype: string|undefined, className: string|null|undefined,
1044
1043
  description: string|undefined): DocumentFragment {
1045
1044
  const fragment = document.createDocumentFragment();
1046
- /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
1045
+
1047
1046
  render(this.previewFormatter.renderPropertyPreview(type, subtype, className, description), fragment);
1048
1047
  return fragment;
1049
1048
  }
@@ -1946,12 +1945,12 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
1946
1945
  string = concatErrorDescriptionAndIssueSummary(string, issueSummary);
1947
1946
  }
1948
1947
 
1949
- const linkInfos = parseSourcePositionsFromErrorStack(runtimeModel, string);
1948
+ const linkInfos = StackTrace.ErrorStackParser.parseSourcePositionsFromErrorStack(runtimeModel, string);
1950
1949
  if (!linkInfos?.length) {
1951
1950
  return null;
1952
1951
  }
1953
1952
  if (exceptionDetails?.stackTrace) {
1954
- augmentErrorStackWithScriptIds(linkInfos, exceptionDetails.stackTrace);
1953
+ StackTrace.ErrorStackParser.augmentErrorStackWithScriptIds(linkInfos, exceptionDetails.stackTrace);
1955
1954
  }
1956
1955
 
1957
1956
  const debuggerModel = runtimeModel.debuggerModel();
@@ -2173,7 +2172,7 @@ export class ConsoleGroupViewMessage extends ConsoleViewMessage {
2173
2172
  this.groupEndMessageInternal = null;
2174
2173
  }
2175
2174
 
2176
- private setCollapsed(collapsed: boolean): void {
2175
+ setCollapsed(collapsed: boolean): void {
2177
2176
  this.collapsedInternal = collapsed;
2178
2177
  if (this.expandGroupIcon) {
2179
2178
  this.expandGroupIcon.name = this.collapsedInternal ? 'triangle-right' : 'triangle-down';
@@ -26,7 +26,6 @@ import * as ConsoleSidebar from './ConsoleSidebar.js';
26
26
  import * as ConsoleView from './ConsoleView.js';
27
27
  import * as ConsoleViewMessage from './ConsoleViewMessage.js';
28
28
  import * as ConsoleViewport from './ConsoleViewport.js';
29
- import * as ErrorStackParser from './ErrorStackParser.js';
30
29
  import * as PromptBuilder from './PromptBuilder.js';
31
30
 
32
31
  export {
@@ -41,6 +40,5 @@ export {
41
40
  ConsoleView,
42
41
  ConsoleViewMessage,
43
42
  ConsoleViewport,
44
- ErrorStackParser,
45
43
  PromptBuilder,
46
44
  };
@@ -881,7 +881,7 @@ export class CSSOverviewCompletedView extends UI.Widget.VBox {
881
881
  interface ElementDetailsViewInput {
882
882
  items: Array<{
883
883
  data: PopulateNodesEventNodeTypes,
884
- link?: HTMLElement,
884
+ link?: LitTemplate,
885
885
  showNode?: () => void,
886
886
  }>;
887
887
  visibility: Set<string>;
@@ -996,18 +996,18 @@ export class ElementDetailsView extends UI.Widget.Widget {
996
996
  const lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.startLine);
997
997
  const columnNumber = styleSheetHeader.columnNumberInSource(ruleLocation.startLine, ruleLocation.startColumn);
998
998
  const matchingSelectorLocation = new SDK.CSSModel.CSSLocation(styleSheetHeader, lineNumber, columnNumber);
999
- link = this.#linkifier.linkifyCSSLocation(matchingSelectorLocation) as HTMLElement;
999
+ link = html`${this.#linkifier.linkifyCSSLocation(matchingSelectorLocation)}`;
1000
1000
  }
1001
1001
  }
1002
1002
 
1003
- return {data: item, link, showNode};
1003
+ return {data: item, link: link as LitTemplate | undefined, showNode};
1004
1004
  }));
1005
1005
 
1006
1006
  this.#view({items, visibility}, {}, this.element);
1007
1007
  }
1008
1008
  }
1009
1009
 
1010
- function renderNode(data: PopulateNodesEventNodeTypes, link?: HTMLElement, showNode?: () => void): LitTemplate {
1010
+ function renderNode(data: PopulateNodesEventNodeTypes, link?: LitTemplate, showNode?: () => void): LitTemplate {
1011
1011
  if (!link) {
1012
1012
  return nothing;
1013
1013
  }
@@ -1027,7 +1027,7 @@ function renderDeclaration(data: PopulateNodesEventNodeTypes): TemplateResult {
1027
1027
  return html`<td>${data.declaration}</td>`;
1028
1028
  }
1029
1029
 
1030
- function renderSourceURL(data: PopulateNodesEventNodeTypes, link?: HTMLElement): TemplateResult {
1030
+ function renderSourceURL(data: PopulateNodesEventNodeTypes, link?: LitTemplate): TemplateResult {
1031
1031
  if ('range' in data && data.range) {
1032
1032
  if (!link) {
1033
1033
  return html`<td>${i18nString(UIStrings.unableToLink)}</td>`;
@@ -2,6 +2,7 @@
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
4
  /* eslint-disable @devtools/no-imperative-dom-api */
5
+ /* eslint-disable @devtools/no-lit-render-outside-of-view */
5
6
 
6
7
  /*
7
8
  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
@@ -748,8 +749,7 @@ function renderAttribute(
748
749
  textContent: el.textContent || undefined,
749
750
  isDynamicLink: true,
750
751
  });
751
- el.removeChildren();
752
- el.append(link);
752
+ render(link, el as HTMLElement);
753
753
  })();
754
754
  });
755
755
 
@@ -2217,7 +2217,6 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
2217
2217
  // a parent node. Use a temporary span container for the HTML.
2218
2218
  const container = document.createElement('span');
2219
2219
 
2220
- // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
2221
2220
  Lit.render(renderAttribute({name: ' ', value: ''}, null, false, this.nodeInternal), container);
2222
2221
  const attr = container.firstElementChild as HTMLElement;
2223
2222
  attr.style.marginLeft = '2px'; // overrides the .editing margin rule
@@ -140,7 +140,7 @@ export class PropertiesWidget extends UI.Widget.VBox {
140
140
  UI.Context.Context.instance().addFlavorChangeListener(SDK.DOMModel.DOMNode, this.setNode, this);
141
141
 
142
142
  this.#view = view;
143
- this.treeOutline = new ObjectUI.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline({readOnly: true});
143
+ this.treeOutline = new ObjectUI.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline();
144
144
  this.treeOutline.setShowSelectionOnKeyboardFocus(/* show */ true, /* preventTabOrder */ false);
145
145
 
146
146
  this.treeOutline.addEventListener(UI.TreeOutline.Events.ElementExpanded, () => {
@@ -209,8 +209,10 @@ export class PropertiesWidget extends UI.Widget.VBox {
209
209
  return;
210
210
  }
211
211
 
212
- this.#objectTree = new ObjectUI.ObjectPropertiesSection.ObjectTree(
213
- object, ObjectUI.ObjectPropertiesSection.ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED);
212
+ this.#objectTree = new ObjectUI.ObjectPropertiesSection.ObjectTree(object, {
213
+ propertiesMode: ObjectUI.ObjectPropertiesSection.ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
214
+ readOnly: true,
215
+ });
214
216
  this.#updateFilter();
215
217
  }
216
218
 
@@ -64,12 +64,30 @@ export class StandaloneStylesContainer extends Common.ObjectWrapper.eventMixin<E
64
64
  #computedStyleModelInternal = new ComputedStyle.ComputedStyleModel.ComputedStyleModel();
65
65
  #view: View;
66
66
  #filter: RegExp|null = null;
67
+ #rebuildThrottler = new Common.Throttler.Throttler(200);
67
68
 
68
69
  constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
69
70
  super(element, {useShadowDom: true});
70
71
  this.#view = view;
71
72
  this.#computedStyleModelInternal.addEventListener(
72
73
  ComputedStyle.ComputedStyleModel.Events.CSS_MODEL_CHANGED, this.#onCSSModelChanged, this);
74
+ this.#computedStyleModelInternal.addEventListener(
75
+ ComputedStyle.ComputedStyleModel.Events.COMPUTED_STYLE_CHANGED, this.#onComputedStyleChanged, this);
76
+ }
77
+
78
+ #onComputedStyleChanged(): void {
79
+ if (this.isEditingStyle || this.userOperation) {
80
+ return;
81
+ }
82
+ this.#rebuildAndUpdate();
83
+ }
84
+
85
+ #rebuildAndUpdate(): void {
86
+ void this.#rebuildThrottler.schedule(async () => {
87
+ this.node()?.domModel().cssModel().discardCachedMatchedCascade();
88
+ await this.#updateSections();
89
+ this.requestUpdate();
90
+ });
73
91
  }
74
92
 
75
93
  async #onCSSModelChanged(
@@ -85,9 +103,7 @@ export class StandaloneStylesContainer extends Common.ObjectWrapper.eventMixin<E
85
103
  return;
86
104
  }
87
105
 
88
- this.node()?.domModel().cssModel().discardCachedMatchedCascade();
89
- await this.#updateSections();
90
- this.requestUpdate();
106
+ this.#rebuildAndUpdate();
91
107
  }
92
108
 
93
109
  get webCustomData(): WebCustomData|undefined {
@@ -135,8 +151,6 @@ export class StandaloneStylesContainer extends Common.ObjectWrapper.eventMixin<E
135
151
  }
136
152
 
137
153
  override async performUpdate(): Promise<void> {
138
- this.hideAllPopovers();
139
-
140
154
  const viewInput: ViewInput = {
141
155
  sections: this.#sections.filter(section => !section.isHidden()),
142
156
  };
@@ -219,10 +233,8 @@ export class StandaloneStylesContainer extends Common.ObjectWrapper.eventMixin<E
219
233
  }
220
234
 
221
235
  forceUpdate(): void {
222
- this.node()?.domModel().cssModel().discardCachedMatchedCascade();
223
- void this.#updateSections().then(() => {
224
- this.requestUpdate();
225
- });
236
+ this.hideAllPopovers();
237
+ this.#rebuildAndUpdate();
226
238
  }
227
239
 
228
240
  hideAllPopovers(): void {
@@ -2,6 +2,7 @@
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
4
  /* eslint-disable @devtools/no-imperative-dom-api */
5
+ /* eslint-disable @devtools/no-lit-render-outside-of-view */
5
6
 
6
7
  /*
7
8
  * Copyright (C) 2007 Apple Inc. All rights reserved.
@@ -50,6 +51,7 @@ import * as Tooltips from '../../ui/components/tooltips/tooltips.js';
50
51
  import {createIcon, type Icon} from '../../ui/kit/kit.js';
51
52
  import type * as Components from '../../ui/legacy/components/utils/utils.js';
52
53
  import * as UI from '../../ui/legacy/legacy.js';
54
+ import {html, type LitTemplate, nothing, render} from '../../ui/lit/lit.js';
53
55
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
54
56
  import * as PanelsCommon from '../common/common.js';
55
57
 
@@ -128,10 +130,24 @@ const UIStrings = {
128
130
 
129
131
  const str_ = i18n.i18n.registerUIStrings('panels/elements/StylePropertiesSection.ts', UIStrings);
130
132
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
133
+ const {widget} = UI.Widget;
131
134
 
132
135
  const STYLE_TAG = '<style>';
133
136
  const DEFAULT_MAX_PROPERTIES = 50;
134
137
 
138
+ export interface ActiveAiSuggestionProperty {
139
+ name: string;
140
+ value: string;
141
+ }
142
+
143
+ export interface ActiveAiSuggestion {
144
+ text: string;
145
+ properties: ActiveAiSuggestionProperty[];
146
+ cursorPosition: number;
147
+ clearCachedRequest?: () => void;
148
+ cssProperty: SDK.CSSProperty.CSSProperty;
149
+ }
150
+
135
151
  export class StylePropertiesSection {
136
152
  protected stylesContainer: StylesContainer;
137
153
  styleInternal: SDK.CSSStyleDeclaration.CSSStyleDeclaration;
@@ -179,6 +195,7 @@ export class StylePropertiesSection {
179
195
  readonly sectionTooltipIdPrefix = StylePropertiesSection.#nextSectionTooltipIdPrefix++;
180
196
 
181
197
  private ghostStyleTreeElements: GhostStylePropertyTreeElement[] = [];
198
+ #activeAiSuggestion?: ActiveAiSuggestion;
182
199
 
183
200
  constructor(
184
201
  stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
@@ -468,9 +485,9 @@ export class StylePropertiesSection {
468
485
 
469
486
  static createRuleOriginNode(
470
487
  matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, linkifier: Components.Linkifier.Linkifier,
471
- rule: SDK.CSSRule.CSSRule|null): Node {
488
+ rule: SDK.CSSRule.CSSRule|null): LitTemplate {
472
489
  if (!rule) {
473
- return document.createTextNode('');
490
+ return nothing;
474
491
  }
475
492
 
476
493
  const ruleLocation = StylePropertiesSection.getRuleLocationFromCSSRule(rule);
@@ -490,24 +507,22 @@ export class StylePropertiesSection {
490
507
  return null;
491
508
  }
492
509
 
493
- function linkifyNode(label: string): Node|null {
510
+ function linkifyNode(label: string): LitTemplate|null {
494
511
  if (header?.ownerNode) {
495
- const link = document.createElement('devtools-widget') as
496
- UI.Widget.WidgetElement<PanelsCommon.DOMLinkifier.DeferredDOMNodeLink>;
497
- link.widgetConfig =
498
- UI.Widget.widgetConfig(e => new PanelsCommon.DOMLinkifier.DeferredDOMNodeLink(e, header.ownerNode));
499
- link.textContent = label;
500
- return link;
512
+ return html`<devtools-widget ${
513
+ widget(e => new PanelsCommon.DOMLinkifier.DeferredDOMNodeLink(e, header.ownerNode))}>
514
+ ${label}
515
+ </devtools-widget>`;
501
516
  }
502
517
  if (rule && rule.style.styleSheetId && rule.treeScope) {
503
518
  // Make link for adopted stylesheet.
504
519
  const ownerNode = new SDK.DOMModel.DeferredDOMNode(rule.cssModelInternal.target(), rule.treeScope);
505
- const link = document.createElement('devtools-widget') as
506
- UI.Widget.WidgetElement<PanelsCommon.DOMLinkifier.DeferredDOMNodeLink>;
507
- link.widgetConfig = UI.Widget.widgetConfig(
508
- e => new PanelsCommon.DOMLinkifier.DeferredDOMNodeLink(e, ownerNode, undefined, rule.style.styleSheetId));
509
- link.textContent = label;
510
- return link;
520
+ // clang-format off
521
+ return html`<devtools-widget ${widget(
522
+ e => new PanelsCommon.DOMLinkifier.DeferredDOMNodeLink(e, ownerNode, undefined, rule.style.styleSheetId))}>
523
+ ${label}
524
+ </devtools-widget>`;
525
+ // clang-format on
511
526
  }
512
527
  return null;
513
528
  }
@@ -515,29 +530,29 @@ export class StylePropertiesSection {
515
530
  if (header?.isMutable && !header.isViaInspector()) {
516
531
  const location = header.isConstructedByNew() && !header.sourceMapURL ? null : linkifyRuleLocation();
517
532
  if (location) {
518
- return location;
533
+ return html`${location}`;
519
534
  }
520
535
  const label = header.isConstructedByNew() ? i18nString(UIStrings.constructedStylesheet) : STYLE_TAG;
521
536
  const node = linkifyNode(label);
522
537
  if (node) {
523
538
  return node;
524
539
  }
525
- return document.createTextNode(label);
540
+ return html`${label}`;
526
541
  }
527
542
 
528
543
  const location = linkifyRuleLocation();
529
544
  if (location) {
530
- return location;
545
+ return html`${location}`;
531
546
  }
532
547
 
533
548
  if (rule.isUserAgent()) {
534
- return document.createTextNode(i18nString(UIStrings.userAgentStylesheet));
549
+ return html`${i18nString(UIStrings.userAgentStylesheet)}`;
535
550
  }
536
551
  if (rule.isInjected()) {
537
- return document.createTextNode(i18nString(UIStrings.injectedStylesheet));
552
+ return html`${i18nString(UIStrings.injectedStylesheet)}`;
538
553
  }
539
554
  if (rule.isViaInspector()) {
540
- return document.createTextNode(i18nString(UIStrings.viaInspector));
555
+ return html`${i18nString(UIStrings.viaInspector)}`;
541
556
  }
542
557
 
543
558
  const node = linkifyNode(STYLE_TAG);
@@ -545,12 +560,12 @@ export class StylePropertiesSection {
545
560
  return node;
546
561
  }
547
562
 
548
- return document.createTextNode('');
563
+ return nothing;
549
564
  }
550
565
 
551
566
  protected createRuleOriginNode(
552
567
  matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, linkifier: Components.Linkifier.Linkifier,
553
- rule: SDK.CSSRule.CSSRule|null): Node {
568
+ rule: SDK.CSSRule.CSSRule|null): LitTemplate {
554
569
  return StylePropertiesSection.createRuleOriginNode(matchedStyles, linkifier, rule);
555
570
  }
556
571
 
@@ -870,7 +885,29 @@ export class StylePropertiesSection {
870
885
  return;
871
886
  }
872
887
 
873
- clearGhostStyleTreeElements(): void {
888
+ set activeAiSuggestion(activeAiSuggestion: ActiveAiSuggestion|undefined) {
889
+ this.#clearActiveAiSuggestion();
890
+ this.#activeAiSuggestion = activeAiSuggestion;
891
+ if (this.#activeAiSuggestion) {
892
+ this.#renderActiveAiSuggestion();
893
+ }
894
+ }
895
+
896
+ get activeAiSuggestion(): ActiveAiSuggestion|undefined {
897
+ return this.#activeAiSuggestion;
898
+ }
899
+
900
+ async commitActiveAiSuggestion(): Promise<void> {
901
+ if (!this.#activeAiSuggestion) {
902
+ return;
903
+ }
904
+ const sourceTreeElement = this.#getAiSuggestionSourceTreeElement();
905
+ // Apply everything atomically
906
+ await sourceTreeElement?.commitAiSuggestion(this.#activeAiSuggestion.text);
907
+ }
908
+
909
+ #clearActiveAiSuggestion(): void {
910
+ this.#getAiSuggestionSourceTreeElement()?.clearActiveAiSuggestion();
874
911
  // Clear existing ghost elements
875
912
  for (const ghost of this.ghostStyleTreeElements) {
876
913
  this.propertiesTreeOutline.removeChild(ghost);
@@ -878,31 +915,30 @@ export class StylePropertiesSection {
878
915
  this.ghostStyleTreeElements = [];
879
916
  }
880
917
 
881
- renderGhostStyleTreeElements(suggestion: string): void {
882
- this.clearGhostStyleTreeElements();
883
- if (!suggestion) {
918
+ #renderActiveAiSuggestion(): void {
919
+ if (!this.#activeAiSuggestion) {
884
920
  return;
885
921
  }
886
922
 
887
- const suggestionLines = suggestion.split(';').map(line => line.trim());
888
- for (const line of suggestionLines) {
889
- const colonIdx = line.indexOf(':');
890
- if (colonIdx === -1) {
891
- continue;
892
- }
893
-
894
- const name = line.substring(0, colonIdx).trim();
895
- const value = line.substring(colonIdx + 1).trim();
896
- if (!name || !value) {
897
- continue;
898
- }
923
+ const sourceTreeElement = this.#getAiSuggestionSourceTreeElement();
924
+ if (!sourceTreeElement || !this.#activeAiSuggestion.properties.length) {
925
+ return;
926
+ }
927
+ sourceTreeElement.renderActiveAiSuggestion(this.#activeAiSuggestion.properties[0]);
899
928
 
929
+ if (this.#activeAiSuggestion.properties.length <= 1) {
930
+ return;
931
+ }
932
+ const index = this.propertiesTreeOutline.rootElement().children().indexOf(sourceTreeElement);
933
+ const properties = this.#activeAiSuggestion.properties.slice(1);
934
+ for (let i = 0; i < properties.length; i++) {
935
+ const property = properties[i];
900
936
  // Create a fake property attached to this style
901
937
  const fakeProperty = new SDK.CSSProperty.CSSProperty(
902
938
  this.styleInternal,
903
939
  this.styleInternal.allProperties().length,
904
- name,
905
- value,
940
+ property.name,
941
+ property.value,
906
942
  false,
907
943
  false,
908
944
  true,
@@ -910,11 +946,23 @@ export class StylePropertiesSection {
910
946
  );
911
947
 
912
948
  const ghost = new GhostStylePropertyTreeElement(this.stylesContainer, this, this.matchedStyles, fakeProperty);
913
- this.propertiesTreeOutline.appendChild(ghost);
949
+ this.propertiesTreeOutline.insertChild(ghost, index + i + 1);
914
950
  this.ghostStyleTreeElements.push(ghost);
915
951
  }
916
952
  }
917
953
 
954
+ #getAiSuggestionSourceTreeElement(): StylePropertyTreeElement|undefined {
955
+ if (!this.#activeAiSuggestion) {
956
+ return;
957
+ }
958
+ const sourceTreeElement = this.closestPropertyForEditing(this.#activeAiSuggestion.cssProperty.index);
959
+ if (!(sourceTreeElement instanceof StylePropertyTreeElement) ||
960
+ sourceTreeElement.property !== this.#activeAiSuggestion.cssProperty) {
961
+ return;
962
+ }
963
+ return sourceTreeElement;
964
+ }
965
+
918
966
  private onNewRuleClick(event: Common.EventTarget.EventTargetEvent<Event>): void {
919
967
  event.data.consume();
920
968
  const rule = this.styleInternal.parentRule;
@@ -1922,9 +1970,9 @@ export class StylePropertiesSection {
1922
1970
  }
1923
1971
 
1924
1972
  protected updateRuleOrigin(): void {
1925
- this.selectorRefElement.removeChildren();
1926
- this.selectorRefElement.appendChild(
1927
- this.createRuleOriginNode(this.matchedStyles, this.stylesContainer.linkifier, this.styleInternal.parentRule));
1973
+ const origin =
1974
+ this.createRuleOriginNode(this.matchedStyles, this.stylesContainer.linkifier, this.styleInternal.parentRule);
1975
+ render(origin, this.selectorRefElement, {host: this});
1928
1976
  }
1929
1977
 
1930
1978
  protected editingSelectorEnded(): void {
@@ -1970,9 +2018,9 @@ export class BlankStylePropertiesSection extends StylePropertiesSection {
1970
2018
  this.normal = false;
1971
2019
  this.ruleLocation = ruleLocation;
1972
2020
  this.styleSheetHeader = styleSheetHeader;
1973
- this.selectorRefElement.removeChildren();
1974
- this.selectorRefElement.appendChild(StylePropertiesSection.linkifyRuleLocation(
1975
- cssModel, this.stylesContainer.linkifier, styleSheetHeader, this.actualRuleLocation()));
2021
+ const locationNode = StylePropertiesSection.linkifyRuleLocation(
2022
+ cssModel, this.stylesContainer.linkifier, styleSheetHeader, this.actualRuleLocation());
2023
+ render(html`${locationNode}`, this.selectorRefElement, {host: this});
1976
2024
  this.maybeCreateAncestorRules(insertAfterStyle);
1977
2025
  this.element.classList.add('blank-section');
1978
2026
  }
@@ -2090,11 +2138,11 @@ export class RegisteredPropertiesSection extends StylePropertiesSection {
2090
2138
 
2091
2139
  override createRuleOriginNode(
2092
2140
  matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, linkifier: Components.Linkifier.Linkifier,
2093
- rule: SDK.CSSRule.CSSRule|null): Node {
2141
+ rule: SDK.CSSRule.CSSRule|null): LitTemplate {
2094
2142
  if (rule) {
2095
2143
  return super.createRuleOriginNode(matchedStyles, linkifier, rule);
2096
2144
  }
2097
- return document.createTextNode('CSS.registerProperty');
2145
+ return html`CSS.registerProperty`;
2098
2146
  }
2099
2147
  }
2100
2148
 
@@ -45,7 +45,7 @@ import {
45
45
  URLRenderer
46
46
  } from './PropertyRenderer.js';
47
47
  import {StyleEditorWidget} from './StyleEditorWidget.js';
48
- import type {StylePropertiesSection} from './StylePropertiesSection.js';
48
+ import type {ActiveAiSuggestionProperty, StylePropertiesSection} from './StylePropertiesSection.js';
49
49
  import {getCssDeclarationAsJavascriptProperty} from './StylePropertyUtils.js';
50
50
  import type {StylesContainer} from './StylesContainer.js';
51
51
  import {CSSPropertyPrompt, REGISTERED_PROPERTY_SECTION_NAME} from './StylesSidebarPane.js';
@@ -3300,6 +3300,21 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3300
3300
  this.editingEnded(context);
3301
3301
  }
3302
3302
 
3303
+ async commitAiSuggestion(fullText: string): Promise<void> {
3304
+ const isEditingName = UI.UIUtils.isBeingEdited(this.nameElement);
3305
+ const context = {
3306
+ expanded: this.expanded,
3307
+ hasChildren: this.isExpandable(),
3308
+ isEditingName,
3309
+ originalProperty: this.property,
3310
+ previousContent: isEditingName ? this.name : this.value
3311
+ };
3312
+
3313
+ this.removePrompt();
3314
+ this.editingEnded(context);
3315
+ await this.applyStyleText(fullText, true);
3316
+ }
3317
+
3303
3318
  private async applyOriginalStyle(context: Context): Promise<void> {
3304
3319
  await this.applyStyleText(this.originalPropertyText, false, context.originalProperty);
3305
3320
  }
@@ -3594,15 +3609,34 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3594
3609
  return event.target === this.expandElement;
3595
3610
  }
3596
3611
 
3597
- showGhostTextInValue(text: string): void {
3612
+ renderActiveAiSuggestion(activeAiSuggestion: ActiveAiSuggestionProperty): void {
3613
+ if (!this.prompt) {
3614
+ return;
3615
+ }
3616
+ const isEditingName = UI.UIUtils.isBeingEdited(this.nameElement);
3617
+ if (isEditingName) {
3618
+ this.prompt.applySuggestion({text: activeAiSuggestion.name}, true);
3619
+ this.#showGhostTextInValue(activeAiSuggestion.value);
3620
+ } else {
3621
+ // Only has ghost text for one field - name part or value part
3622
+ const currentSuggestedText = isEditingName ? activeAiSuggestion.name : activeAiSuggestion.value;
3623
+ this.prompt.applySuggestion({text: currentSuggestedText}, true);
3624
+ }
3625
+ }
3626
+
3627
+ clearActiveAiSuggestion(): void {
3628
+ this.#clearGhostTextInValue();
3629
+ }
3630
+
3631
+ #showGhostTextInValue(text: string): void {
3598
3632
  if (!this.valueElement) {
3599
3633
  return;
3600
3634
  }
3601
- this.clearGhostTextInValue();
3635
+ this.#clearGhostTextInValue();
3602
3636
  this.valueElement.createChild('span', 'ghost-value-prediction').textContent = text;
3603
3637
  }
3604
3638
 
3605
- clearGhostTextInValue(): void {
3639
+ #clearGhostTextInValue(): void {
3606
3640
  if (!this.valueElement) {
3607
3641
  return;
3608
3642
  }