chrome-devtools-frontend 1.0.982087 → 1.0.995629

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 (489) hide show
  1. package/AUTHORS +2 -0
  2. package/config/gni/devtools_grd_files.gni +8 -7
  3. package/config/gni/devtools_image_files.gni +1 -0
  4. package/front_end/.eslintrc.js +10 -0
  5. package/front_end/Images/src/ic_rendering.svg +3 -0
  6. package/front_end/core/common/ParsedURL.ts +39 -28
  7. package/front_end/core/common/ResourceType.ts +1 -1
  8. package/front_end/core/common/SettingRegistration.ts +1 -0
  9. package/front_end/core/host/InspectorFrontendHost.ts +4 -4
  10. package/front_end/core/host/InspectorFrontendHostAPI.ts +7 -6
  11. package/front_end/core/host/Platform.ts +11 -2
  12. package/front_end/core/host/UserMetrics.ts +27 -2
  13. package/front_end/core/i18n/DevToolsLocale.ts +4 -0
  14. package/front_end/core/i18n/locales/af.json +76 -16
  15. package/front_end/core/i18n/locales/am.json +76 -16
  16. package/front_end/core/i18n/locales/ar.json +77 -17
  17. package/front_end/core/i18n/locales/as.json +76 -16
  18. package/front_end/core/i18n/locales/az.json +76 -16
  19. package/front_end/core/i18n/locales/be.json +75 -15
  20. package/front_end/core/i18n/locales/bg.json +76 -16
  21. package/front_end/core/i18n/locales/bn.json +76 -16
  22. package/front_end/core/i18n/locales/bs.json +88 -28
  23. package/front_end/core/i18n/locales/ca.json +76 -16
  24. package/front_end/core/i18n/locales/cs.json +76 -16
  25. package/front_end/core/i18n/locales/cy.json +76 -16
  26. package/front_end/core/i18n/locales/da.json +77 -17
  27. package/front_end/core/i18n/locales/de.json +178 -118
  28. package/front_end/core/i18n/locales/el.json +76 -16
  29. package/front_end/core/i18n/locales/en-GB.json +76 -16
  30. package/front_end/core/i18n/locales/en-US.json +193 -52
  31. package/front_end/core/i18n/locales/en-XL.json +193 -52
  32. package/front_end/core/i18n/locales/es-419.json +76 -16
  33. package/front_end/core/i18n/locales/es.json +76 -16
  34. package/front_end/core/i18n/locales/et.json +76 -16
  35. package/front_end/core/i18n/locales/eu.json +76 -16
  36. package/front_end/core/i18n/locales/fa.json +83 -23
  37. package/front_end/core/i18n/locales/fi.json +76 -16
  38. package/front_end/core/i18n/locales/fil.json +76 -16
  39. package/front_end/core/i18n/locales/fr-CA.json +76 -16
  40. package/front_end/core/i18n/locales/fr.json +76 -16
  41. package/front_end/core/i18n/locales/gl.json +76 -16
  42. package/front_end/core/i18n/locales/gu.json +76 -16
  43. package/front_end/core/i18n/locales/he.json +76 -16
  44. package/front_end/core/i18n/locales/hi.json +76 -16
  45. package/front_end/core/i18n/locales/hr.json +76 -16
  46. package/front_end/core/i18n/locales/hu.json +76 -16
  47. package/front_end/core/i18n/locales/hy.json +76 -16
  48. package/front_end/core/i18n/locales/id.json +79 -19
  49. package/front_end/core/i18n/locales/is.json +75 -15
  50. package/front_end/core/i18n/locales/it.json +124 -64
  51. package/front_end/core/i18n/locales/ja.json +76 -16
  52. package/front_end/core/i18n/locales/ka.json +76 -16
  53. package/front_end/core/i18n/locales/kk.json +76 -16
  54. package/front_end/core/i18n/locales/km.json +76 -16
  55. package/front_end/core/i18n/locales/kn.json +76 -16
  56. package/front_end/core/i18n/locales/ko.json +76 -16
  57. package/front_end/core/i18n/locales/ky.json +76 -16
  58. package/front_end/core/i18n/locales/lo.json +76 -16
  59. package/front_end/core/i18n/locales/lt.json +76 -16
  60. package/front_end/core/i18n/locales/lv.json +76 -16
  61. package/front_end/core/i18n/locales/mk.json +76 -16
  62. package/front_end/core/i18n/locales/ml.json +76 -16
  63. package/front_end/core/i18n/locales/mn.json +76 -16
  64. package/front_end/core/i18n/locales/mr.json +76 -16
  65. package/front_end/core/i18n/locales/ms.json +76 -16
  66. package/front_end/core/i18n/locales/my.json +78 -18
  67. package/front_end/core/i18n/locales/ne.json +76 -16
  68. package/front_end/core/i18n/locales/nl.json +77 -17
  69. package/front_end/core/i18n/locales/no.json +76 -16
  70. package/front_end/core/i18n/locales/or.json +76 -16
  71. package/front_end/core/i18n/locales/pa.json +76 -16
  72. package/front_end/core/i18n/locales/pl.json +78 -18
  73. package/front_end/core/i18n/locales/pt-PT.json +123 -63
  74. package/front_end/core/i18n/locales/pt.json +78 -18
  75. package/front_end/core/i18n/locales/ro.json +76 -16
  76. package/front_end/core/i18n/locales/ru.json +77 -17
  77. package/front_end/core/i18n/locales/si.json +76 -16
  78. package/front_end/core/i18n/locales/sk.json +76 -16
  79. package/front_end/core/i18n/locales/sl.json +76 -16
  80. package/front_end/core/i18n/locales/sq.json +76 -16
  81. package/front_end/core/i18n/locales/sr-Latn.json +76 -16
  82. package/front_end/core/i18n/locales/sr.json +76 -16
  83. package/front_end/core/i18n/locales/sv.json +76 -16
  84. package/front_end/core/i18n/locales/sw.json +76 -16
  85. package/front_end/core/i18n/locales/ta.json +77 -17
  86. package/front_end/core/i18n/locales/te.json +76 -16
  87. package/front_end/core/i18n/locales/th.json +76 -16
  88. package/front_end/core/i18n/locales/tr.json +76 -16
  89. package/front_end/core/i18n/locales/uk.json +76 -16
  90. package/front_end/core/i18n/locales/ur.json +76 -16
  91. package/front_end/core/i18n/locales/uz.json +77 -17
  92. package/front_end/core/i18n/locales/vi.json +76 -16
  93. package/front_end/core/i18n/locales/zh-HK.json +76 -16
  94. package/front_end/core/i18n/locales/zh-TW.json +76 -16
  95. package/front_end/core/i18n/locales/zh.json +76 -16
  96. package/front_end/core/i18n/locales/zu.json +76 -16
  97. package/front_end/core/platform/dom-utilities.ts +16 -0
  98. package/front_end/core/platform/platform.ts +2 -0
  99. package/front_end/core/protocol_client/InspectorBackend.ts +2 -1
  100. package/front_end/core/protocol_client/NodeURL.ts +1 -1
  101. package/front_end/core/root/Runtime.ts +6 -0
  102. package/front_end/core/sdk/AccessibilityModel.ts +7 -6
  103. package/front_end/core/sdk/CSSMatchedStyles.ts +71 -17
  104. package/front_end/core/sdk/CSSMetadata.ts +15 -0
  105. package/front_end/core/sdk/CSSModel.ts +9 -7
  106. package/front_end/core/sdk/CSSProperty.ts +97 -11
  107. package/front_end/core/sdk/CSSStyleSheetHeader.ts +9 -5
  108. package/front_end/core/sdk/CSSSupports.ts +4 -1
  109. package/front_end/core/sdk/ChildTargetManager.ts +3 -1
  110. package/front_end/core/sdk/Connections.ts +3 -2
  111. package/front_end/core/sdk/ConsoleModel.ts +6 -5
  112. package/front_end/core/sdk/Cookie.ts +4 -2
  113. package/front_end/core/sdk/DOMDebuggerModel.ts +10 -6
  114. package/front_end/core/sdk/DOMModel.ts +2 -2
  115. package/front_end/core/sdk/DebuggerModel.ts +27 -5
  116. package/front_end/core/sdk/HeapProfilerModel.ts +2 -1
  117. package/front_end/core/sdk/NetworkManager.ts +13 -12
  118. package/front_end/core/sdk/NetworkRequest.ts +1 -1
  119. package/front_end/core/sdk/PageLoad.ts +3 -1
  120. package/front_end/core/sdk/PageResourceLoader.ts +9 -7
  121. package/front_end/core/sdk/ProfileTreeModel.ts +3 -2
  122. package/front_end/core/sdk/RemoteObject.ts +18 -6
  123. package/front_end/core/sdk/ResourceTreeModel.ts +17 -11
  124. package/front_end/core/sdk/ScreenCaptureModel.ts +3 -0
  125. package/front_end/core/sdk/Script.ts +4 -3
  126. package/front_end/core/sdk/ServiceWorkerCacheModel.ts +2 -1
  127. package/front_end/core/sdk/SourceMap.ts +10 -6
  128. package/front_end/core/sdk/SourceMapManager.ts +47 -5
  129. package/front_end/core/sdk/TracingModel.ts +0 -9
  130. package/front_end/devtools_compatibility.js +1 -0
  131. package/front_end/entrypoints/formatter_worker/CSSRuleParser.ts +1 -1
  132. package/front_end/entrypoints/lighthouse_worker/LighthouseWorkerService.ts +10 -3
  133. package/front_end/entrypoints/main/MainImpl.ts +22 -2
  134. package/front_end/generated/InspectorBackendCommands.js +79 -14
  135. package/front_end/generated/SupportedCSSProperties.js +21 -8
  136. package/front_end/generated/protocol-mapping.d.ts +4 -0
  137. package/front_end/generated/protocol-proxy-api.d.ts +5 -0
  138. package/front_end/generated/protocol.ts +158 -28
  139. package/front_end/legacy/legacy-defs.d.ts +0 -4
  140. package/front_end/legacy_test_runner/heap_profiler_test_runner/heap_profiler_test_runner.js +1 -1
  141. package/front_end/legacy_test_runner/test_runner/TestRunner.js +1 -0
  142. package/front_end/models/bindings/BreakpointManager.ts +68 -11
  143. package/front_end/models/bindings/CSSWorkspaceBinding.ts +9 -2
  144. package/front_end/models/bindings/CompilerScriptMapping.ts +3 -2
  145. package/front_end/models/bindings/ContentProviderBasedProject.ts +12 -9
  146. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +10 -8
  147. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +8 -1
  148. package/front_end/models/bindings/DefaultScriptMapping.ts +8 -2
  149. package/front_end/models/bindings/IgnoreListManager.ts +5 -5
  150. package/front_end/models/bindings/ResourceUtils.ts +5 -4
  151. package/front_end/models/emulation/EmulatedDevices.ts +17 -0
  152. package/front_end/models/extensions/ExtensionAPI.ts +5 -2
  153. package/front_end/models/extensions/ExtensionPanel.ts +2 -1
  154. package/front_end/models/extensions/ExtensionServer.ts +13 -8
  155. package/front_end/models/issues_manager/AttributionReportingIssue.ts +0 -63
  156. package/front_end/models/issues_manager/CookieIssue.ts +7 -0
  157. package/front_end/models/issues_manager/DeprecationIssue.ts +326 -8
  158. package/front_end/models/issues_manager/IssuesManager.ts +4 -0
  159. package/front_end/models/issues_manager/descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
  160. package/front_end/models/issues_manager/descriptions/deprecation.md +1 -1
  161. package/front_end/models/logs/LogManager.ts +2 -1
  162. package/front_end/models/logs/NetworkLog.ts +14 -12
  163. package/front_end/models/persistence/Automapping.ts +17 -16
  164. package/front_end/models/persistence/EditFileSystemView.ts +5 -4
  165. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +24 -24
  166. package/front_end/models/persistence/IsolatedFileSystem.ts +2 -2
  167. package/front_end/models/persistence/IsolatedFileSystemManager.ts +7 -6
  168. package/front_end/models/persistence/NetworkPersistenceManager.ts +92 -54
  169. package/front_end/models/persistence/PersistenceImpl.ts +7 -7
  170. package/front_end/models/persistence/PlatformFileSystem.ts +7 -8
  171. package/front_end/models/persistence/WorkspaceSettingsTab.ts +3 -2
  172. package/front_end/models/text_utils/CodeMirrorUtils.ts +53 -0
  173. package/front_end/models/text_utils/text_utils.ts +2 -0
  174. package/front_end/models/timeline_model/TimelineModel.ts +31 -30
  175. package/front_end/models/timeline_model/TimelineProfileTree.ts +3 -2
  176. package/front_end/models/workspace/UISourceCode.ts +16 -14
  177. package/front_end/models/workspace/WorkspaceImpl.ts +40 -16
  178. package/front_end/panels/accessibility/AccessibilitySubPane.ts +2 -1
  179. package/front_end/panels/application/AppManifestView.ts +1 -1
  180. package/front_end/panels/application/ApplicationPanelCacheSection.ts +5 -4
  181. package/front_end/panels/application/ApplicationPanelSidebar.ts +34 -30
  182. package/front_end/panels/application/ApplicationPanelTreeElement.ts +5 -4
  183. package/front_end/panels/application/DatabaseQueryView.ts +2 -1
  184. package/front_end/panels/application/InterestGroupTreeElement.ts +3 -2
  185. package/front_end/panels/application/ReportingApiTreeElement.ts +3 -2
  186. package/front_end/panels/application/ResourcesPanel.ts +4 -3
  187. package/front_end/panels/application/ServiceWorkerCacheViews.ts +6 -1
  188. package/front_end/panels/application/TrustTokensTreeElement.ts +3 -2
  189. package/front_end/panels/application/components/BackForwardCacheStrings.ts +10 -1
  190. package/front_end/panels/application/components/BackForwardCacheView.ts +163 -13
  191. package/front_end/panels/application/components/backForwardCacheView.css +15 -4
  192. package/front_end/panels/browser_debugger/XHRBreakpointsSidebarPane.ts +19 -19
  193. package/front_end/panels/changes/ChangesView.ts +38 -0
  194. package/front_end/panels/console/ConsolePinPane.ts +7 -0
  195. package/front_end/panels/console/ConsolePrompt.ts +11 -1
  196. package/front_end/panels/console/ConsoleSidebar.ts +2 -1
  197. package/front_end/panels/console/ConsoleView.ts +57 -31
  198. package/front_end/panels/console/ConsoleViewMessage.ts +12 -9
  199. package/front_end/panels/console/ConsoleViewport.ts +2 -1
  200. package/front_end/panels/console/ErrorStackParser.ts +8 -4
  201. package/front_end/panels/console/consoleView.css +0 -1
  202. package/front_end/panels/coverage/CoverageListView.ts +1 -1
  203. package/front_end/panels/coverage/CoverageModel.ts +6 -6
  204. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +2 -1
  205. package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +7 -6
  206. package/front_end/panels/css_overview/components/cssOverviewStartView.css +0 -48
  207. package/front_end/panels/css_overview/cssOverviewCompletedView.css +5 -0
  208. package/front_end/panels/css_overview/cssOverviewSidebarPanel.css +2 -0
  209. package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +2 -1
  210. package/front_end/panels/elements/ComputedStyleWidget.ts +2 -1
  211. package/front_end/panels/elements/ElementStatePaneWidget.ts +4 -6
  212. package/front_end/panels/elements/ElementsPanel.ts +16 -5
  213. package/front_end/panels/elements/ImagePreviewPopover.ts +6 -4
  214. package/front_end/panels/elements/PropertiesWidget.ts +4 -24
  215. package/front_end/panels/elements/StyleEditorWidget.ts +2 -1
  216. package/front_end/panels/elements/StylePropertiesSection.ts +1614 -0
  217. package/front_end/panels/elements/StylePropertyHighlighter.ts +2 -1
  218. package/front_end/panels/elements/StylePropertyTreeElement.ts +20 -1
  219. package/front_end/panels/elements/StylesSidebarPane.ts +97 -1675
  220. package/front_end/panels/elements/elements-legacy.ts +3 -3
  221. package/front_end/panels/elements/elements.ts +3 -0
  222. package/front_end/panels/elements/stylesSidebarPane.css +3 -1
  223. package/front_end/panels/input/InputTimeline.ts +1 -1
  224. package/front_end/panels/issues/AttributionReportingIssueDetailsView.ts +0 -50
  225. package/front_end/panels/issues/ComboBoxOfCheckBoxes.ts +14 -2
  226. package/front_end/panels/issues/IssueAggregator.ts +8 -0
  227. package/front_end/panels/issues/issues.ts +2 -0
  228. package/front_end/panels/lighthouse/LighthouseController.ts +5 -1
  229. package/front_end/panels/lighthouse/LighthousePanel.ts +3 -1
  230. package/front_end/panels/lighthouse/LighthouseTimespanView.ts +3 -3
  231. package/front_end/panels/network/BlockedURLsPane.ts +3 -2
  232. package/front_end/panels/network/NetworkConfigView.ts +6 -0
  233. package/front_end/panels/network/NetworkDataGridNode.ts +4 -0
  234. package/front_end/panels/network/NetworkLogView.ts +1 -1
  235. package/front_end/panels/network/RequestHTMLView.ts +1 -0
  236. package/front_end/panels/network/RequestHeadersView.ts +71 -10
  237. package/front_end/panels/network/networkLogView.css +9 -17
  238. package/front_end/panels/network/requestHeadersTree.css +16 -0
  239. package/front_end/panels/profiler/HeapSnapshotView.ts +2 -0
  240. package/front_end/panels/profiler/LiveHeapProfileView.ts +3 -1
  241. package/front_end/panels/profiler/ProfilesPanel.ts +2 -1
  242. package/front_end/panels/profiler/heapProfiler.css +15 -3
  243. package/front_end/panels/screencast/ScreencastView.ts +1 -1
  244. package/front_end/panels/search/SearchConfig.ts +2 -1
  245. package/front_end/panels/settings/KeybindsSettingsTab.ts +3 -2
  246. package/front_end/panels/settings/emulation/components/userAgentClientHintsForm.css +1 -2
  247. package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +4 -4
  248. package/front_end/panels/sources/BreakpointEditDialog.ts +0 -1
  249. package/front_end/panels/sources/CSSPlugin.ts +6 -6
  250. package/front_end/panels/sources/CoveragePlugin.ts +2 -1
  251. package/front_end/panels/sources/DebuggerPlugin.ts +4 -4
  252. package/front_end/panels/sources/EditingLocationHistoryManager.ts +4 -1
  253. package/front_end/panels/sources/NavigatorView.ts +28 -20
  254. package/front_end/panels/sources/SearchSourcesView.ts +2 -2
  255. package/front_end/panels/sources/SourcesNavigator.ts +4 -2
  256. package/front_end/panels/sources/SourcesPanel.ts +4 -4
  257. package/front_end/panels/sources/SourcesSearchScope.ts +12 -8
  258. package/front_end/panels/sources/SourcesView.ts +3 -1
  259. package/front_end/panels/sources/TabbedEditorContainer.ts +1 -1
  260. package/front_end/panels/sources/components/HeadersView.ts +1 -1
  261. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +9 -9
  262. package/front_end/panels/timeline/TimelinePanel.ts +1 -1
  263. package/front_end/panels/timeline/timelinePanel.css +1 -2
  264. package/front_end/panels/utils/utils.ts +97 -0
  265. package/front_end/third_party/codemirror.next/bundle.ts +27 -25
  266. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  267. package/front_end/third_party/codemirror.next/chunk/cpp.js +2 -2
  268. package/front_end/third_party/codemirror.next/chunk/java.js +2 -1
  269. package/front_end/third_party/codemirror.next/chunk/json.js +2 -2
  270. package/front_end/third_party/codemirror.next/chunk/legacy.js +1 -1
  271. package/front_end/third_party/codemirror.next/chunk/markdown.js +2 -2
  272. package/front_end/third_party/codemirror.next/chunk/php.js +2 -1
  273. package/front_end/third_party/codemirror.next/chunk/python.js +2 -2
  274. package/front_end/third_party/codemirror.next/chunk/wast.js +2 -1
  275. package/front_end/third_party/codemirror.next/chunk/xml.js +2 -1
  276. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +1884 -2281
  277. package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
  278. package/front_end/third_party/codemirror.next/package.json +21 -32
  279. package/front_end/third_party/lit-html/README.chromium +3 -3
  280. package/front_end/third_party/lit-html/package/README.md +1 -1
  281. package/front_end/third_party/lit-html/package/async-directive.d.ts +1 -1
  282. package/front_end/third_party/lit-html/package/async-directive.js.map +1 -1
  283. package/front_end/third_party/lit-html/package/development/async-directive.d.ts +1 -1
  284. package/front_end/third_party/lit-html/package/development/async-directive.js.map +1 -1
  285. package/front_end/third_party/lit-html/package/development/directives/choose.d.ts +32 -0
  286. package/front_end/third_party/lit-html/package/development/directives/choose.d.ts.map +1 -0
  287. package/front_end/third_party/lit-html/package/development/directives/choose.js +41 -0
  288. package/front_end/third_party/lit-html/package/development/directives/choose.js.map +1 -0
  289. package/front_end/third_party/lit-html/package/development/directives/join.d.ts +21 -0
  290. package/front_end/third_party/lit-html/package/development/directives/join.d.ts.map +1 -0
  291. package/front_end/third_party/lit-html/package/development/directives/join.js +19 -0
  292. package/front_end/third_party/lit-html/package/development/directives/join.js.map +1 -0
  293. package/front_end/third_party/lit-html/package/development/directives/keyed.d.ts +23 -0
  294. package/front_end/third_party/lit-html/package/development/directives/keyed.d.ts.map +1 -0
  295. package/front_end/third_party/lit-html/package/development/directives/keyed.js +39 -0
  296. package/front_end/third_party/lit-html/package/development/directives/keyed.js.map +1 -0
  297. package/front_end/third_party/lit-html/package/development/directives/map.d.ts +23 -0
  298. package/front_end/third_party/lit-html/package/development/directives/map.d.ts.map +1 -0
  299. package/front_end/third_party/lit-html/package/development/directives/map.js +30 -0
  300. package/front_end/third_party/lit-html/package/development/directives/map.js.map +1 -0
  301. package/front_end/third_party/lit-html/package/development/directives/range.d.ts +24 -0
  302. package/front_end/third_party/lit-html/package/development/directives/range.d.ts.map +1 -0
  303. package/front_end/third_party/lit-html/package/development/directives/range.js +13 -0
  304. package/front_end/third_party/lit-html/package/development/directives/range.js.map +1 -0
  305. package/front_end/third_party/lit-html/package/development/directives/template-content.d.ts +1 -1
  306. package/front_end/third_party/lit-html/package/development/directives/when.d.ts +26 -0
  307. package/front_end/third_party/lit-html/package/development/directives/when.d.ts.map +1 -0
  308. package/front_end/third_party/lit-html/package/development/directives/when.js +9 -0
  309. package/front_end/third_party/lit-html/package/development/directives/when.js.map +1 -0
  310. package/front_end/third_party/lit-html/package/development/lit-html.d.ts +182 -1
  311. package/front_end/third_party/lit-html/package/development/lit-html.d.ts.map +1 -1
  312. package/front_end/third_party/lit-html/package/development/lit-html.js +187 -4
  313. package/front_end/third_party/lit-html/package/development/lit-html.js.map +1 -1
  314. package/front_end/third_party/lit-html/package/development/static.d.ts.map +1 -1
  315. package/front_end/third_party/lit-html/package/development/static.js +7 -0
  316. package/front_end/third_party/lit-html/package/development/static.js.map +1 -1
  317. package/front_end/third_party/lit-html/package/directives/choose.d.ts +32 -0
  318. package/front_end/third_party/lit-html/package/directives/choose.d.ts.map +1 -0
  319. package/front_end/third_party/lit-html/package/directives/choose.js +7 -0
  320. package/front_end/third_party/lit-html/package/directives/choose.js.map +1 -0
  321. package/front_end/third_party/lit-html/package/directives/class-map.js +1 -1
  322. package/front_end/third_party/lit-html/package/directives/guard.js +1 -1
  323. package/front_end/third_party/lit-html/package/directives/join.d.ts +21 -0
  324. package/front_end/third_party/lit-html/package/directives/join.d.ts.map +1 -0
  325. package/front_end/third_party/lit-html/package/directives/join.js +7 -0
  326. package/front_end/third_party/lit-html/package/directives/join.js.map +1 -0
  327. package/front_end/third_party/lit-html/package/directives/keyed.d.ts +23 -0
  328. package/front_end/third_party/lit-html/package/directives/keyed.d.ts.map +1 -0
  329. package/front_end/third_party/lit-html/package/directives/keyed.js +7 -0
  330. package/front_end/third_party/lit-html/package/directives/keyed.js.map +1 -0
  331. package/front_end/third_party/lit-html/package/directives/map.d.ts +23 -0
  332. package/front_end/third_party/lit-html/package/directives/map.d.ts.map +1 -0
  333. package/front_end/third_party/lit-html/package/directives/map.js +7 -0
  334. package/front_end/third_party/lit-html/package/directives/map.js.map +1 -0
  335. package/front_end/third_party/lit-html/package/directives/range.d.ts +24 -0
  336. package/front_end/third_party/lit-html/package/directives/range.d.ts.map +1 -0
  337. package/front_end/third_party/lit-html/package/directives/range.js +7 -0
  338. package/front_end/third_party/lit-html/package/directives/range.js.map +1 -0
  339. package/front_end/third_party/lit-html/package/directives/ref.js +1 -1
  340. package/front_end/third_party/lit-html/package/directives/repeat.js +1 -1
  341. package/front_end/third_party/lit-html/package/directives/style-map.js +1 -1
  342. package/front_end/third_party/lit-html/package/directives/template-content.d.ts +1 -1
  343. package/front_end/third_party/lit-html/package/directives/template-content.js +1 -1
  344. package/front_end/third_party/lit-html/package/directives/unsafe-html.js +1 -1
  345. package/front_end/third_party/lit-html/package/directives/until.js +1 -1
  346. package/front_end/third_party/lit-html/package/directives/when.d.ts +26 -0
  347. package/front_end/third_party/lit-html/package/directives/when.d.ts.map +1 -0
  348. package/front_end/third_party/lit-html/package/directives/when.js +7 -0
  349. package/front_end/third_party/lit-html/package/directives/when.js.map +1 -0
  350. package/front_end/third_party/lit-html/package/lit-html.d.ts +182 -1
  351. package/front_end/third_party/lit-html/package/lit-html.d.ts.map +1 -1
  352. package/front_end/third_party/lit-html/package/lit-html.js +1 -1
  353. package/front_end/third_party/lit-html/package/lit-html.js.map +1 -1
  354. package/front_end/third_party/lit-html/package/package.json +25 -1
  355. package/front_end/third_party/lit-html/package/private-ssr-support.js +1 -1
  356. package/front_end/third_party/lit-html/package/static.d.ts.map +1 -1
  357. package/front_end/third_party/lit-html/package/static.js +1 -1
  358. package/front_end/third_party/lit-html/package/static.js.map +1 -1
  359. package/front_end/third_party/puppeteer/README.chromium +1 -1
  360. package/front_end/third_party/puppeteer/package/README.md +12 -13
  361. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api-docs-entry.js +5 -1
  362. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api-docs-entry.js.map +1 -1
  363. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js +5 -1
  364. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js.map +1 -1
  365. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.d.ts +2 -2
  366. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js +2 -2
  367. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts +2 -2
  368. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  369. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js +13 -6
  370. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js.map +1 -1
  371. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.js +5 -1
  372. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.js.map +1 -1
  373. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.d.ts +1 -0
  374. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.d.ts.map +1 -1
  375. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.js +4 -1
  376. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.js.map +1 -1
  377. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.d.ts +1 -0
  378. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.d.ts.map +1 -1
  379. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.js +10 -0
  380. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.js.map +1 -1
  381. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/PDFOptions.d.ts +4 -2
  382. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/PDFOptions.d.ts.map +1 -1
  383. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/PDFOptions.js.map +1 -1
  384. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.d.ts.map +1 -1
  385. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.js +12 -1
  386. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.js.map +1 -1
  387. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/fetch.js +5 -1
  388. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/fetch.js.map +1 -1
  389. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.d.ts.map +1 -1
  390. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.js +7 -6
  391. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.js.map +1 -1
  392. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.js +8 -1
  393. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.js.map +1 -1
  394. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.js +6 -2
  395. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.js.map +1 -1
  396. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js +6 -2
  397. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js.map +1 -1
  398. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +1 -1
  399. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.d.ts +2 -2
  400. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js +2 -2
  401. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts +2 -2
  402. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  403. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js +13 -6
  404. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js.map +1 -1
  405. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.d.ts +1 -0
  406. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.d.ts.map +1 -1
  407. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.js +4 -1
  408. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.js.map +1 -1
  409. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.d.ts +1 -0
  410. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.d.ts.map +1 -1
  411. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.js +10 -0
  412. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.js.map +1 -1
  413. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/PDFOptions.d.ts +4 -2
  414. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/PDFOptions.d.ts.map +1 -1
  415. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/PDFOptions.js.map +1 -1
  416. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.d.ts.map +1 -1
  417. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.js +12 -1
  418. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.js.map +1 -1
  419. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.d.ts.map +1 -1
  420. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.js +2 -5
  421. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.js.map +1 -1
  422. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js +3 -0
  423. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js.map +1 -1
  424. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.js +1 -1
  425. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.js.map +1 -1
  426. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js +1 -1
  427. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js.map +1 -1
  428. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +1 -1
  429. package/front_end/third_party/puppeteer/package/lib/types.d.ts +10 -6
  430. package/front_end/third_party/puppeteer/package/package.json +17 -17
  431. package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +1 -1
  432. package/front_end/ui/components/data_grid/DataGrid.ts +8 -9
  433. package/front_end/ui/components/data_grid/DataGridController.ts +3 -1
  434. package/front_end/ui/components/docs/panel_introduction_steps/basic.html +25 -0
  435. package/front_end/ui/components/docs/panel_introduction_steps/basic.ts +25 -0
  436. package/front_end/ui/components/input/input.ts +2 -2
  437. package/front_end/ui/components/linkifier/LinkifierUtils.ts +3 -1
  438. package/front_end/ui/components/panel_introduction_steps/PanelIntroductionSteps.ts +44 -0
  439. package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +56 -0
  440. package/front_end/ui/components/panel_introduction_steps/panel_introduction_steps.ts +5 -0
  441. package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +3 -4
  442. package/front_end/ui/components/text_editor/TextEditor.ts +1 -1
  443. package/front_end/ui/components/text_editor/config.ts +1 -35
  444. package/front_end/ui/components/text_editor/javascript.ts +8 -8
  445. package/front_end/ui/components/tree_outline/TreeOutline.ts +10 -9
  446. package/front_end/ui/components/tree_outline/treeOutline.css +1 -1
  447. package/front_end/ui/legacy/ARIAUtils.ts +4 -2
  448. package/front_end/ui/legacy/ContextMenu.ts +14 -0
  449. package/front_end/ui/legacy/DockController.ts +2 -1
  450. package/front_end/ui/legacy/SettingsUI.ts +3 -3
  451. package/front_end/ui/legacy/SoftContextMenu.ts +43 -14
  452. package/front_end/ui/legacy/Toolbar.ts +16 -0
  453. package/front_end/ui/legacy/Treeoutline.ts +17 -7
  454. package/front_end/ui/legacy/UIUtils.ts +2 -2
  455. package/front_end/ui/legacy/View.ts +14 -8
  456. package/front_end/ui/legacy/ViewManager.ts +2 -1
  457. package/front_end/ui/legacy/ViewRegistration.ts +6 -0
  458. package/front_end/ui/legacy/Widget.ts +2 -1
  459. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +43 -11
  460. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +98 -48
  461. package/front_end/ui/legacy/components/data_grid/ViewportDataGrid.ts +4 -3
  462. package/front_end/ui/legacy/components/data_grid/dataGrid.css +24 -28
  463. package/front_end/ui/legacy/components/inline_editor/CSSAngle.ts +5 -11
  464. package/front_end/ui/legacy/components/inline_editor/CSSLength.ts +8 -1
  465. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +10 -7
  466. package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +11 -10
  467. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +7 -1
  468. package/front_end/ui/legacy/components/utils/ImagePreview.ts +12 -7
  469. package/front_end/ui/legacy/components/utils/Linkifier.ts +7 -5
  470. package/front_end/ui/legacy/reportView.css +1 -0
  471. package/front_end/ui/legacy/splitWidget.css +1 -1
  472. package/front_end/ui/legacy/tabbedPane.css +1 -0
  473. package/front_end/ui/legacy/themeColors.css +1 -1
  474. package/front_end/ui/legacy/toolbar.css +17 -1
  475. package/front_end/ui/legacy/utils/focus-changed.ts +3 -1
  476. package/inspector_overlay/.eslintrc.js +9 -0
  477. package/package.json +17 -17
  478. package/scripts/eslint_rules/lib/check_component_naming.js +4 -0
  479. package/scripts/eslint_rules/lib/es_modules_import.js +6 -0
  480. package/scripts/eslint_rules/lib/inject_checkbox_styles.js +121 -0
  481. package/scripts/eslint_rules/tests/es_modules_import_test.js +12 -0
  482. package/scripts/eslint_rules/tests/inject_checkbox_styles_test.js +127 -0
  483. package/front_end/models/issues_manager/descriptions/arAttributionEventSourceTriggerDataTooLarge.md +0 -4
  484. package/front_end/models/issues_manager/descriptions/arAttributionTriggerDataTooLarge.md +0 -4
  485. package/front_end/models/issues_manager/descriptions/arInvalidAttributionData.md +0 -8
  486. package/front_end/models/issues_manager/descriptions/arInvalidEventSourceTriggerData.md +0 -9
  487. package/front_end/models/issues_manager/descriptions/arInvalidTriggerDedupKey.md +0 -5
  488. package/front_end/models/issues_manager/descriptions/arInvalidTriggerPriority.md +0 -5
  489. package/front_end/models/issues_manager/descriptions/arMissingAttributionData.md +0 -7
