chrome-devtools-frontend 1.0.1739869 → 1.0.1742811

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 (272) hide show
  1. package/.agents/rules/ui-and-widgets/ui-accessibility-and-semantic-html.md +1 -1
  2. package/.agents/rules/ui-and-widgets/ui-css-scoping-and-flex-layout.md +44 -7
  3. package/.agents/rules/ui-and-widgets/ui-lit-declarative-templates-and-directives.md +1 -1
  4. package/.agents/rules/ui-and-widgets/ui-view-output-and-callback-contracts.md +2 -2
  5. package/.agents/rules/ui-and-widgets/ui-widget-dom-and-listener-lifecycle.md +1 -1
  6. package/.agents/skills/code-review/SKILL.md +23 -6
  7. package/.agents/skills/devtools-verification/SKILL.md +2 -1
  8. package/.agents/skills/migrate-chromium-test/SKILL.md +1 -0
  9. package/.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md +27 -11
  10. package/.agents/skills/ui-eng-vision-orchestrator/SKILL.md +41 -23
  11. package/.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md +12 -7
  12. package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +3 -0
  13. package/.agents/skills/ui-widgets/SKILL.md +22 -7
  14. package/.agents/skills/version-control/SKILL.md +10 -1
  15. package/.agents/skills/visual-regression-audit/SKILL.md +88 -0
  16. package/.gitallowed +2 -1
  17. package/.stylelintignore +1 -0
  18. package/.stylelintrc.json +2 -0
  19. package/AUTHORS +1 -0
  20. package/DIR_METADATA +2 -1
  21. package/PRESUBMIT_test.py +143 -0
  22. package/config/owner/INFRA_OWNERS +0 -1
  23. package/docs/contributing/infrastructure.md +2 -2
  24. package/docs/ui_engineering.md +14 -4
  25. package/eslint.config.mjs +1 -18
  26. package/front_end/application_tokens.css +0 -35
  27. package/front_end/core/host/AidaClient.ts +1 -1
  28. package/front_end/core/host/AidaClientTypes.ts +2 -0
  29. package/front_end/core/host/AidaErrors.ts +3 -3
  30. package/front_end/core/host/AidaGcaTranslation.ts +39 -0
  31. package/front_end/core/host/GcaClient.ts +32 -20
  32. package/front_end/core/host/GcaTypes.ts +4 -2
  33. package/front_end/core/host/InspectorFrontendHostAPI.ts +2 -0
  34. package/front_end/core/i18n/DevToolsLocale.ts +0 -1
  35. package/front_end/core/sdk/DebuggerModel.ts +25 -13
  36. package/front_end/core/sdk/PreloadingModel.ts +2 -2
  37. package/front_end/core/sdk/RehydratingConnection.ts +59 -30
  38. package/front_end/core/sdk/StorageKeyManager.ts +0 -1
  39. package/front_end/core/sdk/Target.ts +6 -0
  40. package/front_end/core/sdk/TargetManager.ts +10 -4
  41. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +12 -2
  42. package/front_end/entrypoints/inspector_main/OutermostTargetSelector.ts +159 -52
  43. package/front_end/entrypoints/inspector_main/outermostTargetSelector.css +77 -25
  44. package/front_end/entrypoints/main/MainImpl.ts +32 -15
  45. package/front_end/models/ai_assistance/AiAgent2.ts +95 -46
  46. package/front_end/models/ai_assistance/AiConversation.ts +1 -1
  47. package/front_end/models/ai_assistance/agents/AiAgent.ts +9 -2
  48. package/front_end/models/ai_assistance/agents/ExecuteJavascript.ts +3 -2
  49. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +1 -1
  50. package/front_end/models/ai_assistance/data_formatters/FileFormatter.ts +1 -1
  51. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +5 -4
  52. package/front_end/models/ai_assistance/performance/AICallTree.ts +7 -9
  53. package/front_end/models/ai_assistance/performance/AIQueries.ts +4 -8
  54. package/front_end/models/ai_assistance/skills/SkillRegistry.ts +11 -1
  55. package/front_end/models/ai_assistance/skills/lighthouse.md +1 -0
  56. package/front_end/models/ai_assistance/skills/network.md +3 -4
  57. package/front_end/models/ai_assistance/skills/sources.md +1 -2
  58. package/front_end/models/ai_assistance/skills/styling.md +3 -4
  59. package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +11 -3
  60. package/front_end/models/ai_assistance/tools/ListNetworkRequests.ts +84 -23
  61. package/front_end/models/ai_assistance/tools/ListSources.ts +41 -13
  62. package/front_end/models/badges/Badge.ts +0 -1
  63. package/front_end/models/bindings/ResourceMapping.ts +1 -1
  64. package/front_end/models/bindings/ResourceScriptMapping.ts +1 -1
  65. package/front_end/models/breakpoints/BreakpointManager.ts +2 -4
  66. package/front_end/models/breakpoints/RecurringPauseDetector.ts +140 -0
  67. package/front_end/models/breakpoints/breakpoints.ts +2 -1
  68. package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +2 -2
  69. package/front_end/models/persistence/Automapping.ts +0 -1
  70. package/front_end/models/trace/Processor.ts +16 -7
  71. package/front_end/models/trace/README.md +17 -1
  72. package/front_end/models/trace/extras/ThirdParties.ts +4 -6
  73. package/front_end/models/trace/extras/TraceTree.ts +69 -72
  74. package/front_end/models/trace/handlers/MetaHandler.ts +3 -0
  75. package/front_end/models/trace/handlers/types.ts +15 -0
  76. package/front_end/models/trace/helpers/Trace.ts +5 -3
  77. package/front_end/models/trace/lantern/simulation/Simulator.ts +4 -1
  78. package/front_end/models/web_mcp/WebMCPModel.ts +19 -9
  79. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +30 -3
  80. package/front_end/panels/ai_assistance/components/ChatMessage.ts +2 -4
  81. package/front_end/panels/ai_assistance/components/chatMessage.css +1 -22
  82. package/front_end/panels/ai_assistance/components/exploreWidget.css +1 -19
  83. package/front_end/panels/ai_assistance/components/optInChangeDialog.css +1 -1
  84. package/front_end/panels/ai_assistance/components/walkthroughView.css +0 -13
  85. package/front_end/panels/animation/AnimationGroupPreviewUI.ts +3 -2
  86. package/front_end/panels/animation/AnimationTimeline.ts +5 -3
  87. package/front_end/panels/animation/animationTimeline.css +10 -8
  88. package/front_end/panels/application/ApplicationPanelSidebar.ts +14 -11
  89. package/front_end/panels/application/ReportingApiView.ts +0 -1
  90. package/front_end/panels/application/SubAppsView.ts +0 -1
  91. package/front_end/panels/application/WebMCPTreeElement.ts +3 -6
  92. package/front_end/panels/application/WebMCPView.ts +30 -0
  93. package/front_end/panels/application/components/ReportsGrid.ts +0 -1
  94. package/front_end/panels/application/components/backForwardCacheView.css +0 -7
  95. package/front_end/panels/application/components/permissionsPolicySection.css +2 -2
  96. package/front_end/panels/application/components/protocolHandlersView.css +46 -39
  97. package/front_end/panels/application/components/trustTokensView.css +0 -4
  98. package/front_end/panels/application/cookieItemsView.css +0 -7
  99. package/front_end/panels/application/indexedDBViews.css +0 -6
  100. package/front_end/panels/application/preloading/components/PreloadingDetailsReportView.ts +0 -2
  101. package/front_end/panels/application/preloading/components/PreloadingString.ts +0 -1
  102. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +4 -5
  103. package/front_end/panels/application/preloading/components/preloadingGrid.css +0 -9
  104. package/front_end/panels/application/serviceWorkerUpdateCycleView.css +2 -9
  105. package/front_end/panels/application/serviceWorkersView.css +5 -4
  106. package/front_end/panels/application/storageView.css +0 -5
  107. package/front_end/panels/application/webMCPView.css +17 -0
  108. package/front_end/panels/browser_debugger/ObjectEventListenersSidebarPane.ts +15 -20
  109. package/front_end/panels/changes/changesView.css +0 -5
  110. package/front_end/panels/common/ExtensionServer.ts +80 -10
  111. package/front_end/panels/console/ConsolePanel.ts +92 -18
  112. package/front_end/panels/console/consoleContextSelector.css +1 -8
  113. package/front_end/panels/console/consoleInsightTeaser.css +10 -17
  114. package/front_end/panels/console/consolePinPane.css +3 -1
  115. package/front_end/panels/console/consoleView.css +13 -17
  116. package/front_end/panels/coverage/coverageListView.css +0 -4
  117. package/front_end/panels/css_overview/cssOverviewCompletedView.css +0 -22
  118. package/front_end/panels/css_overview/cssOverviewStartView.css +0 -43
  119. package/front_end/panels/developer_resources/developerResourcesListView.css +0 -4
  120. package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +52 -45
  121. package/front_end/panels/elements/LayoutPane.ts +1 -3
  122. package/front_end/panels/elements/PropertiesWidget.ts +26 -8
  123. package/front_end/panels/elements/PropertyRenderer.ts +45 -21
  124. package/front_end/panels/elements/StandaloneStylesContainer.ts +6 -7
  125. package/front_end/panels/elements/StyleEditorWidget.ts +110 -63
  126. package/front_end/panels/elements/StylePropertiesSection.ts +14 -5
  127. package/front_end/panels/elements/StylePropertyTreeElement.ts +529 -518
  128. package/front_end/panels/elements/StylesContainer.ts +5 -6
  129. package/front_end/panels/elements/StylesSidebarPane.ts +12 -15
  130. package/front_end/panels/elements/components/CSSVariableValueView.ts +17 -4
  131. package/front_end/panels/elements/components/StylePropertyEditor.ts +178 -140
  132. package/front_end/panels/elements/components/cssQuery.css +1 -1
  133. package/front_end/panels/elements/components/stylePropertyEditor.css +60 -56
  134. package/front_end/panels/elements/layoutPane.css +2 -2
  135. package/front_end/panels/elements/metricsSidebarPane.css +6 -7
  136. package/front_end/panels/elements/platformFontsWidget.css +1 -1
  137. package/front_end/panels/elements/stylePropertiesTreeOutline.css +1 -6
  138. package/front_end/panels/elements/stylesSidebarPane.css +3 -4
  139. package/front_end/panels/emulation/deviceModeView.css +1 -1
  140. package/front_end/panels/event_listeners/EventListenersView.ts +9 -2
  141. package/front_end/panels/event_listeners/eventListenersView.css +1 -1
  142. package/front_end/panels/explain/components/consoleInsight.css +1 -2
  143. package/front_end/panels/issues/issuesTree.css +6 -43
  144. package/front_end/panels/layer_viewer/PaintProfilerView.ts +1 -1
  145. package/front_end/panels/layer_viewer/paintProfiler.css +4 -3
  146. package/front_end/panels/lighthouse/LighthouseReportSelector.ts +1 -6
  147. package/front_end/panels/lighthouse/lighthouseStartView.css +5 -16
  148. package/front_end/panels/linear_memory_inspector/components/LinearMemoryValueInterpreter.ts +0 -1
  149. package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +2 -2
  150. package/front_end/panels/linear_memory_inspector/components/linearMemoryViewer.css +2 -2
  151. package/front_end/panels/linear_memory_inspector/components/valueInterpreterSettings.css +1 -1
  152. package/front_end/panels/media/playerListView.css +1 -2
  153. package/front_end/panels/media/playerPropertiesView.css +1 -1
  154. package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +2 -2
  155. package/front_end/panels/network/NetworkLogView.ts +594 -580
  156. package/front_end/panels/network/RequestCookiesView.ts +0 -1
  157. package/front_end/panels/network/networkConfigView.css +1 -2
  158. package/front_end/panels/network/networkLogView.css +363 -364
  159. package/front_end/panels/network/networkPanel.css +1 -5
  160. package/front_end/panels/network/networkTimingTable.css +1 -1
  161. package/front_end/panels/network/networkWaterfallColumn.css +1 -1
  162. package/front_end/panels/network/requestConditionsDrawer.css +0 -4
  163. package/front_end/panels/network/requestCookiesView.css +7 -1
  164. package/front_end/panels/network/requestPayloadTree.css +0 -4
  165. package/front_end/panels/profiler/HeapProfileView.ts +1 -3
  166. package/front_end/panels/profiler/HeapSnapshotView.ts +0 -7
  167. package/front_end/panels/recorder/RecorderPanel.ts +1 -1
  168. package/front_end/panels/recorder/RecordingView.ts +10 -10
  169. package/front_end/panels/recorder/StepView.ts +5 -4
  170. package/front_end/panels/recorder/createRecordingView.css +1 -1
  171. package/front_end/panels/recorder/recorderPanel.css +0 -8
  172. package/front_end/panels/recorder/recordingListView.css +4 -4
  173. package/front_end/panels/recorder/recordingView.css +12 -20
  174. package/front_end/panels/recorder/stepEditor.css +4 -4
  175. package/front_end/panels/recorder/stepView.css +31 -9
  176. package/front_end/panels/recorder/timelineSection.css +4 -0
  177. package/front_end/panels/screencast/ScreencastApp.ts +0 -1
  178. package/front_end/panels/security/mainView.css +1 -1
  179. package/front_end/panels/security/originView.css +2 -2
  180. package/front_end/panels/sensors/SensorsView.ts +273 -346
  181. package/front_end/panels/settings/BackendLinkingSettingsTab.ts +0 -1
  182. package/front_end/panels/settings/backendLinkingSettingsTab.css +7 -7
  183. package/front_end/panels/settings/components/syncSection.css +0 -1
  184. package/front_end/panels/settings/workspaceSettingsTab.css +0 -5
  185. package/front_end/panels/sources/CSSPlugin.ts +177 -98
  186. package/front_end/panels/sources/DebuggerPausedMessage.ts +100 -27
  187. package/front_end/panels/sources/NavigatorView.ts +926 -946
  188. package/front_end/panels/sources/SourcesPanel.ts +9 -2
  189. package/front_end/panels/sources/breakpointsView.css +6 -29
  190. package/front_end/panels/sources/components/HeadersView.css +2 -2
  191. package/front_end/panels/sources/debuggerPausedMessage.css +7 -0
  192. package/front_end/panels/sources/navigatorTree.css +7 -2
  193. package/front_end/panels/sources/sourcesNavigator.css +0 -9
  194. package/front_end/panels/sources/watchExpressionsSidebarPane.css +0 -10
  195. package/front_end/panels/timeline/CompatibilityTracksAppender.ts +3 -0
  196. package/front_end/panels/timeline/LayoutShiftsTrackAppender.ts +0 -10
  197. package/front_end/panels/timeline/ModificationsManager.ts +0 -1
  198. package/front_end/panels/timeline/ThreadAppender.ts +2 -6
  199. package/front_end/panels/timeline/TimelinePanel.ts +2 -2
  200. package/front_end/panels/timeline/TimelineTreeView.ts +38 -41
  201. package/front_end/panels/timeline/TimelineUIUtils.ts +8 -10
  202. package/front_end/panels/timeline/components/LayoutShiftDetails.ts +0 -2
  203. package/front_end/panels/timeline/components/fieldSettingsDialog.css +1 -6
  204. package/front_end/panels/timeline/components/insights/baseInsightComponent.css +0 -12
  205. package/front_end/panels/timeline/components/interactionBreakdown.css +1 -2
  206. package/front_end/panels/timeline/components/layoutShiftDetails.css +2 -9
  207. package/front_end/panels/timeline/components/liveMetricsView.css +0 -16
  208. package/front_end/panels/timeline/components/metricCard.css +1 -5
  209. package/front_end/panels/timeline/components/networkRequestDetails.css +3 -4
  210. package/front_end/panels/timeline/components/networkRequestTooltip.css +6 -4
  211. package/front_end/panels/timeline/components/sidebarAnnotationsTab.css +1 -1
  212. package/front_end/panels/timeline/components/sidebarInsightsTab.css +1 -2
  213. package/front_end/panels/timeline/timelineDetailsView.css +1 -12
  214. package/front_end/panels/timeline/timelineFlamechartPopover.css +0 -4
  215. package/front_end/panels/timeline/timelineMiniMap.css +1 -4
  216. package/front_end/panels/timeline/timelinePanel.css +0 -4
  217. package/front_end/panels/timeline/timelineStatusDialog.css +1 -1
  218. package/front_end/panels/timeline/timelineTreeView.css +0 -12
  219. package/front_end/panels/timeline/utils/EntryNodes.ts +1 -1
  220. package/front_end/panels/webauthn/webauthnPane.css +1 -7
  221. package/front_end/panels/whats_new/ReleaseNoteText.ts +1 -1
  222. package/front_end/third_party/chromium/README.chromium +1 -1
  223. package/front_end/ui/components/adorners/adorner.css +1 -1
  224. package/front_end/ui/components/buttons/button.css +0 -28
  225. package/front_end/ui/components/buttons/textButton.css +1 -45
  226. package/front_end/ui/components/input/checkbox.css +3 -3
  227. package/front_end/ui/components/issue_counter/issueLinkIcon.css +2 -2
  228. package/front_end/ui/components/menus/Menu.ts +14 -0
  229. package/front_end/ui/components/menus/menu.css +2 -14
  230. package/front_end/ui/components/menus/menuItem.css +0 -4
  231. package/front_end/ui/components/request_link_icon/requestLinkIcon.css +2 -2
  232. package/front_end/ui/components/survey_link/SurveyLink.ts +1 -1
  233. package/front_end/ui/components/survey_link/surveyLink.css +3 -3
  234. package/front_end/ui/components/switch/switch.css +3 -2
  235. package/front_end/ui/components/text_editor/theme.ts +1 -1
  236. package/front_end/ui/components/tooltips/Tooltip.ts +3 -3
  237. package/front_end/ui/components/tree_outline/treeOutline.css +0 -23
  238. package/front_end/ui/legacy/ContextMenu.ts +5 -5
  239. package/front_end/ui/legacy/SoftContextMenu.ts +24 -8
  240. package/front_end/ui/legacy/Toolbar.ts +1 -1
  241. package/front_end/ui/legacy/Treeoutline.ts +31 -78
  242. package/front_end/ui/legacy/UIUtils.ts +9 -17
  243. package/front_end/ui/legacy/checkboxTextLabel.css +2 -44
  244. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +39 -27
  245. package/front_end/ui/legacy/components/color_picker/spectrum.css +2 -10
  246. package/front_end/ui/legacy/components/data_grid/dataGrid.css +2 -6
  247. package/front_end/ui/legacy/components/inline_editor/BezierEditor.ts +34 -26
  248. package/front_end/ui/legacy/components/inline_editor/SwatchPopoverHelper.ts +1 -0
  249. package/front_end/ui/legacy/components/inline_editor/cssShadowEditor.css +1 -1
  250. package/front_end/ui/legacy/components/inline_editor/swatchPopover.css +1 -1
  251. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +49 -1
  252. package/front_end/ui/legacy/components/object_ui/objectPopover.css +0 -4
  253. package/front_end/ui/legacy/components/perf_ui/chartViewport.css +1 -9
  254. package/front_end/ui/legacy/components/perf_ui/filmStripView.css +1 -1
  255. package/front_end/ui/legacy/components/perf_ui/overviewGrid.css +2 -1
  256. package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +0 -5
  257. package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +6 -3
  258. package/front_end/ui/legacy/components/source_frame/JSONView.ts +95 -1
  259. package/front_end/ui/legacy/filter.css +1 -1
  260. package/front_end/ui/legacy/inspectorCommon.css +6 -28
  261. package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +1 -1
  262. package/front_end/ui/legacy/listWidget.css +1 -1
  263. package/front_end/ui/legacy/progressIndicator.css +1 -1
  264. package/front_end/ui/legacy/tabbedPane.css +6 -2
  265. package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
  266. package/front_end/ui/visual_logging/LoggingDriver.ts +4 -0
  267. package/front_end/ui/visual_logging/visual_logging.ts +1 -1
  268. package/inspector_overlay/common.ts +0 -3
  269. package/inspector_overlay/main.ts +1 -3
  270. package/inspector_overlay/tool_source_order.css +0 -4
  271. package/package.json +1 -1
  272. package/front_end/generated/SupportedCSSProperties.ts +0 -9705
