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
@@ -15,13 +15,14 @@ import * as Bindings from '../../models/bindings/bindings.js';
15
15
  import * as Elements from '../../models/elements/elements.js';
16
16
  import type * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js';
17
17
  import * as Tooltips from '../../ui/components/tooltips/tooltips.js';
18
- import {createIcon, Icon} from '../../ui/kit/kit.js';
18
+ import {createIcon, type Icon} from '../../ui/kit/kit.js';
19
19
  import * as ColorPicker from '../../ui/legacy/components/color_picker/color_picker.js';
20
20
  import * as InlineEditor from '../../ui/legacy/components/inline_editor/inline_editor.js';
21
21
  import * as UI from '../../ui/legacy/legacy.js';
22
22
  import {
23
23
  Directives,
24
24
  html,
25
+ i18nTemplate as litI18nTemplate,
25
26
  type LitTemplate,
26
27
  nothing,
27
28
  render,
@@ -38,7 +39,7 @@ import {
38
39
  ShadowSwatchPopoverHelper,
39
40
  } from './ColorSwatchPopoverIcon.js';
40
41
  import * as ElementsComponents from './components/components.js';
41
- import {cssRuleValidatorsMap} from './CSSRuleValidator.js';
42
+ import {cssRuleValidatorsMap, type Hint} from './CSSRuleValidator.js';
42
43
  import {CSSValueTraceView} from './CSSValueTraceView.js';
43
44
  import {ElementsPanel} from './ElementsPanel.js';
44
45
  import {
@@ -62,7 +63,7 @@ import {getCssDeclarationAsJavascriptProperty} from './StylePropertyUtils.js';
62
63
  import type {StylesContainer} from './StylesContainer.js';
63
64
  import {CSSPropertyPrompt, REGISTERED_PROPERTY_SECTION_NAME} from './StylesSidebarPane.js';
64
65
 
65
- const {classMap, ref, until} = Directives;
66
+ const {classMap, ifDefined, ref, until} = Directives;
66
67
  const {ifExpanded} = Tooltips.Tooltip;
67
68
  const ASTUtils = SDK.CSSPropertyParser.ASTUtils;
68
69
  const FlexboxEditor = ElementsComponents.StylePropertyEditor.FlexboxEditor;
@@ -113,9 +114,11 @@ const UIStrings = {
113
114
  */
114
115
  viewComputedValue: 'View computed value',
115
116
  /**
116
- * @description Tooltip text for a style property overridden by an animation.
117
+ * @description Tooltip text for a style property overridden by an animation. The placeholder is a link that opens
118
+ * the Animations panel.
119
+ * @example {Open Animations panel} PH1
117
120
  */
118
- overriddenByAnimation: 'Overridden by animation styles',
121
+ overriddenByAnimation: 'Overridden by animation styles. {PH1}',
119
122
  /**
120
123
  * @description Link text in the tooltip to open the Animations panel.
121
124
  */
@@ -193,6 +196,7 @@ const UIStrings = {
193
196
  } as const;
194
197
  const str_ = i18n.i18n.registerUIStrings('panels/elements/StylePropertyTreeElement.ts', UIStrings);
195
198
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
199
+ const i18nTemplate = litI18nTemplate.bind(undefined, str_);
196
200
  const parentMap = new WeakMap<StylesContainer, StylePropertyTreeElement>();
197
201
 
198
202
  interface StylePropertyTreeElementParams {
@@ -206,15 +210,34 @@ interface StylePropertyTreeElementParams {
206
210
  newProperty: boolean;
207
211
  }
208
212
 
213
+ export interface StylePropertyData {
214
+ property: SDK.CSSProperty.CSSProperty;
215
+ readonly tooltipIdFactory: Tooltips.Tooltip.IdFactory;
216
+ readonly lastCommittedProperty: {readonly name: string, readonly value: string};
217
+ editable(): boolean;
218
+ inherited(): boolean;
219
+ overloaded(): boolean;
220
+ parentShorthand(): StylePropertyData|null;
221
+ matchedStyles(): SDK.CSSMatchedStyles.CSSMatchedStyles;
222
+ stylesContainer(): StylesContainer;
223
+ section(): StylePropertiesSection;
224
+ getComputedStyles(): Map<string, string>|null;
225
+ getComputedStyleExtraFields(): Protocol.CSS.ComputedStyleExtraFields|null;
226
+ renderedPropertyText(): string;
227
+ updateTitle(): void;
228
+ applyStyleText(styleText: string, majorChange: boolean): Promise<void>;
229
+ carryOverCommittedProperty(previous: StylePropertyData): void;
230
+ setSiblingProperty(propertyName: string, value?: string): Promise<void>;
231
+ }
209
232
  const EnvFunctionRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.EnvFunctionMatch> =
210
233
  rendererBase(SDK.CSSPropertyParserMatchers.EnvFunctionMatch);
211
234
  // clang-format off
212
235
  export class EnvFunctionRenderer extends EnvFunctionRendererBase {
213
236
  // clang-format on
214
- constructor(
215
- readonly treeElement: StylePropertyTreeElement|null,
216
- readonly matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, readonly computedStyles: Map<string, string>,
217
- readonly computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
237
+ constructor(readonly propertyData: StylePropertyData|null,
238
+ readonly matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
239
+ readonly computedStyles: Map<string, string>,
240
+ readonly computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
218
241
  super();
219
242
  }
220
243
  override render(match: SDK.CSSPropertyParserMatchers.EnvFunctionMatch, context: RenderingContext): LitTemplate {
@@ -229,9 +252,10 @@ export class EnvFunctionRenderer extends EnvFunctionRendererBase {
229
252
  }
230
253
  }
231
254
 
232
- const func =
233
- this.treeElement?.getTracingTooltip(
234
- 'env', match.node, this.matchedStyles, this.computedStyles, this.computedStyleExtraFields, context) ??
255
+ const func = this.propertyData ?
256
+ getTracingTooltip('env', match.node, this.matchedStyles, this.computedStyles, this.computedStyleExtraFields,
257
+ context, this.propertyData.stylesContainer(), this.propertyData.tooltipIdFactory,
258
+ this.propertyData.property, this.propertyData.parentShorthand()?.property.name) :
235
259
  'env';
236
260
  const valueClass = classMap({'inactive-value': !match.varNameIsValid});
237
261
  const fallbackClass = classMap({'inactive-value': match.varNameIsValid});
@@ -250,21 +274,21 @@ const FlexGridRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.FlexGridG
250
274
  // clang-format off
251
275
  export class FlexGridRenderer extends FlexGridRendererBase {
252
276
  // clang-format on
253
- readonly #treeElement: StylePropertyTreeElement|null;
277
+ readonly #propertyData: StylePropertyData|null;
254
278
  readonly #stylesContainer: StylesContainer;
255
- constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null) {
279
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null) {
256
280
  super();
257
- this.#treeElement = treeElement;
281
+ this.#propertyData = propertyData;
258
282
  this.#stylesContainer = stylesContainer;
259
283
  }
260
284
 
261
285
  override render(match: SDK.CSSPropertyParserMatchers.FlexGridGridLanesMatch, context: RenderingContext): LitTemplate {
262
286
  const children = Renderer.render(ASTUtils.siblings(ASTUtils.declValue(match.node)), context).nodes;
263
- if (!this.#treeElement?.editable()) {
287
+ if (!this.#propertyData?.editable()) {
264
288
  return children;
265
289
  }
266
290
  const key =
267
- `${this.#treeElement.section().getSectionIdx()}_${this.#treeElement.section().nextEditorTriggerButtonIdx++}`;
291
+ `${this.#propertyData.section().getSectionIdx()}_${this.#propertyData.section().nextEditorTriggerButtonIdx++}`;
268
292
 
269
293
  function getEditorClass(layoutType: SDK.CSSPropertyParserMatchers.LayoutType): typeof FlexboxEditor|
270
294
  typeof GridEditor|typeof GridLanesEditor {
@@ -301,7 +325,7 @@ export class FlexGridRenderer extends FlexGridRendererBase {
301
325
  }
302
326
 
303
327
  const button = StyleEditorWidget.createTriggerButton(
304
- this.#stylesContainer, this.#treeElement.section(), getEditorClass(match.layoutType),
328
+ this.#stylesContainer, this.#propertyData.section(), getEditorClass(match.layoutType),
305
329
  getButtonTitle(match.layoutType), key, match.layoutType, () => {
306
330
  Host.userMetrics.swatchActivated(getSwatchType(match.layoutType));
307
331
  });
@@ -314,11 +338,11 @@ const CSSWideKeywordRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.CSS
314
338
  // clang-format off
315
339
  export class CSSWideKeywordRenderer extends CSSWideKeywordRendererBase {
316
340
  // clang-format on
317
- readonly #treeElement: StylePropertyTreeElement|null;
341
+ readonly #propertyData: StylePropertyData|null;
318
342
  readonly #stylesContainer: StylesContainer;
319
- constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null) {
343
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null) {
320
344
  super();
321
- this.#treeElement = treeElement;
345
+ this.#propertyData = propertyData;
322
346
  this.#stylesContainer = stylesContainer;
323
347
  }
324
348
 
@@ -330,10 +354,10 @@ export class CSSWideKeywordRenderer extends CSSWideKeywordRendererBase {
330
354
 
331
355
  const swatch = html`<devtools-link-swatch .data=${{
332
356
  text: match.text,
333
- tooltip: resolvedProperty ? undefined : {title: i18nString(UIStrings.sIsNotDefined, {PH1: match.text})},
334
- isDefined: Boolean(resolvedProperty),
335
- onLinkActivate: () => resolvedProperty && this.#stylesContainer.jumpToDeclaration(resolvedProperty),
336
- jslogContext: 'css-wide-keyword-link',
357
+ tooltip: resolvedProperty ? undefined : {title: i18nString(UIStrings.sIsNotDefined, {PH1: match.text})},
358
+ isDefined: Boolean(resolvedProperty),
359
+ onLinkActivate: () => resolvedProperty && this.#stylesContainer.jumpToDeclaration(resolvedProperty),
360
+ jslogContext: 'css-wide-keyword-link',
337
361
  }
338
362
  }></devtools-link-swatch>`;
339
363
 
@@ -342,8 +366,8 @@ export class CSSWideKeywordRenderer extends CSSWideKeywordRendererBase {
342
366
  const color = Common.Color.parse(context.matchedResult.getComputedText(match.node));
343
367
  if (color) {
344
368
  const colorSwatch =
345
- new ColorRenderer(this.#stylesContainer, this.#treeElement).renderColorSwatch(color, match, context);
346
- return this.#treeElement?.editable() ?
369
+ new ColorRenderer(this.#stylesContainer, this.#propertyData).renderColorSwatch(color, match, context);
370
+ return this.#propertyData?.editable() ?
347
371
  html`<devtools-widget ${widget(EditableContent)}>${colorSwatch}${swatch}</devtools-widget>` :
348
372
  html`${colorSwatch}${swatch}`;
349
373
  }
@@ -374,16 +398,15 @@ const VariableRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.VariableM
374
398
  export class VariableRenderer extends VariableRendererBase {
375
399
  // clang-format on
376
400
  readonly #stylesContainer: StylesContainer;
377
- readonly #treeElement: StylePropertyTreeElement|null;
401
+ readonly #propertyData: StylePropertyData|null;
378
402
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
379
403
  readonly #computedStyles: Map<string, string>;
380
404
  readonly #computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null;
381
- constructor(
382
- stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null,
383
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, computedStyles: Map<string, string>,
384
- computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
405
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null,
406
+ matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, computedStyles: Map<string, string>,
407
+ computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
385
408
  super();
386
- this.#treeElement = treeElement;
409
+ this.#propertyData = propertyData;
387
410
  this.#stylesContainer = stylesContainer;
388
411
  this.#matchedStyles = matchedStyles;
389
412
  this.#computedStyles = computedStyles;
@@ -391,7 +414,7 @@ export class VariableRenderer extends VariableRendererBase {
391
414
  }
392
415
 
393
416
  override render(match: SDK.CSSPropertyParserMatchers.VariableMatch, context: RenderingContext): LitTemplate {
394
- if (this.#treeElement?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
417
+ if (this.#propertyData?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
395
418
  return Renderer.render(ASTUtils.children(match.node), context).nodes;
396
419
  }
397
420
 
@@ -407,9 +430,8 @@ export class VariableRenderer extends VariableRendererBase {
407
430
  const {nodes, cssControls} = Renderer.renderValueNodes(
408
431
  {name: declaration.name, value: declaration.value ?? ''},
409
432
  substitution.cachedParsedValue(declaration.declaration, this.#matchedStyles, this.#computedStyles),
410
- getPropertyRenderers(
411
- declaration.name, declaration.style, this.#stylesContainer, this.#matchedStyles, null,
412
- this.#computedStyles, this.#computedStyleExtraFields),
433
+ getPropertyRenderers(declaration.name, declaration.style, this.#stylesContainer, this.#matchedStyles, null,
434
+ this.#computedStyles, this.#computedStyleExtraFields),
413
435
  substitution);
414
436
  cssControls.forEach((value, key) => value.forEach(control => context.addControl(key, control)));
415
437
  return nodes;
@@ -421,9 +443,12 @@ export class VariableRenderer extends VariableRendererBase {
421
443
 
422
444
  const renderedFallback = match.fallback ? Renderer.render(match.fallback, context) : undefined;
423
445
 
424
- const varCall = this.#treeElement?.getTracingTooltip('var', match.node, this.#matchedStyles, this.#computedStyles,
425
- this.#computedStyleExtraFields, context);
426
- const tooltipId = getTooltipId(this.#treeElement, 'custom-property-var');
446
+ const varCall = this.#propertyData ?
447
+ getTracingTooltip('var', match.node, this.#matchedStyles, this.#computedStyles, this.#computedStyleExtraFields,
448
+ context, this.#stylesContainer, this.#propertyData.tooltipIdFactory,
449
+ this.#propertyData.property, this.#propertyData.parentShorthand()?.property.name) :
450
+ undefined;
451
+ const tooltipId = getTooltipId(this.#propertyData, 'custom-property-var');
427
452
  const tooltip = tooltipId ? {tooltipId} : undefined;
428
453
  // clang-format off
429
454
  const varSwatch = html`<span
@@ -451,20 +476,21 @@ export class VariableRenderer extends VariableRendererBase {
451
476
  return varSwatch;
452
477
  }
453
478
 
454
- const colorSwatch =
455
- new ColorRenderer(this.#stylesContainer, this.#treeElement).renderColorSwatch(color, match, context);
456
- context.addControl('color', colorSwatch);
479
+ const colorSwatch =
480
+ new ColorRenderer(this.#stylesContainer, this.#propertyData).renderColorSwatch(color, match, context);
481
+ context.addControl('color', colorSwatch);
457
482
 
458
- if (fromFallback) {
459
- renderedFallback?.cssControls.get('color')?.forEach(
460
- innerSwatch => innerSwatch.addEventListener(InlineEditor.ColorSwatch.ColorChangedEvent.eventName, ev => {
461
- colorSwatch.setColor(ev.data.color);
462
- }));
463
- }
483
+ if (fromFallback) {
484
+ renderedFallback?.cssControls.get('color')?.forEach(
485
+ innerSwatch =>
486
+ innerSwatch.addEventListener(InlineEditor.ColorSwatch.ColorChangedEvent.eventName, ev => {
487
+ colorSwatch.setColor(ev.data.color);
488
+ }));
489
+ }
464
490
 
465
- return this.#treeElement?.editable() ?
466
- html`<devtools-widget ${widget(EditableContent)}>${colorSwatch}${varSwatch}</devtools-widget>` :
467
- html`${colorSwatch}${varSwatch}`;
491
+ return this.#propertyData?.editable() ?
492
+ html`<devtools-widget ${widget(EditableContent)}>${colorSwatch}${varSwatch}</devtools-widget>` :
493
+ html`${colorSwatch}${varSwatch}`;
468
494
  }
469
495
  }
470
496
 
@@ -474,18 +500,18 @@ const VariableNameRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.Varia
474
500
  export class VariableNameRenderer extends VariableNameRendererBase {
475
501
  // clang-format on
476
502
  readonly #stylesContainer: StylesContainer;
477
- readonly #treeElement: StylePropertyTreeElement|null;
503
+ readonly #propertyData: StylePropertyData|null;
478
504
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
479
- constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null,
505
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null,
480
506
  matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles) {
481
507
  super();
482
- this.#treeElement = treeElement;
508
+ this.#propertyData = propertyData;
483
509
  this.#stylesContainer = stylesContainer;
484
510
  this.#matchedStyles = matchedStyles;
485
511
  }
486
512
 
487
513
  override render(match: SDK.CSSPropertyParserMatchers.VariableNameMatch, _context: RenderingContext): LitTemplate {
488
- if (this.#treeElement?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
514
+ if (this.#propertyData?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
489
515
  return html`${match.text}`;
490
516
  }
491
517
 
@@ -494,7 +520,7 @@ export class VariableNameRenderer extends VariableNameRendererBase {
494
520
  const onLinkActivate = (name: string): void =>
495
521
  handleVarDefinitionActivate(declaration ?? name, this.#stylesContainer);
496
522
 
497
- const tooltipId = getTooltipId(this.#treeElement, 'custom-property-var');
523
+ const tooltipId = getTooltipId(this.#propertyData, 'custom-property-var');
498
524
  const tooltip = tooltipId ? {tooltipId} : undefined;
499
525
  // clang-format off
500
526
  return html`<devtools-link-swatch class=css-var-link .data=${{
@@ -520,16 +546,15 @@ const AttributeRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.Attribut
520
546
  export class AttributeRenderer extends AttributeRendererBase {
521
547
  // clang-format on
522
548
  readonly #stylesContainer: StylesContainer;
523
- readonly #treeElement: StylePropertyTreeElement|null;
549
+ readonly #propertyData: StylePropertyData|null;
524
550
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
525
551
  readonly #computedStyles: Map<string, string>;
526
552
  readonly #computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null;
527
- constructor(
528
- stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null,
529
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, computedStyles: Map<string, string>,
530
- computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
553
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null,
554
+ matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, computedStyles: Map<string, string>,
555
+ computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
531
556
  super();
532
- this.#treeElement = treeElement;
557
+ this.#propertyData = propertyData;
533
558
  this.#stylesContainer = stylesContainer;
534
559
  this.#matchedStyles = matchedStyles;
535
560
  this.#computedStyles = computedStyles;
@@ -537,7 +562,7 @@ export class AttributeRenderer extends AttributeRendererBase {
537
562
  }
538
563
 
539
564
  override render(match: SDK.CSSPropertyParserMatchers.AttributeMatch, context: RenderingContext): LitTemplate {
540
- if (this.#treeElement?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
565
+ if (this.#propertyData?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
541
566
  return Renderer.render(ASTUtils.children(match.node), context).nodes;
542
567
  }
543
568
 
@@ -570,9 +595,8 @@ export class AttributeRenderer extends AttributeRendererBase {
570
595
  return Renderer
571
596
  .renderValueNodes(
572
597
  {name: '--property', value: match.substitutionText}, matching,
573
- getPropertyRenderers(
574
- '--property', match.style, this.#stylesContainer, this.#matchedStyles, null, this.#computedStyles,
575
- this.#computedStyleExtraFields),
598
+ getPropertyRenderers('--property', match.style, this.#stylesContainer, this.#matchedStyles, null,
599
+ this.#computedStyles, this.#computedStyleExtraFields),
576
600
  substitution)
577
601
  .nodes;
578
602
  }
@@ -580,9 +604,12 @@ export class AttributeRenderer extends AttributeRendererBase {
580
604
 
581
605
  const renderedFallback = match.fallback ? Renderer.render(match.fallback, context) : undefined;
582
606
 
583
- const attrCall = this.#treeElement?.getTracingTooltip('attr', match.node, this.#matchedStyles, this.#computedStyles,
584
- this.#computedStyleExtraFields, context);
585
- const tooltipId = attributeMissing ? undefined : getTooltipId(this.#treeElement, 'custom-attribute');
607
+ const attrCall = this.#propertyData ?
608
+ getTracingTooltip('attr', match.node, this.#matchedStyles, this.#computedStyles, this.#computedStyleExtraFields,
609
+ context, this.#stylesContainer, this.#propertyData.tooltipIdFactory,
610
+ this.#propertyData.property, this.#propertyData.parentShorthand()?.property.name) :
611
+ undefined;
612
+ const tooltipId = attributeMissing ? undefined : getTooltipId(this.#propertyData, 'custom-attribute');
586
613
  const tooltip = tooltipId ? {tooltipId} : undefined;
587
614
  // clang-format off
588
615
  const varSwatch = html`<span
@@ -609,7 +636,7 @@ export class AttributeRenderer extends AttributeRendererBase {
609
636
  }
610
637
 
611
638
  const colorSwatch =
612
- new ColorRenderer(this.#stylesContainer, this.#treeElement).renderColorSwatch(color, match, context);
639
+ new ColorRenderer(this.#stylesContainer, this.#propertyData).renderColorSwatch(color, match, context);
613
640
  context.addControl('color', colorSwatch);
614
641
 
615
642
  if (fromFallback) {
@@ -619,7 +646,7 @@ export class AttributeRenderer extends AttributeRendererBase {
619
646
  }));
620
647
  }
621
648
 
622
- return this.#treeElement?.editable() ?
649
+ return this.#propertyData?.editable() ?
623
650
  html`<devtools-widget ${widget(EditableContent)}>${colorSwatch}${varSwatch}</devtools-widget>` :
624
651
  html`${colorSwatch}${varSwatch}`;
625
652
  }
@@ -648,8 +675,8 @@ export class LinearGradientRenderer extends LinearGradientRendererBase {
648
675
  if (angle instanceof InlineEditor.CSSAngle.CSSAngle) {
649
676
  angle.updateProperty(context.matchedResult.getComputedText(match.node));
650
677
  const args = ASTUtils.callArgs(match.node);
651
- const angleNode = args[0]?.find(
652
- node => context.matchedResult.getMatch(node) instanceof SDK.CSSPropertyParserMatchers.AngleMatch);
678
+ const angleNode = args[0]?.find(node => context.matchedResult.getMatch(node) instanceof
679
+ SDK.CSSPropertyParserMatchers.AngleMatch);
653
680
  const angleMatch = angleNode && context.matchedResult.getMatch(angleNode);
654
681
  if (angleMatch) {
655
682
  angle.addEventListener(InlineEditor.InlineEditorUtils.ValueChangedEvent.eventName, ev => {
@@ -667,10 +694,10 @@ const RelativeColorChannelRendererBase: RendererBase<SDK.CSSPropertyParserMatche
667
694
  // clang-format off
668
695
  export class RelativeColorChannelRenderer extends RelativeColorChannelRendererBase {
669
696
  // clang-format on
670
- readonly #treeElement: StylePropertyTreeElement|null;
671
- constructor(treeElement: StylePropertyTreeElement|null) {
697
+ readonly #propertyData: StylePropertyData|null;
698
+ constructor(propertyData: StylePropertyData|null) {
672
699
  super();
673
- this.#treeElement = treeElement;
700
+ this.#propertyData = propertyData;
674
701
  }
675
702
  override render(match: SDK.CSSPropertyParserMatchers.RelativeColorChannelMatch,
676
703
  context: RenderingContext): LitTemplate {
@@ -690,7 +717,7 @@ export class RelativeColorChannelRenderer extends RelativeColorChannelRendererBa
690
717
  return evaluation;
691
718
  }
692
719
 
693
- const tooltipId = getTooltipId(this.#treeElement, 'relative-color-channel');
720
+ const tooltipId = getTooltipId(this.#propertyData, 'relative-color-channel');
694
721
  if (!tooltipId) {
695
722
  return html`<span>${match.text}</span>`;
696
723
  }
@@ -706,11 +733,11 @@ const ColorRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.ColorMatch>
706
733
  // clang-format off
707
734
  export class ColorRenderer extends ColorRendererBase {
708
735
  // clang-format on
709
- readonly #treeElement: StylePropertyTreeElement|null;
736
+ readonly #propertyData: StylePropertyData|null;
710
737
  readonly #stylesContainer: StylesContainer;
711
- constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null) {
738
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null) {
712
739
  super();
713
- this.#treeElement = treeElement;
740
+ this.#propertyData = propertyData;
714
741
  this.#stylesContainer = stylesContainer;
715
742
  }
716
743
 
@@ -730,10 +757,13 @@ export class ColorRenderer extends ColorRendererBase {
730
757
  const renderingContext = childTracingContexts?.at(0)?.renderingContext(context) ?? context;
731
758
  const {nodes, cssControls} = Renderer.render(args, renderingContext);
732
759
  const valueChild = html`<span>${
733
- this.#treeElement?.getTracingTooltip(func, match.node, this.#treeElement.matchedStyles(),
734
- this.#treeElement.getComputedStyles() ?? new Map(),
735
- this.#treeElement.getComputedStyleExtraFields(), renderingContext) ??
736
- func}${nodes}</span>`;
760
+ this.#propertyData ?
761
+ getTracingTooltip(func, match.node, this.#propertyData.matchedStyles(),
762
+ this.#propertyData.getComputedStyles() ?? new Map(),
763
+ this.#propertyData.getComputedStyleExtraFields(), renderingContext, this.#stylesContainer,
764
+ this.#propertyData.tooltipIdFactory, this.#propertyData.property,
765
+ this.#propertyData.parentShorthand()?.property.name) :
766
+ func}${nodes}</span>`;
737
767
 
738
768
  return {valueChild, cssControls, childTracingContexts};
739
769
  }
@@ -797,7 +827,7 @@ export class ColorRenderer extends ColorRendererBase {
797
827
  });
798
828
  }
799
829
  }
800
- return this.#treeElement?.editable() ?
830
+ return this.#propertyData?.editable() ?
801
831
  html`<devtools-widget ${widget(EditableContent)}>${swatch}${valueChild}</devtools-widget>` :
802
832
  html`${swatch}${valueChild}`;
803
833
  }
@@ -806,7 +836,7 @@ export class ColorRenderer extends ColorRendererBase {
806
836
  // to update the enclosing `EditableContent`, and the new text is recorded as the edit of `match`.
807
837
  renderColorSwatch(color: Common.Color.Color|undefined, match: SDK.CSSPropertyParser.Match,
808
838
  context: RenderingContext): InlineEditor.ColorSwatch.ColorSwatch {
809
- const editable = this.#treeElement?.editable();
839
+ const editable = this.#propertyData?.editable();
810
840
  const shiftClickMessage = i18nString(UIStrings.shiftClickToChangeColorFormat);
811
841
  const tooltip = editable ? i18nString(UIStrings.openColorPickerS, {PH1: shiftClickMessage}) : '';
812
842
 
@@ -816,18 +846,18 @@ export class ColorRenderer extends ColorRendererBase {
816
846
  swatch.renderColor(color);
817
847
  }
818
848
 
819
- if (this.#treeElement?.editable()) {
849
+ if (this.#propertyData?.editable()) {
820
850
  swatch.slot = 'icon';
821
- const treeElement = this.#treeElement;
851
+ const propertyData = this.#propertyData;
822
852
  const onColorChanged = (): void => {
823
- void treeElement.applyStyleText(treeElement.renderedPropertyText(), false);
853
+ void propertyData.applyStyleText(propertyData.renderedPropertyText(), false);
824
854
  };
825
855
 
826
856
  const onColorFormatChanged = (e: InlineEditor.ColorSwatch.ColorFormatChangedEvent): void => {
827
857
  const text = e.data.color.getAuthoredText() ?? e.data.color.asString();
828
858
  swatch.dispatchEvent(new ValueEditEvent(text));
829
859
  context.recordEdit(match, text);
830
- void treeElement.applyStyleText(treeElement.renderedPropertyText(), false);
860
+ void propertyData.applyStyleText(propertyData.renderedPropertyText(), false);
831
861
  };
832
862
 
833
863
  swatch.addEventListener(InlineEditor.ColorSwatch.ClickEvent.eventName, () => {
@@ -837,14 +867,14 @@ export class ColorRenderer extends ColorRendererBase {
837
867
  swatch.addEventListener(InlineEditor.ColorSwatch.ColorFormatChangedEvent.eventName, onColorFormatChanged);
838
868
 
839
869
  const swatchIcon =
840
- new ColorSwatchPopoverIcon(treeElement, treeElement.stylesContainer().swatchPopoverHelper(), swatch);
870
+ new ColorSwatchPopoverIcon(propertyData, propertyData.stylesContainer().swatchPopoverHelper(), swatch);
841
871
  swatchIcon.addEventListener(ColorSwatchPopoverIconEvents.COLOR_CHANGED, ev => {
842
872
  const text = ev.data.getAuthoredText() ?? ev.data.asString();
843
873
  swatch.dispatchEvent(new ValueEditEvent(text));
844
874
  context.recordEdit(match, text);
845
875
  swatch.setColor(ev.data);
846
876
  });
847
- if (treeElement.property.name === 'color') {
877
+ if (propertyData.property.name === 'color') {
848
878
  void this.#addColorContrastInfo(swatchIcon);
849
879
  }
850
880
  }
@@ -868,14 +898,13 @@ const LightDarkColorRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.Lig
868
898
  // clang-format off
869
899
  export class LightDarkColorRenderer extends LightDarkColorRendererBase {
870
900
  // clang-format on
871
- readonly #treeElement: StylePropertyTreeElement|null;
901
+ readonly #propertyData: StylePropertyData|null;
872
902
  readonly #stylesContainer: StylesContainer;
873
903
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
874
- constructor(
875
- stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
876
- treeElement: StylePropertyTreeElement|null) {
904
+ constructor(stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
905
+ propertyData: StylePropertyData|null) {
877
906
  super();
878
- this.#treeElement = treeElement;
907
+ this.#propertyData = propertyData;
879
908
  this.#stylesContainer = stylesContainer;
880
909
  this.#matchedStyles = matchedStyles;
881
910
  }
@@ -906,12 +935,12 @@ export class LightDarkColorRenderer extends LightDarkColorRendererBase {
906
935
  // Pass an undefined color here to insert a placeholder swatch that will be filled in from the async
907
936
  // applyColorScheme below.
908
937
  const colorSwatch =
909
- new ColorRenderer(this.#stylesContainer, this.#treeElement).renderColorSwatch(undefined, match, context);
938
+ new ColorRenderer(this.#stylesContainer, this.#propertyData).renderColorSwatch(undefined, match, context);
910
939
  context.addControl('color', colorSwatch);
911
940
  const styledContent =
912
941
  until(this.applyColorScheme(match, context, colorSwatch, light, dark, lightControls, darkControls), content);
913
942
 
914
- return this.#treeElement?.editable() ?
943
+ return this.#propertyData?.editable() ?
915
944
  html`<devtools-widget ${widget(EditableContent)}>${colorSwatch}${styledContent}</devtools-widget>` :
916
945
  html`${colorSwatch}${styledContent}`;
917
946
  }
@@ -925,9 +954,8 @@ export class LightDarkColorRenderer extends LightDarkColorRendererBase {
925
954
  }
926
955
 
927
956
  const activeColorSwatches = (activeColor === match.light ? lightControls : darkControls).get('color');
928
- activeColorSwatches?.forEach(
929
- swatch => swatch.addEventListener(
930
- InlineEditor.ColorSwatch.ColorChangedEvent.eventName, ev => colorSwatch.setColor(ev.data.color)));
957
+ activeColorSwatches?.forEach(swatch => swatch.addEventListener(InlineEditor.ColorSwatch.ColorChangedEvent.eventName,
958
+ ev => colorSwatch.setColor(ev.data.color)));
931
959
  const colorText = context.matchedResult.getComputedTextRange(activeColor[0], activeColor[activeColor.length - 1]);
932
960
  const color = colorText && Common.Color.parse(colorText);
933
961
  if (color) {
@@ -979,18 +1007,17 @@ export class ColorMixRenderer extends ColorMixRendererBase {
979
1007
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
980
1008
  readonly #computedStyles: Map<string, string>;
981
1009
  readonly #computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null;
982
- readonly #treeElement: StylePropertyTreeElement|null;
1010
+ readonly #propertyData: StylePropertyData|null;
983
1011
 
984
- constructor(
985
- stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
986
- computedStyles: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null,
987
- treeElement: StylePropertyTreeElement|null) {
1012
+ constructor(stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
1013
+ computedStyles: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null,
1014
+ propertyData: StylePropertyData|null) {
988
1015
  super();
989
1016
  this.#stylesContainer = stylesContainer;
990
1017
  this.#matchedStyles = matchedStyles;
991
1018
  this.#computedStyles = computedStyles;
992
1019
  this.#computedStyleExtraFields = computedStyleExtraFields;
993
- this.#treeElement = treeElement;
1020
+ this.#propertyData = propertyData;
994
1021
  }
995
1022
 
996
1023
  override render(match: SDK.CSSPropertyParserMatchers.ColorMixMatch, context: RenderingContext): LitTemplate {
@@ -998,12 +1025,11 @@ export class ColorMixRenderer extends ColorMixRendererBase {
998
1025
  if (node instanceof InlineEditor.ColorMixSwatch.ColorMixSwatch ||
999
1026
  node instanceof InlineEditor.ColorSwatch.ColorSwatch) {
1000
1027
  if (node instanceof InlineEditor.ColorSwatch.ColorSwatch) {
1001
- node.addEventListener(
1002
- InlineEditor.ColorSwatch.ColorChangedEvent.eventName,
1003
- ev => onChange(ev.data.color.getAuthoredText() ?? ev.data.color.asString()));
1028
+ node.addEventListener(InlineEditor.ColorSwatch.ColorChangedEvent.eventName,
1029
+ ev => onChange(ev.data.color.getAuthoredText() ?? ev.data.color.asString()));
1004
1030
  } else {
1005
- node.addEventListener(
1006
- InlineEditor.ColorMixSwatch.ColorMixChangedEvent.eventName, ev => onChange(ev.data.text));
1031
+ node.addEventListener(InlineEditor.ColorMixSwatch.ColorMixChangedEvent.eventName,
1032
+ ev => onChange(ev.data.text));
1007
1033
  }
1008
1034
  const color = node.getText();
1009
1035
  if (color) {
@@ -1024,10 +1050,13 @@ export class ColorMixRenderer extends ColorMixRendererBase {
1024
1050
  const color1 = Renderer.render(match.color1, color1RenderingContext);
1025
1051
  const color2 = Renderer.render(match.color2, color2RenderingContext);
1026
1052
  const contentChild = html`<span>${
1027
- this.#treeElement?.getTracingTooltip('color-mix', match.node, this.#matchedStyles, this.#computedStyles,
1028
- this.#computedStyleExtraFields, context) ??
1029
- 'color-mix'}(${match.space.length ? html`${Renderer.render(match.space, spaceRenderingContext).nodes}, ` : ''}${
1030
- color1.nodes}, ${color2.nodes})</span>`;
1053
+ this.#propertyData ? getTracingTooltip('color-mix', match.node, this.#matchedStyles, this.#computedStyles,
1054
+ this.#computedStyleExtraFields, context, this.#stylesContainer,
1055
+ this.#propertyData.tooltipIdFactory, this.#propertyData.property,
1056
+ this.#propertyData.parentShorthand()?.property.name) :
1057
+ 'color-mix'}(${
1058
+ match.space.length ? html`${Renderer.render(match.space, spaceRenderingContext).nodes}, ` :
1059
+ ''}${color1.nodes}, ${color2.nodes})</span>`;
1031
1060
 
1032
1061
  const color1Controls = color1.cssControls.get('color') ?? [];
1033
1062
  const color2Controls = color2.cssControls.get('color') ?? [];
@@ -1087,7 +1116,7 @@ export class ColorMixRenderer extends ColorMixRendererBase {
1087
1116
  return html`${swatch}${contentChild}`;
1088
1117
  }
1089
1118
 
1090
- const tooltipId = getTooltipId(this.#treeElement, 'color-mix');
1119
+ const tooltipId = getTooltipId(this.#propertyData, 'color-mix');
1091
1120
  if (!tooltipId) {
1092
1121
  return html`${swatch}${contentChild}`;
1093
1122
  }
@@ -1114,11 +1143,11 @@ const ContrastColorRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.Cont
1114
1143
  // clang-format off
1115
1144
  export class ContrastColorRenderer extends ContrastColorRendererBase {
1116
1145
  // clang-format on
1117
- readonly #treeElement: StylePropertyTreeElement|null;
1146
+ readonly #propertyData: StylePropertyData|null;
1118
1147
  readonly #stylesContainer: StylesContainer;
1119
- constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null) {
1148
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null) {
1120
1149
  super();
1121
- this.#treeElement = treeElement;
1150
+ this.#propertyData = propertyData;
1122
1151
  this.#stylesContainer = stylesContainer;
1123
1152
  }
1124
1153
 
@@ -1141,10 +1170,10 @@ export class ContrastColorRenderer extends ContrastColorRendererBase {
1141
1170
  }
1142
1171
 
1143
1172
  const colorSwatch =
1144
- new ColorRenderer(this.#stylesContainer, this.#treeElement).renderColorSwatch(color, match, context);
1173
+ new ColorRenderer(this.#stylesContainer, this.#propertyData).renderColorSwatch(color, match, context);
1145
1174
  context.addControl('color', colorSwatch);
1146
1175
 
1147
- return this.#treeElement?.editable() ?
1176
+ return this.#propertyData?.editable() ?
1148
1177
  html`<devtools-widget ${widget(EditableContent)}>${colorSwatch}${content}</devtools-widget>` :
1149
1178
  html`${colorSwatch}${content}`;
1150
1179
  }
@@ -1155,15 +1184,15 @@ const AngleRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.AngleMatch>
1155
1184
  // clang-format off
1156
1185
  export class AngleRenderer extends AngleRendererBase {
1157
1186
  // clang-format on
1158
- readonly #treeElement: StylePropertyTreeElement|null;
1159
- constructor(treeElement: StylePropertyTreeElement|null) {
1187
+ readonly #propertyData: StylePropertyData|null;
1188
+ constructor(propertyData: StylePropertyData|null) {
1160
1189
  super();
1161
- this.#treeElement = treeElement;
1190
+ this.#propertyData = propertyData;
1162
1191
  }
1163
1192
 
1164
1193
  override render(match: SDK.CSSPropertyParserMatchers.AngleMatch, context: RenderingContext): LitTemplate {
1165
1194
  const angleText = match.text;
1166
- if (!this.#treeElement?.editable()) {
1195
+ if (!this.#propertyData?.editable()) {
1167
1196
  return html`${angleText}`;
1168
1197
  }
1169
1198
  // TODO(crbug.com/407750607): Render <devtools-css-angle> as a Lit template once cssControls is replaced.
@@ -1172,36 +1201,35 @@ export class AngleRenderer extends AngleRendererBase {
1172
1201
  cssAngle.setAttribute('jslog', `${VisualLogging.showStyleEditor().track({click: true}).context('css-angle')}`);
1173
1202
  cssAngle.data = {
1174
1203
  angleText,
1175
- containingPane:
1176
- (this.#treeElement.stylesContainer().element.enclosingNodeOrSelfWithClass('style-panes-wrapper') as
1177
- HTMLElement),
1204
+ containingPane: (this.#propertyData.stylesContainer().element.enclosingNodeOrSelfWithClass(
1205
+ 'style-panes-wrapper') as HTMLElement),
1178
1206
  };
1179
1207
 
1180
- const treeElement = this.#treeElement;
1208
+ const propertyData = this.#propertyData;
1181
1209
  cssAngle.addEventListener('popovertoggled', ({data}) => {
1182
- const section = treeElement.section();
1210
+ const section = propertyData.section();
1183
1211
  if (!section) {
1184
1212
  return;
1185
1213
  }
1186
1214
 
1187
1215
  if (data.open) {
1188
- treeElement.stylesContainer().hideAllPopovers();
1189
- treeElement.stylesContainer().activeCSSAngle = cssAngle;
1216
+ propertyData.stylesContainer().hideAllPopovers();
1217
+ propertyData.stylesContainer().activeCSSAngle = cssAngle;
1190
1218
  Host.userMetrics.swatchActivated(Host.UserMetrics.SwatchType.ANGLE);
1191
1219
  }
1192
1220
 
1193
1221
  section.element.classList.toggle('has-open-popover', data.open);
1194
- treeElement.stylesContainer().setEditingStyle(data.open);
1222
+ propertyData.stylesContainer().setEditingStyle(data.open);
1195
1223
 
1196
1224
  // Commit the value as a major change after the angle popover is closed.
1197
1225
  if (!data.open) {
1198
- void treeElement.applyStyleText(treeElement.renderedPropertyText(), true);
1226
+ void propertyData.applyStyleText(propertyData.renderedPropertyText(), true);
1199
1227
  }
1200
1228
  });
1201
1229
  cssAngle.addEventListener('valuechanged', async ({data}) => {
1202
1230
  cssAngle.dispatchEvent(new ValueEditEvent(data.value));
1203
1231
  context.recordEdit(match, data.value);
1204
- await treeElement.applyStyleText(treeElement.renderedPropertyText(), false);
1232
+ await propertyData.applyStyleText(propertyData.renderedPropertyText(), false);
1205
1233
  });
1206
1234
  cssAngle.addEventListener('unitchanged', ({data}) => {
1207
1235
  cssAngle.dispatchEvent(new ValueEditEvent(data.value));
@@ -1242,8 +1270,8 @@ export class LinkableNameRenderer extends LinkableNameRendererBase {
1242
1270
  jslogContext: 'css-font-palette',
1243
1271
  metric: null,
1244
1272
  ruleBlock: '', // Not used
1245
- isDefined: Boolean(this.#matchedStyles.atRules().find(
1246
- ar => ar.type() === 'font-palette-values' && ar.name()?.text === match.text)),
1273
+ isDefined: Boolean(this.#matchedStyles.atRules().find(ar => ar.type() === 'font-palette-values' &&
1274
+ ar.name()?.text === match.text)),
1247
1275
  };
1248
1276
  case SDK.CSSPropertyParserMatchers.LinkableNameProperties.LIST_STYLE:
1249
1277
  case SDK.CSSPropertyParserMatchers.LinkableNameProperties.LIST_STYLE_TYPE:
@@ -1251,8 +1279,8 @@ export class LinkableNameRenderer extends LinkableNameRendererBase {
1251
1279
  jslogContext: 'css-list-style-type',
1252
1280
  metric: null,
1253
1281
  ruleBlock: '', // Not used
1254
- isDefined: Boolean(this.#matchedStyles.atRules().find(
1255
- ar => ar.type() === 'counter-style' && ar.name()?.text === match.text)),
1282
+ isDefined: Boolean(this.#matchedStyles.atRules().find(ar => ar.type() === 'counter-style' &&
1283
+ ar.name()?.text === match.text)),
1256
1284
  };
1257
1285
  case SDK.CSSPropertyParserMatchers.LinkableNameProperties.POSITION_TRY:
1258
1286
  case SDK.CSSPropertyParserMatchers.LinkableNameProperties.POSITION_TRY_FALLBACKS:
@@ -1317,20 +1345,20 @@ const BezierRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.BezierMatch
1317
1345
  // clang-format off
1318
1346
  export class BezierRenderer extends BezierRendererBase {
1319
1347
  // clang-format on
1320
- readonly #treeElement: StylePropertyTreeElement|null;
1321
- constructor(treeElement: StylePropertyTreeElement|null) {
1348
+ readonly #propertyData: StylePropertyData|null;
1349
+ constructor(propertyData: StylePropertyData|null) {
1322
1350
  super();
1323
- this.#treeElement = treeElement;
1351
+ this.#propertyData = propertyData;
1324
1352
  }
1325
1353
  override render(match: SDK.CSSPropertyParserMatchers.BezierMatch, context: RenderingContext): LitTemplate {
1326
1354
  const nodes = match.node.name === 'CallExpression' ? Renderer.render(ASTUtils.children(match.node), context).nodes :
1327
1355
  match.text;
1328
- if (!this.#treeElement?.editable() ||
1356
+ if (!this.#propertyData?.editable() ||
1329
1357
  !InlineEditor.AnimationTimingModel.AnimationTimingModel.parse(
1330
1358
  context.matchedResult.getComputedText(match.node))) {
1331
1359
  return html`${nodes}`;
1332
1360
  }
1333
- const swatchPopoverHelper = this.#treeElement.stylesContainer().swatchPopoverHelper();
1361
+ const swatchPopoverHelper = this.#propertyData.stylesContainer().swatchPopoverHelper();
1334
1362
  const icon = createIcon('bezier-curve-filled', 'bezier-swatch-icon');
1335
1363
  icon.slot = 'icon';
1336
1364
  icon.setAttribute('jslog', `${VisualLogging.showStyleEditor('bezier')}`);
@@ -1338,7 +1366,7 @@ export class BezierRenderer extends BezierRendererBase {
1338
1366
  icon.addEventListener('click', () => {
1339
1367
  Host.userMetrics.swatchActivated(Host.UserMetrics.SwatchType.ANIMATION_TIMING);
1340
1368
  });
1341
- new BezierPopoverIcon({treeElement: this.#treeElement, swatchPopoverHelper, swatch: icon, match, context});
1369
+ new BezierPopoverIcon({propertyData: this.#propertyData, swatchPopoverHelper, swatch: icon, match, context});
1342
1370
  return html`<devtools-widget class="bezier-icon-and-text" ${widget(EditableContent)}>${icon}${
1343
1371
  nodes}</devtools-widget>`;
1344
1372
  }
@@ -1351,8 +1379,8 @@ export class AutoBaseRenderer extends AutoBaseRendererBase {
1351
1379
  readonly #computedStyleExtraFields : Protocol.CSS.ComputedStyleExtraFields|null;
1352
1380
  // clang-format on
1353
1381
 
1354
- constructor(
1355
- computedStyle: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
1382
+ constructor(computedStyle: Map<string, string>,
1383
+ computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null) {
1356
1384
  super();
1357
1385
  this.#computedStyleExtraFields = computedStyleExtraFields;
1358
1386
  }
@@ -1406,8 +1434,8 @@ export class ShadowModel implements InlineEditor.CSSShadowEditor.CSSShadowModel
1406
1434
  readonly #shadowType: SDK.CSSPropertyParserMatchers.ShadowType;
1407
1435
  readonly #context: RenderingContext;
1408
1436
 
1409
- constructor(
1410
- shadowType: SDK.CSSPropertyParserMatchers.ShadowType, properties: ShadowProperty[], context: RenderingContext) {
1437
+ constructor(shadowType: SDK.CSSPropertyParserMatchers.ShadowType, properties: ShadowProperty[],
1438
+ context: RenderingContext) {
1411
1439
  this.#shadowType = shadowType;
1412
1440
  this.#properties = properties;
1413
1441
  this.#context = context;
@@ -1597,7 +1625,7 @@ const SHADOW_WIDGET_DEFAULT_VIEW: ShadowWidgetView = (input, _output, target) =>
1597
1625
  class ShadowWidget extends UI.Widget.Widget {
1598
1626
  readonly #view: ShadowWidgetView;
1599
1627
  #model?: ShadowModel;
1600
- #treeElement?: StylePropertyTreeElement;
1628
+ #propertyData?: StylePropertyData;
1601
1629
  #popoverHelper?: ShadowSwatchPopoverHelper;
1602
1630
 
1603
1631
  constructor(element?: HTMLElement, view: ShadowWidgetView = SHADOW_WIDGET_DEFAULT_VIEW) {
@@ -1614,16 +1642,16 @@ class ShadowWidget extends UI.Widget.Widget {
1614
1642
  this.performUpdate();
1615
1643
  }
1616
1644
 
1617
- set treeElement(treeElement: StylePropertyTreeElement) {
1618
- if (this.#treeElement === treeElement) {
1645
+ set propertyData(propertyData: StylePropertyData) {
1646
+ if (this.#propertyData === propertyData) {
1619
1647
  return;
1620
1648
  }
1621
- this.#treeElement = treeElement;
1649
+ this.#propertyData = propertyData;
1622
1650
  this.#popoverHelper =
1623
- new ShadowSwatchPopoverHelper(treeElement, treeElement.stylesContainer().swatchPopoverHelper());
1651
+ new ShadowSwatchPopoverHelper(propertyData, propertyData.stylesContainer().swatchPopoverHelper());
1624
1652
  this.#popoverHelper.addEventListener(ShadowEvents.SHADOW_CHANGED, () => {
1625
1653
  this.performUpdate();
1626
- void treeElement.applyStyleText(treeElement.renderedPropertyText(), false);
1654
+ void propertyData.applyStyleText(propertyData.renderedPropertyText(), false);
1627
1655
  });
1628
1656
  this.performUpdate();
1629
1657
  }
@@ -1648,16 +1676,15 @@ const ShadowRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.ShadowMatch
1648
1676
  rendererBase(SDK.CSSPropertyParserMatchers.ShadowMatch);
1649
1677
  // clang-format off
1650
1678
  export class ShadowRenderer extends ShadowRendererBase {
1651
- readonly #treeElement: StylePropertyTreeElement|null;
1679
+ readonly #propertyData: StylePropertyData|null;
1652
1680
  // clang-format on
1653
- constructor(treeElement: StylePropertyTreeElement|null) {
1681
+ constructor(propertyData: StylePropertyData|null) {
1654
1682
  super();
1655
- this.#treeElement = treeElement;
1683
+ this.#propertyData = propertyData;
1656
1684
  }
1657
1685
 
1658
- shadowModel(
1659
- shadow: CodeMirror.SyntaxNode[], shadowType: SDK.CSSPropertyParserMatchers.ShadowType,
1660
- context: RenderingContext): null|ShadowModel {
1686
+ shadowModel(shadow: CodeMirror.SyntaxNode[], shadowType: SDK.CSSPropertyParserMatchers.ShadowType,
1687
+ context: RenderingContext): null|ShadowModel {
1661
1688
  const properties: Array<ShadowProperty|ShadowLengthProperty> = [];
1662
1689
  const missingLengths: Array<ShadowLengthProperty['propertyType']> =
1663
1690
  [ShadowPropertyType.SPREAD, ShadowPropertyType.BLUR, ShadowPropertyType.Y, ShadowPropertyType.X];
@@ -1672,9 +1699,8 @@ export class ShadowRenderer extends ShadowRendererBase {
1672
1699
  source: CodeMirror.SyntaxNode,
1673
1700
  match: SDK.CSSPropertyParser.Match | undefined,
1674
1701
  expansionContext: RenderingContext | null,
1675
- }> =
1676
- shadow.map(
1677
- value => ({value, source: value, match: context.matchedResult.getMatch(value), expansionContext: null}));
1702
+ }> = shadow.map(value =>
1703
+ ({value, source: value, match: context.matchedResult.getMatch(value), expansionContext: null}));
1678
1704
  for (let item = queue.shift(); item; item = queue.shift()) {
1679
1705
  const {value, source, match, expansionContext} = item;
1680
1706
  const text = (expansionContext ?? context).ast.text(value);
@@ -1727,10 +1753,9 @@ export class ShadowRenderer extends ShadowRendererBase {
1727
1753
  return null;
1728
1754
  }
1729
1755
  properties.push({value, source, propertyType: ShadowPropertyType.INSET, expansionContext});
1730
- } else if (
1731
- match instanceof SDK.CSSPropertyParserMatchers.ColorMatch ||
1732
- match instanceof SDK.CSSPropertyParserMatchers.ColorMixMatch ||
1733
- match instanceof SDK.CSSPropertyParserMatchers.ContrastColorMatch) {
1756
+ } else if (match instanceof SDK.CSSPropertyParserMatchers.ColorMatch ||
1757
+ match instanceof SDK.CSSPropertyParserMatchers.ColorMixMatch ||
1758
+ match instanceof SDK.CSSPropertyParserMatchers.ContrastColorMatch) {
1734
1759
  if (properties.find(({propertyType}) => propertyType === ShadowPropertyType.COLOR)) {
1735
1760
  return null;
1736
1761
  }
@@ -1767,7 +1792,7 @@ export class ShadowRenderer extends ShadowRendererBase {
1767
1792
  result.push(document.createTextNode(', '));
1768
1793
  }
1769
1794
 
1770
- if (!model || !this.#treeElement?.editable()) {
1795
+ if (!model || !this.#propertyData?.editable()) {
1771
1796
  const {nodes} = Renderer.render(shadow, nestedContext);
1772
1797
  result.push(nodes);
1773
1798
  texts.push(() => nestedEdits.textRange(...ASTUtils.range(shadow)));
@@ -1775,7 +1800,7 @@ export class ShadowRenderer extends ShadowRendererBase {
1775
1800
  }
1776
1801
 
1777
1802
  result.push(
1778
- html`<devtools-widget ${widget(ShadowWidget, {model, treeElement: this.#treeElement})}></devtools-widget>`);
1803
+ html`<devtools-widget ${widget(ShadowWidget, {model, propertyData: this.#propertyData})}></devtools-widget>`);
1779
1804
  texts.push(() =>
1780
1805
  isImportant ? `${model.text()} ${nestedEdits.textRange(isImportant, isImportant)}` : model.text());
1781
1806
 
@@ -1823,9 +1848,8 @@ export const SHORTHANDS_FOR_PERCENTAGES: Set<string> = new Set([
1823
1848
  'padding-inline',
1824
1849
  ]);
1825
1850
 
1826
- async function resolveValues(
1827
- stylesContainer: StylesContainer, propertyName: string, match: SDK.CSSPropertyParser.Match,
1828
- context: RenderingContext, ...values: string[]): Promise<string[]|null|undefined> {
1851
+ async function resolveValues(stylesContainer: StylesContainer, propertyName: string, match: SDK.CSSPropertyParser.Match,
1852
+ context: RenderingContext, ...values: string[]): Promise<string[]|null|undefined> {
1829
1853
  // We want to resolve values against the original property we're tracing and not the property we're substituting,
1830
1854
  // so try to look up the original name.
1831
1855
  propertyName = context.tracing?.propertyName ?? context.matchedResult.ast.propertyName ?? propertyName;
@@ -1849,12 +1873,12 @@ const LengthRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.LengthMatch
1849
1873
  export class LengthRenderer extends LengthRendererBase {
1850
1874
  // clang-format on
1851
1875
  readonly #stylesContainer: StylesContainer;
1852
- readonly #treeElement: StylePropertyTreeElement|null;
1876
+ readonly #propertyData: StylePropertyData|null;
1853
1877
  readonly #propertyName: string;
1854
- constructor(stylesContainer: StylesContainer, propertyName: string, treeElement: StylePropertyTreeElement|null) {
1878
+ constructor(stylesContainer: StylesContainer, propertyName: string, propertyData: StylePropertyData|null) {
1855
1879
  super();
1856
1880
  this.#stylesContainer = stylesContainer;
1857
- this.#treeElement = treeElement;
1881
+ this.#propertyData = propertyData;
1858
1882
  this.#propertyName = propertyName;
1859
1883
  }
1860
1884
 
@@ -1865,7 +1889,7 @@ export class LengthRenderer extends LengthRendererBase {
1865
1889
  template,
1866
1890
  asyncEvalCallback: () => this.getTooltipValue(match, context),
1867
1891
  }));
1868
- const tooltipId = getTooltipId(this.#treeElement, 'length');
1892
+ const tooltipId = getTooltipId(this.#propertyData, 'length');
1869
1893
  if (evaluation || !tooltipId) {
1870
1894
  return html`<span tabindex=-1>${evaluation ?? template}</span>`;
1871
1895
  }
@@ -1897,18 +1921,17 @@ export class BaseFunctionRenderer extends BaseFunctionRendererBase {
1897
1921
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
1898
1922
  readonly #computedStyles: Map<string, string>;
1899
1923
  readonly #computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null;
1900
- readonly #treeElement: StylePropertyTreeElement|null;
1924
+ readonly #propertyData: StylePropertyData|null;
1901
1925
  readonly #propertyName: string;
1902
- constructor(
1903
- stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
1904
- computedStyles: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null,
1905
- propertyName: string, treeElement: StylePropertyTreeElement|null) {
1926
+ constructor(stylesContainer: StylesContainer, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
1927
+ computedStyles: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null,
1928
+ propertyName: string, propertyData: StylePropertyData|null) {
1906
1929
  super();
1907
1930
  this.#matchedStyles = matchedStyles;
1908
1931
  this.#computedStyles = computedStyles;
1909
1932
  this.#computedStyleExtraFields = computedStyleExtraFields;
1910
1933
  this.#stylesContainer = stylesContainer;
1911
- this.#treeElement = treeElement;
1934
+ this.#propertyData = propertyData;
1912
1935
  this.#propertyName = propertyName;
1913
1936
  }
1914
1937
 
@@ -1926,8 +1949,11 @@ export class BaseFunctionRenderer extends BaseFunctionRendererBase {
1926
1949
  (arg, idx) =>
1927
1950
  Renderer.render(arg, childTracingContexts ? childTracingContexts[idx].renderingContext(context) : context)
1928
1951
  .nodes);
1929
- const func = this.#treeElement?.getTracingTooltip(match.func, match.node, this.#matchedStyles, this.#computedStyles,
1930
- this.#computedStyleExtraFields, context) ??
1952
+ const func = this.#propertyData ?
1953
+ getTracingTooltip(match.func, match.node, this.#matchedStyles, this.#computedStyles,
1954
+ this.#computedStyleExtraFields, context, this.#stylesContainer,
1955
+ this.#propertyData.tooltipIdFactory, this.#propertyData.property,
1956
+ this.#propertyData.parentShorthand()?.property.name) :
1931
1957
  match.func;
1932
1958
  const args = this.#renderArgs(renderedArgs);
1933
1959
 
@@ -2100,6 +2126,24 @@ export class PositionAnchorRenderer extends PositionAnchorRendererBase {
2100
2126
  }
2101
2127
  }
2102
2128
 
2129
+ function findSiblingProperty(stylesContainer: StylesContainer, propertyData: StylePropertyData,
2130
+ propertyName: string): StylePropertyData|undefined {
2131
+ const resolvedProperty = propertyData.matchedStyles().resolveProperty(propertyName, propertyData.property.ownerStyle);
2132
+ const activeSection = propertyData.section();
2133
+ if (resolvedProperty) {
2134
+ const allSections = stylesContainer.allSections();
2135
+ const sections = !allSections.includes(activeSection) ? [activeSection, ...allSections] : allSections;
2136
+ for (const section of sections) {
2137
+ const found = section.findProperty(resolvedProperty);
2138
+ if (found) {
2139
+ return found;
2140
+ }
2141
+ }
2142
+ }
2143
+
2144
+ return activeSection.findProperty(propertyName);
2145
+ }
2146
+
2103
2147
  const PositionAreaRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.PositionAreaMatch> =
2104
2148
  rendererBase(SDK.CSSPropertyParserMatchers.PositionAreaMatch);
2105
2149
  // clang-format off
@@ -2107,58 +2151,28 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2107
2151
  // clang-format on
2108
2152
  static #active?: {
2109
2153
  editor: InlineEditor.PositionAreaEditor.PositionAreaEditor,
2110
- treeElement: StylePropertyTreeElement,
2154
+ propertyData: StylePropertyData,
2111
2155
  edit: (value: string) => void,
2112
2156
  key?: string,
2113
2157
  };
2114
2158
  static readonly #EDITABLE_PROPERTIES: readonly string[] = ['align-self', 'justify-self'];
2115
- readonly #treeElement: StylePropertyTreeElement|null;
2159
+ readonly #propertyData: StylePropertyData|null;
2116
2160
  readonly #stylesContainer: StylesContainer;
2117
- constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null) {
2161
+ constructor(stylesContainer: StylesContainer, propertyData: StylePropertyData|null) {
2118
2162
  super();
2119
- this.#treeElement = treeElement;
2163
+ this.#propertyData = propertyData;
2120
2164
  this.#stylesContainer = stylesContainer;
2121
2165
  }
2122
2166
 
2123
- #findTreeElementForProperty(propertyName: string): StylePropertyTreeElement|undefined {
2124
- const activeTreeElement = PositionAreaRenderer.#active?.treeElement;
2125
- if (!activeTreeElement) {
2126
- return undefined;
2127
- }
2128
- const matchedStyles = activeTreeElement.matchedStyles();
2129
- const resolvedProperty = matchedStyles.resolveProperty(propertyName, activeTreeElement.property.ownerStyle);
2130
- const activeSection = activeTreeElement.section();
2131
- if (resolvedProperty) {
2132
- const allSections = this.#stylesContainer.allSections();
2133
- const sections =
2134
- activeSection && !allSections.includes(activeSection) ? [activeSection, ...allSections] : allSections;
2135
- for (const section of sections) {
2136
- for (const child of section.propertiesTreeOutline?.rootElement().children() ?? []) {
2137
- if (child instanceof StylePropertyTreeElement && child.property === resolvedProperty) {
2138
- return child;
2139
- }
2140
- }
2141
- }
2142
- }
2143
-
2144
- return this.#findPropertyInSection(activeSection, propertyName);
2145
- }
2146
-
2147
- #findPropertyInSection(section: StylePropertiesSection|undefined, propertyName: string): StylePropertyTreeElement
2148
- |undefined {
2149
- return section?.propertiesTreeOutline?.rootElement().children().find(
2150
- (child): child is StylePropertyTreeElement =>
2151
- child instanceof StylePropertyTreeElement && child.property.name === propertyName);
2152
- }
2153
2167
  override render(match: SDK.CSSPropertyParserMatchers.PositionAreaMatch, context: RenderingContext): LitTemplate {
2154
2168
  const children = Renderer.render(ASTUtils.siblings(ASTUtils.declValue(match.node)), context).nodes;
2155
2169
  // The text of the match is the value as authored, which may contain comments or var()s that resolve to the area.
2156
- if (!this.#treeElement?.editable() ||
2170
+ if (!this.#propertyData?.editable() ||
2157
2171
  !InlineEditor.PositionAreaEditor.parsePositionArea(context.matchedResult.getComputedPropertyValueText())) {
2158
2172
  return html`${children}`;
2159
2173
  }
2160
2174
 
2161
- const section = this.#treeElement.section();
2175
+ const section = this.#propertyData.section();
2162
2176
  const key = section ? `${section.getSectionIdx()}_${section.nextEditorTriggerButtonIdx++}` : undefined;
2163
2177
 
2164
2178
  let button: Element|undefined;
@@ -2166,14 +2180,14 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2166
2180
  button?.dispatchEvent(new ValueEditEvent(value));
2167
2181
  context.recordEdit(match, value);
2168
2182
  };
2169
- const treeElement = this.#treeElement;
2183
+ const propertyData = this.#propertyData;
2170
2184
  const popoverHelper = this.#stylesContainer.swatchPopoverHelper();
2171
2185
  const isActive =
2172
2186
  Boolean(PositionAreaRenderer.#active && popoverHelper.isShowing(PositionAreaRenderer.#active.editor) &&
2173
2187
  key !== undefined && PositionAreaRenderer.#active.key === key);
2174
2188
  if (isActive && PositionAreaRenderer.#active) {
2175
- treeElement.carryOverCommittedProperty(PositionAreaRenderer.#active.treeElement);
2176
- PositionAreaRenderer.#active.treeElement = treeElement;
2189
+ propertyData.carryOverCommittedProperty(PositionAreaRenderer.#active.propertyData);
2190
+ PositionAreaRenderer.#active.propertyData = propertyData;
2177
2191
  PositionAreaRenderer.#active.edit = edit;
2178
2192
  }
2179
2193
  const onClick = (event: Event): void => {
@@ -2183,14 +2197,14 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2183
2197
  return;
2184
2198
  }
2185
2199
  const editor = new InlineEditor.PositionAreaEditor.PositionAreaEditor();
2186
- const active = {editor, key, treeElement, edit};
2200
+ const active = {editor, key, propertyData, edit};
2187
2201
  PositionAreaRenderer.#active = active;
2188
2202
  const valueText = context.edits?.getEdit(match) ?? context.matchedResult.getComputedPropertyValueText();
2189
2203
  editor.area = InlineEditor.PositionAreaEditor.parsePositionArea(valueText) ?? undefined;
2190
2204
 
2191
2205
  const initialProperties = new Map<string, {value: string, section: StylePropertiesSection}>();
2192
2206
  for (const propertyName of PositionAreaRenderer.#EDITABLE_PROPERTIES) {
2193
- const target = this.#findTreeElementForProperty(propertyName);
2207
+ const target = findSiblingProperty(this.#stylesContainer, active.propertyData, propertyName);
2194
2208
  if (target) {
2195
2209
  initialProperties.set(propertyName, {
2196
2210
  value: target.property.value,
@@ -2199,17 +2213,17 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2199
2213
  }
2200
2214
  }
2201
2215
  const updateProperty = (propertyName: string, computedStyle: Map<string, string>|null): void => {
2202
- const matchedStyles = active.treeElement.matchedStyles();
2203
- const resolved = matchedStyles.resolveProperty(propertyName, active.treeElement.property.ownerStyle);
2216
+ const matchedStyles = active.propertyData.matchedStyles();
2217
+ const resolved = matchedStyles.resolveProperty(propertyName, active.propertyData.property.ownerStyle);
2204
2218
  const authored = resolved && !resolved.ownerStyle.parentRule?.isUserAgent() ? resolved.value : undefined;
2205
2219
  const computed = computedStyle?.get(propertyName);
2206
2220
  editor.setProperty(propertyName, authored, computed);
2207
2221
  };
2208
2222
 
2209
2223
  const updateEditorProperties = async(): Promise<void> => {
2210
- active.treeElement.matchedStyles().resetActiveProperties();
2211
- updateProperty('align-self', active.treeElement.getComputedStyles());
2212
- updateProperty('justify-self', active.treeElement.getComputedStyles());
2224
+ active.propertyData.matchedStyles().resetActiveProperties();
2225
+ updateProperty('align-self', active.propertyData.getComputedStyles());
2226
+ updateProperty('justify-self', active.propertyData.getComputedStyles());
2213
2227
  const computedStyle = await this.#stylesContainer.computedStyleModel().fetchComputedStyle();
2214
2228
  updateProperty('align-self', computedStyle?.computedStyle ?? null);
2215
2229
  updateProperty('justify-self', computedStyle?.computedStyle ?? null);
@@ -2219,31 +2233,14 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2219
2233
  (changeEvent: Common.EventTarget.EventTargetEvent<InlineEditor.PositionAreaEditor.Area>): void => {
2220
2234
  const area = InlineEditor.PositionAreaEditor.stringifyPositionArea(changeEvent.data);
2221
2235
  active.edit(area);
2222
- void active.treeElement.applyStyleText(active.treeElement.renderedPropertyText(), false);
2236
+ void active.propertyData.applyStyleText(active.propertyData.renderedPropertyText(), false);
2223
2237
  };
2224
2238
  const onPropertyChanged =
2225
2239
  async(changeEvent: Common.EventTarget.EventTargetEvent<InlineEditor.PositionAreaEditor.PropertyChangeEvent>):
2226
2240
  Promise<void> => {
2227
- const activeSection = active.treeElement.section();
2228
- if (!activeSection) {
2229
- return;
2230
- }
2231
2241
  const {propertyName, value} = changeEvent.data;
2232
- let target = this.#findTreeElementForProperty(propertyName);
2233
- if (value) {
2234
- if (!target) {
2235
- target = activeSection.addNewBlankProperty();
2236
- target.property.name = propertyName;
2237
- }
2238
- target.property.value = value;
2239
- target.updateTitle();
2240
- await target.applyStyleText(target.renderedPropertyText(), false);
2241
- this.#stylesContainer.refreshUpdate(activeSection, target, true);
2242
- } else if (target) {
2243
- await target.applyStyleText('', false);
2244
- this.#stylesContainer.refreshUpdate(activeSection, target, true);
2245
- }
2246
- void updateEditorProperties();
2242
+ await active.propertyData.setSiblingProperty(propertyName, value);
2243
+ await updateEditorProperties();
2247
2244
  };
2248
2245
  editor.addEventListener(InlineEditor.PositionAreaEditor.Events.POSITION_AREA_CHANGED, onPositionAreaChanged);
2249
2246
  editor.addEventListener(InlineEditor.PositionAreaEditor.Events.PROPERTY_CHANGED, onPropertyChanged);
@@ -2256,8 +2253,8 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2256
2253
  scrollerElement.addEventListener('scroll', onScroll, false);
2257
2254
  }
2258
2255
 
2259
- const originalPropertyText = treeElement.property.propertyText;
2260
- this.#stylesContainer.setActiveProperty(treeElement);
2256
+ const originalPropertyText = propertyData.property.propertyText;
2257
+ this.#stylesContainer.setActiveProperty(propertyData);
2261
2258
  this.#stylesContainer.setEditingStyle(true);
2262
2259
 
2263
2260
  popoverHelper.show(editor, button, commitEdit => {
@@ -2266,13 +2263,13 @@ export class PositionAreaRenderer extends PositionAreaRendererBase {
2266
2263
  }
2267
2264
  editor.removeEventListener(InlineEditor.PositionAreaEditor.Events.POSITION_AREA_CHANGED, onPositionAreaChanged);
2268
2265
  editor.removeEventListener(InlineEditor.PositionAreaEditor.Events.PROPERTY_CHANGED, onPropertyChanged);
2269
- const propertyText = commitEdit ? active.treeElement.renderedPropertyText() : originalPropertyText || '';
2270
- void active.treeElement.applyStyleText(propertyText, true);
2271
- const node = this.#stylesContainer.node() ?? active.treeElement.matchedStyles().node();
2266
+ const propertyText = commitEdit ? active.propertyData.renderedPropertyText() : originalPropertyText || '';
2267
+ void active.propertyData.applyStyleText(propertyText, true);
2268
+ const node = this.#stylesContainer.node() ?? active.propertyData.matchedStyles().node();
2272
2269
  for (const propertyName of PositionAreaRenderer.#EDITABLE_PROPERTIES) {
2273
2270
  const originalTarget = initialProperties.get(propertyName);
2274
- const targetSection = originalTarget?.section ?? active.treeElement.section();
2275
- const target = this.#findPropertyInSection(targetSection, propertyName);
2271
+ const targetSection = originalTarget?.section ?? active.propertyData.section();
2272
+ const target = targetSection.findProperty(propertyName);
2276
2273
  const oldValue = originalTarget?.value ?? '';
2277
2274
  const newValue = target?.property.value ?? '';
2278
2275
  const ruleHeader = targetSection.headerText();
@@ -2319,13 +2316,13 @@ const PositionTryRendererBase: RendererBase<SDK.CSSPropertyParserMatchers.Positi
2319
2316
  // clang-format off
2320
2317
  export class PositionTryRenderer extends PositionTryRendererBase {
2321
2318
  readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
2322
- readonly #treeElement: StylePropertyTreeElement|null;
2319
+ readonly #propertyData: StylePropertyData|null;
2323
2320
  // clang-format on
2324
2321
 
2325
- constructor(matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, treeElement: StylePropertyTreeElement|null) {
2322
+ constructor(matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, propertyData: StylePropertyData|null) {
2326
2323
  super();
2327
2324
  this.#matchedStyles = matchedStyles;
2328
- this.#treeElement = treeElement;
2325
+ this.#propertyData = propertyData;
2329
2326
  }
2330
2327
 
2331
2328
  override render(match: SDK.CSSPropertyParserMatchers.PositionTryMatch, context: RenderingContext): LitTemplate {
@@ -2334,13 +2331,13 @@ export class PositionTryRenderer extends PositionTryRendererBase {
2334
2331
  const {nodes} = Renderer.render(match.preamble, context);
2335
2332
  content.push(nodes);
2336
2333
  }
2337
- const node = this.#treeElement ? this.#matchedStyles.nodeForStyle(this.#treeElement.property.ownerStyle) :
2338
- this.#matchedStyles.node();
2334
+ const node = this.#propertyData ? this.#matchedStyles.nodeForStyle(this.#propertyData.property.ownerStyle) :
2335
+ this.#matchedStyles.node();
2339
2336
  const fallbackLabels: string[] = [];
2340
2337
  for (const [i, fallback] of match.fallbacks.entries()) {
2341
2338
  const important = fallback.find(node => node.name === 'Important');
2342
2339
  const classes = classMap({
2343
- 'inactive-value': !this.#treeElement?.inherited() && node === this.#matchedStyles.node() &&
2340
+ 'inactive-value': !this.#propertyData?.inherited() && node === this.#matchedStyles.node() &&
2344
2341
  i !== this.#matchedStyles.activePositionFallbackIndex(),
2345
2342
  });
2346
2343
  content.push(html`<span class=${classes}>${i > 0 ? ', ' : nothing}${
@@ -2351,8 +2348,8 @@ export class PositionTryRenderer extends PositionTryRendererBase {
2351
2348
  fallbackLabels.push(
2352
2349
  context.matchedResult.getComputedTextRange(fallback[0], fallback[fallback.length - 1]).trim());
2353
2350
  }
2354
- if (!this.#treeElement || this.#treeElement.overloaded() || this.#treeElement.inherited() ||
2355
- !this.#treeElement.property.activeInStyle() || !node) {
2351
+ if (!this.#propertyData || this.#propertyData.overloaded() || this.#propertyData.inherited() ||
2352
+ !this.#propertyData.property.activeInStyle() || !node) {
2356
2353
  return html`${content}`;
2357
2354
  }
2358
2355
  const cssModel = this.#matchedStyles.cssModel();
@@ -2398,17 +2395,18 @@ export class PositionTryRenderer extends PositionTryRendererBase {
2398
2395
 
2399
2396
  // Returns an id for <devtools-tooltips> that's stable across re-rendering of property values but unique across
2400
2397
  // sections and across switches between different nodes.
2401
- function getTooltipId(treeElement: StylePropertyTreeElement|null, key: string): string|undefined;
2398
+ function getTooltipId(propertyData: StylePropertyData|null, key: string): string|undefined;
2402
2399
  function getTooltipId(tooltipIdFactory: Tooltips.Tooltip.IdFactory, key: string, property: SDK.CSSProperty.CSSProperty,
2403
2400
  shorthandName?: string): string;
2404
- function getTooltipId(tooltipIdFactoryOrTreeElement: Tooltips.Tooltip.IdFactory|StylePropertyTreeElement|null,
2405
- key: string, property?: SDK.CSSProperty.CSSProperty, shorthandName?: string): string|undefined {
2406
- if (!tooltipIdFactoryOrTreeElement) {
2401
+ function getTooltipId(tooltipIdFactoryOrPropertyData: Tooltips.Tooltip.IdFactory|StylePropertyData|null, key: string,
2402
+ property?: SDK.CSSProperty.CSSProperty, shorthandName?: string): string|undefined {
2403
+ if (!tooltipIdFactoryOrPropertyData) {
2407
2404
  return undefined;
2408
2405
  }
2409
- if (tooltipIdFactoryOrTreeElement instanceof StylePropertyTreeElement) {
2410
- const treeElement = tooltipIdFactoryOrTreeElement;
2411
- return getTooltipId(treeElement.tooltipIdFactory, key, treeElement.property, treeElement.getLonghand()?.name);
2406
+ if (!(tooltipIdFactoryOrPropertyData instanceof Tooltips.Tooltip.IdFactory)) {
2407
+ const propertyData = tooltipIdFactoryOrPropertyData;
2408
+ return getTooltipId(propertyData.tooltipIdFactory, key, propertyData.property,
2409
+ propertyData.parentShorthand()?.property.name);
2412
2410
  }
2413
2411
 
2414
2412
  if (!property) {
@@ -2423,48 +2421,189 @@ function getTooltipId(tooltipIdFactoryOrTreeElement: Tooltips.Tooltip.IdFactory|
2423
2421
  index < ownIndex && (other.name === property.name || other.name === propertyNameForCounting) ? value + 1 :
2424
2422
  value,
2425
2423
  0);
2426
- return tooltipIdFactoryOrTreeElement.keyed(key, propertyCount);
2424
+ return tooltipIdFactoryOrPropertyData.keyed(key, propertyCount);
2425
+ }
2426
+
2427
+ function getInvalidPropertyMessage(property: SDK.CSSProperty.CSSProperty): Platform.UIString.LocalizedString {
2428
+ return SDK.CSSMetadata.cssMetadata().isCSSPropertyName(property.name) ? i18nString(UIStrings.invalidPropertyValue) :
2429
+ i18nString(UIStrings.unknownPropertyName);
2430
+ }
2431
+ function getLinkableFunction(functionName: string, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
2432
+ property: SDK.CSSProperty.CSSProperty, stylesContainer: StylesContainer): LitTemplate {
2433
+ const {registeredFunction, treeScopeDistance} = matchedStyles.getRegisteredFunction(functionName, property);
2434
+ const isDefined = Boolean(registeredFunction);
2435
+ return html`<devtools-link-swatch .data=${{
2436
+ jslogContext: 'css-function',
2437
+ text: functionName,
2438
+ tooltip: isDefined ? undefined : {title: i18nString(UIStrings.sIsNotDefined, {PH1: functionName})},
2439
+ isDefined,
2440
+ onLinkActivate: (): void => {
2441
+ if (!registeredFunction) {
2442
+ return;
2443
+ }
2444
+ stylesContainer.jumpToFunctionDefinition(registeredFunction, treeScopeDistance);
2445
+ },
2446
+ } as InlineEditor.LinkSwatch.LinkSwatchRenderData}></devtools-link-swatch>`;
2447
+ }
2448
+
2449
+ function getTracingTooltip(
2450
+ functionName: string, node: CodeMirror.SyntaxNode, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
2451
+ computedStyles: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null,
2452
+ context: RenderingContext, stylesContainer: StylesContainer, tooltipIdFactory: Tooltips.Tooltip.IdFactory,
2453
+ styleProperty: SDK.CSSProperty.CSSProperty, shorthandName: string|undefined): TemplateResult {
2454
+ if (context.tracing || !context.property) {
2455
+ return html`${functionName}`;
2456
+ }
2457
+ const text = context.ast.text(node);
2458
+ const expandPercentagesInShorthands = context.matchedResult.getLonghandValuesCount() > 1;
2459
+ const shorthandPositionOffset = context.matchedResult.getComputedLonghandName(node);
2460
+ const {property} = context;
2461
+ const tooltipId = getTooltipId(tooltipIdFactory, `${functionName}-trace`, styleProperty, shorthandName);
2462
+ // clang-format off
2463
+ return html`
2464
+ <span tabIndex=-1 class=tracing-anchor aria-details=${tooltipId}>${functionName.startsWith('--')
2465
+ ? getLinkableFunction(functionName, matchedStyles, context.property, stylesContainer)
2466
+ : functionName}</span>
2467
+ <devtools-tooltip
2468
+ id=${tooltipId}
2469
+ use-hotkey
2470
+ variant=rich
2471
+ jslogContext=elements.css-value-trace
2472
+ @beforetoggle=${function(this: Tooltips.Tooltip.Tooltip, e: ToggleEvent) {
2473
+ if (e.newState === 'open') {
2474
+ void (this.querySelector('devtools-widget') as UI.Widget.WidgetElement<CSSValueTraceView>| null)
2475
+ ?.getWidget()
2476
+ ?.showTrace(
2477
+ property, text, matchedStyles, computedStyles,
2478
+ getPropertyRenderers(property.name,
2479
+ property.ownerStyle, stylesContainer, matchedStyles, null, computedStyles, computedStyleExtraFields),
2480
+ expandPercentagesInShorthands, shorthandPositionOffset, this.openedViaHotkey);
2481
+ }
2482
+ }}
2483
+ @toggle=${function(this: Tooltips.Tooltip.Tooltip, e: ToggleEvent) {
2484
+ if (e.newState !== 'open') {
2485
+ (this.querySelector('devtools-widget') as UI.Widget.WidgetElement<CSSValueTraceView>| null)
2486
+ ?.getWidget()
2487
+ ?.resetPendingFocus();
2488
+ }
2489
+ }}>
2490
+ <devtools-widget
2491
+ @keydown=${(e: KeyboardEvent) => {
2492
+ const maybeTooltip = (e.target as Element).parentElement ;
2493
+ if (!(maybeTooltip instanceof Tooltips.Tooltip.Tooltip)) {
2494
+ return;
2495
+ }
2496
+ if (e.key === 'Escape' || (e.altKey && e.key === 'ArrowDown')){
2497
+ maybeTooltip.hideTooltip();
2498
+ maybeTooltip.anchor?.focus();
2499
+ e.consume(true);
2500
+ }
2501
+ }}
2502
+ ${widget(CSSValueTraceView)}>
2503
+ </devtools-widget>
2504
+ </devtools-tooltip>`;
2505
+ // clang-format on
2427
2506
  }
2428
2507
  export function getPropertyRenderers(
2429
2508
  propertyName: string, style: SDK.CSSStyleDeclaration.CSSStyleDeclaration, stylesContainer: StylesContainer,
2430
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, treeElement: StylePropertyTreeElement|null,
2509
+ matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, propertyData: StylePropertyData|null,
2431
2510
  computedStyles: Map<string, string>, computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null):
2432
2511
  Array<MatchRenderer<SDK.CSSPropertyParser.Match>> {
2433
2512
  return [
2434
- new VariableRenderer(stylesContainer, treeElement, matchedStyles, computedStyles, computedStyleExtraFields),
2435
- new VariableNameRenderer(stylesContainer, treeElement, matchedStyles),
2436
- new ColorRenderer(stylesContainer, treeElement),
2437
- new ColorMixRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, treeElement),
2438
- new ContrastColorRenderer(stylesContainer, treeElement),
2513
+ new VariableRenderer(stylesContainer, propertyData, matchedStyles, computedStyles, computedStyleExtraFields),
2514
+ new VariableNameRenderer(stylesContainer, propertyData, matchedStyles),
2515
+ new ColorRenderer(stylesContainer, propertyData),
2516
+ new ColorMixRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyData),
2517
+ new ContrastColorRenderer(stylesContainer, propertyData),
2439
2518
  new URLRenderer(style.parentRule, stylesContainer.node()),
2440
- new AngleRenderer(treeElement),
2519
+ new AngleRenderer(propertyData),
2441
2520
  new LinkableNameRenderer(matchedStyles, stylesContainer),
2442
- new BezierRenderer(treeElement),
2521
+ new BezierRenderer(propertyData),
2443
2522
  new StringRenderer(),
2444
- new ShadowRenderer(treeElement),
2445
- new CSSWideKeywordRenderer(stylesContainer, treeElement),
2446
- new LightDarkColorRenderer(stylesContainer, matchedStyles, treeElement),
2523
+ new ShadowRenderer(propertyData),
2524
+ new CSSWideKeywordRenderer(stylesContainer, propertyData),
2525
+ new LightDarkColorRenderer(stylesContainer, matchedStyles, propertyData),
2447
2526
  new GridTemplateRenderer(),
2448
2527
  new LinearGradientRenderer(),
2449
2528
  new AnchorFunctionRenderer(stylesContainer),
2450
2529
  new PositionAnchorRenderer(stylesContainer),
2451
- new FlexGridRenderer(stylesContainer, treeElement),
2452
- new PositionAreaRenderer(stylesContainer, treeElement),
2453
- new EnvFunctionRenderer(treeElement, matchedStyles, computedStyles, computedStyleExtraFields),
2454
- new PositionTryRenderer(matchedStyles, treeElement),
2455
- new LengthRenderer(stylesContainer, propertyName, treeElement),
2530
+ new FlexGridRenderer(stylesContainer, propertyData),
2531
+ new PositionAreaRenderer(stylesContainer, propertyData),
2532
+ new EnvFunctionRenderer(propertyData, matchedStyles, computedStyles, computedStyleExtraFields),
2533
+ new PositionTryRenderer(matchedStyles, propertyData),
2534
+ new LengthRenderer(stylesContainer, propertyName, propertyData),
2456
2535
  new MathFunctionRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyName,
2457
- treeElement),
2536
+ propertyData),
2458
2537
  new CustomFunctionRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyName,
2459
- treeElement),
2538
+ propertyData),
2460
2539
  new AutoBaseRenderer(computedStyles, computedStyleExtraFields),
2461
2540
  new BinOpRenderer(),
2462
- new RelativeColorChannelRenderer(treeElement),
2463
- new AttributeRenderer(stylesContainer, treeElement, matchedStyles, computedStyles, computedStyleExtraFields),
2541
+ new RelativeColorChannelRenderer(propertyData),
2542
+ new AttributeRenderer(stylesContainer, propertyData, matchedStyles, computedStyles, computedStyleExtraFields),
2464
2543
  ];
2465
2544
  }
2466
2545
 
2467
- export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2546
+ function exclamationMarkTemplate(
2547
+ propertyData: StylePropertyData,
2548
+ details: ElementsComponents.CSSVariableValueView.RegisteredPropertyDetails|null): LitTemplate {
2549
+ const tooltipId = details ? getTooltipId(propertyData.tooltipIdFactory, 'property-warning', propertyData.property,
2550
+ propertyData.parentShorthand()?.property.name) :
2551
+ undefined;
2552
+ // clang-format off
2553
+ return html`<span><span
2554
+ class="exclamation-mark"
2555
+ tabindex="-1"
2556
+ title=${ifDefined(details ? undefined : getInvalidPropertyMessage(propertyData.property))}
2557
+ aria-details=${ifDefined(tooltipId)}></span>${details && tooltipId ? html`<devtools-tooltip
2558
+ id=${tooltipId}
2559
+ variant="rich"
2560
+ jslogContext="elements.invalid-property-decl-popover">${
2561
+ widget(ElementsComponents.CSSVariableValueView.CSSVariableParserError, {details})
2562
+ }</devtools-tooltip>` : nothing}</span>`;
2563
+ // clang-format on
2564
+ }
2565
+
2566
+ function authoringHintTemplate(propertyData: StylePropertyData, hint: Hint): LitTemplate {
2567
+ const tooltipId = getTooltipId(propertyData.tooltipIdFactory, 'css-hint', propertyData.property,
2568
+ propertyData.parentShorthand()?.property.name);
2569
+ // clang-format off
2570
+ return html`<span class="hint-wrapper"><devtools-icon
2571
+ name="info"
2572
+ class="hint small"
2573
+ tabindex="-1"
2574
+ aria-details=${tooltipId}></devtools-icon></span><devtools-tooltip
2575
+ id=${tooltipId}
2576
+ variant="rich"
2577
+ padding="large"
2578
+ jslogContext="elements.css-hint">${
2579
+ widget(ElementsComponents.CSSHintDetailsView.CSSHintDetailsView, {authoringHint: hint})
2580
+ }</devtools-tooltip>`;
2581
+ // clang-format on
2582
+ }
2583
+
2584
+ function animationOverrideHintTemplate(propertyData: StylePropertyData): LitTemplate {
2585
+ const tooltipId = getTooltipId(propertyData.tooltipIdFactory, 'animation-override-hint', propertyData.property,
2586
+ propertyData.parentShorthand()?.property.name);
2587
+ // clang-format off
2588
+ return html`<span class="animation-override-hint-wrapper hint-wrapper"><devtools-icon
2589
+ name="info"
2590
+ class="hint small"
2591
+ tabindex="-1"
2592
+ aria-details=${tooltipId}></devtools-icon></span><devtools-tooltip
2593
+ id=${tooltipId}
2594
+ variant="rich"
2595
+ padding="large"
2596
+ jslogContext="elements.css-animation-hint"><div class="animation-override-hint">${
2597
+ i18nTemplate(UIStrings.overriddenByAnimation, {PH1: html`<devtools-link
2598
+ jslogContext="open-in-animations-panel"
2599
+ @click=${(event: Event) => {
2600
+ event.preventDefault();
2601
+ void UI.ViewManager.ViewManager.instance().showView('animations');
2602
+ }}>${i18nString(UIStrings.openAnimationsPanel)}</devtools-link>`})}</div></devtools-tooltip>`;
2603
+ // clang-format on
2604
+ }
2605
+
2606
+ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement implements StylePropertyData {
2468
2607
  private readonly style: SDK.CSSStyleDeclaration.CSSStyleDeclaration;
2469
2608
  #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
2470
2609
  property: SDK.CSSProperty.CSSProperty;
@@ -2494,7 +2633,7 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2494
2633
  #edits: ValueUpdateTracking|undefined;
2495
2634
  // Stores the last committed property so incremental live previews and
2496
2635
  // in-place mutations of `this.property` don't overwrite the baseline for change tracking.
2497
- #lastCommittedProperty: {name: string, value: string};
2636
+ #lastCommittedProperty: {readonly name: string, readonly value: string};
2498
2637
 
2499
2638
  #lazyRender?: boolean;
2500
2639
 
@@ -2535,9 +2674,31 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2535
2674
  super.onunbind();
2536
2675
  }
2537
2676
 
2538
- carryOverCommittedProperty(previous: StylePropertyTreeElement): void {
2539
- this.#lastCommittedProperty = previous.#lastCommittedProperty;
2677
+ get lastCommittedProperty(): {readonly name: string, readonly value: string} {
2678
+ return this.#lastCommittedProperty;
2679
+ }
2680
+
2681
+ carryOverCommittedProperty(previous: StylePropertyData): void {
2682
+ this.#lastCommittedProperty = previous.lastCommittedProperty;
2540
2683
  }
2684
+
2685
+ async setSiblingProperty(propertyName: string, value?: string): Promise<void> {
2686
+ let target = findSiblingProperty(this.#stylesContainer, this, propertyName);
2687
+ if (value) {
2688
+ if (!target) {
2689
+ target = this.#parentSection.addNewBlankProperty();
2690
+ target.property.name = propertyName;
2691
+ }
2692
+ target.property.value = value;
2693
+ target.updateTitle();
2694
+ await target.applyStyleText(target.renderedPropertyText(), false);
2695
+ this.#stylesContainer.refreshUpdate(target.section(), target, true);
2696
+ } else if (target) {
2697
+ await target.applyStyleText('', false);
2698
+ this.#stylesContainer.refreshUpdate(target.section(), target, true);
2699
+ }
2700
+ }
2701
+
2541
2702
  async gridNames(): Promise<Set<string>> {
2542
2703
  if (!SDK.CSSMetadata.cssMetadata().isGridNameAwareProperty(this.name)) {
2543
2704
  return new Set();
@@ -2566,8 +2727,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2566
2727
  ?.flatMap(row => row.substring(1, row.length - 1).split(/\s+/).filter(cell => !cell.match(/^\.*$/))));
2567
2728
  }
2568
2729
  if (SDK.CSSMetadata.cssMetadata().isGridColumnNameAwareProperty(this.name)) {
2569
- return new Set(getNames(
2570
- 'grid-template-columns', node => node.name === 'ValueName' && node.parent?.name === 'BracketedValue'));
2730
+ return new Set(getNames('grid-template-columns',
2731
+ node => node.name === 'ValueName' && node.parent?.name === 'BracketedValue'));
2571
2732
  }
2572
2733
  return new Set(
2573
2734
  getNames('grid-template-rows', node => node.name === 'ValueName' && node.parent?.name === 'BracketedValue'));
@@ -2583,6 +2744,10 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2583
2744
  return this.parent instanceof StylePropertyTreeElement && this.parent.isShorthand ? this.parent : null;
2584
2745
  }
2585
2746
 
2747
+ parentShorthand(): StylePropertyData|null {
2748
+ return this.getLonghand();
2749
+ }
2750
+
2586
2751
  editable(): boolean {
2587
2752
  const hasSourceData = Boolean(this.style.styleSheetId && this.style.range);
2588
2753
  return !this.getLonghand() && hasSourceData;
@@ -2932,9 +3097,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2932
3097
  }
2933
3098
 
2934
3099
  const renderers = this.property.parsedOk ?
2935
- getPropertyRenderers(
2936
- this.name, this.style, this.#stylesContainer, this.#matchedStyles, this,
2937
- this.getComputedStyles() ?? new Map(), this.getComputedStyleExtraFields()) :
3100
+ getPropertyRenderers(this.name, this.style, this.#stylesContainer, this.#matchedStyles, this,
3101
+ this.getComputedStyles() ?? new Map(), this.getComputedStyleExtraFields()) :
2938
3102
  [];
2939
3103
 
2940
3104
  const existingDocWidget =
@@ -2956,9 +3120,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2956
3120
  }
2957
3121
 
2958
3122
  const indent = Common.Settings.Settings.instance().resolve(SDK.SDKSettings.textEditorIndentSettingDescriptor).get();
2959
- UI.UIUtils.createTextChild(
2960
- this.listItemElement.createChild('span', 'styles-clipboard-only'),
2961
- indent.repeat(this.section().nestingLevel + 1) + (this.property.disabled ? '/* ' : ''));
3123
+ UI.UIUtils.createTextChild(this.listItemElement.createChild('span', 'styles-clipboard-only'),
3124
+ indent.repeat(this.section().nestingLevel + 1) + (this.property.disabled ? '/* ' : ''));
2962
3125
  this.listItemElement.appendChild(this.nameElement);
2963
3126
 
2964
3127
  if (this.property.name.startsWith('--') &&
@@ -3076,142 +3239,44 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3076
3239
  this.listItemElement.insertBefore(enabledCheckboxElement, this.listItemElement.firstChild);
3077
3240
  }
3078
3241
 
3079
- const that = this;
3080
- this.valueElement.addEventListener('keydown', nonEditingNameValueKeyDown);
3081
- this.nameElement.addEventListener('keydown', nonEditingNameValueKeyDown);
3082
-
3083
- function nonEditingNameValueKeyDown(this: HTMLElement, event: KeyboardEvent): void {
3084
- if (UI.UIUtils.isBeingEdited(this)) {
3085
- return;
3086
- }
3087
- if (event.key !== Platform.KeyboardUtilities.ENTER_KEY && event.key !== ' ') {
3088
- return;
3089
- }
3090
- if (this === that.valueElement) {
3091
- that.startEditingValue();
3242
+ // The name and the value each start their own edit when the user presses Enter or Space on them.
3243
+ const valueElement = this.valueElement;
3244
+ const nameElement = this.nameElement;
3245
+ valueElement.addEventListener('keydown', event => {
3246
+ if (isStartEditingKey(valueElement, event)) {
3247
+ this.startEditingValue();
3092
3248
  event.consume(true);
3093
- } else if (this === that.nameElement) {
3094
- that.startEditingName();
3249
+ }
3250
+ });
3251
+ nameElement.addEventListener('keydown', event => {
3252
+ if (isStartEditingKey(nameElement, event)) {
3253
+ this.startEditingName();
3095
3254
  event.consume(true);
3096
3255
  }
3256
+ });
3257
+
3258
+ function isStartEditingKey(element: HTMLElement, event: KeyboardEvent): boolean {
3259
+ if (UI.UIUtils.isBeingEdited(element)) {
3260
+ return false;
3261
+ }
3262
+ return !event.isComposing && Platform.KeyboardUtilities.isEnterOrSpaceKey(event);
3097
3263
  }
3098
3264
  }
3099
3265
 
3100
3266
  createExclamationMark(property: SDK.CSSProperty.CSSProperty,
3101
- title: ElementsComponents.CSSVariableValueView.CSSVariableParserError|HTMLElement|
3102
- null): Element {
3103
- const container = document.createElement('span');
3104
- const exclamationElement = container.createChild('span');
3105
- exclamationElement.tabIndex = -1;
3106
- exclamationElement.classList.add('exclamation-mark');
3107
- const invalidMessage = SDK.CSSMetadata.cssMetadata().isCSSPropertyName(property.name) ?
3108
- i18nString(UIStrings.invalidPropertyValue) :
3109
- i18nString(UIStrings.unknownPropertyName);
3110
- if (title === null) {
3111
- UI.Tooltip.Tooltip.install(exclamationElement, invalidMessage);
3112
- } else {
3113
- const tooltipId =
3114
- getTooltipId(this.tooltipIdFactory, 'property-warning', this.property, this.getLonghand()?.name);
3115
- exclamationElement.setAttribute('aria-describedby', tooltipId);
3116
- const tooltip = new Tooltips.Tooltip.Tooltip({
3117
- anchor: exclamationElement,
3118
- variant: 'simple',
3119
- id: tooltipId,
3120
- jslogContext: 'elements.invalid-property-decl-popover',
3121
- });
3122
- if (title instanceof UI.Widget.Widget) {
3123
- title.show(tooltip, undefined, /* suppressOrphanWidgetError= */ true);
3124
- } else {
3125
- tooltip.appendChild(title);
3126
- }
3127
- container.appendChild(tooltip);
3128
- }
3129
- const invalidString =
3130
- i18nString(UIStrings.invalidString, {PH1: invalidMessage, PH2: property.name, PH3: property.value});
3267
+ details: ElementsComponents.CSSVariableValueView.RegisteredPropertyDetails|
3268
+ null): DocumentFragment {
3269
+ const fragment = document.createDocumentFragment();
3270
+ // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
3271
+ render(exclamationMarkTemplate(this, details), fragment);
3272
+
3273
+ const invalidString = i18nString(
3274
+ UIStrings.invalidString, {PH1: getInvalidPropertyMessage(property), PH2: property.name, PH3: property.value});
3131
3275
 
3132
3276
  // Storing the invalidString for future screen reader support when editing the property
3133
3277
  property.setDisplayedStringForInvalidProperty(invalidString);
3134
3278
 
3135
- return container;
3136
- }
3137
-
3138
- #getLinkableFunction(
3139
- functionName: string, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
3140
- property: SDK.CSSProperty.CSSProperty): InlineEditor.LinkSwatch.LinkSwatch {
3141
- const swatch = new InlineEditor.LinkSwatch.LinkSwatch();
3142
- const {registeredFunction, treeScopeDistance} = matchedStyles.getRegisteredFunction(functionName, property);
3143
- const isDefined = Boolean(registeredFunction);
3144
- swatch.data = {
3145
- jslogContext: 'css-function',
3146
- text: functionName,
3147
- tooltip: isDefined ? undefined : {title: i18nString(UIStrings.sIsNotDefined, {PH1: functionName})},
3148
- isDefined,
3149
- onLinkActivate: (): void => {
3150
- if (!registeredFunction) {
3151
- return;
3152
- }
3153
- this.#stylesContainer.jumpToFunctionDefinition(registeredFunction, treeScopeDistance);
3154
- },
3155
- };
3156
- return swatch;
3157
- }
3158
-
3159
- getTracingTooltip(functionName: string, node: CodeMirror.SyntaxNode,
3160
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, computedStyles: Map<string, string>,
3161
- computedStyleExtraFields: Protocol.CSS.ComputedStyleExtraFields|null,
3162
- context: RenderingContext): TemplateResult {
3163
- if (context.tracing || !context.property) {
3164
- return html`${functionName}`;
3165
- }
3166
- const text = context.ast.text(node);
3167
- const expandPercentagesInShorthands = context.matchedResult.getLonghandValuesCount() > 1;
3168
- const shorthandPositionOffset = context.matchedResult.getComputedLonghandName(node);
3169
- const {property} = context;
3170
- const stylesContainer = this.stylesContainer();
3171
- const tooltipId =
3172
- getTooltipId(this.tooltipIdFactory, `${functionName}-trace`, this.property, this.getLonghand()?.name);
3173
- // clang-format off
3174
- return html`
3175
- <span tabIndex=-1 class=tracing-anchor aria-details=${tooltipId}>${functionName.startsWith('--') ? this.#getLinkableFunction(functionName, matchedStyles, context.property) : functionName}</span>
3176
- <devtools-tooltip
3177
- id=${tooltipId}
3178
- use-hotkey
3179
- variant=rich
3180
- jslogContext=elements.css-value-trace
3181
- @beforetoggle=${function(this: Tooltips.Tooltip.Tooltip, e: ToggleEvent) {
3182
- if (e.newState === 'open') {
3183
- void (this.querySelector('devtools-widget') as UI.Widget.WidgetElement<CSSValueTraceView>| null)
3184
- ?.getWidget()
3185
- ?.showTrace(
3186
- property, text, matchedStyles, computedStyles,
3187
- getPropertyRenderers(property.name,
3188
- property.ownerStyle, stylesContainer, matchedStyles, null, computedStyles, computedStyleExtraFields),
3189
- expandPercentagesInShorthands, shorthandPositionOffset, this.openedViaHotkey);
3190
- }
3191
- }}
3192
- @toggle=${function(this: Tooltips.Tooltip.Tooltip, e: ToggleEvent) {
3193
- if (e.newState !== 'open') {
3194
- (this.querySelector('devtools-widget') as UI.Widget.WidgetElement<CSSValueTraceView>| null)
3195
- ?.getWidget()
3196
- ?.resetPendingFocus();
3197
- }
3198
- }}>
3199
- <devtools-widget
3200
- @keydown=${(e: KeyboardEvent) => {
3201
- const maybeTooltip = (e.target as Element).parentElement ;
3202
- if (!(maybeTooltip instanceof Tooltips.Tooltip.Tooltip)) {
3203
- return;
3204
- }
3205
- if (e.key === 'Escape' || (e.altKey && e.key === 'ArrowDown')){
3206
- maybeTooltip.hideTooltip();
3207
- maybeTooltip.anchor?.focus();
3208
- e.consume(true);
3209
- }
3210
- }}
3211
- ${widget(CSSValueTraceView)}>
3212
- </devtools-widget>
3213
- </devtools-tooltip>`;
3214
- // clang-format on
3279
+ return fragment;
3215
3280
  }
3216
3281
 
3217
3282
  updateAuthoringHint(): void {
@@ -3236,28 +3301,14 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3236
3301
 
3237
3302
  const localName = this.node()?.localName();
3238
3303
  for (const validator of cssRuleValidatorsMap.get(propertyName) || []) {
3239
- const hint = validator.getHint(
3240
- propertyName, this.computedStyles || undefined, this.parentsComputedStyles || undefined,
3241
- localName?.toLowerCase(), fontFaces);
3304
+ const hint = validator.getHint(propertyName, this.computedStyles || undefined,
3305
+ this.parentsComputedStyles || undefined, localName?.toLowerCase(), fontFaces);
3242
3306
  if (hint) {
3243
- const wrapper = document.createElement('span');
3244
- wrapper.classList.add('hint-wrapper');
3245
- const hintIcon = new Icon();
3246
- hintIcon.name = 'info';
3247
- hintIcon.classList.add('hint', 'small');
3248
- hintIcon.tabIndex = -1;
3249
- wrapper.append(hintIcon);
3250
- this.listItemElement.append(wrapper);
3307
+ const fragment = document.createDocumentFragment();
3308
+ // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
3309
+ render(authoringHintTemplate(this, hint), fragment);
3310
+ this.listItemElement.append(fragment);
3251
3311
  this.listItemElement.classList.add('inactive-property');
3252
- const tooltipId = getTooltipId(this.tooltipIdFactory, 'css-hint', this.property, this.getLonghand()?.name);
3253
- hintIcon.setAttribute('aria-details', tooltipId);
3254
- const tooltip = new Tooltips.Tooltip.Tooltip(
3255
- {anchor: hintIcon, variant: 'rich', padding: 'large', id: tooltipId, jslogContext: 'elements.css-hint'});
3256
- const hintDetailsView = new ElementsComponents.CSSHintDetailsView.CSSHintDetailsView();
3257
- hintDetailsView.authoringHint = hint;
3258
- hintDetailsView.markAsRoot();
3259
- hintDetailsView.show(tooltip);
3260
- this.listItemElement.appendChild(tooltip);
3261
3312
  break;
3262
3313
  }
3263
3314
  }
@@ -3276,45 +3327,10 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3276
3327
  return;
3277
3328
  }
3278
3329
 
3279
- const wrapper = document.createElement('span');
3280
- wrapper.classList.add('animation-override-hint-wrapper', 'hint-wrapper');
3281
- const hintIcon = new Icon();
3282
- hintIcon.name = 'info';
3283
- hintIcon.classList.add('hint', 'small');
3284
- hintIcon.tabIndex = -1;
3285
-
3286
- wrapper.append(hintIcon);
3287
- this.listItemElement.append(wrapper);
3288
-
3289
- const tooltipId =
3290
- getTooltipId(this.tooltipIdFactory, 'animation-override-hint', this.property, this.getLonghand()?.name);
3291
- hintIcon.setAttribute('aria-details', tooltipId);
3292
-
3293
- const tooltip = new Tooltips.Tooltip.Tooltip({
3294
- anchor: hintIcon,
3295
- variant: 'rich',
3296
- padding: 'large',
3297
- id: tooltipId,
3298
- jslogContext: 'elements.css-animation-hint',
3299
- });
3300
- const message = i18nString(UIStrings.overriddenByAnimation);
3301
- const content = document.createElement('div');
3302
- content.classList.add('animation-override-hint');
3303
- content.textContent = message;
3304
-
3305
- const link = document.createElement('devtools-link');
3306
- link.textContent = i18nString(UIStrings.openAnimationsPanel);
3307
- link.jslogContext = 'open-in-animations-panel';
3308
- link.addEventListener('click', event => {
3309
- event.preventDefault();
3310
- void UI.ViewManager.ViewManager.instance().showView('animations');
3311
- });
3312
-
3313
- content.appendChild(document.createTextNode(' '));
3314
- content.appendChild(link);
3315
- tooltip.appendChild(content);
3316
-
3317
- this.listItemElement.appendChild(tooltip);
3330
+ const fragment = document.createDocumentFragment();
3331
+ // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
3332
+ render(animationOverrideHintTemplate(this), fragment);
3333
+ this.listItemElement.append(fragment);
3318
3334
  }
3319
3335
 
3320
3336
  private overriddenByAnimation(): boolean {
@@ -3386,8 +3402,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3386
3402
  }, {checked: !this.property.disabled, jslogContext: 'toggle-property-and-continue-editing'});
3387
3403
  }
3388
3404
  const revealCallback = this.navigateToSource.bind(this) as () => void;
3389
- contextMenu.defaultSection().appendItem(
3390
- i18nString(UIStrings.openInSourcesPanel), revealCallback, {jslogContext: 'reveal-in-sources-panel'});
3405
+ contextMenu.defaultSection().appendItem(i18nString(UIStrings.openInSourcesPanel), revealCallback,
3406
+ {jslogContext: 'reveal-in-sources-panel'});
3391
3407
  void contextMenu.show();
3392
3408
  }
3393
3409
 
@@ -3422,18 +3438,18 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3422
3438
  Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(ruleText);
3423
3439
  }, {jslogContext: 'copy-rule'});
3424
3440
 
3425
- contextMenu.headerSection().appendItem(
3426
- i18nString(UIStrings.copyCssDeclarationAsJs), this.copyCssDeclarationAsJs.bind(this),
3427
- {jslogContext: 'copy-css-declaration-as-js'});
3441
+ contextMenu.headerSection().appendItem(i18nString(UIStrings.copyCssDeclarationAsJs),
3442
+ this.copyCssDeclarationAsJs.bind(this),
3443
+ {jslogContext: 'copy-css-declaration-as-js'});
3428
3444
 
3429
3445
  contextMenu.clipboardSection().appendItem(i18nString(UIStrings.copyAllDeclarations), () => {
3430
3446
  const allDeclarationText = this.#parentSection.formatLeadingProperties().allDeclarationText;
3431
3447
  Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(allDeclarationText);
3432
3448
  }, {jslogContext: 'copy-all-declarations'});
3433
3449
 
3434
- contextMenu.clipboardSection().appendItem(
3435
- i18nString(UIStrings.copyAllCssDeclarationsAsJs), this.copyAllCssDeclarationAsJs.bind(this),
3436
- {jslogContext: 'copy-all-css-declarations-as-js'});
3450
+ contextMenu.clipboardSection().appendItem(i18nString(UIStrings.copyAllCssDeclarationsAsJs),
3451
+ this.copyAllCssDeclarationAsJs.bind(this),
3452
+ {jslogContext: 'copy-all-css-declarations-as-js'});
3437
3453
 
3438
3454
  contextMenu.footerSection().appendItem(i18nString(UIStrings.viewComputedValue), () => {
3439
3455
  void this.viewComputedValue();
@@ -3640,13 +3656,11 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3640
3656
  if ((keyboardEvent.key === 'Enter' && !keyboardEvent.shiftKey) ||
3641
3657
  (context.isEditingName && keyboardEvent.key === ' ')) {
3642
3658
  result = 'forward';
3643
- } else if (
3644
- keyboardEvent.keyCode === UI.KeyboardShortcut.Keys.Esc.code ||
3645
- keyboardEvent.key === Platform.KeyboardUtilities.ESCAPE_KEY) {
3659
+ } else if (keyboardEvent.keyCode === UI.KeyboardShortcut.Keys.Esc.code ||
3660
+ keyboardEvent.key === Platform.KeyboardUtilities.ESCAPE_KEY) {
3646
3661
  result = 'cancel';
3647
- } else if (
3648
- !context.isEditingName && this.newProperty &&
3649
- keyboardEvent.keyCode === UI.KeyboardShortcut.Keys.Backspace.code) {
3662
+ } else if (!context.isEditingName && this.newProperty &&
3663
+ keyboardEvent.keyCode === UI.KeyboardShortcut.Keys.Backspace.code) {
3650
3664
  // For a new property, when Backspace is pressed at the beginning of new property value, move back to the property name.
3651
3665
  const selection = target.getComponentSelection();
3652
3666
  if (selection && selection.isCollapsed && !selection.focusOffset) {
@@ -3897,9 +3911,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3897
3911
  let propertyText;
3898
3912
  if (nameValueEntered) {
3899
3913
  propertyText = this.nameElement.textContent;
3900
- } else if (
3901
- blankInput ||
3902
- (this.newProperty && Platform.StringUtilities.isWhitespace(this.valueElement.textContent || ''))) {
3914
+ } else if (blankInput ||
3915
+ (this.newProperty && Platform.StringUtilities.isWhitespace(this.valueElement.textContent || ''))) {
3903
3916
  propertyText = '';
3904
3917
  } else if (isEditingName) {
3905
3918
  propertyText = userInput + ': ' + this.property.value;
@@ -3923,9 +3936,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3923
3936
  /**
3924
3937
  * The Callback to start editing the next/previous property/selector.
3925
3938
  */
3926
- function moveToNextCallback(
3927
- this: StylePropertyTreeElement, alreadyNew: boolean, valueChanged: boolean,
3928
- section: StylePropertiesSection): void {
3939
+ function moveToNextCallback(this: StylePropertyTreeElement, alreadyNew: boolean, valueChanged: boolean,
3940
+ section: StylePropertiesSection): void {
3929
3941
  if (!moveDirection) {
3930
3942
  this.#stylesContainer.resetFocus();
3931
3943
  return;
@@ -4030,8 +4042,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
4030
4042
  return this.applyStyleThrottler.schedule(this.innerApplyStyleText.bind(this, styleText, majorChange, property));
4031
4043
  }
4032
4044
 
4033
- private async innerApplyStyleText(
4034
- styleText: string, majorChange: boolean, property?: SDK.CSSProperty.CSSProperty|null): Promise<void> {
4045
+ private async innerApplyStyleText(styleText: string, majorChange: boolean,
4046
+ property?: SDK.CSSProperty.CSSProperty|null): Promise<void> {
4035
4047
  // this.property might have been nulled at the end of the last innerApplyStyleText.
4036
4048
  if (!this.treeOutline || !this.property) {
4037
4049
  return;
@@ -4204,9 +4216,8 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
4204
4216
  }
4205
4217
 
4206
4218
  export class GhostStylePropertyTreeElement extends StylePropertyTreeElement {
4207
- constructor(
4208
- stylesContainer: StylesContainer, section: StylePropertiesSection,
4209
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, property: SDK.CSSProperty.CSSProperty) {
4219
+ constructor(stylesContainer: StylesContainer, section: StylePropertiesSection,
4220
+ matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, property: SDK.CSSProperty.CSSProperty) {
4210
4221
  super({
4211
4222
  stylesContainer,
4212
4223
  section,