@@ -39,32 +39,29 @@ import * as Root from '../../core/root/root.js';
39
39
  import * as SDK from '../../core/sdk/sdk.js';
40
40
  import * as Protocol from '../../generated/protocol.js';
41
41
  import * as Bindings from '../../models/bindings/bindings.js';
42
- import * as Formatter from '../../models/formatter/formatter.js';
42
+ import type * as Formatter from '../../models/formatter/formatter.js';
43
43
  import * as TextUtils from '../../models/text_utils/text_utils.js';
44
44
  import * as Workspace from '../../models/workspace/workspace.js';
45
45
  import * as WorkspaceDiff from '../../models/workspace_diff/workspace_diff.js';
46
- import type * as Diff from '../../third_party/diff/diff.js';
46
+ import {formatCSSChangesFromDiff} from '../../panels/utils/utils.js';
47
47
  import * as DiffView from '../../ui/components/diff_view/diff_view.js';
48
48
  import * as IconButton from '../../ui/components/icon_button/icon_button.js';
49
49
  import * as InlineEditor from '../../ui/legacy/components/inline_editor/inline_editor.js';
50
50
  import * as Components from '../../ui/legacy/components/utils/utils.js';
51
51
  import * as UI from '../../ui/legacy/legacy.js';
52
52
 