@@ -5,7 +5,7 @@ import '../../ui/kit/kit.js';
5
5
 
6
6
  import * as Elements from '../../models/elements/elements.js';
7
7
  import * as UI from '../../ui/legacy/legacy.js';
8
- import {Directives, html, type LitTemplate, render} from '../../ui/lit/lit.js';
8
+ import {Directives, html, type LitTemplate, nothing, render} from '../../ui/lit/lit.js';
9
9
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
10
10
 
11
11
  import type * as ElementsComponents from './components/components.js';
@@ -13,36 +13,42 @@ import type {StylePropertiesSection} from './StylePropertiesSection.js';
13
13
  import {StylePropertyTreeElement} from './StylePropertyTreeElement.js';
14
14
  import type {StylesContainer} from './StylesContainer.js';
15
15
 
16
- const {ref} = Directives;
17
- type PropertySelectedEvent = ElementsComponents.StylePropertyEditor.PropertySelectedEvent;
18
- type PropertyDeselectedEvent = ElementsComponents.StylePropertyEditor.PropertyDeselectedEvent;
16
+ const {ref, repeat} = Directives;
19
17
 
20
18
  let instance: StyleEditorWidget|null = null;
21
- export interface Editor extends HTMLElement {
22
- data: {
23
- authoredProperties: Map<String, String>,
24
- computedProperties: Map<String, String>,
25
- };
26
- getEditableProperties(): Array<{propertyName: string}>;
27
- jslogContext: string;
28
- }
29
19
 