53
- import {FontEditorSectionManager} from './ColorSwatchPopoverIcon.js';
54
53
  import * as ElementsComponents from './components/components.js';
55
54
  import type {ComputedStyleChangedEvent} from './ComputedStyleModel.js';
56
55
  import {ComputedStyleModel} from './ComputedStyleModel.js';
57
- import {linkifyDeferredNodeReference} from './DOMLinkifier.js';
58
56
  import {ElementsPanel} from './ElementsPanel.js';
59
57
  import {ElementsSidebarPane} from './ElementsSidebarPane.js';
60
58
  import {ImagePreviewPopover} from './ImagePreviewPopover.js';
61
59
  import {StyleEditorWidget} from './StyleEditorWidget.js';
62
60
  import {StylePropertyHighlighter} from './StylePropertyHighlighter.js';
63
- import stylesSectionTreeStyles from './stylesSectionTree.css.js';
64
61
  import stylesSidebarPaneStyles from './stylesSidebarPane.css.js';
65
62
 
66
- import type {Context} from './StylePropertyTreeElement.js';
67
- import {StylePropertyTreeElement} from './StylePropertyTreeElement.js';
63
+ import type {StylePropertyTreeElement} from './StylePropertyTreeElement.js';
64
+ import {StylePropertiesSection, BlankStylePropertiesSection, KeyframePropertiesSection, HighlightPseudoStylePropertiesSection} from './StylePropertiesSection.js';
68
65
  import * as LayersWidget from './LayersWidget.js';
69
66
 