30
20
  export interface ViewInput {
31
- editor: Editor;
21
+ editorClass?: typeof ElementsComponents.StylePropertyEditor.StylePropertyEditor;
32
22
  authoredProperties: Map<string, string>;
33
23
  computedProperties: Map<string, string>;
24
+ onPropertySelected: (event: ElementsComponents.StylePropertyEditor.PropertySelectedEvent) => void;
25
+ onPropertyDeselected: (event: ElementsComponents.StylePropertyEditor.PropertyDeselectedEvent) => void;
26
+ }
27
+
28
+ export interface ViewOutput {
29
+ waitForEditorUpdate?: () => Promise<void>;
34
30
  }
35
31
 
36
- export type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
32
+ export type View = (input: ViewInput, output: ViewOutput, target: HTMLElement) => void;
37
33
 
38
- export const DEFAULT_VIEW: View = (input, _output, target) => {
39
- input.editor.data = {
40
- authoredProperties: input.authoredProperties,
41
- computedProperties: input.computedProperties,
42
- };
34
+ export const DEFAULT_VIEW: View = (input, output, target) => {
43
35
  // clang-format off
44
36
  render(
45
- html`<div tabindex="0" autofocus>${input.editor}</div>`,
37
+ html`<div tabindex="0" autofocus>${input.editorClass ? repeat(
38
+ [input.editorClass],
39
+ editorClass => editorClass,
40
+ editorClass => html`<devtools-widget
41
+ ${UI.Widget.widget(editorClass, {
42
+ authoredProperties: input.authoredProperties,
43
+ computedProperties: input.computedProperties,
44
+ })}
45
+ ${UI.Widget.widgetRef(editorClass, editor => {
46
+ output.waitForEditorUpdate = () => editor.updateComplete;
47
+ })}
48
+ @propertyselected=${input.onPropertySelected}
49
+ @propertydeselected=${input.onPropertyDeselected}
50
+ ></devtools-widget>`,
51
+ ) : nothing}</div>`,
46
52
  target, {container: {classes: ['with-padding']}});
47
53
  // clang-format on
48
54
  };
@@ -51,54 +57,59 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
51
57
  * Thin UI.Widget wrapper around style editors to allow using it as a popover.
52
58
  */
53
59
  export class StyleEditorWidget extends UI.Widget.VBox {
54
- private editor?: Editor;
55
- private stylesContainer?: StylesContainer;
56
- private section?: StylePropertiesSection;
60
+ #editorClass?: typeof ElementsComponents.StylePropertyEditor.StylePropertyEditor;
61
+ #stylesContainer?: StylesContainer;
62
+ #section?: StylePropertiesSection;
57
63
  readonly #view: View;
64
+ readonly #viewOutput: ViewOutput = {};
58
65
 
59
66
  #triggerKey: string|undefined;
60
67
  #initialProperties: Map<string, string>|null = null;
61
68
 
62
69
  constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
63
- super(element, {useShadowDom: true});
70
+ super(element);
64
71
  this.#view = view;
65
- this.onPropertySelected = this.onPropertySelected.bind(this);
66
- this.onPropertyDeselected = this.onPropertyDeselected.bind(this);
67
72
  }
68
73
 
69
74
  getSection(): StylePropertiesSection|undefined {
70
- return this.section;
75
+ return this.#section;
71
76
  }
72
77
 
73
- async onPropertySelected(event: PropertySelectedEvent): Promise<void> {
74
- if (!this.section) {
78
+ async onPropertySelected(event: ElementsComponents.StylePropertyEditor.PropertySelectedEvent): Promise<void> {
79
+ if (!this.#section) {
75
80
  return;
76
81
  }
77
- const target = ensureTreeElementForProperty(this.section, event.data.name);
78
- target.property.value = event.data.value;
82
+ const {name, value} = event.data;
83
+ const target = ensureTreeElementForProperty(this.#section, name);
84
+ target.property.value = value;
79
85
  target.updateTitle();
80
86
  await target.applyStyleText(target.renderedPropertyText(), false);
87
+ if (this.#section) {
88
+ this.#stylesContainer?.refreshUpdate(this.#section, target, true);
89
+ }
81
90
  this.requestUpdate();
82
91
  }
83
92
 
84
- async onPropertyDeselected(event: PropertyDeselectedEvent): Promise<void> {
85
- if (!this.section) {
93
+ async onPropertyDeselected(event: ElementsComponents.StylePropertyEditor.PropertyDeselectedEvent): Promise<void> {
94
+ if (!this.#section) {
86
95
  return;
87
96
  }
88
- const target = ensureTreeElementForProperty(this.section, event.data.name);
97
+ const {name} = event.data;
98
+ const target = ensureTreeElementForProperty(this.#section, name);
89
99
  await target.applyStyleText('', false);
100
+ if (this.#section) {
101
+ this.#stylesContainer?.refreshUpdate(this.#section, target, true);
102
+ }
90
103
  this.requestUpdate();
91
104
  }
92
105
 
93
106
  bindContext(stylesContainer: StylesContainer, section: StylePropertiesSection): void {
94
- this.stylesContainer = stylesContainer;
95
- this.section = section;
107
+ this.#stylesContainer = stylesContainer;
108
+ this.#section = section;
96
109
  if (!this.#initialProperties) {
97
110
  this.#initialProperties =
98
- this.editor ? getAuthoredStyles(section, this.editor.getEditableProperties()) : new Map();
111
+ this.#editorClass ? getAuthoredStyles(section, this.#editorClass.editableProperties) : new Map();
99
112
  }
100
- this.editor?.addEventListener('propertyselected', this.onPropertySelected);
101
- this.editor?.addEventListener('propertydeselected', this.onPropertyDeselected);
102
113
  }
103
114
 
104
115
  setTriggerKey(value: string): void {
@@ -110,25 +121,36 @@ export class StyleEditorWidget extends UI.Widget.VBox {
110
121
  }
111
122
 
112
123
  unbindContext(): void {
113
- this.stylesContainer = undefined;
114
- this.section = undefined;
115
- this.editor?.removeEventListener('propertyselected', this.onPropertySelected);
116
- this.editor?.removeEventListener('propertydeselected', this.onPropertyDeselected);
124
+ this.#stylesContainer = undefined;
125
+ this.#section = undefined;
126
+ }
127
+
128
+ #clearEditor(): void {
129
+ this.#editorClass = undefined;
130
+ this.#initialProperties = null;
131
+ this.#viewOutput.waitForEditorUpdate = undefined;
132
+ this.#view({
133
+ authoredProperties: new Map(),
134
+ computedProperties: new Map(),
135
+ onPropertySelected: this.onPropertySelected.bind(this),
136
+ onPropertyDeselected: this.onPropertyDeselected.bind(this),
137
+ },
138
+ this.#viewOutput, this.contentElement);
117
139
  }
118
140
 
119
141
  #trackChanges(): void {
120
142
  const initialProperties = this.#initialProperties;
121
143
  this.#initialProperties = null;
122
- if (!this.editor || !this.section || !this.stylesContainer || !initialProperties) {
144
+ if (!this.#editorClass || !this.#section || !this.#stylesContainer || !initialProperties) {
123
145
  return;
124
146
  }
125
- const finalProperties = getAuthoredStyles(this.section, this.editor.getEditableProperties());
126
- const node = this.stylesContainer.node() ?? this.section.matchedStyles.node();
127
- const ruleHeader = this.section.headerText();
128
- for (const {propertyName} of this.editor.getEditableProperties()) {
147
+ const finalProperties = getAuthoredStyles(this.#section, this.#editorClass.editableProperties);
148
+ const node = this.#stylesContainer.node() ?? this.#section.matchedStyles.node();
149
+ const ruleHeader = this.#section.headerText();
150
+ for (const {propertyName} of this.#editorClass.editableProperties) {
129
151
  const oldValue = initialProperties.get(propertyName) ?? '';
130
152
  const newValue = finalProperties.get(propertyName) ?? '';
131
- Elements.StyleChanges.trackStylePropertyEdit(this.stylesContainer.changeTracker, node, {
153
+ Elements.StyleChanges.trackStylePropertyEdit(this.#stylesContainer.changeTracker, node, {
132
154
  ruleHeader,
133
155
  oldName: oldValue ? propertyName : '',
134
156
  oldValue,
@@ -137,21 +159,32 @@ export class StyleEditorWidget extends UI.Widget.VBox {
137
159
  });
138
160
  }
139
161
  }
162
+
140
163
  async render(): Promise<void> {
141
- if (!this.editor) {
164
+ if (!this.#editorClass) {
142
165
  return;
143
166
  }
167
+ const computedProperties = this.#stylesContainer ? await fetchComputedStyles(this.#stylesContainer) : new Map();
168
+ if (!this.#editorClass) {
169
+ return;
170
+ }
171
+ const authoredProperties =
172
+ this.#section ? getAuthoredStyles(this.#section, this.#editorClass.editableProperties) : new Map();
144
173
  this.#view({
145
- editor: this.editor,
146
- authoredProperties: this.section ? getAuthoredStyles(this.section, this.editor.getEditableProperties()) :
147
- new Map(),
148
- computedProperties: this.stylesContainer ? await fetchComputedStyles(this.stylesContainer) : new Map(),
174
+ editorClass: this.#editorClass,
175
+ authoredProperties,
176
+ computedProperties,
177
+ onPropertySelected: this.onPropertySelected.bind(this),
178
+ onPropertyDeselected: this.onPropertyDeselected.bind(this),
149
179
  },
150
- undefined, this.contentElement);
180
+ this.#viewOutput, this.contentElement);
181
+ await this.#viewOutput.waitForEditorUpdate?.();
182
+ if (this.#stylesContainer?.swatchPopoverHelper().isShowing(this)) {
183
+ this.#stylesContainer.swatchPopoverHelper().reposition();
184
+ }
151
185
  }
152
186
 
153
187
  override async performUpdate(): Promise<void> {
154
- await super.performUpdate();
155
188
  await this.render();
156
189
  }
157
190
 
@@ -162,15 +195,14 @@ export class StyleEditorWidget extends UI.Widget.VBox {
162
195
  return instance;
163
196
  }
164
197
 
165
- setEditor(editorClass: {new(): Editor}): void {
166
- if (!(this.editor instanceof editorClass)) {
167
- this.editor = new editorClass();
168
- }
198
+ setEditor(editorClass: typeof ElementsComponents.StylePropertyEditor.StylePropertyEditor): void {
199
+ this.#editorClass = editorClass;
169
200
  }
170
201
 
171
202
  static createTriggerButton(stylesContainer: StylesContainer, section: StylePropertiesSection,
172
- editorClass: {new(): Editor}, buttonTitle: string, triggerKey: string,
173
- jslogContext: string, onClick?: () => void): LitTemplate {
203
+ editorClass: typeof ElementsComponents.StylePropertyEditor.StylePropertyEditor,
204
+ buttonTitle: string, triggerKey: string, jslogContext: string,
205
+ onClick?: () => void): LitTemplate {
174
206
  const popoverHelper = stylesContainer.swatchPopoverHelper();
175
207
  let triggerButton: Element|undefined;
176
208
  // clang-format off
@@ -195,20 +227,34 @@ export class StyleEditorWidget extends UI.Widget.VBox {
195
227
  return;
196
228
  }
197
229
  const widget = StyleEditorWidget.instance();
230
+ if (popoverHelper.isShowing()) {
231
+ const isSameTrigger = popoverHelper.isShowing(widget) && widget.getTriggerKey() === triggerKey;
232
+ popoverHelper.hide(true);
233
+ if (isSameTrigger) {
234
+ return;
235
+ }
236
+ }
198
237
  widget.setEditor(editorClass);
199
238
  widget.bindContext(stylesContainer, section);
200
239
  widget.setTriggerKey(triggerKey);
201
240
  await widget.render();
202
- widget.focus();
241
+ if (!triggerButton.isConnected) {
242
+ widget.unbindContext();
243
+ widget.#clearEditor();
244
+ return;
245
+ }
203
246
  const scrollerElement = triggerButton.enclosingNodeOrSelfWithClass('style-panes-wrapper');
204
247
  const onScroll = (): void => {
205
248
  popoverHelper.hide(true);
206
249
  };
207
250
  const onStylesUpdateCompleted = widget.requestUpdate.bind(widget);
208
251
  stylesContainer.addStyleUpdateListener(onStylesUpdateCompleted);
252
+ stylesContainer.setEditingStyle(true);
209
253
  popoverHelper.show(widget, triggerButton, () => {
254
+ stylesContainer.setEditingStyle(false);
210
255
  widget.#trackChanges();
211
256
  widget.unbindContext();
257
+ widget.#clearEditor();
212
258
  if (scrollerElement) {
213
259
  scrollerElement.removeEventListener('scroll', onScroll);
214
260
  }
@@ -218,6 +264,7 @@ export class StyleEditorWidget extends UI.Widget.VBox {
218
264
  scrollerElement.addEventListener('scroll', onScroll);
219
265
  }
220
266
  }}
267
+ @mousedown=${(event: Event) => event.consume()}
221
268
  @mouseup=${(event: Event) => {
222
269
  // Stop propagation to prevent the property editor from being activated.
223
270
  event.stopPropagation();
@@ -63,6 +63,7 @@ import {
63
63
  type Context,
64
64
  GhostStylePropertyTreeElement,
65
65
  handleVarDefinitionActivate,
66
+ type StylePropertyData,
66
67
  StylePropertyTreeElement,
67
68
  } from './StylePropertyTreeElement.js';
68
69
  import type {StylesContainer} from './StylesContainer.js';
@@ -1266,6 +1267,7 @@ export class StylePropertiesSection {
1266
1267
  if (lastAncestor && this.#collapseIcon && this.#statusElement) {
1267
1268
  this.#collapseIcon.slot = 'indent';
1268
1269
  lastAncestor.append(this.#collapseIcon, this.#statusElement);
1270
+ lastAncestor.classList.add('has-collapse-icon');
1269
1271
  }
1270
1272
  this.#ancestorClosingBracesElement.firstElementChild?.classList.add('sidebar-pane-closing-brace');
1271
1273
  }
@@ -1312,17 +1314,24 @@ export class StylePropertiesSection {
1312
1314
  return (curSection?.editable) ? curSection : null;
1313
1315
  }
1314
1316
 
1315
- refreshUpdate(editedTreeElement: StylePropertyTreeElement): void {
1316
- this.stylesContainer.refreshUpdate(this, editedTreeElement);
1317
+ findProperty(propertyOrName: SDK.CSSProperty.CSSProperty|string): StylePropertyData|undefined {
1318
+ return this.propertiesTreeOutline.rootElement().children().findLast(
1319
+ (child): child is StylePropertyTreeElement => child instanceof StylePropertyTreeElement &&
1320
+ (typeof propertyOrName === 'string' ? child.property.name === propertyOrName :
1321
+ child.property === propertyOrName));
1317
1322
  }
1318
1323
 
1319
- updateVarFunctions(editedTreeElement: StylePropertyTreeElement): void {
1320
- if (!editedTreeElement.property.name.startsWith('--')) {
1324
+ refreshUpdate(editedProperty: StylePropertyData): void {
1325
+ this.stylesContainer.refreshUpdate(this, editedProperty);
1326
+ }
1327
+
1328
+ updateVarFunctions(editedProperty: StylePropertyData): void {
1329
+ if (!editedProperty.property.name.startsWith('--')) {
1321
1330
  return;
1322
1331
  }
1323
1332
  let child = this.propertiesTreeOutline.firstChild();
1324
1333
  while (child) {
1325
- if (child !== editedTreeElement && child instanceof StylePropertyTreeElement) {
1334
+ if (child instanceof StylePropertyTreeElement && child !== editedProperty) {
1326
1335
  child.refreshIfComputedValueChanged();
1327
1336
  }
1328
1337
  child = child.traverseNextTreeElement(false /* skipUnrevealed */, null /* stayWithin */, true /* dontPopulate */);