70
67
  const UIStrings = {
@@ -98,51 +95,10 @@ const UIStrings = {
98
95
  */
99
96
  inheritedFroms: 'Inherited from ',
100
97
  /**
101
- *@description Tooltip text that appears when hovering over the largeicon add button in the Styles Sidebar Pane of the Elements panel
102
- */
103
- insertStyleRuleBelow: 'Insert Style Rule Below',
104
- /**
105
- *@description Text in Styles Sidebar Pane of the Elements panel
106
- */
107
- constructedStylesheet: 'constructed stylesheet',
108
- /**
109
- *@description Text in Styles Sidebar Pane of the Elements panel
110
- */
111
- userAgentStylesheet: 'user agent stylesheet',
112
- /**
113
- *@description Text in Styles Sidebar Pane of the Elements panel
114
- */
115
- injectedStylesheet: 'injected stylesheet',
116
- /**
117
- *@description Text in Styles Sidebar Pane of the Elements panel
118
- */
119
- viaInspector: 'via inspector',
120
- /**
121
- *@description Text in Styles Sidebar Pane of the Elements panel
98
+ *@description Text of an inherited psuedo element in Styles Sidebar Pane of the Elements panel
99
+ *@example {highlight} PH1
122
100
  */
123
- styleAttribute: '`style` attribute',
124
- /**
125
- *@description Text in Styles Sidebar Pane of the Elements panel
126
- *@example {html} PH1
127
- */
128
- sattributesStyle: '{PH1}[Attributes Style]',
129
- /**
130
- *@description Show all button text content in Styles Sidebar Pane of the Elements panel
131
- *@example {3} PH1
132
- */
133
- showAllPropertiesSMore: 'Show All Properties ({PH1} more)',
134
- /**
135
- *@description Text in Elements Tree Element of the Elements panel, copy should be used as a verb
136
- */
137
- copySelector: 'Copy `selector`',
138
- /**
139
- *@description A context menu item in Styles panel to copy CSS rule
140
- */
141
- copyRule: 'Copy rule',
142
- /**
143
- *@description A context menu item in Styles panel to copy all CSS declarations
144
- */
145
- copyAllDeclarations: 'Copy all declarations',
101
+ inheritedFromSPseudoOf: 'Inherited from ::{PH1} pseudo of ',
146
102
  /**
147
103
  *@description Title of in styles sidebar pane of the elements panel
148
104
  *@example {Ctrl} PH1
@@ -177,17 +133,13 @@ const UIStrings = {
177
133
  */
178
134
  cssPropertyValue: '`CSS` property value: {PH1}',
179
135
  /**
180
- *@description Text that is announced by the screen reader when the user focuses on an input field for editing the name of a CSS selector in the Styles panel
181
- */
182
- cssSelector: '`CSS` selector',
183
- /**
184
- *@description Tooltip text that appears when hovering over the css changes button in the Styles Sidebar Pane of the Elements panel
136
+ *@description Tooltip text that appears when hovering over the rendering button in the Styles Sidebar Pane of the Elements panel
185
137
  */
186
- copyAllCSSChanges: 'Copy all the CSS changes',
138
+ toggleRenderingEmulations: 'Toggle common rendering emulations',
187
139
  /**
188
- *@description Tooltip text that appears after clicking on the copy CSS changes button
140
+ *@description Rendering emulation option for toggling the automatic dark mode
189
141
  */
190
- copiedToClipboard: 'Copied to clipboard',
142
+ automaticDarkMode: 'Automatic dark mode',
191
143
  /**
192
144
  *@description Text displayed on layer separators in the styles sidebar pane.
193
145
  */
@@ -221,11 +173,6 @@ const HIGHLIGHTABLE_PROPERTIES = [
221
173
 
222
174
  let stylesSidebarPaneInstance: StylesSidebarPane;
223
175
 
224
- // TODO(crbug.com/1172300) This workaround is needed to keep the linter happy.
225
- // Otherwise it complains about: Unknown word CssSyntaxError
226
- const STYLE_TAG = '<' +
227
- 'style>';
228
-
229
176
  export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventTypes, typeof ElementsSidebarPane>(
230
177
  ElementsSidebarPane) {
231
178
  private currentToolbarPane: UI.Widget.Widget|null;
@@ -253,7 +200,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
253
200
  private readonly resizeThrottler: Common.Throttler.Throttler;
254
201
  private readonly imagePreviewPopover: ImagePreviewPopover;
255
202
  activeCSSAngle: InlineEditor.CSSAngle.CSSAngle|null;
256
- #urlToChangeTracker: Map<string, ChangeTracker> = new Map();
203
+ #urlToChangeTracker: Map<Platform.DevToolsPath.UrlString, ChangeTracker> = new Map();
257
204
 
258
205
  static instance(): StylesSidebarPane {
259
206
  if (!stylesSidebarPaneInstance) {
@@ -465,7 +412,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
465
412
  }
466
413
 
467
414
  private sectionsContainerKeyDown(event: Event): void {
468
- const activeElement = this.sectionsContainer.ownerDocument.deepActiveElement();
415
+ const activeElement = Platform.DOMUtilities.deepActiveElement(this.sectionsContainer.ownerDocument);
469
416
  if (!activeElement) {
470
417
  return;
471
418
  }
@@ -625,9 +572,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
625
572
  await this.innerRebuildUpdate(matchedStyles);
626
573
  if (!this.initialUpdateCompleted) {
627
574
  this.initialUpdateCompleted = true;
628
- if (Root.Runtime.experiments.isEnabled(Root.Runtime.ExperimentName.STYLES_PANE_CSS_CHANGES)) {
629
- this.appendToolbarItem(this.createCopyAllChangesButton());
630
- }
575
+ this.appendToolbarItem(this.createRenderingShortcuts());
631
576
  this.dispatchEventToListeners(Events.InitialUpdateCompleted);
632
577
  }
633
578
 
@@ -921,14 +866,32 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
921
866
  }
922
867
  pseudoTypes = pseudoTypes.concat([...keys].sort());
923
868
  for (const pseudoType of pseudoTypes) {
924
- blocks.push(SectionBlock.createPseudoTypeBlock(pseudoType));
925
- lastLayers = null;
869
+ lastParentNode = null;
870
+ const pseudoStyles = matchedStyles.pseudoStyles(pseudoType);
871
+ for (let i = 0; i < pseudoStyles.length; ++i) {
872
+ const style = pseudoStyles[i];
873
+ const parentNode = matchedStyles.isInherited(style) ? matchedStyles.nodeForStyle(style) : null;
874
+
875
+ // Start a new SectionBlock if this is the first rule for this pseudo type, or if this
876
+ // rule is inherited from a different parent than the previous rule.
877
+ if (i === 0 || parentNode !== lastParentNode) {
878
+ lastLayers = null;
879
+ if (parentNode) {
880
+ const block = await SectionBlock.createInheritedPseudoTypeBlock(pseudoType, parentNode);
881
+ blocks.push(block);
882
+ } else {
883
+ const block = SectionBlock.createPseudoTypeBlock(pseudoType);
884
+ blocks.push(block);
885
+ }
886
+ }
887
+ lastParentNode = parentNode;
926
888
 
927
- for (const style of matchedStyles.pseudoStyles(pseudoType)) {
928
889
  addLayerSeparator(style);
929
890
  const lastBlock = blocks[blocks.length - 1];
930
891
  this.idleCallbackManager.schedule(() => {
931
- const section = new StylePropertiesSection(this, matchedStyles, style, sectionIdx);
892
+ const section = SDK.CSSMetadata.cssMetadata().isHighlightPseudoType(pseudoType) ?
893
+ new HighlightPseudoStylePropertiesSection(this, matchedStyles, style, sectionIdx) :
894
+ new StylePropertiesSection(this, matchedStyles, style, sectionIdx);
932
895
  sectionIdx++;
933
896
  lastBlock.sections.push(section);
934
897
  });
@@ -1064,7 +1027,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
1064
1027
  return sections;
1065
1028
  }
1066
1029
 
1067
- async trackURLForChanges(url: string): Promise<void> {
1030
+ async trackURLForChanges(url: Platform.DevToolsPath.UrlString): Promise<void> {
1068
1031
  const currentTracker = this.#urlToChangeTracker.get(url);
1069
1032
  if (currentTracker) {
1070
1033
  WorkspaceDiff.WorkspaceDiff.workspaceDiff().unsubscribeFromDiffChange(
@@ -1132,7 +1095,7 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
1132
1095
  changeTracker.formattedCurrentMapping = formattedCurrentMapping;
1133
1096
  }
1134
1097
 
1135
- private async getFormattedChanges(): Promise<string> {
1098
+ async getFormattedChanges(): Promise<string> {
1136
1099
  let allChanges = '';
1137
1100
  for (const [url, {uiSourceCode}] of this.#urlToChangeTracker) {
1138
1101
  const diffResponse =
@@ -1244,32 +1207,52 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
1244
1207
  }
1245
1208
  }
1246
1209
 
1247
- private createCopyAllChangesButton(): UI.Toolbar.ToolbarButton {
1248
- const copyAllIcon = new IconButton.Icon.Icon();
1249
- copyAllIcon.data = {
1250
- iconName: 'ic_changes',
1210
+ private createRenderingShortcuts(): UI.Toolbar.ToolbarButton {
1211
+ const prefersColorSchemeSetting =
1212
+ Common.Settings.Settings.instance().moduleSetting<string>('emulatedCSSMediaFeaturePrefersColorScheme');
1213
+ const autoDarkModeSetting = Common.Settings.Settings.instance().moduleSetting('emulateAutoDarkMode');
1214
+ const decorateStatus = (condition: boolean, title: string): string => `${condition ? '✓ ' : ''}${title}`;
1215
+
1216
+ const icon = new IconButton.Icon.Icon();
1217
+ icon.data = {
1218
+ iconName: 'ic_rendering',
1251
1219
  color: 'var(--color-text-secondary)',
1252
1220
  width: '18px',
1253
1221
  height: '18px',
1254
1222
  };
1255
- const copyAllChangesButton = new UI.Toolbar.ToolbarButton(i18nString(UIStrings.copyAllCSSChanges), copyAllIcon);
1256
- // TODO(1296947): implement a dedicated component to share between all copy buttons
1257
- copyAllChangesButton.element.setAttribute('data-content', i18nString(UIStrings.copiedToClipboard));
1258
- let timeout: number|undefined;
1259
- copyAllChangesButton.addEventListener(UI.Toolbar.ToolbarButton.Events.Click, async () => {
1260
- const allChanges = await this.getFormattedChanges();
1261
- Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(allChanges);
1262
- if (timeout) {
1263
- clearTimeout(timeout);
1264
- timeout = undefined;
1265
- }
1266
- copyAllChangesButton.element.classList.add('copied-to-clipboard');
1267
- timeout = window.setTimeout(() => {
1268
- copyAllChangesButton.element.classList.remove('copied-to-clipboard');
1269
- timeout = undefined;
1270
- }, 2000);
1271
- });
1272
- return copyAllChangesButton;
1223
+ const button = new UI.Toolbar.ToolbarToggle(i18nString(UIStrings.toggleRenderingEmulations), icon);
1224
+ button.setToggleWithDot(true);
1225
+
1226
+ button.element.addEventListener('click', event => {
1227
+ const menu = new UI.ContextMenu.ContextMenu(event);
1228
+ const preferredColorScheme = prefersColorSchemeSetting.get();
1229
+ const isLightColorScheme = preferredColorScheme === 'light';
1230
+ const isDarkColorScheme = preferredColorScheme === 'dark';
1231
+ const isAutoDarkEnabled = autoDarkModeSetting.get();
1232
+ const lightColorSchemeOption = decorateStatus(isLightColorScheme, 'prefers-color-scheme: light');
1233
+ const darkColorSchemeOption = decorateStatus(isDarkColorScheme, 'prefers-color-scheme: dark');
1234
+ const autoDarkModeOption = decorateStatus(isAutoDarkEnabled, i18nString(UIStrings.automaticDarkMode));
1235
+
1236
+ menu.defaultSection().appendItem(lightColorSchemeOption, () => {
1237
+ autoDarkModeSetting.set(false);
1238
+ prefersColorSchemeSetting.set(isLightColorScheme ? '' : 'light');
1239
+ button.setToggled(Boolean(prefersColorSchemeSetting.get()));
1240
+ });
1241
+ menu.defaultSection().appendItem(darkColorSchemeOption, () => {
1242
+ autoDarkModeSetting.set(false);
1243
+ prefersColorSchemeSetting.set(isDarkColorScheme ? '' : 'dark');
1244
+ button.setToggled(Boolean(prefersColorSchemeSetting.get()));
1245
+ });
1246
+ menu.defaultSection().appendItem(autoDarkModeOption, () => {
1247
+ autoDarkModeSetting.set(!isAutoDarkEnabled);
1248
+ button.setToggled(Boolean(prefersColorSchemeSetting.get()));
1249
+ });
1250
+
1251
+ void menu.show();
1252
+ event.stopPropagation();
1253
+ }, {capture: true});
1254
+
1255
+ return button;
1273
1256
  }
1274
1257
  }
1275
1258
 
@@ -1294,102 +1277,6 @@ type ChangeTracker = {
1294
1277
  formattedCurrentMapping?: Formatter.ScriptFormatter.FormatterSourceMapping,
1295
1278
  };
1296
1279
 
1297
- export async function formatCSSChangesFromDiff(diff: Diff.Diff.DiffArray): Promise<string> {
1298
- const {originalLines, currentLines, rows} = DiffView.DiffView.buildDiffRows(diff);
1299
-
1300
- const {propertyToSelector: originalPropertyToSelector, ruleToSelector: originalRuleToSelector} =
1301
- await buildPropertyRuleMaps(originalLines.join('\n'));
1302
- const {propertyToSelector: currentPropertyToSelector, ruleToSelector: currentRuleToSelector} =
1303
- await buildPropertyRuleMaps(currentLines.join('\n'));
1304
- let changes = '';
1305
- let recordedOriginalSelector, recordedCurrentSelector;
1306
- for (const {currentLineNumber, originalLineNumber, type} of rows) {
1307
- // diff line arrays starts at 0, but line numbers start at 1.
1308
- const currentLineIndex = currentLineNumber - 1;
1309
- const originalLineIndex = originalLineNumber - 1;
1310
- switch (type) {
1311
- case DiffView.DiffView.RowType.Deletion: {
1312
- const originalLine = originalLines[originalLineIndex].trim();
1313
- if (originalRuleToSelector.has(originalLineIndex)) {
1314
- changes += `/* ${originalLine} { */\n`;
1315
- recordedOriginalSelector = originalLine;
1316
- continue;
1317
- }
1318
-
1319
- const originalSelector = originalPropertyToSelector.get(originalLineIndex);
1320
- if (!originalSelector) {
1321
- continue;
1322
- }
1323
- if (originalSelector !== recordedOriginalSelector && originalSelector !== recordedCurrentSelector) {
1324
- if (recordedOriginalSelector || recordedCurrentSelector) {
1325
- changes += '}\n\n';
1326
- }
1327
- changes += `${originalSelector} {\n`;
1328
- }
1329
- recordedOriginalSelector = originalSelector;
1330
- changes += ` /* ${originalLine} */\n`;
1331
- break;
1332
- }
1333
- case DiffView.DiffView.RowType.Addition: {
1334
- const currentLine = currentLines[currentLineIndex].trim();
1335
- if (currentRuleToSelector.has(currentLineIndex)) {
1336
- changes += `${currentLine} {\n`;
1337
- recordedCurrentSelector = currentLine;
1338
- continue;
1339
- }
1340
-
1341
- const currentSelector = currentPropertyToSelector.get(currentLineIndex);
1342
- if (!currentSelector) {
1343
- continue;
1344
- }
1345
- if (currentSelector !== recordedOriginalSelector && currentSelector !== recordedCurrentSelector) {
1346
- if (recordedOriginalSelector || recordedCurrentSelector) {
1347
- changes += '}\n\n';
1348
- }
1349
- changes += `${currentSelector} {\n`;
1350
- }
1351
- recordedCurrentSelector = currentSelector;
1352
- changes += ` ${currentLine}\n`;
1353
- break;
1354
- }
1355
- default:
1356
- break;
1357
- }
1358
- }
1359
- if (changes.length > 0) {
1360
- changes += '}';
1361
- }
1362
- return changes;
1363
- }
1364
-
1365
- async function buildPropertyRuleMaps(content: string):
1366
- Promise<{propertyToSelector: Map<number, string>, ruleToSelector: Map<number, string>}> {
1367
- const rules = await new Promise<Formatter.FormatterWorkerPool.CSSRule[]>(res => {
1368
- const rules: Formatter.FormatterWorkerPool.CSSRule[] = [];
1369
- Formatter.FormatterWorkerPool.formatterWorkerPool().parseCSS(content, (isLastChunk, currentRules) => {
1370
- rules.push(...currentRules);
1371
- if (isLastChunk) {
1372
- res(rules);
1373
- }
1374
- });
1375
- });
1376
- const propertyToSelector = new Map<number, string>();
1377
- const ruleToSelector = new Map<number, string>();
1378
- for (const rule of rules) {
1379
- if ('styleRange' in rule) {
1380
- const selector = rule.selectorText.split('\n').pop()?.trim();
1381
- if (!selector) {
1382
- continue;
1383
- }
1384
- ruleToSelector.set(rule.styleRange.startLine, selector);
1385
- for (const property of rule.properties) {
1386
- propertyToSelector.set(property.range.startLine, selector);
1387
- }
1388
- }
1389
- }
1390
- return {propertyToSelector, ruleToSelector};
1391
- }
1392
-
1393
1280
  const MAX_LINK_LENGTH = 23;
1394
1281
 
1395
1282
  export class SectionBlock {
@@ -1407,6 +1294,20 @@ export class SectionBlock {
1407
1294
  return new SectionBlock(separatorElement);
1408
1295
  }
1409
1296
 
1297
+ static async createInheritedPseudoTypeBlock(pseudoType: Protocol.DOM.PseudoType, node: SDK.DOMModel.DOMNode):
1298
+ Promise<SectionBlock> {
1299
+ const separatorElement = document.createElement('div');
1300
+ separatorElement.className = 'sidebar-separator';
1301
+
1302
+ UI.UIUtils.createTextChild(separatorElement, i18nString(UIStrings.inheritedFromSPseudoOf, {PH1: pseudoType}));
1303
+ const link = await Common.Linkifier.Linkifier.linkify(node, {
1304
+ preventKeyboardFocus: true,
1305
+ tooltip: undefined,
1306
+ });
1307
+ separatorElement.appendChild(link);
1308
+ return new SectionBlock(separatorElement);
1309
+ }
1310
+
1410
1311
  static createKeyframesBlock(keyframesName: string): SectionBlock {
1411
1312
  const separatorElement = document.createElement('div');
1412
1313
  separatorElement.className = 'sidebar-separator';
@@ -1501,1485 +1402,6 @@ export class IdleCallbackManager {
1501
1402
  }
1502
1403
  }
1503
1404
 
1504
- export class StylePropertiesSection {
1505
- protected parentPane: StylesSidebarPane;
1506
- styleInternal: SDK.CSSStyleDeclaration.CSSStyleDeclaration;
1507
- readonly matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
1508
- editable: boolean;
1509
- private hoverTimer: number|null;
1510
- private willCauseCancelEditing: boolean;
1511
- private forceShowAll: boolean;
1512
- private readonly originalPropertiesCount: number;
1513
- element: HTMLDivElement;
1514
- private readonly innerElement: HTMLElement;
1515
- private readonly titleElement: HTMLElement;
1516
- propertiesTreeOutline: UI.TreeOutline.TreeOutlineInShadow;
1517
- private showAllButton: HTMLButtonElement;
1518
- protected selectorElement: HTMLSpanElement;
1519
- private readonly newStyleRuleToolbar: UI.Toolbar.Toolbar|undefined;
1520
- private readonly fontEditorToolbar: UI.Toolbar.Toolbar|undefined;
1521
- private readonly fontEditorSectionManager: FontEditorSectionManager|undefined;
1522
- private readonly fontEditorButton: UI.Toolbar.ToolbarButton|undefined;
1523
- private selectedSinceMouseDown: boolean;
1524
- private readonly elementToSelectorIndex: WeakMap<Element, number>;
1525
- navigable: boolean|null|undefined;
1526
- protected readonly selectorRefElement: HTMLElement;
1527
- private readonly selectorContainer: HTMLDivElement;
1528
- private readonly fontPopoverIcon: FontEditorSectionManager|null;
1529
- private hoverableSelectorsMode: boolean;
1530
- private isHiddenInternal: boolean;
1531
-
1532
- private queryListElement: HTMLElement;
1533
-
1534
- // Used to identify buttons that trigger a flexbox or grid editor.
1535
- nextEditorTriggerButtonIdx = 1;
1536
- private sectionIdx = 0;
1537
-
1538
- constructor(
1539
- parentPane: StylesSidebarPane, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
1540
- style: SDK.CSSStyleDeclaration.CSSStyleDeclaration, sectionIdx: number) {
1541
- this.parentPane = parentPane;
1542
- this.sectionIdx = sectionIdx;
1543
- this.styleInternal = style;
1544
- this.matchedStyles = matchedStyles;
1545
- this.editable = Boolean(style.styleSheetId && style.range);
1546
- this.hoverTimer = null;
1547
- this.willCauseCancelEditing = false;
1548
- this.forceShowAll = false;
1549
- this.originalPropertiesCount = style.leadingProperties().length;
1550
-
1551
- const rule = style.parentRule;
1552
- this.element = document.createElement('div');
1553
- this.element.classList.add('styles-section');
1554
- this.element.classList.add('matched-styles');
1555
- this.element.classList.add('monospace');
1556
- UI.ARIAUtils.setAccessibleName(this.element, `${this.headerText()}, css selector`);
1557
- this.element.tabIndex = -1;
1558
- UI.ARIAUtils.markAsListitem(this.element);
1559
- this.element.addEventListener('keydown', this.onKeyDown.bind(this), false);
1560
- parentPane.sectionByElement.set(this.element, this);
1561
- this.innerElement = this.element.createChild('div');
1562
-
1563
- this.titleElement = this.innerElement.createChild('div', 'styles-section-title ' + (rule ? 'styles-selector' : ''));
1564
-
1565
- this.propertiesTreeOutline = new UI.TreeOutline.TreeOutlineInShadow();
1566
- this.propertiesTreeOutline.setFocusable(false);
1567
- this.propertiesTreeOutline.registerCSSFiles([stylesSectionTreeStyles]);
1568
- this.propertiesTreeOutline.element.classList.add('style-properties', 'matched-styles', 'monospace');
1569
- // @ts-ignore TODO: fix ad hoc section property in a separate CL to be safe
1570
- this.propertiesTreeOutline.section = this;
1571
- this.innerElement.appendChild(this.propertiesTreeOutline.element);
1572
-
1573
- this.showAllButton = UI.UIUtils.createTextButton('', this.showAllItems.bind(this), 'styles-show-all');
1574
- this.innerElement.appendChild(this.showAllButton);
1575
-
1576
- const selectorContainer = document.createElement('div');
1577
- this.selectorElement = document.createElement('span');
1578
- UI.ARIAUtils.setAccessibleName(this.selectorElement, i18nString(UIStrings.cssSelector));
1579
- this.selectorElement.classList.add('selector');
1580
- this.selectorElement.textContent = this.headerText();
1581
- selectorContainer.appendChild(this.selectorElement);
1582
- this.selectorElement.addEventListener('mouseenter', this.onMouseEnterSelector.bind(this), false);
1583
- this.selectorElement.addEventListener('mousemove', event => event.consume(), false);
1584
- this.selectorElement.addEventListener('mouseleave', this.onMouseOutSelector.bind(this), false);
1585
-
1586
- const openBrace = selectorContainer.createChild('span', 'sidebar-pane-open-brace');
1587
- openBrace.textContent = ' {';
1588
- selectorContainer.addEventListener('mousedown', this.handleEmptySpaceMouseDown.bind(this), false);
1589
- selectorContainer.addEventListener('click', this.handleSelectorContainerClick.bind(this), false);
1590
-
1591
- const closeBrace = this.innerElement.createChild('div', 'sidebar-pane-closing-brace');
1592
- closeBrace.textContent = '}';
1593
-
1594
- if (this.styleInternal.parentRule) {
1595
- const newRuleButton = new UI.Toolbar.ToolbarButton(i18nString(UIStrings.insertStyleRuleBelow), 'largeicon-add');
1596
- newRuleButton.addEventListener(UI.Toolbar.ToolbarButton.Events.Click, this.onNewRuleClick, this);
1597
- newRuleButton.element.tabIndex = -1;
1598
- if (!this.newStyleRuleToolbar) {
1599
- this.newStyleRuleToolbar =
1600
- new UI.Toolbar.Toolbar('sidebar-pane-section-toolbar new-rule-toolbar', this.innerElement);
1601
- }
1602
- this.newStyleRuleToolbar.appendToolbarItem(newRuleButton);
1603
- UI.ARIAUtils.markAsHidden(this.newStyleRuleToolbar.element);
1604
- }
1605
-
1606
- if (Root.Runtime.experiments.isEnabled('fontEditor') && this.editable) {
1607
- this.fontEditorToolbar = new UI.Toolbar.Toolbar('sidebar-pane-section-toolbar', this.innerElement);
1608
- this.fontEditorSectionManager = new FontEditorSectionManager(this.parentPane.swatchPopoverHelper(), this);
1609
- this.fontEditorButton = new UI.Toolbar.ToolbarButton('Font Editor', 'largeicon-font-editor');
1610
- this.fontEditorButton.addEventListener(UI.Toolbar.ToolbarButton.Events.Click, () => {
1611
- this.onFontEditorButtonClicked();
1612
- }, this);
1613
- this.fontEditorButton.element.addEventListener('keydown', event => {
1614
- if (isEnterOrSpaceKey(event)) {
1615
- event.consume(true);
1616
- this.onFontEditorButtonClicked();
1617
- }
1618
- }, false);
1619
- this.fontEditorToolbar.appendToolbarItem(this.fontEditorButton);
1620
-
1621
- if (this.styleInternal.type === SDK.CSSStyleDeclaration.Type.Inline) {
1622
- if (this.newStyleRuleToolbar) {
1623
- this.newStyleRuleToolbar.element.classList.add('shifted-toolbar');
1624
- }
1625
- } else {
1626
- this.fontEditorToolbar.element.classList.add('font-toolbar-hidden');
1627
- }
1628
- }
1629
-
1630
- this.selectorElement.addEventListener('click', this.handleSelectorClick.bind(this), false);
1631
- this.element.addEventListener('contextmenu', this.handleContextMenuEvent.bind(this), false);
1632
- this.element.addEventListener('mousedown', this.handleEmptySpaceMouseDown.bind(this), false);
1633
- this.element.addEventListener('click', this.handleEmptySpaceClick.bind(this), false);
1634
- this.element.addEventListener('mousemove', this.onMouseMove.bind(this), false);
1635
- this.element.addEventListener('mouseleave', this.onMouseLeave.bind(this), false);
1636
- this.selectedSinceMouseDown = false;
1637
-
1638
- this.elementToSelectorIndex = new WeakMap();
1639
-
1640
- if (rule) {
1641
- // Prevent editing the user agent and user rules.
1642
- if (rule.isUserAgent() || rule.isInjected()) {
1643
- this.editable = false;
1644
- } else {
1645
- // Check this is a real CSSRule, not a bogus object coming from BlankStylePropertiesSection.
1646
- if (rule.styleSheetId) {
1647
- const header = rule.cssModel().styleSheetHeaderForId(rule.styleSheetId);
1648
- this.navigable = header && !header.isAnonymousInlineStyleSheet();
1649
- }
1650
- }
1651
- }
1652
-
1653
- this.queryListElement = this.titleElement.createChild('div', 'query-list query-matches');
1654
- this.selectorRefElement = this.titleElement.createChild('div', 'styles-section-subtitle');
1655
- this.updateQueryList();
1656
- this.updateRuleOrigin();
1657
- this.titleElement.appendChild(selectorContainer);
1658
- this.selectorContainer = selectorContainer;
1659
-
1660
- if (this.navigable) {
1661
- this.element.classList.add('navigable');
1662
- }
1663
-
1664
- if (!this.editable) {
1665
- this.element.classList.add('read-only');
1666
- this.propertiesTreeOutline.element.classList.add('read-only');
1667
- }
1668
- this.fontPopoverIcon = null;
1669
- this.hoverableSelectorsMode = false;
1670
- this.isHiddenInternal = false;
1671
- this.markSelectorMatches();
1672
- this.onpopulate();
1673
- }
1674
-
1675
- setSectionIdx(sectionIdx: number): void {
1676
- this.sectionIdx = sectionIdx;
1677
- this.onpopulate();
1678
- }
1679
-
1680
- getSectionIdx(): number {
1681
- return this.sectionIdx;
1682
- }
1683
-
1684
- registerFontProperty(treeElement: StylePropertyTreeElement): void {
1685
- if (this.fontEditorSectionManager) {
1686
- this.fontEditorSectionManager.registerFontProperty(treeElement);
1687
- }
1688
- if (this.fontEditorToolbar) {
1689
- this.fontEditorToolbar.element.classList.remove('font-toolbar-hidden');
1690
- if (this.newStyleRuleToolbar) {
1691
- this.newStyleRuleToolbar.element.classList.add('shifted-toolbar');
1692
- }
1693
- }
1694
- }
1695
-
1696
- resetToolbars(): void {
1697
- if (this.parentPane.swatchPopoverHelper().isShowing() ||
1698
- this.styleInternal.type === SDK.CSSStyleDeclaration.Type.Inline) {
1699
- return;
1700
- }
1701
- if (this.fontEditorToolbar) {
1702
- this.fontEditorToolbar.element.classList.add('font-toolbar-hidden');
1703
- }
1704
- if (this.newStyleRuleToolbar) {
1705
- this.newStyleRuleToolbar.element.classList.remove('shifted-toolbar');
1706
- }
1707
- }
1708
-
1709
- static createRuleOriginNode(
1710
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, linkifier: Components.Linkifier.Linkifier,
1711
- rule: SDK.CSSRule.CSSRule|null): Node {
1712
- if (!rule) {
1713
- return document.createTextNode('');
1714
- }
1715
-
1716
- const ruleLocation = this.getRuleLocationFromCSSRule(rule);
1717
-
1718
- const header = rule.styleSheetId ? matchedStyles.cssModel().styleSheetHeaderForId(rule.styleSheetId) : null;
1719
-
1720
- function linkifyRuleLocation(): Node|null {
1721
- if (!rule) {
1722
- return null;
1723
- }
1724
- if (ruleLocation && rule.styleSheetId && header && !header.isAnonymousInlineStyleSheet()) {
1725
- return StylePropertiesSection.linkifyRuleLocation(
1726
- matchedStyles.cssModel(), linkifier, rule.styleSheetId, ruleLocation);
1727
- }
1728
- return null;
1729
- }
1730
-
1731
- function linkifyNode(label: string): Node|null {
1732
- if (header?.ownerNode) {
1733
- const link = linkifyDeferredNodeReference(header.ownerNode, {
1734
- preventKeyboardFocus: false,
1735
- tooltip: undefined,
1736
- });
1737
- link.textContent = label;
1738
- return link;
1739
- }
1740
- return null;
1741
- }
1742
-
1743
- if (header?.isMutable && !header.isViaInspector()) {
1744
- const location = header.isConstructedByNew() ? null : linkifyRuleLocation();
1745
- if (location) {
1746
- return location;
1747
- }
1748
- const label = header.isConstructedByNew() ? i18nString(UIStrings.constructedStylesheet) : STYLE_TAG;
1749
- const node = linkifyNode(label);
1750
- if (node) {
1751
- return node;
1752
- }
1753
- return document.createTextNode(label);
1754
- }
1755
-
1756
- const location = linkifyRuleLocation();
1757
- if (location) {
1758
- return location;
1759
- }
1760
-
1761
- if (rule.isUserAgent()) {
1762
- return document.createTextNode(i18nString(UIStrings.userAgentStylesheet));
1763
- }
1764
- if (rule.isInjected()) {
1765
- return document.createTextNode(i18nString(UIStrings.injectedStylesheet));
1766
- }
1767
- if (rule.isViaInspector()) {
1768
- return document.createTextNode(i18nString(UIStrings.viaInspector));
1769
- }
1770
-
1771
- const node = linkifyNode(STYLE_TAG);
1772
- if (node) {
1773
- return node;
1774
- }
1775
-
1776
- return document.createTextNode('');
1777
- }
1778
-
1779
- private static getRuleLocationFromCSSRule(rule: SDK.CSSRule.CSSRule): TextUtils.TextRange.TextRange|null|undefined {
1780
- let ruleLocation;
1781
- if (rule instanceof SDK.CSSRule.CSSStyleRule) {
1782
- ruleLocation = rule.style.range;
1783
- } else if (rule instanceof SDK.CSSRule.CSSKeyframeRule) {
1784
- ruleLocation = rule.key().range;
1785
- }
1786
- return ruleLocation;
1787
- }
1788
-
1789
- static tryNavigateToRuleLocation(
1790
- matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, rule: SDK.CSSRule.CSSRule|null): void {
1791
- if (!rule) {
1792
- return;
1793
- }
1794
-
1795
- const ruleLocation = this.getRuleLocationFromCSSRule(rule);
1796
- const header = rule.styleSheetId ? matchedStyles.cssModel().styleSheetHeaderForId(rule.styleSheetId) : null;
1797
-
1798
- if (ruleLocation && rule.styleSheetId && header && !header.isAnonymousInlineStyleSheet()) {
1799
- const matchingSelectorLocation =
1800
- this.getCSSSelectorLocation(matchedStyles.cssModel(), rule.styleSheetId, ruleLocation);
1801
- this.revealSelectorSource(matchingSelectorLocation, true);
1802
- }
1803
- }
1804
-
1805
- protected static linkifyRuleLocation(
1806
- cssModel: SDK.CSSModel.CSSModel, linkifier: Components.Linkifier.Linkifier,
1807
- styleSheetId: Protocol.CSS.StyleSheetId, ruleLocation: TextUtils.TextRange.TextRange): Node {
1808
- const matchingSelectorLocation = this.getCSSSelectorLocation(cssModel, styleSheetId, ruleLocation);
1809
- return linkifier.linkifyCSSLocation(matchingSelectorLocation);
1810
- }
1811
-
1812
- private static getCSSSelectorLocation(
1813
- cssModel: SDK.CSSModel.CSSModel, styleSheetId: Protocol.CSS.StyleSheetId,
1814
- ruleLocation: TextUtils.TextRange.TextRange): SDK.CSSModel.CSSLocation {
1815
- const styleSheetHeader =
1816
- (cssModel.styleSheetHeaderForId(styleSheetId) as SDK.CSSStyleSheetHeader.CSSStyleSheetHeader);
1817
- const lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.startLine);
1818
- const columnNumber = styleSheetHeader.columnNumberInSource(ruleLocation.startLine, ruleLocation.startColumn);
1819
- return new SDK.CSSModel.CSSLocation(styleSheetHeader, lineNumber, columnNumber);
1820
- }
1821
-
1822
- private getFocused(): HTMLElement|null {
1823
- return (this.propertiesTreeOutline.shadowRoot.activeElement as HTMLElement) || null;
1824
- }
1825
-
1826
- private focusNext(element: HTMLElement): void {
1827
- // Clear remembered focused item (if any).
1828
- const focused = this.getFocused();
1829
- if (focused) {
1830
- focused.tabIndex = -1;
1831
- }
1832
-
1833
- // Focus the next item and remember it (if in our subtree).
1834
- element.focus();
1835
- if (this.propertiesTreeOutline.shadowRoot.contains(element)) {
1836
- element.tabIndex = 0;
1837
- }
1838
- }
1839
-
1840
- private ruleNavigation(keyboardEvent: KeyboardEvent): void {
1841
- if (keyboardEvent.altKey || keyboardEvent.ctrlKey || keyboardEvent.metaKey || keyboardEvent.shiftKey) {
1842
- return;
1843
- }
1844
-
1845
- const focused = this.getFocused();
1846
-
1847
- let focusNext: HTMLElement|null = null;
1848
- const focusable =
1849
- Array.from((this.propertiesTreeOutline.shadowRoot.querySelectorAll('[tabindex]') as NodeListOf<HTMLElement>));
1850
-
1851
- if (focusable.length === 0) {
1852
- return;
1853
- }
1854
-
1855
- const focusedIndex = focused ? focusable.indexOf(focused) : -1;
1856
-
1857
- if (keyboardEvent.key === 'ArrowLeft') {
1858
- focusNext = focusable[focusedIndex - 1] || this.element;
1859
- } else if (keyboardEvent.key === 'ArrowRight') {
1860
- focusNext = focusable[focusedIndex + 1] || this.element;
1861
- } else if (keyboardEvent.key === 'ArrowUp' || keyboardEvent.key === 'ArrowDown') {
1862
- this.focusNext(this.element);
1863
- return;
1864
- }
1865
-
1866
- if (focusNext) {
1867
- this.focusNext(focusNext);
1868
- keyboardEvent.consume(true);
1869
- }
1870
- }
1871
-
1872
- private onKeyDown(event: Event): void {
1873
- const keyboardEvent = (event as KeyboardEvent);
1874
- if (UI.UIUtils.isEditing() || !this.editable || keyboardEvent.altKey || keyboardEvent.ctrlKey ||
1875
- keyboardEvent.metaKey) {
1876
- return;
1877
- }
1878
- switch (keyboardEvent.key) {
1879
- case 'Enter':
1880
- case ' ':
1881
- this.startEditingAtFirstPosition();
1882
- keyboardEvent.consume(true);
1883
- break;
1884
- case 'ArrowLeft':
1885
- case 'ArrowRight':
1886
- case 'ArrowUp':
1887
- case 'ArrowDown':
1888
- this.ruleNavigation(keyboardEvent);
1889
- break;
1890
- default:
1891
- // Filter out non-printable key strokes.
1892
- if (keyboardEvent.key.length === 1) {
1893
- this.addNewBlankProperty(0).startEditing();
1894
- }
1895
- break;
1896
- }
1897
- }
1898
-
1899
- private setSectionHovered(isHovered: boolean): void {
1900
- this.element.classList.toggle('styles-panel-hovered', isHovered);
1901
- this.propertiesTreeOutline.element.classList.toggle('styles-panel-hovered', isHovered);
1902
- if (this.hoverableSelectorsMode !== isHovered) {
1903
- this.hoverableSelectorsMode = isHovered;
1904
- this.markSelectorMatches();
1905
- }
1906
- }
1907
-
1908
- private onMouseLeave(_event: Event): void {
1909
- this.setSectionHovered(false);
1910
- this.parentPane.setActiveProperty(null);
1911
- }
1912
-
1913
- private onMouseMove(event: MouseEvent): void {
1914
- const hasCtrlOrMeta = UI.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(event);
1915
- this.setSectionHovered(hasCtrlOrMeta);
1916
-
1917
- const treeElement = this.propertiesTreeOutline.treeElementFromEvent(event);
1918
- if (treeElement instanceof StylePropertyTreeElement) {
1919
- this.parentPane.setActiveProperty((treeElement as StylePropertyTreeElement));
1920
- } else {
1921
- this.parentPane.setActiveProperty(null);
1922
- }
1923
- const selection = this.element.getComponentSelection();
1924
- if (!this.selectedSinceMouseDown && selection && selection.toString()) {
1925
- this.selectedSinceMouseDown = true;
1926
- }
1927
- }
1928
-
1929
- private onFontEditorButtonClicked(): void {
1930
- if (this.fontEditorSectionManager && this.fontEditorButton) {
1931
- void this.fontEditorSectionManager.showPopover(this.fontEditorButton.element, this.parentPane);
1932
- }
1933
- }
1934
-
1935
- style(): SDK.CSSStyleDeclaration.CSSStyleDeclaration {
1936
- return this.styleInternal;
1937
- }
1938
-
1939
- headerText(): string {
1940
- const node = this.matchedStyles.nodeForStyle(this.styleInternal);
1941
- if (this.styleInternal.type === SDK.CSSStyleDeclaration.Type.Inline) {
1942
- return this.matchedStyles.isInherited(this.styleInternal) ? i18nString(UIStrings.styleAttribute) :
1943
- 'element.style';
1944
- }
1945
- if (node && this.styleInternal.type === SDK.CSSStyleDeclaration.Type.Attributes) {
1946
- return i18nString(UIStrings.sattributesStyle, {PH1: node.nodeNameInCorrectCase()});
1947
- }
1948
- if (this.styleInternal.parentRule instanceof SDK.CSSRule.CSSStyleRule) {
1949
- return this.styleInternal.parentRule.selectorText();
1950
- }
1951
- return '';
1952
- }
1953
-
1954
- private onMouseOutSelector(): void {
1955
- if (this.hoverTimer) {
1956
- clearTimeout(this.hoverTimer);
1957
- }
1958
- SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight();
1959
- }
1960
-
1961
- private onMouseEnterSelector(): void {
1962
- if (this.hoverTimer) {
1963
- clearTimeout(this.hoverTimer);
1964
- }
1965
- this.hoverTimer = window.setTimeout(this.highlight.bind(this), 300);
1966
- }
1967
-
1968
- highlight(mode: string|undefined = 'all'): void {
1969
- SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight();
1970
- const node = this.parentPane.node();
1971
- if (!node) {
1972
- return;
1973
- }
1974
- const selectorList =
1975
- this.styleInternal.parentRule && this.styleInternal.parentRule instanceof SDK.CSSRule.CSSStyleRule ?
1976
- this.styleInternal.parentRule.selectorText() :
1977
- undefined;
1978
- node.domModel().overlayModel().highlightInOverlay({node, selectorList}, mode);
1979
- }
1980
-
1981
- firstSibling(): StylePropertiesSection|null {
1982
- const parent = this.element.parentElement;
1983
- if (!parent) {
1984
- return null;
1985
- }
1986
-
1987
- let childElement: (ChildNode|null) = parent.firstChild;
1988
- while (childElement) {
1989
- const childSection = this.parentPane.sectionByElement.get(childElement);
1990
- if (childSection) {
1991
- return childSection;
1992
- }
1993
- childElement = childElement.nextSibling;
1994
- }
1995
-
1996
- return null;
1997
- }
1998
-
1999
- findCurrentOrNextVisible(willIterateForward: boolean, originalSection?: StylePropertiesSection):
2000
- StylePropertiesSection|null {
2001
- if (!this.isHidden()) {
2002
- return this;
2003
- }
2004
- if (this === originalSection) {
2005
- return null;
2006
- }
2007
- if (!originalSection) {
2008
- originalSection = this;
2009
- }
2010
- let visibleSibling: (StylePropertiesSection|null)|null = null;
2011
- const nextSibling = willIterateForward ? this.nextSibling() : this.previousSibling();
2012
- if (nextSibling) {
2013
- visibleSibling = nextSibling.findCurrentOrNextVisible(willIterateForward, originalSection);
2014
- } else {
2015
- const loopSibling = willIterateForward ? this.firstSibling() : this.lastSibling();
2016
- if (loopSibling) {
2017
- visibleSibling = loopSibling.findCurrentOrNextVisible(willIterateForward, originalSection);
2018
- }
2019
- }
2020
-
2021
- return visibleSibling;
2022
- }
2023
-
2024
- lastSibling(): StylePropertiesSection|null {
2025
- const parent = this.element.parentElement;
2026
- if (!parent) {
2027
- return null;
2028
- }
2029
-
2030
- let childElement: (ChildNode|null) = parent.lastChild;
2031
- while (childElement) {
2032
- const childSection = this.parentPane.sectionByElement.get(childElement);
2033
- if (childSection) {
2034
- return childSection;
2035
- }
2036
- childElement = childElement.previousSibling;
2037
- }
2038
-
2039
- return null;
2040
- }
2041
-
2042
- nextSibling(): StylePropertiesSection|undefined {
2043
- let curElement: (ChildNode|null)|HTMLDivElement = this.element;
2044
- do {
2045
- curElement = curElement.nextSibling;
2046
- } while (curElement && !this.parentPane.sectionByElement.has(curElement));
2047
-
2048
- if (curElement) {
2049
- return this.parentPane.sectionByElement.get(curElement);
2050
- }
2051
- return;
2052
- }
2053
-
2054
- previousSibling(): StylePropertiesSection|undefined {
2055
- let curElement: (ChildNode|null)|HTMLDivElement = this.element;
2056
- do {
2057
- curElement = curElement.previousSibling;
2058
- } while (curElement && !this.parentPane.sectionByElement.has(curElement));
2059
-
2060
- if (curElement) {
2061
- return this.parentPane.sectionByElement.get(curElement);
2062
- }
2063
- return;
2064
- }
2065
-
2066
- private onNewRuleClick(event: Common.EventTarget.EventTargetEvent<Event>): void {
2067
- event.data.consume();
2068
- const rule = this.styleInternal.parentRule;
2069
- if (!rule || !rule.style.range || rule.styleSheetId === undefined) {
2070
- return;
2071
- }
2072
- const range =
2073
- TextUtils.TextRange.TextRange.createFromLocation(rule.style.range.endLine, rule.style.range.endColumn + 1);
2074
- this.parentPane.addBlankSection(this, rule.styleSheetId, range);
2075
- }
2076
-
2077
- styleSheetEdited(edit: SDK.CSSModel.Edit): void {
2078
- const rule = this.styleInternal.parentRule;
2079
- if (rule) {
2080
- rule.rebase(edit);
2081
- } else {
2082
- this.styleInternal.rebase(edit);
2083
- }
2084
-
2085
- this.updateQueryList();
2086
- this.updateRuleOrigin();
2087
- }
2088
-
2089
- protected createAtRuleLists(rule: SDK.CSSRule.CSSStyleRule): void {
2090
- this.createMediaList(rule.media);
2091
- this.createContainerQueryList(rule.containerQueries);
2092
- this.createSupportsList(rule.supports);
2093
- }
2094
-
2095
- protected createMediaList(mediaRules: SDK.CSSMedia.CSSMedia[]): void {
2096
- for (let i = mediaRules.length - 1; i >= 0; --i) {
2097
- const media = mediaRules[i];
2098
- // Don't display trivial non-print media types.
2099
- const isMedia = !media.text || !media.text.includes('(') && media.text !== 'print';
2100
- if (isMedia) {
2101
- continue;
2102
- }
2103
-
2104
- let queryPrefix = '';
2105
- let queryText = '';
2106
- let onQueryTextClick;
2107
- switch (media.source) {
2108
- case SDK.CSSMedia.Source.LINKED_SHEET:
2109
- case SDK.CSSMedia.Source.INLINE_SHEET: {
2110
- queryText = `media="${media.text}"`;
2111
- break;
2112
- }
2113
- case SDK.CSSMedia.Source.MEDIA_RULE: {
2114
- queryPrefix = '@media';
2115
- queryText = media.text;
2116
- if (media.styleSheetId) {
2117
- onQueryTextClick = this.handleQueryRuleClick.bind(this, media);
2118
- }
2119
- break;
2120
- }
2121
- case SDK.CSSMedia.Source.IMPORT_RULE: {
2122
- queryText = `@import ${media.text}`;
2123
- break;
2124
- }
2125
- }
2126
-
2127
- const mediaQueryElement = new ElementsComponents.CSSQuery.CSSQuery();
2128
- mediaQueryElement.data = {
2129
- queryPrefix,
2130
- queryText,
2131
- onQueryTextClick,
2132
- };
2133
- this.queryListElement.append(mediaQueryElement);
2134
- }
2135
- }
2136
-
2137
- protected createContainerQueryList(containerQueries: SDK.CSSContainerQuery.CSSContainerQuery[]): void {
2138
- for (let i = containerQueries.length - 1; i >= 0; --i) {
2139
- const containerQuery = containerQueries[i];
2140
- if (!containerQuery.text) {
2141
- continue;
2142
- }
2143
-
2144
- let onQueryTextClick;
2145
- if (containerQuery.styleSheetId) {
2146
- onQueryTextClick = this.handleQueryRuleClick.bind(this, containerQuery);
2147
- }
2148
-
2149
- const containerQueryElement = new ElementsComponents.CSSQuery.CSSQuery();
2150
- containerQueryElement.data = {
2151
- queryPrefix: '@container',
2152
- queryName: containerQuery.name,
2153
- queryText: containerQuery.text,
2154
- onQueryTextClick,
2155
- };
2156
- this.queryListElement.append(containerQueryElement);
2157
-
2158
- void this.addContainerForContainerQuery(containerQuery);
2159
- }
2160
- }
2161
-
2162
- protected createSupportsList(supportsList: SDK.CSSSupports.CSSSupports[]): void {
2163
- for (let i = supportsList.length - 1; i >= 0; --i) {
2164
- const supports = supportsList[i];
2165
- if (!supports.text) {
2166
- continue;
2167
- }
2168
-
2169
- let onQueryTextClick;
2170
- if (supports.styleSheetId) {
2171
- onQueryTextClick = this.handleQueryRuleClick.bind(this, supports);
2172
- }
2173
-
2174
- const supportsElement = new ElementsComponents.CSSQuery.CSSQuery();
2175
- supportsElement.data = {
2176
- queryPrefix: '@supports',
2177
- queryText: supports.text,
2178
- onQueryTextClick,
2179
- };
2180
- this.queryListElement.append(supportsElement);
2181
- }
2182
- }
2183
-
2184
- private async addContainerForContainerQuery(containerQuery: SDK.CSSContainerQuery.CSSContainerQuery): Promise<void> {
2185
- const container = await containerQuery.getContainerForNode(this.matchedStyles.node().id);
2186
- if (!container) {
2187
- return;
2188
- }
2189
-
2190
- const containerElement = new ElementsComponents.QueryContainer.QueryContainer();
2191
- containerElement.data = {
2192
- container: ElementsComponents.Helper.legacyNodeToElementsComponentsNode(container.containerNode),
2193
- queryName: containerQuery.name,
2194
- onContainerLinkClick: (event): void => {
2195
- event.preventDefault();
2196
- void ElementsPanel.instance().revealAndSelectNode(container.containerNode, true, true);
2197
- void container.containerNode.scrollIntoView();
2198
- },
2199
- };
2200
-
2201
- containerElement.addEventListener('queriedsizerequested', async () => {
2202
- const details = await container.getContainerSizeDetails();
2203
- if (details) {
2204
- containerElement.updateContainerQueriedSizeDetails(details);
2205
- }
2206
- });
2207
-
2208
- this.queryListElement.prepend(containerElement);
2209
- }
2210
-
2211
- private updateQueryList(): void {
2212
- this.queryListElement.removeChildren();
2213
- if (this.styleInternal.parentRule && this.styleInternal.parentRule instanceof SDK.CSSRule.CSSStyleRule) {
2214
- this.createAtRuleLists(this.styleInternal.parentRule);
2215
- }
2216
- }
2217
-
2218
- isPropertyInherited(propertyName: string): boolean {
2219
- if (this.matchedStyles.isInherited(this.styleInternal)) {
2220
- // While rendering inherited stylesheet, reverse meaning of this property.
2221
- // Render truly inherited properties with black, i.e. return them as non-inherited.
2222
- return !SDK.CSSMetadata.cssMetadata().isPropertyInherited(propertyName);
2223
- }
2224
- return false;
2225
- }
2226
-
2227
- nextEditableSibling(): StylePropertiesSection|null {
2228
- let curSection: (StylePropertiesSection|undefined)|(StylePropertiesSection | null)|this = this;
2229
- do {
2230
- curSection = curSection.nextSibling();
2231
- } while (curSection && !curSection.editable);
2232
-
2233
- if (!curSection) {
2234
- curSection = this.firstSibling();
2235
- while (curSection && !curSection.editable) {
2236
- curSection = curSection.nextSibling();
2237
- }
2238
- }
2239
-
2240
- return (curSection && curSection.editable) ? curSection : null;
2241
- }
2242
-
2243
- previousEditableSibling(): StylePropertiesSection|null {
2244
- let curSection: (StylePropertiesSection|undefined)|(StylePropertiesSection | null)|this = this;
2245
- do {
2246
- curSection = curSection.previousSibling();
2247
- } while (curSection && !curSection.editable);
2248
-
2249
- if (!curSection) {
2250
- curSection = this.lastSibling();
2251
- while (curSection && !curSection.editable) {
2252
- curSection = curSection.previousSibling();
2253
- }
2254
- }
2255
-
2256
- return (curSection && curSection.editable) ? curSection : null;
2257
- }
2258
-
2259
- refreshUpdate(editedTreeElement: StylePropertyTreeElement): void {
2260
- this.parentPane.refreshUpdate(this, editedTreeElement);
2261
- }
2262
-
2263
- updateVarFunctions(editedTreeElement: StylePropertyTreeElement): void {
2264
- let child = this.propertiesTreeOutline.firstChild();
2265
- while (child) {
2266
- if (child !== editedTreeElement && child instanceof StylePropertyTreeElement) {
2267
- child.updateTitleIfComputedValueChanged();
2268
- }
2269
- child = child.traverseNextTreeElement(false /* skipUnrevealed */, null /* stayWithin */, true /* dontPopulate */);
2270
- }
2271
- }
2272
-
2273
- update(full: boolean): void {
2274
- this.selectorElement.textContent = this.headerText();
2275
- this.markSelectorMatches();
2276
- if (full) {
2277
- this.onpopulate();
2278
- } else {
2279
- let child = this.propertiesTreeOutline.firstChild();
2280
- while (child && child instanceof StylePropertyTreeElement) {
2281
- child.setOverloaded(this.isPropertyOverloaded(child.property));
2282
- child =
2283
- child.traverseNextTreeElement(false /* skipUnrevealed */, null /* stayWithin */, true /* dontPopulate */);
2284
- }
2285
- }
2286
- }
2287
-
2288
- showAllItems(event?: Event): void {
2289
- if (event) {
2290
- event.consume();
2291
- }
2292
- if (this.forceShowAll) {
2293
- return;
2294
- }
2295
- this.forceShowAll = true;
2296
- this.onpopulate();
2297
- }
2298
-
2299
- onpopulate(): void {
2300
- this.parentPane.setActiveProperty(null);
2301
- this.nextEditorTriggerButtonIdx = 1;
2302
- this.propertiesTreeOutline.removeChildren();
2303
- const style = this.styleInternal;
2304
- let count = 0;
2305
- const properties = style.leadingProperties();
2306
- const maxProperties = StylePropertiesSection.MaxProperties + properties.length - this.originalPropertiesCount;
2307
-
2308
- for (const property of properties) {
2309
- if (!this.forceShowAll && count >= maxProperties) {
2310
- break;
2311
- }
2312
- count++;
2313
- const isShorthand = Boolean(style.longhandProperties(property.name).length);
2314
- const inherited = this.isPropertyInherited(property.name);
2315
- const overloaded = this.isPropertyOverloaded(property);
2316
- if (style.parentRule && style.parentRule.isUserAgent() && inherited) {
2317
- continue;
2318
- }
2319
- const item = new StylePropertyTreeElement(
2320
- this.parentPane, this.matchedStyles, property, isShorthand, inherited, overloaded, false);
2321
- this.propertiesTreeOutline.appendChild(item);
2322
- }
2323
-
2324
- if (count < properties.length) {
2325
- this.showAllButton.classList.remove('hidden');
2326
- this.showAllButton.textContent = i18nString(UIStrings.showAllPropertiesSMore, {PH1: properties.length - count});
2327
- } else {
2328
- this.showAllButton.classList.add('hidden');
2329
- }
2330
- }
2331
-
2332
- isPropertyOverloaded(property: SDK.CSSProperty.CSSProperty): boolean {
2333
- return this.matchedStyles.propertyState(property) === SDK.CSSMatchedStyles.PropertyState.Overloaded;
2334
- }
2335
-
2336
- updateFilter(): boolean {
2337
- let hasMatchingChild = false;
2338
- this.showAllItems();
2339
- for (const child of this.propertiesTreeOutline.rootElement().children()) {
2340
- if (child instanceof StylePropertyTreeElement) {
2341
- const childHasMatches = child.updateFilter();
2342
- hasMatchingChild = hasMatchingChild || childHasMatches;
2343
- }
2344
- }
2345
-
2346
- const regex = this.parentPane.filterRegex();
2347
- const hideRule = !hasMatchingChild && regex !== null && !regex.test(this.element.deepTextContent());
2348
- this.isHiddenInternal = hideRule;
2349
- this.element.classList.toggle('hidden', hideRule);
2350
- if (!hideRule && this.styleInternal.parentRule) {
2351
- this.markSelectorHighlights();
2352
- }
2353
- return !hideRule;
2354
- }
2355
-
2356
- isHidden(): boolean {
2357
- return this.isHiddenInternal;
2358
- }
2359
-
2360
- markSelectorMatches(): void {
2361
- const rule = this.styleInternal.parentRule;
2362
- if (!rule || !(rule instanceof SDK.CSSRule.CSSStyleRule)) {
2363
- return;
2364
- }
2365
-
2366
- this.queryListElement.classList.toggle('query-matches', this.matchedStyles.mediaMatches(this.styleInternal));
2367
-
2368
- const selectorTexts = rule.selectors.map(selector => selector.text);
2369
- const matchingSelectorIndexes = this.matchedStyles.getMatchingSelectors(rule);
2370
- const matchingSelectors = (new Array(selectorTexts.length).fill(false) as boolean[]);
2371
- for (const matchingIndex of matchingSelectorIndexes) {
2372
- matchingSelectors[matchingIndex] = true;
2373
- }
2374
-
2375
- if (this.parentPane.isEditingStyle) {
2376
- return;
2377
- }
2378
-
2379
- const fragment = this.hoverableSelectorsMode ? this.renderHoverableSelectors(selectorTexts, matchingSelectors) :
2380
- this.renderSimplifiedSelectors(selectorTexts, matchingSelectors);
2381
- this.selectorElement.removeChildren();
2382
- this.selectorElement.appendChild(fragment);
2383
- this.markSelectorHighlights();
2384
- }
2385
-
2386
- private renderHoverableSelectors(selectors: string[], matchingSelectors: boolean[]): DocumentFragment {
2387
- const fragment = document.createDocumentFragment();
2388
- for (let i = 0; i < selectors.length; ++i) {
2389
- if (i) {
2390
- UI.UIUtils.createTextChild(fragment, ', ');
2391
- }
2392
- fragment.appendChild(this.createSelectorElement(selectors[i], matchingSelectors[i], i));
2393
- }
2394
- return fragment;
2395
- }
2396
-
2397
- private createSelectorElement(text: string, isMatching: boolean, navigationIndex?: number): Element {
2398
- const element = document.createElement('span');
2399
- element.classList.add('simple-selector');
2400
- element.classList.toggle('selector-matches', isMatching);
2401
- if (typeof navigationIndex === 'number') {
2402
- this.elementToSelectorIndex.set(element, navigationIndex);
2403
- }
2404
- element.textContent = text;
2405
- return element;
2406
- }
2407
-
2408
- private renderSimplifiedSelectors(selectors: string[], matchingSelectors: boolean[]): DocumentFragment {
2409
- const fragment = document.createDocumentFragment();
2410
- let currentMatching = false;
2411
- let text = '';
2412
- for (let i = 0; i < selectors.length; ++i) {
2413
- if (currentMatching !== matchingSelectors[i] && text) {
2414
- fragment.appendChild(this.createSelectorElement(text, currentMatching));
2415
- text = '';
2416
- }
2417
- currentMatching = matchingSelectors[i];
2418
- text += selectors[i] + (i === selectors.length - 1 ? '' : ', ');
2419
- }
2420
- if (text) {
2421
- fragment.appendChild(this.createSelectorElement(text, currentMatching));
2422
- }
2423
- return fragment;
2424
- }
2425
-
2426
- markSelectorHighlights(): void {
2427
- const selectors = this.selectorElement.getElementsByClassName('simple-selector');
2428
- const regex = this.parentPane.filterRegex();
2429
- for (let i = 0; i < selectors.length; ++i) {
2430
- const selectorMatchesFilter = regex !== null && regex.test(selectors[i].textContent || '');
2431
- selectors[i].classList.toggle('filter-match', selectorMatchesFilter);
2432
- }
2433
- }
2434
-
2435
- private checkWillCancelEditing(): boolean {
2436
- const willCauseCancelEditing = this.willCauseCancelEditing;
2437
- this.willCauseCancelEditing = false;
2438
- return willCauseCancelEditing;
2439
- }
2440
-
2441
- private handleSelectorContainerClick(event: Event): void {
2442
- if (this.checkWillCancelEditing() || !this.editable) {
2443
- return;
2444
- }
2445
- if (event.target === this.selectorContainer) {
2446
- this.addNewBlankProperty(0).startEditing();
2447
- event.consume(true);
2448
- }
2449
- }
2450
-
2451
- addNewBlankProperty(index: number|undefined = this.propertiesTreeOutline.rootElement().childCount()):
2452
- StylePropertyTreeElement {
2453
- const property = this.styleInternal.newBlankProperty(index);
2454
- const item = new StylePropertyTreeElement(this.parentPane, this.matchedStyles, property, false, false, false, true);
2455
- this.propertiesTreeOutline.insertChild(item, property.index);
2456
- return item;
2457
- }
2458
-
2459
- private handleEmptySpaceMouseDown(): void {
2460
- this.willCauseCancelEditing = this.parentPane.isEditingStyle;
2461
- this.selectedSinceMouseDown = false;
2462
- }
2463
-
2464
- private handleEmptySpaceClick(event: Event): void {
2465
- if (!this.editable || this.element.hasSelection() || this.checkWillCancelEditing() || this.selectedSinceMouseDown) {
2466
- return;
2467
- }
2468
-
2469
- const target = (event.target as Element);
2470
-
2471
- if (target.classList.contains('header') || this.element.classList.contains('read-only') ||
2472
- target.enclosingNodeOrSelfWithClass('query')) {
2473
- event.consume();
2474
- return;
2475
- }
2476
- const deepTarget = UI.UIUtils.deepElementFromEvent(event);
2477
- const treeElement = deepTarget && UI.TreeOutline.TreeElement.getTreeElementBylistItemNode(deepTarget);
2478
- if (treeElement && treeElement instanceof StylePropertyTreeElement) {
2479
- this.addNewBlankProperty(treeElement.property.index + 1).startEditing();
2480
- } else {
2481
- this.addNewBlankProperty().startEditing();
2482
- }
2483
- event.consume(true);
2484
- }
2485
-
2486
- private handleQueryRuleClick(query: SDK.CSSQuery.CSSQuery, event: Event): void {
2487
- const element = event.currentTarget as Element;
2488
- if (UI.UIUtils.isBeingEdited(element)) {
2489
- return;
2490
- }
2491
-
2492
- if (UI.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(event as MouseEvent) && this.navigable) {
2493
- const location = query.rawLocation();
2494
- if (!location) {
2495
- event.consume(true);
2496
- return;
2497
- }
2498
- const uiLocation = Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().rawLocationToUILocation(location);
2499
- if (uiLocation) {
2500
- void Common.Revealer.reveal(uiLocation);
2501
- }
2502
- event.consume(true);
2503
- return;
2504
- }
2505
-
2506
- if (!this.editable) {
2507
- return;
2508
- }
2509
-
2510
- const config = new UI.InplaceEditor.Config(
2511
- this.editingMediaCommitted.bind(this, query), this.editingMediaCancelled.bind(this, element), undefined,
2512
- this.editingMediaBlurHandler.bind(this));
2513
- UI.InplaceEditor.InplaceEditor.startEditing(element, config);
2514
-
2515
- const selection = element.getComponentSelection();
2516
- if (selection) {
2517
- selection.selectAllChildren(element);
2518
- }
2519
- this.parentPane.setEditingStyle(true);
2520
- const parentMediaElement = element.enclosingNodeOrSelfWithClass('query');
2521
- parentMediaElement.classList.add('editing-query');
2522
-
2523
- event.consume(true);
2524
- }
2525
-
2526
- private editingMediaFinished(element: Element): void {
2527
- this.parentPane.setEditingStyle(false);
2528
- const parentMediaElement = element.enclosingNodeOrSelfWithClass('query');
2529
- parentMediaElement.classList.remove('editing-query');
2530
- }
2531
-
2532
- private editingMediaCancelled(element: Element): void {
2533
- this.editingMediaFinished(element);
2534
- // Mark the selectors in group if necessary.
2535
- // This is overridden by BlankStylePropertiesSection.
2536
- this.markSelectorMatches();
2537
- const selection = element.getComponentSelection();
2538
- if (selection) {
2539
- selection.collapse(element, 0);
2540
- }
2541
- }
2542
-
2543
- private editingMediaBlurHandler(): boolean {
2544
- return true;
2545
- }
2546
-
2547
- private async editingMediaCommitted(
2548
- query: SDK.CSSQuery.CSSQuery, element: Element, newContent: string, _oldContent: string,
2549
- _context: Context|undefined, _moveDirection: string): Promise<void> {
2550
- this.parentPane.setEditingStyle(false);
2551
- this.editingMediaFinished(element);
2552
-
2553
- if (newContent) {
2554
- newContent = newContent.trim();
2555
- }
2556
-
2557
- // This gets deleted in finishOperation(), which is called both on success and failure.
2558
- this.parentPane.setUserOperation(true);
2559
- const cssModel = this.parentPane.cssModel();
2560
- if (cssModel && query.styleSheetId) {
2561
- const range = query.range as TextUtils.TextRange.TextRange;
2562
- let success = false;
2563
- if (query instanceof SDK.CSSContainerQuery.CSSContainerQuery) {
2564
- success = await cssModel.setContainerQueryText(query.styleSheetId, range, newContent);
2565
- } else if (query instanceof SDK.CSSSupports.CSSSupports) {
2566
- success = await cssModel.setSupportsText(query.styleSheetId, range, newContent);
2567
- } else {
2568
- success = await cssModel.setMediaText(query.styleSheetId, range, newContent);
2569
- }
2570
-
2571
- if (success) {
2572
- this.matchedStyles.resetActiveProperties();
2573
- this.parentPane.refreshUpdate(this);
2574
- }
2575
- this.parentPane.setUserOperation(false);
2576
- this.editingMediaTextCommittedForTest();
2577
- }
2578
- }
2579
-
2580
- private editingMediaTextCommittedForTest(): void {
2581
- }
2582
-
2583
- private handleSelectorClick(event: Event): void {
2584
- const target = (event.target as Element | null);
2585
- if (!target) {
2586
- return;
2587
- }
2588
- if (UI.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey((event as MouseEvent)) && this.navigable &&
2589
- target.classList.contains('simple-selector')) {
2590
- const selectorIndex = this.elementToSelectorIndex.get(target);
2591
- if (selectorIndex) {
2592
- this.navigateToSelectorSource(selectorIndex, true);
2593
- }
2594
- event.consume(true);
2595
- return;
2596
- }
2597
- if (this.element.hasSelection()) {
2598
- return;
2599
- }
2600
- this.startEditingAtFirstPosition();
2601
- event.consume(true);
2602
- }
2603
-
2604
- private handleContextMenuEvent(event: Event): void {
2605
- const target = (event.target as Element | null);
2606
- if (!target) {
2607
- return;
2608
- }
2609
-
2610
- const contextMenu = new UI.ContextMenu.ContextMenu(event);
2611
- contextMenu.clipboardSection().appendItem(i18nString(UIStrings.copySelector), () => {
2612
- const selectorText = this.headerText();
2613
- Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(selectorText);
2614
- });
2615
-
2616
- contextMenu.clipboardSection().appendItem(i18nString(UIStrings.copyRule), () => {
2617
- const ruleText = StylesSidebarPane.formatLeadingProperties(this).ruleText;
2618
- Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(ruleText);
2619
- });
2620
-
2621
- contextMenu.clipboardSection().appendItem(i18nString(UIStrings.copyAllDeclarations), () => {
2622
- const allDeclarationText = StylesSidebarPane.formatLeadingProperties(this).allDeclarationText;
2623
- Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(allDeclarationText);
2624
- });
2625
-
2626
- void contextMenu.show();
2627
- }
2628
-
2629
- private navigateToSelectorSource(index: number, focus: boolean): void {
2630
- const cssModel = this.parentPane.cssModel();
2631
- if (!cssModel) {
2632
- return;
2633
- }
2634
- const rule = (this.styleInternal.parentRule as SDK.CSSRule.CSSStyleRule | null);
2635
- if (!rule || rule.styleSheetId === undefined) {
2636
- return;
2637
- }
2638
- const header = cssModel.styleSheetHeaderForId(rule.styleSheetId);
2639
- if (!header) {
2640
- return;
2641
- }
2642
- const rawLocation =
2643
- new SDK.CSSModel.CSSLocation(header, rule.lineNumberInSource(index), rule.columnNumberInSource(index));
2644
- StylePropertiesSection.revealSelectorSource(rawLocation, focus);
2645
- }
2646
-
2647
- private static revealSelectorSource(rawLocation: SDK.CSSModel.CSSLocation, focus: boolean): void {
2648
- const uiLocation = Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().rawLocationToUILocation(rawLocation);
2649
- if (uiLocation) {
2650
- void Common.Revealer.reveal(uiLocation, !focus);
2651
- }
2652
- }
2653
-
2654
- private startEditingAtFirstPosition(): void {
2655
- if (!this.editable) {
2656
- return;
2657
- }
2658
-
2659
- if (!this.styleInternal.parentRule) {
2660
- this.moveEditorFromSelector('forward');
2661
- return;
2662
- }
2663
-
2664
- this.startEditingSelector();
2665
- }
2666
-
2667
- startEditingSelector(): void {
2668
- const element = this.selectorElement;
2669
- if (UI.UIUtils.isBeingEdited(element)) {
2670
- return;
2671
- }
2672
-
2673
- element.scrollIntoViewIfNeeded(false);
2674
- // Reset selector marks in group, and normalize whitespace.
2675
- const textContent = element.textContent;
2676
- if (textContent !== null) {
2677
- element.textContent = textContent.replace(/\s+/g, ' ').trim();
2678
- }
2679
-
2680
- const config =
2681
- new UI.InplaceEditor.Config(this.editingSelectorCommitted.bind(this), this.editingSelectorCancelled.bind(this));
2682
- UI.InplaceEditor.InplaceEditor.startEditing(this.selectorElement, config);
2683
-
2684
- const selection = element.getComponentSelection();
2685
- if (selection) {
2686
- selection.selectAllChildren(element);
2687
- }
2688
- this.parentPane.setEditingStyle(true);
2689
- if (element.classList.contains('simple-selector')) {
2690
- this.navigateToSelectorSource(0, false);
2691
- }
2692
- }
2693
-
2694
- moveEditorFromSelector(moveDirection: string): void {
2695
- this.markSelectorMatches();
2696
-
2697
- if (!moveDirection) {
2698
- return;
2699
- }
2700
-
2701
- if (moveDirection === 'forward') {
2702
- const firstChild = (this.propertiesTreeOutline.firstChild() as StylePropertyTreeElement);
2703
- let currentChild: (StylePropertyTreeElement|null)|StylePropertyTreeElement = firstChild;
2704
- while (currentChild && currentChild.inherited()) {
2705
- const sibling: UI.TreeOutline.TreeElement|null = currentChild.nextSibling;
2706
- currentChild = sibling instanceof StylePropertyTreeElement ? sibling : null;
2707
- }
2708
- if (!currentChild) {
2709
- this.addNewBlankProperty().startEditing();
2710
- } else {
2711
- currentChild.startEditing(currentChild.nameElement);
2712
- }
2713
- } else {
2714
- const previousSection = this.previousEditableSibling();
2715
- if (!previousSection) {
2716
- return;
2717
- }
2718
-
2719
- previousSection.addNewBlankProperty().startEditing();
2720
- }
2721
- }
2722
-
2723
- editingSelectorCommitted(
2724
- element: Element, newContent: string, oldContent: string, context: Context|undefined,
2725
- moveDirection: string): void {
2726
- this.editingSelectorEnded();
2727
- if (newContent) {
2728
- newContent = newContent.trim();
2729
- }
2730
- if (newContent === oldContent) {
2731
- // Revert to a trimmed version of the selector if need be.
2732
- this.selectorElement.textContent = newContent;
2733
- this.moveEditorFromSelector(moveDirection);
2734
- return;
2735
- }
2736
- const rule = this.styleInternal.parentRule;
2737
- if (!rule) {
2738
- return;
2739
- }
2740
-
2741
- function headerTextCommitted(this: StylePropertiesSection): void {
2742
- this.parentPane.setUserOperation(false);
2743
- this.moveEditorFromSelector(moveDirection);
2744
- this.editingSelectorCommittedForTest();
2745
- }
2746
-
2747
- // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure.
2748
- this.parentPane.setUserOperation(true);
2749
- void this.setHeaderText(rule, newContent).then(headerTextCommitted.bind(this));
2750
- }
2751
-
2752
- setHeaderText(rule: SDK.CSSRule.CSSRule, newContent: string): Promise<void> {
2753
- function onSelectorsUpdated(
2754
- this: StylePropertiesSection, rule: SDK.CSSRule.CSSStyleRule, success: boolean): Promise<void> {
2755
- if (!success) {
2756
- return Promise.resolve();
2757
- }
2758
- return this.matchedStyles.recomputeMatchingSelectors(rule).then(updateSourceRanges.bind(this, rule));
2759
- }
2760
-
2761
- function updateSourceRanges(this: StylePropertiesSection, rule: SDK.CSSRule.CSSStyleRule): void {
2762
- const doesAffectSelectedNode = this.matchedStyles.getMatchingSelectors(rule).length > 0;
2763
- this.propertiesTreeOutline.element.classList.toggle('no-affect', !doesAffectSelectedNode);
2764
- this.matchedStyles.resetActiveProperties();
2765
- this.parentPane.refreshUpdate(this);
2766
- }
2767
-
2768
- if (!(rule instanceof SDK.CSSRule.CSSStyleRule)) {
2769
- return Promise.resolve();
2770
- }
2771
- const oldSelectorRange = rule.selectorRange();
2772
- if (!oldSelectorRange) {
2773
- return Promise.resolve();
2774
- }
2775
- return rule.setSelectorText(newContent).then(onSelectorsUpdated.bind(this, rule, Boolean(oldSelectorRange)));
2776
- }
2777
-
2778
- protected editingSelectorCommittedForTest(): void {
2779
- }
2780
-
2781
- protected updateRuleOrigin(): void {
2782
- this.selectorRefElement.removeChildren();
2783
- this.selectorRefElement.appendChild(StylePropertiesSection.createRuleOriginNode(
2784
- this.matchedStyles, this.parentPane.linkifier, this.styleInternal.parentRule));
2785
- }
2786
-
2787
- protected editingSelectorEnded(): void {
2788
- this.parentPane.setEditingStyle(false);
2789
- }
2790
-
2791
- editingSelectorCancelled(): void {
2792
- this.editingSelectorEnded();
2793
-
2794
- // Mark the selectors in group if necessary.
2795
- // This is overridden by BlankStylePropertiesSection.
2796
- this.markSelectorMatches();
2797
- }
2798
-
2799
- /**
2800
- * A property at or near an index and suitable for subsequent editing.
2801
- * Either the last property, if index out-of-upper-bound,
2802
- * or property at index, if such a property exists,
2803
- * or otherwise, null.
2804
- */
2805
- closestPropertyForEditing(propertyIndex: number): UI.TreeOutline.TreeElement|null {
2806
- const rootElement = this.propertiesTreeOutline.rootElement();
2807
- if (propertyIndex >= rootElement.childCount()) {
2808
- return rootElement.lastChild();
2809
- }
2810
- return rootElement.childAt(propertyIndex);
2811
- }
2812
-
2813
- // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
2814
- // eslint-disable-next-line @typescript-eslint/naming-convention
2815
- static MaxProperties = 50;
2816
- }
2817
-
2818
- export class BlankStylePropertiesSection extends StylePropertiesSection {
2819
- private normal: boolean;
2820
- private readonly ruleLocation: TextUtils.TextRange.TextRange;
2821
- private readonly styleSheetId: Protocol.CSS.StyleSheetId;
2822
-
2823
- constructor(
2824
- stylesPane: StylesSidebarPane, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles, defaultSelectorText: string,
2825
- styleSheetId: Protocol.CSS.StyleSheetId, ruleLocation: TextUtils.TextRange.TextRange,
2826
- insertAfterStyle: SDK.CSSStyleDeclaration.CSSStyleDeclaration, sectionIdx: number) {
2827
- const cssModel = (stylesPane.cssModel() as SDK.CSSModel.CSSModel);
2828
- const rule = SDK.CSSRule.CSSStyleRule.createDummyRule(cssModel, defaultSelectorText);
2829
- super(stylesPane, matchedStyles, rule.style, sectionIdx);
2830
- this.normal = false;
2831
- this.ruleLocation = ruleLocation;
2832
- this.styleSheetId = styleSheetId;
2833
- this.selectorRefElement.removeChildren();
2834
- this.selectorRefElement.appendChild(StylePropertiesSection.linkifyRuleLocation(
2835
- cssModel, this.parentPane.linkifier, styleSheetId, this.actualRuleLocation()));
2836
- if (insertAfterStyle && insertAfterStyle.parentRule &&
2837
- insertAfterStyle.parentRule instanceof SDK.CSSRule.CSSStyleRule) {
2838
- this.createAtRuleLists(insertAfterStyle.parentRule);
2839
- }
2840
- this.element.classList.add('blank-section');
2841
- }
2842
-
2843
- private actualRuleLocation(): TextUtils.TextRange.TextRange {
2844
- const prefix = this.rulePrefix();
2845
- const lines = prefix.split('\n');
2846
- const lastLine = lines[lines.length - 1];
2847
- const editRange = new TextUtils.TextRange.TextRange(0, 0, lines.length - 1, lastLine ? lastLine.length : 0);
2848
- return this.ruleLocation.rebaseAfterTextEdit(TextUtils.TextRange.TextRange.createFromLocation(0, 0), editRange);
2849
- }
2850
-
2851
- private rulePrefix(): string {
2852
- return this.ruleLocation.startLine === 0 && this.ruleLocation.startColumn === 0 ? '' : '\n\n';
2853
- }
2854
-
2855
- get isBlank(): boolean {
2856
- return !this.normal;
2857
- }
2858
-
2859
- editingSelectorCommitted(
2860
- element: Element, newContent: string, oldContent: string, context: Context|undefined,
2861
- moveDirection: string): void {
2862
- if (!this.isBlank) {
2863
- super.editingSelectorCommitted(element, newContent, oldContent, context, moveDirection);
2864
- return;
2865
- }
2866
-
2867
- function onRuleAdded(this: BlankStylePropertiesSection, newRule: SDK.CSSRule.CSSStyleRule|null): Promise<void> {
2868
- if (!newRule) {
2869
- this.editingSelectorCancelled();
2870
- this.editingSelectorCommittedForTest();
2871
- return Promise.resolve();
2872
- }
2873
- return this.matchedStyles.addNewRule(newRule, this.matchedStyles.node())
2874
- .then(onAddedToCascade.bind(this, newRule));
2875
- }
2876
-
2877
- function onAddedToCascade(this: BlankStylePropertiesSection, newRule: SDK.CSSRule.CSSStyleRule): void {
2878
- const doesSelectorAffectSelectedNode = this.matchedStyles.getMatchingSelectors(newRule).length > 0;
2879
- this.makeNormal(newRule);
2880
-
2881
- if (!doesSelectorAffectSelectedNode) {
2882
- this.propertiesTreeOutline.element.classList.add('no-affect');
2883
- }
2884
-
2885
- this.updateRuleOrigin();
2886
-
2887
- this.parentPane.setUserOperation(false);
2888
- this.editingSelectorEnded();
2889
- if (this.element.parentElement) // Might have been detached already.
2890
- {
2891
- this.moveEditorFromSelector(moveDirection);
2892
- }
2893
- this.markSelectorMatches();
2894
-
2895
- this.editingSelectorCommittedForTest();
2896
- }
2897
-
2898
- if (newContent) {
2899
- newContent = newContent.trim();
2900
- }
2901
- this.parentPane.setUserOperation(true);
2902
-
2903
- const cssModel = this.parentPane.cssModel();
2904
- const ruleText = this.rulePrefix() + newContent + ' {}';
2905
- if (cssModel) {
2906
- void cssModel.addRule(this.styleSheetId, ruleText, this.ruleLocation).then(onRuleAdded.bind(this));
2907
- }
2908
- }
2909
-
2910
- editingSelectorCancelled(): void {
2911
- this.parentPane.setUserOperation(false);
2912
- if (!this.isBlank) {
2913
- super.editingSelectorCancelled();
2914
- return;
2915
- }
2916
-
2917
- this.editingSelectorEnded();
2918
- this.parentPane.removeSection(this);
2919
- }
2920
-
2921
- private makeNormal(newRule: SDK.CSSRule.CSSRule): void {
2922
- this.element.classList.remove('blank-section');
2923
- this.styleInternal = newRule.style;
2924
- // FIXME: replace this instance by a normal StylePropertiesSection.
2925
- this.normal = true;
2926
- }
2927
- }
2928
-
2929
- export class KeyframePropertiesSection extends StylePropertiesSection {
2930
- constructor(
2931
- stylesPane: StylesSidebarPane, matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles,
2932
- style: SDK.CSSStyleDeclaration.CSSStyleDeclaration, sectionIdx: number) {
2933
- super(stylesPane, matchedStyles, style, sectionIdx);
2934
- this.selectorElement.className = 'keyframe-key';
2935
- }
2936
-
2937
- headerText(): string {
2938
- if (this.styleInternal.parentRule instanceof SDK.CSSRule.CSSKeyframeRule) {
2939
- return this.styleInternal.parentRule.key().text;
2940
- }
2941
- return '';
2942
- }
2943
-
2944
- setHeaderText(rule: SDK.CSSRule.CSSRule, newContent: string): Promise<void> {
2945
- function updateSourceRanges(this: KeyframePropertiesSection, success: boolean): void {
2946
- if (!success) {
2947
- return;
2948
- }
2949
- this.parentPane.refreshUpdate(this);
2950
- }
2951
-
2952
- if (!(rule instanceof SDK.CSSRule.CSSKeyframeRule)) {
2953
- return Promise.resolve();
2954
- }
2955
- const oldRange = rule.key().range;
2956
- if (!oldRange) {
2957
- return Promise.resolve();
2958
- }
2959
- return rule.setKeyText(newContent).then(updateSourceRanges.bind(this));
2960
- }
2961
-
2962
- isPropertyInherited(_propertyName: string): boolean {
2963
- return false;
2964
- }
2965
-
2966
- isPropertyOverloaded(_property: SDK.CSSProperty.CSSProperty): boolean {
2967
- return false;
2968
- }
2969
-
2970
- markSelectorHighlights(): void {
2971
- }
2972
-
2973
- markSelectorMatches(): void {
2974
- if (this.styleInternal.parentRule instanceof SDK.CSSRule.CSSKeyframeRule) {
2975
- this.selectorElement.textContent = this.styleInternal.parentRule.key().text;
2976
- }
2977
- }
2978
-
2979
- highlight(): void {
2980
- }
2981
- }
2982
-
2983
1405
  export function quoteFamilyName(familyName: string): string {
2984
1406
  return `'${familyName.replaceAll('\'', '\\\'')}'`;
2985
1407
  }
@@ -3448,14 +1870,14 @@ export class StylesSidebarPropertyRenderer {
3448
1870
 
3449
1871
  private processURL(text: string): Node {
3450
1872
  // Strip "url(" and ")" along with whitespace.
3451
- let url = text.substring(4, text.length - 1).trim();
1873
+ let url = text.substring(4, text.length - 1).trim() as Platform.DevToolsPath.UrlString;
3452
1874
  const isQuoted = /^'.*'$/s.test(url) || /^".*"$/s.test(url);
3453
1875
  if (isQuoted) {
3454
- url = url.substring(1, url.length - 1);
1876
+ url = Common.ParsedURL.ParsedURL.substring(url, 1, url.length - 1);
3455
1877
  }
3456
1878
  const container = document.createDocumentFragment();
3457
1879
  UI.UIUtils.createTextChild(container, 'url(');
3458
- let hrefUrl: (string|null)|null = null;
1880
+ let hrefUrl: Platform.DevToolsPath.UrlString|null = null;
3459
1881
  if (this.rule && this.rule.resourceURL()) {
3460
1882
  hrefUrl = Common.ParsedURL.ParsedURL.completeURL(this.rule.resourceURL(), url);
3461
1883
  } else if (this.node) {