devtools-tracing 1.1.1 → 1.2.0

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 (528) hide show
  1. package/.claude/settings.local.json +14 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +28854 -0
  4. package/package.json +11 -8
  5. package/generate.ts +0 -649
  6. package/index.ts +0 -17
  7. package/lib/extension-api/ExtensionAPI.d.ts +0 -357
  8. package/lib/front_end/core/common/App.ts +0 -7
  9. package/lib/front_end/core/common/AppProvider.ts +0 -32
  10. package/lib/front_end/core/common/Base64.ts +0 -47
  11. package/lib/front_end/core/common/CharacterIdMap.ts +0 -30
  12. package/lib/front_end/core/common/Color.ts +0 -2506
  13. package/lib/front_end/core/common/ColorConverter.ts +0 -402
  14. package/lib/front_end/core/common/ColorUtils.ts +0 -252
  15. package/lib/front_end/core/common/Console.ts +0 -114
  16. package/lib/front_end/core/common/Debouncer.ts +0 -15
  17. package/lib/front_end/core/common/EventTarget.ts +0 -52
  18. package/lib/front_end/core/common/Gzip.ts +0 -74
  19. package/lib/front_end/core/common/JavaScriptMetaData.ts +0 -29
  20. package/lib/front_end/core/common/Lazy.ts +0 -31
  21. package/lib/front_end/core/common/Linkifier.ts +0 -55
  22. package/lib/front_end/core/common/MapWithDefault.ts +0 -26
  23. package/lib/front_end/core/common/Mutex.ts +0 -55
  24. package/lib/front_end/core/common/Object.ts +0 -145
  25. package/lib/front_end/core/common/ParsedURL.ts +0 -554
  26. package/lib/front_end/core/common/Progress.ts +0 -180
  27. package/lib/front_end/core/common/QueryParamHandler.ts +0 -7
  28. package/lib/front_end/core/common/ResolverBase.ts +0 -85
  29. package/lib/front_end/core/common/ResourceType.ts +0 -588
  30. package/lib/front_end/core/common/ReturnToPanel.ts +0 -17
  31. package/lib/front_end/core/common/Revealer.ts +0 -192
  32. package/lib/front_end/core/common/Runnable.ts +0 -41
  33. package/lib/front_end/core/common/SegmentedRange.ts +0 -87
  34. package/lib/front_end/core/common/SettingRegistration.ts +0 -339
  35. package/lib/front_end/core/common/Settings.ts +0 -1497
  36. package/lib/front_end/core/common/SimpleHistoryManager.ts +0 -124
  37. package/lib/front_end/core/common/StringOutputStream.ts +0 -26
  38. package/lib/front_end/core/common/TextDictionary.ts +0 -48
  39. package/lib/front_end/core/common/Throttler.ts +0 -99
  40. package/lib/front_end/core/common/Trie.ts +0 -152
  41. package/lib/front_end/core/common/Worker.ts +0 -60
  42. package/lib/front_end/core/common/common.ts +0 -81
  43. package/lib/front_end/core/host/AidaClient.ts +0 -733
  44. package/lib/front_end/core/host/GdpClient.ts +0 -316
  45. package/lib/front_end/core/host/InspectorFrontendHost.ts +0 -648
  46. package/lib/front_end/core/host/InspectorFrontendHostAPI.ts +0 -551
  47. package/lib/front_end/core/host/Platform.ts +0 -76
  48. package/lib/front_end/core/host/ResourceLoader.ts +0 -282
  49. package/lib/front_end/core/host/UserMetrics.ts +0 -1230
  50. package/lib/front_end/core/host/host.ts +0 -23
  51. package/lib/front_end/core/i18n/ByteUtilities.ts +0 -82
  52. package/lib/front_end/core/i18n/DevToolsLocale.ts +0 -87
  53. package/lib/front_end/core/i18n/NumberFormatter.ts +0 -82
  54. package/lib/front_end/core/i18n/i18n.ts +0 -17
  55. package/lib/front_end/core/i18n/i18nImpl.ts +0 -204
  56. package/lib/front_end/core/i18n/i18nTypes.ts +0 -10
  57. package/lib/front_end/core/i18n/locales.js +0 -14
  58. package/lib/front_end/core/i18n/time-utilities.ts +0 -174
  59. package/lib/front_end/core/platform/ArrayUtilities.ts +0 -271
  60. package/lib/front_end/core/platform/Brand.ts +0 -23
  61. package/lib/front_end/core/platform/Constructor.ts +0 -10
  62. package/lib/front_end/core/platform/DOMUtilities.ts +0 -138
  63. package/lib/front_end/core/platform/DateUtilities.ts +0 -15
  64. package/lib/front_end/core/platform/DevToolsPath.ts +0 -53
  65. package/lib/front_end/core/platform/KeyboardUtilities.ts +0 -38
  66. package/lib/front_end/core/platform/MapUtilities.ts +0 -95
  67. package/lib/front_end/core/platform/MimeType.ts +0 -175
  68. package/lib/front_end/core/platform/NumberUtilities.ts +0 -80
  69. package/lib/front_end/core/platform/StringUtilities.ts +0 -588
  70. package/lib/front_end/core/platform/Timing.ts +0 -17
  71. package/lib/front_end/core/platform/TypedArrayUtilities.ts +0 -189
  72. package/lib/front_end/core/platform/TypescriptUtilities.ts +0 -86
  73. package/lib/front_end/core/platform/UIString.ts +0 -39
  74. package/lib/front_end/core/platform/UserVisibleError.ts +0 -28
  75. package/lib/front_end/core/platform/platform.ts +0 -45
  76. package/lib/front_end/core/protocol_client/ConnectionTransport.ts +0 -26
  77. package/lib/front_end/core/protocol_client/InspectorBackend.ts +0 -1050
  78. package/lib/front_end/core/protocol_client/NodeURL.ts +0 -42
  79. package/lib/front_end/core/protocol_client/protocol_client.ts +0 -13
  80. package/lib/front_end/core/root/Runtime.ts +0 -609
  81. package/lib/front_end/core/root/root.ts +0 -6
  82. package/lib/front_end/core/sdk/AccessibilityModel.ts +0 -353
  83. package/lib/front_end/core/sdk/AnimationModel.ts +0 -1041
  84. package/lib/front_end/core/sdk/AutofillModel.ts +0 -184
  85. package/lib/front_end/core/sdk/CPUProfilerModel.ts +0 -148
  86. package/lib/front_end/core/sdk/CPUThrottlingManager.ts +0 -282
  87. package/lib/front_end/core/sdk/CSSContainerQuery.ts +0 -139
  88. package/lib/front_end/core/sdk/CSSFontFace.ts +0 -40
  89. package/lib/front_end/core/sdk/CSSLayer.ts +0 -30
  90. package/lib/front_end/core/sdk/CSSMatchedStyles.ts +0 -1646
  91. package/lib/front_end/core/sdk/CSSMedia.ts +0 -121
  92. package/lib/front_end/core/sdk/CSSMetadata.ts +0 -1647
  93. package/lib/front_end/core/sdk/CSSModel.ts +0 -1128
  94. package/lib/front_end/core/sdk/CSSProperty.ts +0 -384
  95. package/lib/front_end/core/sdk/CSSPropertyParser.ts +0 -681
  96. package/lib/front_end/core/sdk/CSSPropertyParserMatchers.ts +0 -1395
  97. package/lib/front_end/core/sdk/CSSQuery.ts +0 -72
  98. package/lib/front_end/core/sdk/CSSRule.ts +0 -465
  99. package/lib/front_end/core/sdk/CSSScope.ts +0 -30
  100. package/lib/front_end/core/sdk/CSSStartingStyle.ts +0 -29
  101. package/lib/front_end/core/sdk/CSSStyleDeclaration.ts +0 -313
  102. package/lib/front_end/core/sdk/CSSStyleSheetHeader.ts +0 -196
  103. package/lib/front_end/core/sdk/CSSSupports.ts +0 -33
  104. package/lib/front_end/core/sdk/CategorizedBreakpoint.ts +0 -64
  105. package/lib/front_end/core/sdk/ChildTargetManager.ts +0 -314
  106. package/lib/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +0 -62
  107. package/lib/front_end/core/sdk/Connections.ts +0 -293
  108. package/lib/front_end/core/sdk/ConsoleModel.ts +0 -808
  109. package/lib/front_end/core/sdk/ConsoleModelTypes.ts +0 -15
  110. package/lib/front_end/core/sdk/Cookie.ts +0 -319
  111. package/lib/front_end/core/sdk/CookieModel.ts +0 -239
  112. package/lib/front_end/core/sdk/CookieParser.ts +0 -185
  113. package/lib/front_end/core/sdk/DOMDebuggerModel.ts +0 -787
  114. package/lib/front_end/core/sdk/DOMModel.ts +0 -1961
  115. package/lib/front_end/core/sdk/DebuggerModel.ts +0 -1605
  116. package/lib/front_end/core/sdk/EmulationModel.ts +0 -648
  117. package/lib/front_end/core/sdk/EnhancedTracesParser.ts +0 -515
  118. package/lib/front_end/core/sdk/EventBreakpointsModel.ts +0 -183
  119. package/lib/front_end/core/sdk/FrameAssociated.ts +0 -11
  120. package/lib/front_end/core/sdk/FrameManager.ts +0 -259
  121. package/lib/front_end/core/sdk/HeapProfilerModel.ts +0 -225
  122. package/lib/front_end/core/sdk/HttpReasonPhraseStrings.ts +0 -77
  123. package/lib/front_end/core/sdk/IOModel.ts +0 -91
  124. package/lib/front_end/core/sdk/IsolateManager.ts +0 -257
  125. package/lib/front_end/core/sdk/IssuesModel.ts +0 -70
  126. package/lib/front_end/core/sdk/LayerTreeBase.ts +0 -169
  127. package/lib/front_end/core/sdk/LogModel.ts +0 -56
  128. package/lib/front_end/core/sdk/NetworkManager.ts +0 -2823
  129. package/lib/front_end/core/sdk/NetworkRequest.ts +0 -2253
  130. package/lib/front_end/core/sdk/OverlayColorGenerator.ts +0 -52
  131. package/lib/front_end/core/sdk/OverlayModel.ts +0 -1011
  132. package/lib/front_end/core/sdk/OverlayPersistentHighlighter.ts +0 -522
  133. package/lib/front_end/core/sdk/PageLoad.ts +0 -35
  134. package/lib/front_end/core/sdk/PageResourceLoader.ts +0 -435
  135. package/lib/front_end/core/sdk/PaintProfiler.ts +0 -110
  136. package/lib/front_end/core/sdk/PerformanceMetricsModel.ts +0 -84
  137. package/lib/front_end/core/sdk/PreloadingModel.ts +0 -863
  138. package/lib/front_end/core/sdk/RehydratingConnection.ts +0 -386
  139. package/lib/front_end/core/sdk/RehydratingObject.ts +0 -66
  140. package/lib/front_end/core/sdk/RemoteObject.ts +0 -1160
  141. package/lib/front_end/core/sdk/Resource.ts +0 -232
  142. package/lib/front_end/core/sdk/ResourceTreeModel.ts +0 -1160
  143. package/lib/front_end/core/sdk/RuntimeModel.ts +0 -732
  144. package/lib/front_end/core/sdk/SDKModel.ts +0 -65
  145. package/lib/front_end/core/sdk/ScopeTreeCache.ts +0 -45
  146. package/lib/front_end/core/sdk/ScreenCaptureModel.ts +0 -255
  147. package/lib/front_end/core/sdk/Script.ts +0 -534
  148. package/lib/front_end/core/sdk/SecurityOriginManager.ts +0 -76
  149. package/lib/front_end/core/sdk/ServerSentEvents.ts +0 -80
  150. package/lib/front_end/core/sdk/ServerSentEventsProtocol.ts +0 -122
  151. package/lib/front_end/core/sdk/ServerTiming.ts +0 -260
  152. package/lib/front_end/core/sdk/ServiceWorkerCacheModel.ts +0 -377
  153. package/lib/front_end/core/sdk/ServiceWorkerManager.ts +0 -605
  154. package/lib/front_end/core/sdk/SourceMap.ts +0 -867
  155. package/lib/front_end/core/sdk/SourceMapCache.ts +0 -54
  156. package/lib/front_end/core/sdk/SourceMapFunctionRanges.ts +0 -156
  157. package/lib/front_end/core/sdk/SourceMapManager.ts +0 -239
  158. package/lib/front_end/core/sdk/SourceMapScopeChainEntry.ts +0 -189
  159. package/lib/front_end/core/sdk/SourceMapScopesInfo.ts +0 -508
  160. package/lib/front_end/core/sdk/StorageBucketsModel.ts +0 -204
  161. package/lib/front_end/core/sdk/StorageKeyManager.ts +0 -98
  162. package/lib/front_end/core/sdk/Target.ts +0 -332
  163. package/lib/front_end/core/sdk/TargetManager.ts +0 -453
  164. package/lib/front_end/core/sdk/TraceObject.ts +0 -61
  165. package/lib/front_end/core/sdk/WebAuthnModel.ts +0 -104
  166. package/lib/front_end/core/sdk/sdk.ts +0 -174
  167. package/lib/front_end/entrypoints/formatter_worker/FormatterActions.ts +0 -59
  168. package/lib/front_end/generated/InspectorBackendCommands.js +0 -1617
  169. package/lib/front_end/generated/SupportedCSSProperties.js +0 -7512
  170. package/lib/front_end/generated/protocol-proxy-api.d.ts +0 -5022
  171. package/lib/front_end/generated/protocol.ts +0 -22014
  172. package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +0 -318
  173. package/lib/front_end/models/bindings/CompilerScriptMapping.ts +0 -536
  174. package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +0 -187
  175. package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +0 -1197
  176. package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -733
  177. package/lib/front_end/models/bindings/DefaultScriptMapping.ts +0 -141
  178. package/lib/front_end/models/bindings/FileUtils.ts +0 -228
  179. package/lib/front_end/models/bindings/LiveLocation.ts +0 -81
  180. package/lib/front_end/models/bindings/NetworkProject.ts +0 -157
  181. package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +0 -312
  182. package/lib/front_end/models/bindings/ResourceMapping.ts +0 -539
  183. package/lib/front_end/models/bindings/ResourceScriptMapping.ts +0 -491
  184. package/lib/front_end/models/bindings/ResourceUtils.ts +0 -103
  185. package/lib/front_end/models/bindings/SASSSourceMapping.ts +0 -222
  186. package/lib/front_end/models/bindings/StylesSourceMapping.ts +0 -316
  187. package/lib/front_end/models/bindings/TempFile.ts +0 -67
  188. package/lib/front_end/models/bindings/bindings.ts +0 -39
  189. package/lib/front_end/models/cpu_profile/CPUProfileDataModel.ts +0 -571
  190. package/lib/front_end/models/cpu_profile/ProfileTreeModel.ts +0 -103
  191. package/lib/front_end/models/cpu_profile/cpu_profile.ts +0 -11
  192. package/lib/front_end/models/formatter/FormatterWorkerPool.ts +0 -219
  193. package/lib/front_end/models/formatter/ScriptFormatter.ts +0 -112
  194. package/lib/front_end/models/formatter/formatter.ts +0 -8
  195. package/lib/front_end/models/source_map_scopes/NamesResolver.ts +0 -765
  196. package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +0 -84
  197. package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +0 -11
  198. package/lib/front_end/models/stack_trace/StackTrace.ts +0 -53
  199. package/lib/front_end/models/stack_trace/StackTraceImpl.ts +0 -85
  200. package/lib/front_end/models/stack_trace/StackTraceModel.ts +0 -128
  201. package/lib/front_end/models/stack_trace/Trie.ts +0 -163
  202. package/lib/front_end/models/stack_trace/stack_trace.ts +0 -9
  203. package/lib/front_end/models/stack_trace/stack_trace_impl.ts +0 -13
  204. package/lib/front_end/models/text_utils/CodeMirrorUtils.ts +0 -37
  205. package/lib/front_end/models/text_utils/ContentData.ts +0 -199
  206. package/lib/front_end/models/text_utils/ContentProvider.ts +0 -68
  207. package/lib/front_end/models/text_utils/StaticContentProvider.ts +0 -49
  208. package/lib/front_end/models/text_utils/StreamingContentData.ts +0 -108
  209. package/lib/front_end/models/text_utils/Text.ts +0 -90
  210. package/lib/front_end/models/text_utils/TextCursor.ts +0 -44
  211. package/lib/front_end/models/text_utils/TextRange.ts +0 -266
  212. package/lib/front_end/models/text_utils/TextUtils.ts +0 -401
  213. package/lib/front_end/models/text_utils/WasmDisassembly.ts +0 -87
  214. package/lib/front_end/models/text_utils/text_utils.ts +0 -27
  215. package/lib/front_end/models/trace/EntityMapper.ts +0 -141
  216. package/lib/front_end/models/trace/EventsSerializer.ts +0 -101
  217. package/lib/front_end/models/trace/LanternComputationData.ts +0 -438
  218. package/lib/front_end/models/trace/ModelImpl.ts +0 -236
  219. package/lib/front_end/models/trace/Name.ts +0 -136
  220. package/lib/front_end/models/trace/Processor.ts +0 -652
  221. package/lib/front_end/models/trace/Styles.ts +0 -1138
  222. package/lib/front_end/models/trace/extras/FilmStrip.ts +0 -78
  223. package/lib/front_end/models/trace/extras/MainThreadActivity.ts +0 -86
  224. package/lib/front_end/models/trace/extras/ScriptDuplication.ts +0 -236
  225. package/lib/front_end/models/trace/extras/StackTraceForEvent.ts +0 -203
  226. package/lib/front_end/models/trace/extras/ThirdParties.ts +0 -164
  227. package/lib/front_end/models/trace/extras/TraceFilter.ts +0 -62
  228. package/lib/front_end/models/trace/extras/TraceTree.ts +0 -701
  229. package/lib/front_end/models/trace/extras/extras.ts +0 -11
  230. package/lib/front_end/models/trace/handlers/AnimationFramesHandler.ts +0 -128
  231. package/lib/front_end/models/trace/handlers/AnimationHandler.ts +0 -36
  232. package/lib/front_end/models/trace/handlers/AsyncJSCallsHandler.ts +0 -239
  233. package/lib/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +0 -183
  234. package/lib/front_end/models/trace/handlers/DOMStatsHandler.ts +0 -31
  235. package/lib/front_end/models/trace/handlers/ExtensionTraceDataHandler.ts +0 -306
  236. package/lib/front_end/models/trace/handlers/FlowsHandler.ts +0 -175
  237. package/lib/front_end/models/trace/handlers/FramesHandler.ts +0 -571
  238. package/lib/front_end/models/trace/handlers/GPUHandler.ts +0 -50
  239. package/lib/front_end/models/trace/handlers/ImagePaintingHandler.ts +0 -183
  240. package/lib/front_end/models/trace/handlers/InitiatorsHandler.ts +0 -193
  241. package/lib/front_end/models/trace/handlers/InvalidationsHandler.ts +0 -168
  242. package/lib/front_end/models/trace/handlers/LargestImagePaintHandler.ts +0 -109
  243. package/lib/front_end/models/trace/handlers/LargestTextPaintHandler.ts +0 -35
  244. package/lib/front_end/models/trace/handlers/LayerTreeHandler.ts +0 -123
  245. package/lib/front_end/models/trace/handlers/LayoutShiftsHandler.ts +0 -573
  246. package/lib/front_end/models/trace/handlers/MemoryHandler.ts +0 -31
  247. package/lib/front_end/models/trace/handlers/MetaHandler.ts +0 -525
  248. package/lib/front_end/models/trace/handlers/ModelHandlers.ts +0 -34
  249. package/lib/front_end/models/trace/handlers/NetworkRequestsHandler.ts +0 -672
  250. package/lib/front_end/models/trace/handlers/PageFramesHandler.ts +0 -52
  251. package/lib/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +0 -460
  252. package/lib/front_end/models/trace/handlers/RendererHandler.ts +0 -428
  253. package/lib/front_end/models/trace/handlers/SamplesHandler.ts +0 -271
  254. package/lib/front_end/models/trace/handlers/ScreenshotsHandler.ts +0 -122
  255. package/lib/front_end/models/trace/handlers/ScriptsHandler.ts +0 -336
  256. package/lib/front_end/models/trace/handlers/SelectorStatsHandler.ts +0 -110
  257. package/lib/front_end/models/trace/handlers/Threads.ts +0 -139
  258. package/lib/front_end/models/trace/handlers/UserInteractionsHandler.ts +0 -400
  259. package/lib/front_end/models/trace/handlers/UserTimingsHandler.ts +0 -233
  260. package/lib/front_end/models/trace/handlers/WarningsHandler.ts +0 -162
  261. package/lib/front_end/models/trace/handlers/WorkersHandler.ts +0 -45
  262. package/lib/front_end/models/trace/handlers/handlers.ts +0 -8
  263. package/lib/front_end/models/trace/handlers/helpers.ts +0 -196
  264. package/lib/front_end/models/trace/handlers/types.ts +0 -75
  265. package/lib/front_end/models/trace/helpers/Extensions.ts +0 -54
  266. package/lib/front_end/models/trace/helpers/Network.ts +0 -129
  267. package/lib/front_end/models/trace/helpers/SamplesIntegrator.ts +0 -544
  268. package/lib/front_end/models/trace/helpers/SyntheticEvents.ts +0 -87
  269. package/lib/front_end/models/trace/helpers/Timing.ts +0 -248
  270. package/lib/front_end/models/trace/helpers/Trace.ts +0 -928
  271. package/lib/front_end/models/trace/helpers/TreeHelpers.ts +0 -320
  272. package/lib/front_end/models/trace/helpers/helpers.ts +0 -11
  273. package/lib/front_end/models/trace/insights/CLSCulprits.ts +0 -668
  274. package/lib/front_end/models/trace/insights/Cache.ts +0 -269
  275. package/lib/front_end/models/trace/insights/Common.ts +0 -453
  276. package/lib/front_end/models/trace/insights/DOMSize.ts +0 -223
  277. package/lib/front_end/models/trace/insights/DocumentLatency.ts +0 -319
  278. package/lib/front_end/models/trace/insights/DuplicatedJavaScript.ts +0 -126
  279. package/lib/front_end/models/trace/insights/FontDisplay.ts +0 -119
  280. package/lib/front_end/models/trace/insights/ForcedReflow.ts +0 -220
  281. package/lib/front_end/models/trace/insights/INPBreakdown.ts +0 -171
  282. package/lib/front_end/models/trace/insights/ImageDelivery.ts +0 -348
  283. package/lib/front_end/models/trace/insights/LCPBreakdown.ts +0 -268
  284. package/lib/front_end/models/trace/insights/LCPDiscovery.ts +0 -237
  285. package/lib/front_end/models/trace/insights/LegacyJavaScript.ts +0 -138
  286. package/lib/front_end/models/trace/insights/Models.ts +0 -22
  287. package/lib/front_end/models/trace/insights/ModernHTTP.ts +0 -257
  288. package/lib/front_end/models/trace/insights/NetworkDependencyTree.ts +0 -726
  289. package/lib/front_end/models/trace/insights/RenderBlocking.ts +0 -257
  290. package/lib/front_end/models/trace/insights/SlowCSSSelector.ts +0 -175
  291. package/lib/front_end/models/trace/insights/Statistics.ts +0 -101
  292. package/lib/front_end/models/trace/insights/ThirdParties.ts +0 -130
  293. package/lib/front_end/models/trace/insights/Viewport.ts +0 -138
  294. package/lib/front_end/models/trace/insights/insights.ts +0 -10
  295. package/lib/front_end/models/trace/insights/types.ts +0 -157
  296. package/lib/front_end/models/trace/lantern/core/LanternError.ts +0 -7
  297. package/lib/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +0 -619
  298. package/lib/front_end/models/trace/lantern/core/core.ts +0 -6
  299. package/lib/front_end/models/trace/lantern/graph/BaseNode.ts +0 -345
  300. package/lib/front_end/models/trace/lantern/graph/CPUNode.ts +0 -80
  301. package/lib/front_end/models/trace/lantern/graph/NetworkNode.ts +0 -101
  302. package/lib/front_end/models/trace/lantern/graph/PageDependencyGraph.ts +0 -636
  303. package/lib/front_end/models/trace/lantern/graph/graph.ts +0 -8
  304. package/lib/front_end/models/trace/lantern/lantern.ts +0 -17
  305. package/lib/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +0 -187
  306. package/lib/front_end/models/trace/lantern/metrics/Interactive.ts +0 -88
  307. package/lib/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +0 -92
  308. package/lib/front_end/models/trace/lantern/metrics/MaxPotentialFID.ts +0 -72
  309. package/lib/front_end/models/trace/lantern/metrics/Metric.ts +0 -126
  310. package/lib/front_end/models/trace/lantern/metrics/SpeedIndex.ts +0 -126
  311. package/lib/front_end/models/trace/lantern/metrics/TBTUtils.ts +0 -82
  312. package/lib/front_end/models/trace/lantern/metrics/TotalBlockingTime.ts +0 -112
  313. package/lib/front_end/models/trace/lantern/metrics/metrics.ts +0 -12
  314. package/lib/front_end/models/trace/lantern/simulation/ConnectionPool.ts +0 -150
  315. package/lib/front_end/models/trace/lantern/simulation/Constants.ts +0 -46
  316. package/lib/front_end/models/trace/lantern/simulation/DNSCache.ts +0 -61
  317. package/lib/front_end/models/trace/lantern/simulation/SimulationTimingMap.ts +0 -196
  318. package/lib/front_end/models/trace/lantern/simulation/Simulator.ts +0 -556
  319. package/lib/front_end/models/trace/lantern/simulation/TCPConnection.ts +0 -192
  320. package/lib/front_end/models/trace/lantern/simulation/simulation.ts +0 -10
  321. package/lib/front_end/models/trace/lantern/types/Lantern.ts +0 -220
  322. package/lib/front_end/models/trace/lantern/types/types.ts +0 -5
  323. package/lib/front_end/models/trace/trace.ts +0 -33
  324. package/lib/front_end/models/trace/types/Configuration.ts +0 -110
  325. package/lib/front_end/models/trace/types/Extensions.ts +0 -136
  326. package/lib/front_end/models/trace/types/File.ts +0 -281
  327. package/lib/front_end/models/trace/types/Overlays.ts +0 -138
  328. package/lib/front_end/models/trace/types/Timing.ts +0 -30
  329. package/lib/front_end/models/trace/types/TraceEvents.ts +0 -3277
  330. package/lib/front_end/models/trace/types/types.ts +0 -10
  331. package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +0 -240
  332. package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +0 -5
  333. package/lib/front_end/models/workspace/FileManager.ts +0 -97
  334. package/lib/front_end/models/workspace/IgnoreListManager.ts +0 -628
  335. package/lib/front_end/models/workspace/SearchConfig.ts +0 -149
  336. package/lib/front_end/models/workspace/UISourceCode.ts +0 -698
  337. package/lib/front_end/models/workspace/WorkspaceImpl.ts +0 -339
  338. package/lib/front_end/models/workspace/workspace.ts +0 -17
  339. package/lib/front_end/panels/timeline/TimelineUIUtils.ts +0 -1029
  340. package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +0 -49
  341. package/lib/front_end/panels/timeline/extensions/extensions.ts +0 -9
  342. package/lib/front_end/third_party/codemirror.next/LICENSE +0 -21
  343. package/lib/front_end/third_party/codemirror.next/README.chromium +0 -30
  344. package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +0 -24
  345. package/lib/front_end/third_party/codemirror.next/bundle.ts +0 -135
  346. package/lib/front_end/third_party/codemirror.next/chunk/angular.js +0 -2
  347. package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +0 -1
  348. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +0 -2
  349. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +0 -1
  350. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +0 -2
  351. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +0 -1
  352. package/lib/front_end/third_party/codemirror.next/chunk/css.js +0 -2
  353. package/lib/front_end/third_party/codemirror.next/chunk/html.js +0 -4
  354. package/lib/front_end/third_party/codemirror.next/chunk/java.js +0 -2
  355. package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +0 -1
  356. package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +0 -2
  357. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +0 -2
  358. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +0 -1
  359. package/lib/front_end/third_party/codemirror.next/chunk/less.js +0 -2
  360. package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +0 -1
  361. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +0 -2
  362. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +0 -1
  363. package/lib/front_end/third_party/codemirror.next/chunk/php.js +0 -2
  364. package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +0 -1
  365. package/lib/front_end/third_party/codemirror.next/chunk/python.js +0 -2
  366. package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +0 -1
  367. package/lib/front_end/third_party/codemirror.next/chunk/sass.js +0 -2
  368. package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +0 -1
  369. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +0 -2
  370. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +0 -1
  371. package/lib/front_end/third_party/codemirror.next/chunk/vue.js +0 -2
  372. package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +0 -1
  373. package/lib/front_end/third_party/codemirror.next/chunk/wast.js +0 -2
  374. package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +0 -1
  375. package/lib/front_end/third_party/codemirror.next/chunk/xml.js +0 -2
  376. package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +0 -1
  377. package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +0 -8057
  378. package/lib/front_end/third_party/codemirror.next/codemirror.next.js +0 -2
  379. package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +0 -1
  380. package/lib/front_end/third_party/codemirror.next/package.json +0 -43
  381. package/lib/front_end/third_party/codemirror.next/rebuild.sh +0 -6
  382. package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +0 -49
  383. package/lib/front_end/third_party/i18n/LICENSE +0 -202
  384. package/lib/front_end/third_party/i18n/README.chromium +0 -15
  385. package/lib/front_end/third_party/i18n/i18n-impl.ts +0 -61
  386. package/lib/front_end/third_party/i18n/i18n.ts +0 -11
  387. package/lib/front_end/third_party/i18n/localized-string-set.ts +0 -129
  388. package/lib/front_end/third_party/intl-messageformat/LICENSE +0 -33
  389. package/lib/front_end/third_party/intl-messageformat/README.chromium +0 -24
  390. package/lib/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +0 -16
  391. package/lib/front_end/third_party/intl-messageformat/intl-messageformat.ts +0 -6
  392. package/lib/front_end/third_party/intl-messageformat/package/LICENSE.md +0 -33
  393. package/lib/front_end/third_party/intl-messageformat/package/README.md +0 -3
  394. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts +0 -6
  395. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts.map +0 -1
  396. package/lib/front_end/third_party/intl-messageformat/package/index.js +0 -13
  397. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.d.ts +0 -5
  398. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.js +0 -1710
  399. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.iife.js +0 -1815
  400. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts +0 -6
  401. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts.map +0 -1
  402. package/lib/front_end/third_party/intl-messageformat/package/lib/index.js +0 -10
  403. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts +0 -34
  404. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts.map +0 -1
  405. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.js +0 -229
  406. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts +0 -28
  407. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts.map +0 -1
  408. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.js +0 -48
  409. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts +0 -34
  410. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts.map +0 -1
  411. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.js +0 -179
  412. package/lib/front_end/third_party/intl-messageformat/package/package.json +0 -42
  413. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts +0 -34
  414. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts.map +0 -1
  415. package/lib/front_end/third_party/intl-messageformat/package/src/core.js +0 -230
  416. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts +0 -28
  417. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts.map +0 -1
  418. package/lib/front_end/third_party/intl-messageformat/package/src/error.js +0 -51
  419. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts +0 -34
  420. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts.map +0 -1
  421. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.js +0 -182
  422. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/error.d.ts +0 -79
  423. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/index.d.ts +0 -15
  424. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/parser.d.ts +0 -153
  425. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/types.d.ts +0 -139
  426. package/lib/front_end/third_party/legacy-javascript/LICENSE +0 -202
  427. package/lib/front_end/third_party/legacy-javascript/README.chromium +0 -13
  428. package/lib/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +0 -8
  429. package/lib/front_end/third_party/legacy-javascript/legacy-javascript.ts +0 -3
  430. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.d.ts +0 -18
  431. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +0 -943
  432. package/lib/front_end/third_party/legacy-javascript/package.json +0 -8
  433. package/lib/front_end/third_party/legacy-javascript/rebuild.sh +0 -9
  434. package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +0 -26
  435. package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +0 -31
  436. package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -33
  437. package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -26
  438. package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +0 -64
  439. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -62
  440. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +0 -1
  441. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -37
  442. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -1
  443. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -29
  444. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -1
  445. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -8
  446. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -1
  447. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -6
  448. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -1
  449. package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +0 -21
  450. package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +0 -14
  451. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +0 -196
  452. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +0 -1
  453. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +0 -262
  454. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -235
  455. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -1
  456. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -359
  457. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -39
  458. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -1
  459. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -53
  460. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -438
  461. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -1
  462. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -539
  463. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -23
  464. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -1
  465. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -35
  466. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -257
  467. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -1
  468. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -348
  469. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -8
  470. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -1
  471. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -20
  472. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +0 -8
  473. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +0 -184
  474. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -9
  475. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -1
  476. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -12
  477. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -82
  478. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -1
  479. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -99
  480. package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +0 -5
  481. package/lib/front_end/third_party/third-party-web/LICENSE +0 -20
  482. package/lib/front_end/third_party/third-party-web/README.chromium +0 -13
  483. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.d.ts +0 -2
  484. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.js +0 -149
  485. package/lib/front_end/third_party/third-party-web/package/LICENSE +0 -20
  486. package/lib/front_end/third_party/third-party-web/package/README.md +0 -929
  487. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive-nostats.json +0 -1
  488. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive.json +0 -1
  489. package/lib/front_end/third_party/third-party-web/package/dist/entities-nostats.json +0 -1
  490. package/lib/front_end/third_party/third-party-web/package/dist/entities.json +0 -1
  491. package/lib/front_end/third_party/third-party-web/package/facades.md +0 -46
  492. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.d.ts +0 -1
  493. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.js +0 -1
  494. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.d.ts +0 -1
  495. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.js +0 -1
  496. package/lib/front_end/third_party/third-party-web/package/lib/__snapshots__/index.test.js.snap +0 -1006
  497. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.js +0 -139
  498. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.test.js +0 -44
  499. package/lib/front_end/third_party/third-party-web/package/lib/entities.test.js +0 -27
  500. package/lib/front_end/third_party/third-party-web/package/lib/index.d.ts +0 -34
  501. package/lib/front_end/third_party/third-party-web/package/lib/index.js +0 -3
  502. package/lib/front_end/third_party/third-party-web/package/lib/index.test.js +0 -246
  503. package/lib/front_end/third_party/third-party-web/package/lib/markdown/faqs.partial.md +0 -36
  504. package/lib/front_end/third_party/third-party-web/package/lib/markdown/goals.partial.md +0 -9
  505. package/lib/front_end/third_party/third-party-web/package/lib/markdown/methodology.partial.md +0 -5
  506. package/lib/front_end/third_party/third-party-web/package/lib/markdown/template.md +0 -151
  507. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-02-01.md +0 -1
  508. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-03-01.md +0 -1
  509. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-06.md +0 -1
  510. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-13.md +0 -14
  511. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2021-01-01.md +0 -1
  512. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2024-07-01.md +0 -3
  513. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.d.ts +0 -1
  514. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.js +0 -3
  515. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.d.ts +0 -1
  516. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.js +0 -3
  517. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.d.ts +0 -1
  518. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.js +0 -3
  519. package/lib/front_end/third_party/third-party-web/package/nostats-subset.d.ts +0 -1
  520. package/lib/front_end/third_party/third-party-web/package/nostats-subset.js +0 -1
  521. package/lib/front_end/third_party/third-party-web/package/package.json +0 -46
  522. package/lib/front_end/third_party/third-party-web/package.json +0 -8
  523. package/lib/front_end/third_party/third-party-web/rebuild.sh +0 -13
  524. package/lib/front_end/third_party/third-party-web/third-party-web-tsconfig.json +0 -8
  525. package/lib/front_end/third_party/third-party-web/third-party-web.ts +0 -3
  526. package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +0 -222
  527. package/lib/front_end/ui/legacy/theme_support/theme_support.ts +0 -5
  528. package/patches/chrome-devtools-frontend+1.0.1533544.patch +0 -1716
@@ -1,1646 +0,0 @@
1
- // Copyright 2016 The Chromium Authors
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
-
5
- import * as Protocol from '../../generated/protocol.js';
6
- import type * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js';
7
- import * as Platform from '../platform/platform.js';
8
-
9
- import {CSSMetadata, cssMetadata, CSSWideKeyword} from './CSSMetadata.js';
10
- import type {CSSModel} from './CSSModel.js';
11
- import {CSSProperty} from './CSSProperty.js';
12
- import * as PropertyParser from './CSSPropertyParser.js';
13
- import type {Match, Matcher, SyntaxTree} from './CSSPropertyParser.js';
14
- import {
15
- AnchorFunctionMatcher,
16
- AngleMatcher,
17
- AttributeMatcher,
18
- AutoBaseMatcher,
19
- BaseVariableMatcher,
20
- BezierMatcher,
21
- BinOpMatcher,
22
- ColorMatcher,
23
- ColorMixMatcher,
24
- CustomFunctionMatcher,
25
- defaultValueForCSSType,
26
- EnvFunctionMatcher,
27
- FlexGridMatcher,
28
- GridTemplateMatcher,
29
- LengthMatcher,
30
- LightDarkColorMatcher,
31
- LinearGradientMatcher,
32
- LinkableNameMatcher,
33
- localEvalCSS,
34
- MathFunctionMatcher,
35
- PositionAnchorMatcher,
36
- PositionTryMatcher,
37
- RelativeColorChannelMatcher,
38
- ShadowMatcher,
39
- StringMatcher,
40
- URLMatcher,
41
- VariableMatcher
42
- } from './CSSPropertyParserMatchers.js';
43
- import {
44
- CSSFontPaletteValuesRule,
45
- CSSFunctionRule,
46
- CSSKeyframeRule,
47
- CSSKeyframesRule,
48
- CSSPositionTryRule,
49
- CSSPropertyRule,
50
- CSSStyleRule,
51
- } from './CSSRule.js';
52
- import {CSSStyleDeclaration, Type} from './CSSStyleDeclaration.js';
53
- import type {DOMNode} from './DOMModel.js';
54
-
55
- function containsStyle(styles: CSSStyleDeclaration[]|Set<CSSStyleDeclaration>, query: CSSStyleDeclaration): boolean {
56
- if (!query.styleSheetId || !query.range) {
57
- return false;
58
- }
59
- for (const style of styles) {
60
- if (query.styleSheetId === style.styleSheetId && style.range && query.range.equal(style.range)) {
61
- return true;
62
- }
63
- }
64
- return false;
65
- }
66
-
67
- function containsCustomProperties(style: CSSStyleDeclaration): boolean {
68
- const properties = style.allProperties();
69
- return properties.some(property => cssMetadata().isCustomProperty(property.name));
70
- }
71
-
72
- function containsInherited(style: CSSStyleDeclaration): boolean {
73
- const properties = style.allProperties();
74
- for (let i = 0; i < properties.length; ++i) {
75
- const property = properties[i];
76
- // Does this style contain non-overridden inherited property?
77
- if (property.activeInStyle() && cssMetadata().isPropertyInherited(property.name)) {
78
- return true;
79
- }
80
- }
81
- return false;
82
- }
83
-
84
- function cleanUserAgentPayload(payload: Protocol.CSS.RuleMatch[]): Protocol.CSS.RuleMatch[] {
85
- for (const ruleMatch of payload) {
86
- cleanUserAgentSelectors(ruleMatch);
87
- }
88
-
89
- // Merge UA rules that are sequential and have similar selector/media.
90
- const cleanMatchedPayload = [];
91
- for (const ruleMatch of payload) {
92
- const lastMatch = cleanMatchedPayload[cleanMatchedPayload.length - 1];
93
- if (!lastMatch || ruleMatch.rule.origin !== 'user-agent' || lastMatch.rule.origin !== 'user-agent' ||
94
- ruleMatch.rule.selectorList.text !== lastMatch.rule.selectorList.text ||
95
- mediaText(ruleMatch) !== mediaText(lastMatch)) {
96
- cleanMatchedPayload.push(ruleMatch);
97
- continue;
98
- }
99
- mergeRule(ruleMatch, lastMatch);
100
- }
101
- return cleanMatchedPayload;
102
-
103
- function mergeRule(from: Protocol.CSS.RuleMatch, to: Protocol.CSS.RuleMatch): void {
104
- const shorthands = new Map<string, string>();
105
- const properties = new Map<string, string>();
106
- for (const entry of to.rule.style.shorthandEntries) {
107
- shorthands.set(entry.name, entry.value);
108
- }
109
- for (const entry of to.rule.style.cssProperties) {
110
- properties.set(entry.name, entry.value);
111
- }
112
- for (const entry of from.rule.style.shorthandEntries) {
113
- shorthands.set(entry.name, entry.value);
114
- }
115
- for (const entry of from.rule.style.cssProperties) {
116
- properties.set(entry.name, entry.value);
117
- }
118
- to.rule.style.shorthandEntries = [...shorthands.entries()].map(([name, value]) => ({name, value}));
119
- to.rule.style.cssProperties = [...properties.entries()].map(([name, value]) => ({name, value}));
120
- }
121
-
122
- function mediaText(ruleMatch: Protocol.CSS.RuleMatch): string|null {
123
- if (!ruleMatch.rule.media) {
124
- return null;
125
- }
126
- return ruleMatch.rule.media.map(media => media.text).join(', ');
127
- }
128
-
129
- function cleanUserAgentSelectors(ruleMatch: Protocol.CSS.RuleMatch): void {
130
- const {matchingSelectors, rule} = ruleMatch;
131
- if (rule.origin !== 'user-agent' || !matchingSelectors.length) {
132
- return;
133
- }
134
- rule.selectorList.selectors = rule.selectorList.selectors.filter((_, i) => matchingSelectors.includes(i));
135
- rule.selectorList.text = rule.selectorList.selectors.map(item => item.text).join(', ');
136
- ruleMatch.matchingSelectors = matchingSelectors.map((_, i) => i);
137
- }
138
- }
139
-
140
- /**
141
- * Return a mapping of the highlight names in the specified RuleMatch to
142
- * the indices of selectors in that selector list with that highlight name.
143
- *
144
- * For example, consider the following ruleset:
145
- * span::highlight(foo), div, #mySpan::highlight(bar), .highlighted::highlight(foo) {
146
- * color: blue;
147
- * }
148
- *
149
- * For a <span id="mySpan" class="highlighted"></span>, a RuleMatch for that span
150
- * would have matchingSelectors [0, 2, 3] indicating that the span
151
- * matches all of the highlight selectors.
152
- *
153
- * For that RuleMatch, this function would produce the following map:
154
- * {
155
- * "foo": [0, 3],
156
- * "bar": [2]
157
- * }
158
- *
159
- * @param ruleMatch
160
- * @returns A mapping of highlight names to lists of indices into the selector
161
- * list associated with ruleMatch. The indices correspond to the selectors in the rule
162
- * associated with the key's highlight name.
163
- */
164
- function customHighlightNamesToMatchingSelectorIndices(ruleMatch: Protocol.CSS.RuleMatch): Map<string, number[]> {
165
- const highlightNamesToMatchingSelectors = new Map<string, number[]>();
166
-
167
- for (let i = 0; i < ruleMatch.matchingSelectors.length; i++) {
168
- const matchingSelectorIndex = ruleMatch.matchingSelectors[i];
169
- const selectorText = ruleMatch.rule.selectorList.selectors[matchingSelectorIndex].text;
170
- const highlightNameMatch = selectorText.match(/::highlight\((.*)\)/);
171
- if (highlightNameMatch) {
172
- const highlightName = highlightNameMatch[1];
173
- const selectorsForName = highlightNamesToMatchingSelectors.get(highlightName);
174
- if (selectorsForName) {
175
- selectorsForName.push(matchingSelectorIndex);
176
- } else {
177
- highlightNamesToMatchingSelectors.set(highlightName, [matchingSelectorIndex]);
178
- }
179
- }
180
- }
181
- return highlightNamesToMatchingSelectors;
182
- }
183
-
184
- function queryMatches(style: CSSStyleDeclaration): boolean {
185
- if (!style.parentRule) {
186
- return true;
187
- }
188
- const parentRule = style.parentRule as CSSStyleRule;
189
- const queries = [...parentRule.media, ...parentRule.containerQueries, ...parentRule.supports, ...parentRule.scopes];
190
- for (const query of queries) {
191
- if (!query.active()) {
192
- return false;
193
- }
194
- }
195
- return true;
196
- }
197
-
198
- export interface CSSMatchedStylesPayload {
199
- cssModel: CSSModel;
200
- node: DOMNode;
201
- activePositionFallbackIndex: number;
202
- inlinePayload: Protocol.CSS.CSSStyle|null;
203
- attributesPayload: Protocol.CSS.CSSStyle|null;
204
- matchedPayload: Protocol.CSS.RuleMatch[];
205
- pseudoPayload: Protocol.CSS.PseudoElementMatches[];
206
- inheritedPayload: Protocol.CSS.InheritedStyleEntry[];
207
- inheritedPseudoPayload: Protocol.CSS.InheritedPseudoElementMatches[];
208
- animationsPayload: Protocol.CSS.CSSKeyframesRule[];
209
- parentLayoutNodeId: Protocol.DOM.NodeId|undefined;
210
- positionTryRules: Protocol.CSS.CSSPositionTryRule[];
211
- propertyRules: Protocol.CSS.CSSPropertyRule[];
212
- cssPropertyRegistrations: Protocol.CSS.CSSPropertyRegistration[];
213
- fontPaletteValuesRule: Protocol.CSS.CSSFontPaletteValuesRule|undefined;
214
- animationStylesPayload: Protocol.CSS.CSSAnimationStyle[];
215
- transitionsStylePayload: Protocol.CSS.CSSStyle|null;
216
- inheritedAnimatedPayload: Protocol.CSS.InheritedAnimatedStyleEntry[];
217
- functionRules: Protocol.CSS.CSSFunctionRule[];
218
- }
219
-
220
- export interface CSSType {
221
- type: string;
222
- isCSSTokens: boolean;
223
- }
224
-
225
- export class CSSRegisteredProperty {
226
- #registration: Protocol.CSS.CSSPropertyRegistration|CSSPropertyRule;
227
- #cssModel: CSSModel;
228
- #style: CSSStyleDeclaration|undefined;
229
- constructor(cssModel: CSSModel, registration: CSSPropertyRule|Protocol.CSS.CSSPropertyRegistration) {
230
- this.#cssModel = cssModel;
231
- this.#registration = registration;
232
- }
233
-
234
- propertyName(): string {
235
- return this.#registration instanceof CSSPropertyRule ? this.#registration.propertyName().text :
236
- this.#registration.propertyName;
237
- }
238
-
239
- initialValue(): string|null {
240
- return this.#registration instanceof CSSPropertyRule ? this.#registration.initialValue() :
241
- this.#registration.initialValue?.text ?? null;
242
- }
243
-
244
- inherits(): boolean {
245
- return this.#registration instanceof CSSPropertyRule ? this.#registration.inherits() : this.#registration.inherits;
246
- }
247
-
248
- syntax(): string {
249
- return this.#registration instanceof CSSPropertyRule ? this.#registration.syntax() :
250
- `"${this.#registration.syntax}"`;
251
- }
252
-
253
- parseValue(matchedStyles: CSSMatchedStyles, computedStyles: Map<string, string>|null):
254
- PropertyParser.BottomUpTreeMatching|null {
255
- const value = this.initialValue();
256
- if (!value) {
257
- return null;
258
- }
259
-
260
- return PropertyParser.matchDeclaration(
261
- this.propertyName(), value, matchedStyles.propertyMatchers(this.style(), computedStyles));
262
- }
263
-
264
- #asCSSProperties(): Protocol.CSS.CSSProperty[] {
265
- if (this.#registration instanceof CSSPropertyRule) {
266
- return [];
267
- }
268
- const {inherits, initialValue, syntax} = this.#registration;
269
- const properties = [
270
- {name: 'inherits', value: `${inherits}`},
271
- {name: 'syntax', value: `"${syntax}"`},
272
- ];
273
- if (initialValue !== undefined) {
274
- properties.push({name: 'initial-value', value: initialValue.text});
275
- }
276
- return properties;
277
- }
278
-
279
- style(): CSSStyleDeclaration {
280
- if (!this.#style) {
281
- this.#style = this.#registration instanceof CSSPropertyRule ?
282
- this.#registration.style :
283
- new CSSStyleDeclaration(
284
- this.#cssModel, null, {cssProperties: this.#asCSSProperties(), shorthandEntries: []}, Type.Pseudo);
285
- }
286
- return this.#style;
287
- }
288
- }
289
-
290
- export class CSSMatchedStyles {
291
- #cssModel: CSSModel;
292
- #node: DOMNode;
293
- #addedStyles = new Map<CSSStyleDeclaration, DOMNode>();
294
- #matchingSelectors = new Map<number, Map<string, boolean>>();
295
- #keyframes: CSSKeyframesRule[] = [];
296
- #registeredProperties: CSSRegisteredProperty[];
297
- #registeredPropertyMap = new Map<string, CSSRegisteredProperty>();
298
- #nodeForStyle = new Map<CSSStyleDeclaration, DOMNode|null>();
299
- #inheritedStyles = new Set<CSSStyleDeclaration>();
300
- #styleToDOMCascade = new Map<CSSStyleDeclaration, DOMInheritanceCascade>();
301
- #parentLayoutNodeId: Protocol.DOM.NodeId|undefined;
302
- #positionTryRules: CSSPositionTryRule[];
303
- #activePositionFallbackIndex: number;
304
- #mainDOMCascade?: DOMInheritanceCascade;
305
- #pseudoDOMCascades?: Map<Protocol.DOM.PseudoType, DOMInheritanceCascade>;
306
- #customHighlightPseudoDOMCascades?: Map<string, DOMInheritanceCascade>;
307
- #functionRules: CSSFunctionRule[];
308
- #functionRuleMap = new Map<string, CSSFunctionRule>();
309
- readonly #fontPaletteValuesRule: CSSFontPaletteValuesRule|undefined;
310
- #environmentVariables: Record<string, string> = {};
311
-
312
- static async create(payload: CSSMatchedStylesPayload): Promise<CSSMatchedStyles> {
313
- const cssMatchedStyles = new CSSMatchedStyles(payload);
314
- await cssMatchedStyles.init(payload);
315
- return cssMatchedStyles;
316
- }
317
-
318
- private constructor({
319
- cssModel,
320
- node,
321
- animationsPayload,
322
- parentLayoutNodeId,
323
- positionTryRules,
324
- propertyRules,
325
- cssPropertyRegistrations,
326
- fontPaletteValuesRule,
327
- activePositionFallbackIndex,
328
- functionRules,
329
- }: CSSMatchedStylesPayload) {
330
- this.#cssModel = cssModel;
331
- this.#node = node;
332
- this.#registeredProperties = [
333
- ...propertyRules.map(rule => new CSSPropertyRule(cssModel, rule)),
334
- ...cssPropertyRegistrations,
335
- ].map(r => new CSSRegisteredProperty(cssModel, r));
336
- if (animationsPayload) {
337
- this.#keyframes = animationsPayload.map(rule => new CSSKeyframesRule(cssModel, rule));
338
- }
339
- this.#positionTryRules = positionTryRules.map(rule => new CSSPositionTryRule(cssModel, rule));
340
- this.#parentLayoutNodeId = parentLayoutNodeId;
341
- this.#fontPaletteValuesRule =
342
- fontPaletteValuesRule ? new CSSFontPaletteValuesRule(cssModel, fontPaletteValuesRule) : undefined;
343
-
344
- this.#activePositionFallbackIndex = activePositionFallbackIndex;
345
- this.#functionRules = functionRules.map(rule => new CSSFunctionRule(cssModel, rule));
346
- }
347
-
348
- private async init({
349
- matchedPayload,
350
- inheritedPayload,
351
- inlinePayload,
352
- attributesPayload,
353
- pseudoPayload,
354
- inheritedPseudoPayload,
355
- animationStylesPayload,
356
- transitionsStylePayload,
357
- inheritedAnimatedPayload,
358
- }: CSSMatchedStylesPayload): Promise<void> {
359
- matchedPayload = cleanUserAgentPayload(matchedPayload);
360
- for (const inheritedResult of inheritedPayload) {
361
- inheritedResult.matchedCSSRules = cleanUserAgentPayload(inheritedResult.matchedCSSRules);
362
- }
363
-
364
- this.#environmentVariables = await this.cssModel().getEnvironmentVariales();
365
-
366
- this.#mainDOMCascade = await this.buildMainCascade(
367
- inlinePayload, attributesPayload, matchedPayload, inheritedPayload, animationStylesPayload,
368
- transitionsStylePayload, inheritedAnimatedPayload);
369
- [this.#pseudoDOMCascades, this.#customHighlightPseudoDOMCascades] =
370
- this.buildPseudoCascades(pseudoPayload, inheritedPseudoPayload);
371
-
372
- for (const domCascade of Array.from(this.#customHighlightPseudoDOMCascades.values())
373
- .concat(Array.from(this.#pseudoDOMCascades.values()))
374
- .concat(this.#mainDOMCascade)) {
375
- for (const style of domCascade.styles()) {
376
- this.#styleToDOMCascade.set(style, domCascade);
377
- }
378
- }
379
-
380
- for (const prop of this.#registeredProperties) {
381
- this.#registeredPropertyMap.set(prop.propertyName(), prop);
382
- }
383
-
384
- for (const rule of this.#functionRules) {
385
- this.#functionRuleMap.set(rule.functionName().text, rule);
386
- }
387
- }
388
-
389
- private async buildMainCascade(
390
- inlinePayload: Protocol.CSS.CSSStyle|null,
391
- attributesPayload: Protocol.CSS.CSSStyle|null,
392
- matchedPayload: Protocol.CSS.RuleMatch[],
393
- inheritedPayload: Protocol.CSS.InheritedStyleEntry[],
394
- animationStylesPayload: Protocol.CSS.CSSAnimationStyle[],
395
- transitionsStylePayload: Protocol.CSS.CSSStyle|null,
396
- inheritedAnimatedPayload: Protocol.CSS.InheritedAnimatedStyleEntry[],
397
- ): Promise<DOMInheritanceCascade> {
398
- const nodeCascades: NodeCascade[] = [];
399
-
400
- const nodeStyles: CSSStyleDeclaration[] = [];
401
-
402
- function addAttributesStyle(this: CSSMatchedStyles): void {
403
- if (!attributesPayload) {
404
- return;
405
- }
406
- const style = new CSSStyleDeclaration(this.#cssModel, null, attributesPayload, Type.Attributes);
407
- this.#nodeForStyle.set(style, this.#node);
408
- nodeStyles.push(style);
409
- }
410
-
411
- // Transition styles take precedence over animation styles & inline styles.
412
- if (transitionsStylePayload) {
413
- const style = new CSSStyleDeclaration(this.#cssModel, null, transitionsStylePayload, Type.Transition);
414
- this.#nodeForStyle.set(style, this.#node);
415
- nodeStyles.push(style);
416
- }
417
-
418
- // Animation styles take precedence over inline styles.
419
- for (const animationsStyle of animationStylesPayload) {
420
- const style =
421
- new CSSStyleDeclaration(this.#cssModel, null, animationsStyle.style, Type.Animation, animationsStyle.name);
422
- this.#nodeForStyle.set(style, this.#node);
423
- nodeStyles.push(style);
424
- }
425
-
426
- // Inline style takes precedence over regular and inherited rules.
427
- if (inlinePayload && this.#node.nodeType() === Node.ELEMENT_NODE) {
428
- const style = new CSSStyleDeclaration(this.#cssModel, null, inlinePayload, Type.Inline);
429
- this.#nodeForStyle.set(style, this.#node);
430
- nodeStyles.push(style);
431
- }
432
-
433
- // Add rules in reverse order to match the cascade order.
434
- let addedAttributesStyle;
435
- for (let i = matchedPayload.length - 1; i >= 0; --i) {
436
- const rule = new CSSStyleRule(this.#cssModel, matchedPayload[i].rule);
437
- if ((rule.isInjected() || rule.isUserAgent()) && !addedAttributesStyle) {
438
- // Show element's Style Attributes after all author rules.
439
- addedAttributesStyle = true;
440
- addAttributesStyle.call(this);
441
- }
442
- this.#nodeForStyle.set(rule.style, this.#node);
443
- nodeStyles.push(rule.style);
444
- this.addMatchingSelectors(this.#node, rule, matchedPayload[i].matchingSelectors);
445
- }
446
-
447
- if (!addedAttributesStyle) {
448
- addAttributesStyle.call(this);
449
- }
450
- nodeCascades.push(new NodeCascade(this, nodeStyles, this.#node, false /* #isInherited */));
451
-
452
- // Walk the node structure and identify styles with inherited properties.
453
- let parentNode: (DOMNode|null) = this.#node.parentNode;
454
- const traverseParentInFlatTree = async(node: DOMNode): Promise<DOMNode|null> => {
455
- if (node.hasAssignedSlot()) {
456
- return await node.assignedSlot?.deferredNode.resolvePromise() ?? null;
457
- }
458
-
459
- return node.parentNode;
460
- };
461
-
462
- for (let i = 0; parentNode && inheritedPayload && i < inheritedPayload.length; ++i) {
463
- const inheritedStyles = [];
464
- const entryPayload = inheritedPayload[i];
465
- const inheritedAnimatedEntryPayload = inheritedAnimatedPayload[i];
466
- const inheritedInlineStyle = entryPayload.inlineStyle ?
467
- new CSSStyleDeclaration(this.#cssModel, null, entryPayload.inlineStyle, Type.Inline) :
468
- null;
469
- const inheritedTransitionsStyle = inheritedAnimatedEntryPayload?.transitionsStyle ?
470
- new CSSStyleDeclaration(
471
- this.#cssModel, null, inheritedAnimatedEntryPayload?.transitionsStyle, Type.Transition) :
472
- null;
473
- const inheritedAnimationStyles =
474
- inheritedAnimatedEntryPayload?.animationStyles?.map(
475
- animationStyle => new CSSStyleDeclaration(
476
- this.#cssModel, null, animationStyle.style, Type.Animation, animationStyle.name)) ??
477
- [];
478
- if (inheritedTransitionsStyle && containsInherited(inheritedTransitionsStyle)) {
479
- this.#nodeForStyle.set(inheritedTransitionsStyle, parentNode);
480
- inheritedStyles.push(inheritedTransitionsStyle);
481
- this.#inheritedStyles.add(inheritedTransitionsStyle);
482
- }
483
-
484
- for (const inheritedAnimationsStyle of inheritedAnimationStyles) {
485
- if (!containsInherited(inheritedAnimationsStyle)) {
486
- continue;
487
- }
488
-
489
- this.#nodeForStyle.set(inheritedAnimationsStyle, parentNode);
490
- inheritedStyles.push(inheritedAnimationsStyle);
491
- this.#inheritedStyles.add(inheritedAnimationsStyle);
492
- }
493
-
494
- if (inheritedInlineStyle && containsInherited(inheritedInlineStyle)) {
495
- this.#nodeForStyle.set(inheritedInlineStyle, parentNode);
496
- inheritedStyles.push(inheritedInlineStyle);
497
- this.#inheritedStyles.add(inheritedInlineStyle);
498
- }
499
-
500
- const inheritedMatchedCSSRules = entryPayload.matchedCSSRules || [];
501
- for (let j = inheritedMatchedCSSRules.length - 1; j >= 0; --j) {
502
- const inheritedRule = new CSSStyleRule(this.#cssModel, inheritedMatchedCSSRules[j].rule);
503
- this.addMatchingSelectors(parentNode, inheritedRule, inheritedMatchedCSSRules[j].matchingSelectors);
504
- if (!containsInherited(inheritedRule.style)) {
505
- continue;
506
- }
507
- if (!containsCustomProperties(inheritedRule.style)) {
508
- if (containsStyle(nodeStyles, inheritedRule.style) ||
509
- containsStyle(this.#inheritedStyles, inheritedRule.style)) {
510
- continue;
511
- }
512
- }
513
- this.#nodeForStyle.set(inheritedRule.style, parentNode);
514
- inheritedStyles.push(inheritedRule.style);
515
- this.#inheritedStyles.add(inheritedRule.style);
516
- }
517
- const node = parentNode;
518
- parentNode = await traverseParentInFlatTree(parentNode);
519
- nodeCascades.push(new NodeCascade(this, inheritedStyles, node, true /* #isInherited */));
520
- }
521
-
522
- return new DOMInheritanceCascade(this, nodeCascades, this.#registeredProperties);
523
- }
524
-
525
- /**
526
- * Pseudo rule matches received via the inspector protocol are grouped by pseudo type.
527
- * For custom highlight pseudos, we need to instead group the rule matches by highlight
528
- * name in order to produce separate cascades for each highlight name. This is necessary
529
- * so that styles of ::highlight(foo) are not shown as overriding styles of ::highlight(bar).
530
- *
531
- * This helper function takes a list of rule matches and generates separate NodeCascades
532
- * for each custom highlight name that was matched.
533
- */
534
- private buildSplitCustomHighlightCascades(
535
- rules: Protocol.CSS.RuleMatch[], node: DOMNode, isInherited: boolean,
536
- pseudoCascades: Map<string, NodeCascade[]>): void {
537
- const splitHighlightRules = new Map<string, CSSStyleDeclaration[]>();
538
-
539
- for (let j = rules.length - 1; j >= 0; --j) {
540
- const highlightNamesToMatchingSelectorIndices = customHighlightNamesToMatchingSelectorIndices(rules[j]);
541
-
542
- for (const [highlightName, matchingSelectors] of highlightNamesToMatchingSelectorIndices) {
543
- const pseudoRule = new CSSStyleRule(this.#cssModel, rules[j].rule);
544
- this.#nodeForStyle.set(pseudoRule.style, node);
545
- if (isInherited) {
546
- this.#inheritedStyles.add(pseudoRule.style);
547
- }
548
- this.addMatchingSelectors(node, pseudoRule, matchingSelectors);
549
-
550
- const ruleListForHighlightName = splitHighlightRules.get(highlightName);
551
- if (ruleListForHighlightName) {
552
- ruleListForHighlightName.push(pseudoRule.style);
553
- } else {
554
- splitHighlightRules.set(highlightName, [pseudoRule.style]);
555
- }
556
- }
557
- }
558
-
559
- for (const [highlightName, highlightStyles] of splitHighlightRules) {
560
- const nodeCascade =
561
- new NodeCascade(this, highlightStyles, node, isInherited, true /* #isHighlightPseudoCascade*/);
562
- const cascadeListForHighlightName = pseudoCascades.get(highlightName);
563
- if (cascadeListForHighlightName) {
564
- cascadeListForHighlightName.push(nodeCascade);
565
- } else {
566
- pseudoCascades.set(highlightName, [nodeCascade]);
567
- }
568
- }
569
- }
570
-
571
- private buildPseudoCascades(
572
- pseudoPayload: Protocol.CSS.PseudoElementMatches[],
573
- inheritedPseudoPayload: Protocol.CSS.InheritedPseudoElementMatches[]):
574
- [Map<Protocol.DOM.PseudoType, DOMInheritanceCascade>, Map<string, DOMInheritanceCascade>] {
575
- const pseudoInheritanceCascades = new Map<Protocol.DOM.PseudoType, DOMInheritanceCascade>();
576
- const customHighlightPseudoInheritanceCascades = new Map<string, DOMInheritanceCascade>();
577
- if (!pseudoPayload) {
578
- return [pseudoInheritanceCascades, customHighlightPseudoInheritanceCascades];
579
- }
580
-
581
- const pseudoCascades = new Map<Protocol.DOM.PseudoType, NodeCascade[]>();
582
- const customHighlightPseudoCascades = new Map<string, NodeCascade[]>();
583
- for (let i = 0; i < pseudoPayload.length; ++i) {
584
- const entryPayload = pseudoPayload[i];
585
- // PseudoElement nodes are not created unless "content" css property is set.
586
- const pseudoElement = this.#node.pseudoElements().get(entryPayload.pseudoType)?.at(-1) || null;
587
- const pseudoStyles = [];
588
- const rules = entryPayload.matches || [];
589
-
590
- if (entryPayload.pseudoType === Protocol.DOM.PseudoType.Highlight) {
591
- this.buildSplitCustomHighlightCascades(
592
- rules, this.#node, false /* #isInherited */, customHighlightPseudoCascades);
593
- } else {
594
- for (let j = rules.length - 1; j >= 0; --j) {
595
- const pseudoRule = new CSSStyleRule(this.#cssModel, rules[j].rule);
596
- pseudoStyles.push(pseudoRule.style);
597
- const nodeForStyle =
598
- cssMetadata().isHighlightPseudoType(entryPayload.pseudoType) ? this.#node : pseudoElement;
599
- this.#nodeForStyle.set(pseudoRule.style, nodeForStyle);
600
- if (nodeForStyle) {
601
- this.addMatchingSelectors(nodeForStyle, pseudoRule, rules[j].matchingSelectors);
602
- }
603
- }
604
- const isHighlightPseudoCascade = cssMetadata().isHighlightPseudoType(entryPayload.pseudoType);
605
- const nodeCascade = new NodeCascade(
606
- this, pseudoStyles, this.#node, false /* #isInherited */,
607
- isHighlightPseudoCascade /* #isHighlightPseudoCascade*/);
608
- pseudoCascades.set(entryPayload.pseudoType, [nodeCascade]);
609
- }
610
- }
611
-
612
- if (inheritedPseudoPayload) {
613
- let parentNode: (DOMNode|null) = this.#node.parentNode;
614
- for (let i = 0; parentNode && i < inheritedPseudoPayload.length; ++i) {
615
- const inheritedPseudoMatches = inheritedPseudoPayload[i].pseudoElements;
616
- for (let j = 0; j < inheritedPseudoMatches.length; ++j) {
617
- const inheritedEntryPayload = inheritedPseudoMatches[j];
618
- const rules = inheritedEntryPayload.matches || [];
619
-
620
- if (inheritedEntryPayload.pseudoType === Protocol.DOM.PseudoType.Highlight) {
621
- this.buildSplitCustomHighlightCascades(
622
- rules, parentNode, true /* #isInherited */, customHighlightPseudoCascades);
623
- } else {
624
- const pseudoStyles = [];
625
- for (let k = rules.length - 1; k >= 0; --k) {
626
- const pseudoRule = new CSSStyleRule(this.#cssModel, rules[k].rule);
627
- pseudoStyles.push(pseudoRule.style);
628
- this.#nodeForStyle.set(pseudoRule.style, parentNode);
629
- this.#inheritedStyles.add(pseudoRule.style);
630
- this.addMatchingSelectors(parentNode, pseudoRule, rules[k].matchingSelectors);
631
- }
632
-
633
- const isHighlightPseudoCascade = cssMetadata().isHighlightPseudoType(inheritedEntryPayload.pseudoType);
634
- const nodeCascade = new NodeCascade(
635
- this, pseudoStyles, parentNode, true /* #isInherited */,
636
- isHighlightPseudoCascade /* #isHighlightPseudoCascade*/);
637
- const cascadeListForPseudoType = pseudoCascades.get(inheritedEntryPayload.pseudoType);
638
- if (cascadeListForPseudoType) {
639
- cascadeListForPseudoType.push(nodeCascade);
640
- } else {
641
- pseudoCascades.set(inheritedEntryPayload.pseudoType, [nodeCascade]);
642
- }
643
- }
644
- }
645
-
646
- parentNode = parentNode.parentNode;
647
- }
648
- }
649
-
650
- // Now that we've built the arrays of NodeCascades for each pseudo type, convert them into
651
- // DOMInheritanceCascades.
652
- for (const [pseudoType, nodeCascade] of pseudoCascades.entries()) {
653
- pseudoInheritanceCascades.set(
654
- pseudoType, new DOMInheritanceCascade(this, nodeCascade, this.#registeredProperties));
655
- }
656
-
657
- for (const [highlightName, nodeCascade] of customHighlightPseudoCascades.entries()) {
658
- customHighlightPseudoInheritanceCascades.set(
659
- highlightName, new DOMInheritanceCascade(this, nodeCascade, this.#registeredProperties));
660
- }
661
-
662
- return [pseudoInheritanceCascades, customHighlightPseudoInheritanceCascades];
663
- }
664
-
665
- private addMatchingSelectors(
666
- this: CSSMatchedStyles, node: DOMNode, rule: CSSStyleRule, matchingSelectorIndices: number[]): void {
667
- for (const matchingSelectorIndex of matchingSelectorIndices) {
668
- const selector = rule.selectors[matchingSelectorIndex];
669
- if (selector) {
670
- this.setSelectorMatches(node, selector.text, true);
671
- }
672
- }
673
- }
674
-
675
- node(): DOMNode {
676
- return this.#node;
677
- }
678
-
679
- cssModel(): CSSModel {
680
- return this.#cssModel;
681
- }
682
-
683
- hasMatchingSelectors(rule: CSSStyleRule): boolean {
684
- return (rule.selectors.length === 0 || this.getMatchingSelectors(rule).length > 0) && queryMatches(rule.style);
685
- }
686
-
687
- getParentLayoutNodeId(): Protocol.DOM.NodeId|undefined {
688
- return this.#parentLayoutNodeId;
689
- }
690
-
691
- getMatchingSelectors(rule: CSSStyleRule): number[] {
692
- const node = this.nodeForStyle(rule.style);
693
- if (!node || typeof node.id !== 'number') {
694
- return [];
695
- }
696
- const map = this.#matchingSelectors.get(node.id);
697
- if (!map) {
698
- return [];
699
- }
700
- const result = [];
701
- for (let i = 0; i < rule.selectors.length; ++i) {
702
- if (map.get(rule.selectors[i].text)) {
703
- result.push(i);
704
- }
705
- }
706
- return result;
707
- }
708
-
709
- async recomputeMatchingSelectors(rule: CSSStyleRule): Promise<void> {
710
- const node = this.nodeForStyle(rule.style);
711
- if (!node) {
712
- return;
713
- }
714
- const promises = [];
715
- for (const selector of rule.selectors) {
716
- promises.push(querySelector.call(this, node, selector.text));
717
- }
718
- await Promise.all(promises);
719
-
720
- async function querySelector(this: CSSMatchedStyles, node: DOMNode, selectorText: string): Promise<void> {
721
- const ownerDocument = node.ownerDocument;
722
- if (!ownerDocument) {
723
- return;
724
- }
725
- // We assume that "matching" property does not ever change during the
726
- // MatchedStyleResult's lifetime.
727
- if (typeof node.id === 'number') {
728
- const map = this.#matchingSelectors.get(node.id);
729
- if (map?.has(selectorText)) {
730
- return;
731
- }
732
- }
733
-
734
- if (typeof ownerDocument.id !== 'number') {
735
- return;
736
- }
737
- const matchingNodeIds = await this.#node.domModel().querySelectorAll(ownerDocument.id, selectorText);
738
-
739
- if (matchingNodeIds) {
740
- if (typeof node.id === 'number') {
741
- this.setSelectorMatches(node, selectorText, matchingNodeIds.indexOf(node.id) !== -1);
742
- } else {
743
- this.setSelectorMatches(node, selectorText, false);
744
- }
745
- }
746
- }
747
- }
748
-
749
- addNewRule(rule: CSSStyleRule, node: DOMNode): Promise<void> {
750
- this.#addedStyles.set(rule.style, node);
751
- return this.recomputeMatchingSelectors(rule);
752
- }
753
-
754
- private setSelectorMatches(node: DOMNode, selectorText: string, value: boolean): void {
755
- if (typeof node.id !== 'number') {
756
- return;
757
- }
758
- let map = this.#matchingSelectors.get(node.id);
759
- if (!map) {
760
- map = new Map();
761
- this.#matchingSelectors.set(node.id, map);
762
- }
763
- map.set(selectorText, value);
764
- }
765
-
766
- nodeStyles(): CSSStyleDeclaration[] {
767
- Platform.assertNotNullOrUndefined(this.#mainDOMCascade);
768
- return this.#mainDOMCascade.styles();
769
- }
770
-
771
- inheritedStyles(): CSSStyleDeclaration[] {
772
- return this.#mainDOMCascade?.styles().filter(style => this.isInherited(style)) ?? [];
773
- }
774
-
775
- animationStyles(): CSSStyleDeclaration[] {
776
- return this.#mainDOMCascade?.styles().filter(style => !this.isInherited(style) && style.type === Type.Animation) ??
777
- [];
778
- }
779
-
780
- transitionsStyle(): CSSStyleDeclaration|null {
781
- return this.#mainDOMCascade?.styles().find(style => !this.isInherited(style) && style.type === Type.Transition) ??
782
- null;
783
- }
784
-
785
- registeredProperties(): CSSRegisteredProperty[] {
786
- return this.#registeredProperties;
787
- }
788
-
789
- getRegisteredProperty(name: string): CSSRegisteredProperty|undefined {
790
- return this.#registeredPropertyMap.get(name);
791
- }
792
-
793
- getRegisteredFunction(name: string): string|undefined {
794
- const functionRule = this.#functionRuleMap.get(name);
795
- return functionRule ? functionRule.nameWithParameters() : undefined;
796
- }
797
-
798
- functionRules(): CSSFunctionRule[] {
799
- return this.#functionRules;
800
- }
801
-
802
- fontPaletteValuesRule(): CSSFontPaletteValuesRule|undefined {
803
- return this.#fontPaletteValuesRule;
804
- }
805
-
806
- keyframes(): CSSKeyframesRule[] {
807
- return this.#keyframes;
808
- }
809
-
810
- positionTryRules(): CSSPositionTryRule[] {
811
- return this.#positionTryRules;
812
- }
813
-
814
- activePositionFallbackIndex(): number {
815
- return this.#activePositionFallbackIndex;
816
- }
817
-
818
- pseudoStyles(pseudoType: Protocol.DOM.PseudoType): CSSStyleDeclaration[] {
819
- Platform.assertNotNullOrUndefined(this.#pseudoDOMCascades);
820
- const domCascade = this.#pseudoDOMCascades.get(pseudoType);
821
- return domCascade ? domCascade.styles() : [];
822
- }
823
-
824
- pseudoTypes(): Set<Protocol.DOM.PseudoType> {
825
- Platform.assertNotNullOrUndefined(this.#pseudoDOMCascades);
826
- return new Set(this.#pseudoDOMCascades.keys());
827
- }
828
-
829
- customHighlightPseudoStyles(highlightName: string): CSSStyleDeclaration[] {
830
- Platform.assertNotNullOrUndefined(this.#customHighlightPseudoDOMCascades);
831
- const domCascade = this.#customHighlightPseudoDOMCascades.get(highlightName);
832
- return domCascade ? domCascade.styles() : [];
833
- }
834
-
835
- customHighlightPseudoNames(): Set<string> {
836
- Platform.assertNotNullOrUndefined(this.#customHighlightPseudoDOMCascades);
837
- return new Set(this.#customHighlightPseudoDOMCascades.keys());
838
- }
839
-
840
- nodeForStyle(style: CSSStyleDeclaration): DOMNode|null {
841
- return this.#addedStyles.get(style) || this.#nodeForStyle.get(style) || null;
842
- }
843
-
844
- availableCSSVariables(style: CSSStyleDeclaration): string[] {
845
- const domCascade = this.#styleToDOMCascade.get(style);
846
- return domCascade ? domCascade.findAvailableCSSVariables(style) : [];
847
- }
848
-
849
- computeCSSVariable(style: CSSStyleDeclaration, variableName: string): CSSVariableValue|null {
850
- if (style.parentRule instanceof CSSKeyframeRule) {
851
- // The resolution of the variables inside of a CSS keyframe rule depends on where this keyframe rule is used.
852
- // So, we need to find the style with active CSS property `animation-name` that equals to the keyframe's name.
853
- const keyframeName = style.parentRule.parentRuleName();
854
- const activeStyle = this.#mainDOMCascade?.styles().find(searchStyle => {
855
- return searchStyle.allProperties().some(
856
- property => property.name === 'animation-name' && property.value === keyframeName &&
857
- this.#mainDOMCascade?.propertyState(property) === PropertyState.ACTIVE);
858
- });
859
-
860
- if (!activeStyle) {
861
- return null;
862
- }
863
-
864
- style = activeStyle;
865
- }
866
-
867
- const domCascade = this.#styleToDOMCascade.get(style);
868
- return domCascade ? domCascade.computeCSSVariable(style, variableName) : null;
869
- }
870
-
871
- computeAttribute(style: CSSStyleDeclaration, attributeName: string, type: CSSType): string|null {
872
- const domCascade = this.#styleToDOMCascade.get(style);
873
- return domCascade ? domCascade.computeAttribute(style, attributeName, type) : null;
874
- }
875
-
876
- originatingNodeForStyle(style: CSSStyleDeclaration): DOMNode|null {
877
- let node: DOMNode|null = this.nodeForStyle(style) ?? this.node();
878
-
879
- // If it's a pseudo-element, we need to find the originating element.
880
- while (node?.pseudoType()) {
881
- node = node.parentNode;
882
- }
883
- return node;
884
- }
885
-
886
- rawAttributeValueFromStyle(style: CSSStyleDeclaration, attributeName: string): string|null {
887
- const node = this.originatingNodeForStyle(style);
888
- if (!node) {
889
- return null;
890
- }
891
- return node.getAttribute(attributeName) ?? null;
892
- }
893
-
894
- resolveProperty(name: string, ownerStyle: CSSStyleDeclaration): CSSProperty|null {
895
- return this.#styleToDOMCascade.get(ownerStyle)?.resolveProperty(name, ownerStyle) ?? null;
896
- }
897
-
898
- resolveGlobalKeyword(property: CSSProperty, keyword: CSSWideKeyword): CSSValueSource|null {
899
- const resolved = this.#styleToDOMCascade.get(property.ownerStyle)?.resolveGlobalKeyword(property, keyword);
900
- return resolved ? new CSSValueSource(resolved) : null;
901
- }
902
-
903
- isInherited(style: CSSStyleDeclaration): boolean {
904
- return this.#inheritedStyles.has(style);
905
- }
906
-
907
- propertyState(property: CSSProperty): PropertyState|null {
908
- const domCascade = this.#styleToDOMCascade.get(property.ownerStyle);
909
- return domCascade ? domCascade.propertyState(property) : null;
910
- }
911
-
912
- resetActiveProperties(): void {
913
- Platform.assertNotNullOrUndefined(this.#mainDOMCascade);
914
- Platform.assertNotNullOrUndefined(this.#pseudoDOMCascades);
915
- Platform.assertNotNullOrUndefined(this.#customHighlightPseudoDOMCascades);
916
- this.#mainDOMCascade.reset();
917
- for (const domCascade of this.#pseudoDOMCascades.values()) {
918
- domCascade.reset();
919
- }
920
-
921
- for (const domCascade of this.#customHighlightPseudoDOMCascades.values()) {
922
- domCascade.reset();
923
- }
924
- }
925
-
926
- propertyMatchers(style: CSSStyleDeclaration, computedStyles: Map<string, string>|null): Array<Matcher<Match>> {
927
- return [
928
- new VariableMatcher(this, style),
929
- new ColorMatcher(() => computedStyles?.get('color') ?? null),
930
- new ColorMixMatcher(),
931
- new URLMatcher(),
932
- new AngleMatcher(),
933
- new LinkableNameMatcher(),
934
- new BezierMatcher(),
935
- new StringMatcher(),
936
- new ShadowMatcher(),
937
- new LightDarkColorMatcher(style),
938
- new GridTemplateMatcher(),
939
- new LinearGradientMatcher(),
940
- new AnchorFunctionMatcher(),
941
- new PositionAnchorMatcher(),
942
- new FlexGridMatcher(),
943
- new PositionTryMatcher(),
944
- new LengthMatcher(),
945
- new MathFunctionMatcher(),
946
- new CustomFunctionMatcher(),
947
- new AutoBaseMatcher(),
948
- new BinOpMatcher(),
949
- new RelativeColorChannelMatcher(),
950
- new AttributeMatcher(this, style),
951
- new EnvFunctionMatcher(this),
952
- ];
953
- }
954
-
955
- environmentVariable(name: string): string|undefined {
956
- return this.#environmentVariables[name];
957
- }
958
- }
959
-
960
- class NodeCascade {
961
- #matchedStyles: CSSMatchedStyles;
962
- readonly styles: CSSStyleDeclaration[];
963
- readonly #isInherited: boolean;
964
- readonly #isHighlightPseudoCascade: boolean;
965
- readonly propertiesState = new Map<CSSProperty, PropertyState>();
966
- readonly activeProperties = new Map<string, CSSProperty>();
967
- readonly #node: DOMNode;
968
- constructor(
969
- matchedStyles: CSSMatchedStyles, styles: CSSStyleDeclaration[], node: DOMNode, isInherited: boolean,
970
- isHighlightPseudoCascade = false) {
971
- this.#matchedStyles = matchedStyles;
972
- this.styles = styles;
973
- this.#isInherited = isInherited;
974
- this.#isHighlightPseudoCascade = isHighlightPseudoCascade;
975
- this.#node = node;
976
- }
977
-
978
- computeActiveProperties(): void {
979
- this.propertiesState.clear();
980
- this.activeProperties.clear();
981
-
982
- for (let i = this.styles.length - 1; i >= 0; i--) {
983
- const style = this.styles[i];
984
- const rule = style.parentRule;
985
- // Compute cascade for CSSStyleRules only.
986
- if (rule && !(rule instanceof CSSStyleRule)) {
987
- continue;
988
- }
989
- if (rule && !this.#matchedStyles.hasMatchingSelectors(rule)) {
990
- continue;
991
- }
992
-
993
- for (const property of style.allProperties()) {
994
- // Do not pick non-inherited properties from inherited styles.
995
- const metadata = cssMetadata();
996
-
997
- // All properties are inherited for highlight pseudos.
998
- if (this.#isInherited && !this.#isHighlightPseudoCascade && !metadata.isPropertyInherited(property.name)) {
999
- continue;
1000
- }
1001
-
1002
- // When a property does not have a range in an otherwise ranged CSSStyleDeclaration,
1003
- // we consider it as a non-leading property (see computeLeadingProperties()), and most
1004
- // of them are computed longhands. We exclude these from activeProperties calculation,
1005
- // and use parsed longhands instead (see below).
1006
- if (style.range && !property.range) {
1007
- continue;
1008
- }
1009
-
1010
- if (!property.activeInStyle()) {
1011
- this.propertiesState.set(property, PropertyState.OVERLOADED);
1012
- continue;
1013
- }
1014
-
1015
- // If the custom property was registered with `inherits: false;`, inherited properties are invalid.
1016
- if (this.#isInherited) {
1017
- const registration = this.#matchedStyles.getRegisteredProperty(property.name);
1018
- if (registration && !registration.inherits()) {
1019
- this.propertiesState.set(property, PropertyState.OVERLOADED);
1020
- continue;
1021
- }
1022
- }
1023
-
1024
- const canonicalName = metadata.canonicalPropertyName(property.name);
1025
- this.updatePropertyState(property, canonicalName);
1026
- for (const longhand of property.getLonghandProperties()) {
1027
- if (metadata.isCSSPropertyName(longhand.name)) {
1028
- this.updatePropertyState(longhand, longhand.name);
1029
- }
1030
- }
1031
- }
1032
- }
1033
- }
1034
-
1035
- #treeScopeDistance(property: CSSProperty): number {
1036
- if (!property.ownerStyle.parentRule && property.ownerStyle.type !== Type.Inline) {
1037
- return -1;
1038
- }
1039
- const root = this.#node.getTreeRoot();
1040
- const nodeId = property.ownerStyle.parentRule?.treeScope ?? root?.backendNodeId();
1041
- if (nodeId === undefined) {
1042
- return -1;
1043
- }
1044
-
1045
- let distance = 0;
1046
- for (let ancestor: DOMNode|null = this.#node; ancestor; ancestor = ancestor.parentNode) {
1047
- if (ancestor.backendNodeId() === nodeId) {
1048
- return distance;
1049
- }
1050
- distance++;
1051
- }
1052
- return -1;
1053
- }
1054
-
1055
- #needsCascadeContextStep(): boolean {
1056
- if (!this.#node.isInShadowTree()) {
1057
- return false;
1058
- }
1059
-
1060
- if (this.#node.ancestorShadowRoot()?.shadowRootType() === 'user-agent') {
1061
- // In UA shadow dom, only standards-track pseudo elements override style attributes. -webkit-* and -internal-*
1062
- // pseudos are still exempt from that to retain legacy behavior.
1063
- const pseudoElement = this.#node.getAttribute('pseudo');
1064
- return !pseudoElement?.startsWith('-webkit-') && !pseudoElement?.startsWith('-internal-');
1065
- }
1066
-
1067
- return true;
1068
- }
1069
-
1070
- private updatePropertyState(propertyWithHigherSpecificity: CSSProperty, canonicalName: string): void {
1071
- const activeProperty = this.activeProperties.get(canonicalName);
1072
- if (activeProperty?.important && !propertyWithHigherSpecificity.important ||
1073
- activeProperty && this.#needsCascadeContextStep() &&
1074
- this.#treeScopeDistance(activeProperty) > this.#treeScopeDistance(propertyWithHigherSpecificity)) {
1075
- this.propertiesState.set(propertyWithHigherSpecificity, PropertyState.OVERLOADED);
1076
- return;
1077
- }
1078
-
1079
- if (activeProperty) {
1080
- this.propertiesState.set(activeProperty, PropertyState.OVERLOADED);
1081
- }
1082
- this.propertiesState.set(propertyWithHigherSpecificity, PropertyState.ACTIVE);
1083
- this.activeProperties.set(canonicalName, propertyWithHigherSpecificity);
1084
- }
1085
- }
1086
-
1087
- function isRegular(declaration: CSSProperty|CSSRegisteredProperty): declaration is CSSProperty {
1088
- return 'ownerStyle' in declaration;
1089
- }
1090
- export class CSSValueSource {
1091
- readonly declaration: CSSProperty|CSSRegisteredProperty;
1092
- constructor(declaration: CSSProperty|CSSRegisteredProperty) {
1093
- this.declaration = declaration;
1094
- }
1095
-
1096
- get value(): string|null {
1097
- return isRegular(this.declaration) ? this.declaration.value : this.declaration.initialValue();
1098
- }
1099
- get style(): CSSStyleDeclaration {
1100
- return isRegular(this.declaration) ? this.declaration.ownerStyle : this.declaration.style();
1101
- }
1102
- get name(): string {
1103
- return isRegular(this.declaration) ? this.declaration.name : this.declaration.propertyName();
1104
- }
1105
- }
1106
-
1107
- export interface CSSVariableValue {
1108
- value: string;
1109
- declaration: CSSValueSource;
1110
- }
1111
-
1112
- interface CSSAttributeValue {
1113
- value: string;
1114
- }
1115
-
1116
- class SCCRecordEntry {
1117
- private rootDiscoveryTime: number;
1118
- get isRootEntry(): boolean {
1119
- return this.rootDiscoveryTime === this.discoveryTime;
1120
- }
1121
- updateRoot(neighbor: SCCRecordEntry): void {
1122
- this.rootDiscoveryTime = Math.min(this.rootDiscoveryTime, neighbor.rootDiscoveryTime);
1123
- }
1124
- constructor(readonly nodeCascade: NodeCascade, readonly name: string, private readonly discoveryTime: number) {
1125
- this.rootDiscoveryTime = discoveryTime;
1126
- }
1127
- }
1128
-
1129
- class SCCRecord {
1130
- #time = 0;
1131
- #stack: SCCRecordEntry[] = [];
1132
- #entries = new Map<NodeCascade, Map<string, SCCRecordEntry>>();
1133
-
1134
- get(nodeCascade: NodeCascade, variable: string): SCCRecordEntry|undefined {
1135
- return this.#entries.get(nodeCascade)?.get(variable);
1136
- }
1137
-
1138
- add(nodeCascade: NodeCascade, variable: string): SCCRecordEntry {
1139
- const existing = this.get(nodeCascade, variable);
1140
- if (existing) {
1141
- return existing;
1142
- }
1143
- const entry = new SCCRecordEntry(nodeCascade, variable, this.#time++);
1144
- this.#stack.push(entry);
1145
- let map = this.#entries.get(nodeCascade);
1146
- if (!map) {
1147
- map = new Map();
1148
- this.#entries.set(nodeCascade, map);
1149
- }
1150
- map.set(variable, entry);
1151
- return entry;
1152
- }
1153
-
1154
- isInInProgressSCC(childRecord: SCCRecordEntry): boolean {
1155
- return this.#stack.includes(childRecord);
1156
- }
1157
-
1158
- finishSCC(root: SCCRecordEntry): SCCRecordEntry[] {
1159
- const startIndex = this.#stack.lastIndexOf(root);
1160
- console.assert(startIndex >= 0, 'Root is not an in-progress scc');
1161
- return this.#stack.splice(startIndex);
1162
- }
1163
- }
1164
-
1165
- function* forEach<T>(array: T[], startAfter?: T): Generator<T> {
1166
- const startIdx = startAfter !== undefined ? array.indexOf(startAfter) + 1 : 0;
1167
- for (let i = startIdx; i < array.length; ++i) {
1168
- yield array[i];
1169
- }
1170
- }
1171
-
1172
- class DOMInheritanceCascade {
1173
- readonly #propertiesState = new Map<CSSProperty, PropertyState>();
1174
- readonly #availableCSSVariables = new Map<NodeCascade, Map<string, CSSVariableValue|null>>();
1175
- readonly #computedCSSVariables = new Map<NodeCascade, Map<string, CSSVariableValue|CSSAttributeValue|null>>();
1176
- readonly #styleToNodeCascade = new Map<CSSStyleDeclaration, NodeCascade>();
1177
- #initialized = false;
1178
- readonly #nodeCascades: NodeCascade[];
1179
- #registeredProperties: CSSRegisteredProperty[];
1180
- readonly #matchedStyles: CSSMatchedStyles;
1181
- constructor(
1182
- matchedStyles: CSSMatchedStyles, nodeCascades: NodeCascade[], registeredProperties: CSSRegisteredProperty[]) {
1183
- this.#nodeCascades = nodeCascades;
1184
- this.#matchedStyles = matchedStyles;
1185
- this.#registeredProperties = registeredProperties;
1186
-
1187
- for (const nodeCascade of nodeCascades) {
1188
- for (const style of nodeCascade.styles) {
1189
- this.#styleToNodeCascade.set(style, nodeCascade);
1190
- }
1191
- }
1192
- }
1193
-
1194
- findAvailableCSSVariables(style: CSSStyleDeclaration): string[] {
1195
- const nodeCascade = this.#styleToNodeCascade.get(style);
1196
- if (!nodeCascade) {
1197
- return [];
1198
- }
1199
- this.ensureInitialized();
1200
- const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
1201
- if (!availableCSSVariables) {
1202
- return [];
1203
- }
1204
- return Array.from(availableCSSVariables.keys());
1205
- }
1206
-
1207
- #findPropertyInPreviousStyle(property: CSSProperty, filter: (property: CSSProperty) => boolean): CSSProperty|null {
1208
- const cascade = this.#styleToNodeCascade.get(property.ownerStyle);
1209
- if (!cascade) {
1210
- return null;
1211
- }
1212
-
1213
- for (const style of forEach(cascade.styles, property.ownerStyle)) {
1214
- const candidate =
1215
- style.allProperties().findLast(candidate => candidate.name === property.name && filter(candidate));
1216
- if (candidate) {
1217
- return candidate;
1218
- }
1219
- }
1220
- return null;
1221
- }
1222
-
1223
- resolveProperty(name: string, ownerStyle: CSSStyleDeclaration): CSSProperty|null {
1224
- const cascade = this.#styleToNodeCascade.get(ownerStyle);
1225
- if (!cascade) {
1226
- return null;
1227
- }
1228
-
1229
- for (const style of cascade.styles) {
1230
- const candidate = style.allProperties().findLast(candidate => candidate.name === name);
1231
- if (candidate) {
1232
- return candidate;
1233
- }
1234
- }
1235
-
1236
- return this.#findPropertyInParentCascadeIfInherited({name, ownerStyle});
1237
- }
1238
-
1239
- #findPropertyInParentCascade(property: {name: string, ownerStyle: CSSStyleDeclaration}): CSSProperty|null {
1240
- const nodeCascade = this.#styleToNodeCascade.get(property.ownerStyle);
1241
- if (!nodeCascade) {
1242
- return null;
1243
- }
1244
- for (const cascade of forEach(this.#nodeCascades, nodeCascade)) {
1245
- for (const style of cascade.styles) {
1246
- const inheritedProperty =
1247
- style.allProperties().findLast(inheritedProperty => inheritedProperty.name === property.name);
1248
- if (inheritedProperty) {
1249
- return inheritedProperty;
1250
- }
1251
- }
1252
- }
1253
- return null;
1254
- }
1255
-
1256
- #findPropertyInParentCascadeIfInherited(property: {name: string, ownerStyle: CSSStyleDeclaration}): CSSProperty|null {
1257
- if (!cssMetadata().isPropertyInherited(property.name) ||
1258
- !(this.#findCustomPropertyRegistration(property.name)?.inherits() ?? true)) {
1259
- return null;
1260
- }
1261
- return this.#findPropertyInParentCascade(property);
1262
- }
1263
-
1264
- #findCustomPropertyRegistration(property: string): CSSRegisteredProperty|null {
1265
- const registration = this.#registeredProperties.find(registration => registration.propertyName() === property);
1266
- return registration ? registration : null;
1267
- }
1268
-
1269
- resolveGlobalKeyword(property: CSSProperty, keyword: CSSWideKeyword): null|CSSProperty|CSSRegisteredProperty {
1270
- const isPreviousLayer = (other: CSSProperty): boolean => {
1271
- // If there's no parent rule on then it isn't layered and is thus not in a previous one.
1272
- if (!(other.ownerStyle.parentRule instanceof CSSStyleRule)) {
1273
- return false;
1274
- }
1275
- // Element-attached style -> author origin counts as a previous layer transition for revert-layer.
1276
- if (property.ownerStyle.type === Type.Inline) {
1277
- return true;
1278
- }
1279
- // Compare layers
1280
- if (property.ownerStyle.parentRule instanceof CSSStyleRule &&
1281
- other.ownerStyle.parentRule?.origin === Protocol.CSS.StyleSheetOrigin.Regular) {
1282
- return JSON.stringify(other.ownerStyle.parentRule.layers) !==
1283
- JSON.stringify(property.ownerStyle.parentRule.layers);
1284
- }
1285
- return false;
1286
- };
1287
-
1288
- switch (keyword) {
1289
- case CSSWideKeyword.INITIAL:
1290
- return this.#findCustomPropertyRegistration(property.name);
1291
- case CSSWideKeyword.INHERIT:
1292
- return this.#findPropertyInParentCascade(property) ?? this.#findCustomPropertyRegistration(property.name);
1293
- case CSSWideKeyword.REVERT:
1294
- return this.#findPropertyInPreviousStyle(
1295
- property,
1296
- other => other.ownerStyle.parentRule !== null &&
1297
- other.ownerStyle.parentRule.origin !==
1298
- (property.ownerStyle.parentRule?.origin ?? Protocol.CSS.StyleSheetOrigin.Regular)) ??
1299
- this.resolveGlobalKeyword(property, CSSWideKeyword.UNSET);
1300
- case CSSWideKeyword.REVERT_LAYER:
1301
- return this.#findPropertyInPreviousStyle(property, isPreviousLayer) ??
1302
- this.resolveGlobalKeyword(property, CSSWideKeyword.REVERT);
1303
- case CSSWideKeyword.UNSET:
1304
- return this.#findPropertyInParentCascadeIfInherited(property) ??
1305
- this.#findCustomPropertyRegistration(property.name);
1306
- }
1307
- }
1308
-
1309
- computeCSSVariable(style: CSSStyleDeclaration, variableName: string): CSSVariableValue|null {
1310
- this.ensureInitialized();
1311
- const nodeCascade = this.#styleToNodeCascade.get(style);
1312
- if (!nodeCascade) {
1313
- return null;
1314
- }
1315
- return this.#computeCSSVariable(nodeCascade, variableName);
1316
- }
1317
-
1318
- #computeCSSVariable(nodeCascade: NodeCascade, variableName: string, sccRecord = new SCCRecord()): CSSVariableValue
1319
- |null {
1320
- const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
1321
- const computedCSSVariables = this.#computedCSSVariables.get(nodeCascade);
1322
- if (!computedCSSVariables || !availableCSSVariables?.has(variableName)) {
1323
- return null;
1324
- }
1325
-
1326
- if (computedCSSVariables?.has(variableName)) {
1327
- return (computedCSSVariables.get(variableName) as CSSVariableValue | null | undefined) || null;
1328
- }
1329
-
1330
- let definedValue = availableCSSVariables.get(variableName);
1331
- if (definedValue === undefined || definedValue === null) {
1332
- return null;
1333
- }
1334
-
1335
- if (definedValue.declaration.declaration instanceof CSSProperty && definedValue.declaration.value &&
1336
- CSSMetadata.isCSSWideKeyword(definedValue.declaration.value)) {
1337
- const resolvedProperty =
1338
- this.resolveGlobalKeyword(definedValue.declaration.declaration, definedValue.declaration.value);
1339
- if (!resolvedProperty) {
1340
- return definedValue;
1341
- }
1342
- const declaration = new CSSValueSource(resolvedProperty);
1343
- const {value} = declaration;
1344
- if (!value) {
1345
- return definedValue;
1346
- }
1347
- definedValue = {declaration, value};
1348
- }
1349
-
1350
- const ast = PropertyParser.tokenizeDeclaration(`--${variableName}`, definedValue.value);
1351
- if (!ast) {
1352
- return null;
1353
- }
1354
-
1355
- return this.#walkTree(
1356
- nodeCascade, ast, definedValue.declaration.style, variableName, sccRecord, definedValue.declaration) as
1357
- CSSVariableValue |
1358
- null;
1359
- }
1360
-
1361
- computeAttribute(style: CSSStyleDeclaration, attributeName: string, type: CSSType): string|null {
1362
- this.ensureInitialized();
1363
- const nodeCascade = this.#styleToNodeCascade.get(style);
1364
- if (!nodeCascade) {
1365
- return null;
1366
- }
1367
- return this.#computeAttribute(nodeCascade, style, attributeName, type, new SCCRecord());
1368
- }
1369
-
1370
- private attributeValueAsType(style: CSSStyleDeclaration, attributeName: string, type: string): string|null {
1371
- const rawValue = this.#matchedStyles.rawAttributeValueFromStyle(style, attributeName);
1372
- if (rawValue === null) {
1373
- return null;
1374
- }
1375
- return localEvalCSS(rawValue, type);
1376
- }
1377
-
1378
- private attributeValueWithSubstitutions(
1379
- nodeCascade: NodeCascade, style: CSSStyleDeclaration, attributeName: string, sccRecord: SCCRecord): string|null {
1380
- const rawValue = this.#matchedStyles.rawAttributeValueFromStyle(style, attributeName);
1381
- if (rawValue === null) {
1382
- return null;
1383
- }
1384
- const ast = PropertyParser.tokenizeDeclaration('--property', rawValue);
1385
- if (!ast) {
1386
- return null;
1387
- }
1388
- return this.#walkTree(nodeCascade, ast, style, `attr(${attributeName})`, sccRecord)?.value ?? null;
1389
- }
1390
-
1391
- #computeAttribute(
1392
- nodeCascade: NodeCascade, style: CSSStyleDeclaration, attributeName: string, type: CSSType,
1393
- sccRecord = new SCCRecord()): string|null {
1394
- if (type.isCSSTokens) {
1395
- const value = this.attributeValueWithSubstitutions(nodeCascade, style, attributeName, sccRecord);
1396
- if (value !== null && localEvalCSS(value, type.type) !== null) {
1397
- return value;
1398
- }
1399
- return null;
1400
- }
1401
- return this.attributeValueAsType(style, attributeName, type.type);
1402
- }
1403
-
1404
- #walkTree(
1405
- outerNodeCascade: NodeCascade, ast: SyntaxTree, parentStyle: CSSStyleDeclaration, substitutionName: string,
1406
- sccRecord: SCCRecord, declaration?: CSSValueSource): CSSVariableValue|CSSAttributeValue|null {
1407
- const record = sccRecord.add(outerNodeCascade, substitutionName);
1408
- const computedCSSVariablesMap = this.#computedCSSVariables;
1409
- const innerNodeCascade = this.#styleToNodeCascade.get(parentStyle);
1410
-
1411
- // While computing CSS variable and attribute values we need to detect declaration cycles. Every declaration on the cycle is
1412
- // invalid. However, var()s outside of the cycle that reference a property on the cycle are not automatically
1413
- // invalid, but rather use the fallback value. We use a version of Tarjan's algorithm to detect cycles, which are
1414
- // SCCs on the custom property dependency graph. Computing variable values is DFS. When encountering a previously
1415
- // unseen variable, we record its discovery time. We keep a stack of visited variables and detect cycles when we
1416
- // find a reference to a variable already on the stack. For each node we also keep track of the "root" of the
1417
- // corresponding SCC, which is the node in that component with the smallest discovery time. This is determined by
1418
- // bubbling up the minimum discovery time whenever we close a cycle.
1419
- const matching = PropertyParser.BottomUpTreeMatching.walk(ast, [
1420
- new BaseVariableMatcher(match => {
1421
- const {value, mayFallback} = recurseWithCycleDetection(
1422
- match.name, nodeCascade => this.#computeCSSVariable(nodeCascade, match.name, sccRecord)?.value ?? null);
1423
- if (!mayFallback || value !== null) {
1424
- return value;
1425
- }
1426
-
1427
- // Variable reference is not resolved, use the fallback.
1428
- if (!match.fallback) {
1429
- return null;
1430
- }
1431
- return evaluateFallback(match.fallback, match.matching);
1432
- }),
1433
- new EnvFunctionMatcher(this.#matchedStyles),
1434
- new AttributeMatcher(
1435
- this.#matchedStyles, parentStyle,
1436
- match => {
1437
- const recordName = `attr(${match.name})`;
1438
- let attributeValue = null;
1439
- if (!match.isCSSTokens) {
1440
- const {value, mayFallback} = recurseWithCycleDetection(
1441
- recordName, () => this.attributeValueAsType(parentStyle, match.name, match.cssType()));
1442
- if (value === null && !mayFallback) {
1443
- return null;
1444
- }
1445
- attributeValue = value;
1446
- } else {
1447
- const {value, mayFallback} = recurseWithCycleDetection(
1448
- recordName,
1449
- nodeCascade => this.attributeValueWithSubstitutions(nodeCascade, parentStyle, match.name, sccRecord));
1450
- if (value === null && !mayFallback) {
1451
- return null;
1452
- }
1453
- if (value !== null && localEvalCSS(value, match.cssType()) !== null) {
1454
- attributeValue = value;
1455
- }
1456
- }
1457
-
1458
- if (attributeValue !== null) {
1459
- return attributeValue;
1460
- }
1461
- // Variable reference is not resolved, use the fallback.
1462
- if (!match.fallback || !match.isValidType) {
1463
- // Except in this case, we use the default value for the type.
1464
- return defaultValueForCSSType(match.type);
1465
- }
1466
- return evaluateFallback(match.fallback, match.matching);
1467
- })
1468
- ]);
1469
- const decl = PropertyParser.ASTUtils.siblings(PropertyParser.ASTUtils.declValue(matching.ast.tree));
1470
- const declText = decl.length > 0 ? matching.getComputedTextRange(decl[0], decl[decl.length - 1]) : '';
1471
- const hasUnresolvedSubstitutions =
1472
- decl.length > 0 && matching.hasUnresolvedSubstitutionsRange(decl[0], decl[decl.length - 1]);
1473
- const computedText = hasUnresolvedSubstitutions ? null : declText;
1474
- const outerComputedCSSVariables = computedCSSVariablesMap.get(outerNodeCascade);
1475
- if (!outerComputedCSSVariables) {
1476
- return null;
1477
- }
1478
-
1479
- if (record.isRootEntry) {
1480
- // Variables are kept on the stack until all descendents in the same SCC have been visited. That's the case when
1481
- // completing the recursion on the root of the SCC.
1482
- const scc = sccRecord.finishSCC(record);
1483
- if (scc.length > 1) {
1484
- for (const entry of scc) {
1485
- console.assert(entry.nodeCascade === outerNodeCascade, 'Circles should be within the cascade');
1486
- outerComputedCSSVariables.set(entry.name, null);
1487
- }
1488
- return null;
1489
- }
1490
- }
1491
- if (computedText === null) {
1492
- outerComputedCSSVariables.set(substitutionName, null);
1493
- return null;
1494
- }
1495
-
1496
- const cssVariableValue = {value: computedText, declaration};
1497
- outerComputedCSSVariables.set(substitutionName, cssVariableValue);
1498
- return cssVariableValue;
1499
-
1500
- function recurseWithCycleDetection(
1501
- recordName: string, func: (nc: NodeCascade) => string | null): {value: string|null, mayFallback: boolean} {
1502
- if (!innerNodeCascade) {
1503
- return {value: null, mayFallback: false};
1504
- }
1505
-
1506
- const childRecord = sccRecord.get(innerNodeCascade, recordName);
1507
- if (childRecord) {
1508
- if (sccRecord.isInInProgressSCC(childRecord)) {
1509
- // Cycle detected, update the root.
1510
- record.updateRoot(childRecord);
1511
- return {value: null, mayFallback: false};
1512
- }
1513
-
1514
- // We've seen the variable before, so we can look up the text directly.
1515
- return {
1516
- value: computedCSSVariablesMap.get(innerNodeCascade)?.get(recordName)?.value ?? null,
1517
- mayFallback: false
1518
- };
1519
- }
1520
-
1521
- const value = func(innerNodeCascade);
1522
- // Variable reference is resolved, so return it.
1523
- const newChildRecord = sccRecord.get(innerNodeCascade, recordName);
1524
- // The SCC record for the referenced variable may not exist if the var was already computed in a previous
1525
- // iteration. That means it's in a different SCC.
1526
- newChildRecord && record.updateRoot(newChildRecord);
1527
- return {value, mayFallback: true};
1528
- }
1529
-
1530
- function evaluateFallback(fallback: CodeMirror.SyntaxNode[], matching: PropertyParser.BottomUpTreeMatching): string|
1531
- null {
1532
- if (fallback.length === 0) {
1533
- return '';
1534
- }
1535
- if (matching.hasUnresolvedSubstitutionsRange(fallback[0], fallback[fallback.length - 1])) {
1536
- return null;
1537
- }
1538
- return matching.getComputedTextRange(fallback[0], fallback[fallback.length - 1]);
1539
- }
1540
- }
1541
-
1542
- styles(): CSSStyleDeclaration[] {
1543
- return Array.from(this.#styleToNodeCascade.keys());
1544
- }
1545
-
1546
- propertyState(property: CSSProperty): PropertyState|null {
1547
- this.ensureInitialized();
1548
- return this.#propertiesState.get(property) || null;
1549
- }
1550
-
1551
- reset(): void {
1552
- this.#initialized = false;
1553
- this.#propertiesState.clear();
1554
- this.#availableCSSVariables.clear();
1555
- this.#computedCSSVariables.clear();
1556
- }
1557
-
1558
- private ensureInitialized(): void {
1559
- if (this.#initialized) {
1560
- return;
1561
- }
1562
- this.#initialized = true;
1563
-
1564
- const activeProperties = new Map<string, CSSProperty>();
1565
- for (const nodeCascade of this.#nodeCascades) {
1566
- nodeCascade.computeActiveProperties();
1567
- for (const [property, state] of nodeCascade.propertiesState) {
1568
- if (state === PropertyState.OVERLOADED) {
1569
- this.#propertiesState.set(property, PropertyState.OVERLOADED);
1570
- continue;
1571
- }
1572
- const canonicalName = cssMetadata().canonicalPropertyName(property.name);
1573
- if (activeProperties.has(canonicalName)) {
1574
- this.#propertiesState.set(property, PropertyState.OVERLOADED);
1575
- continue;
1576
- }
1577
- activeProperties.set(canonicalName, property);
1578
- this.#propertiesState.set(property, PropertyState.ACTIVE);
1579
- }
1580
- }
1581
- // If every longhand of the shorthand is not active, then the shorthand is not active too.
1582
- for (const [canonicalName, shorthandProperty] of activeProperties) {
1583
- const shorthandStyle = shorthandProperty.ownerStyle;
1584
- const longhands = shorthandProperty.getLonghandProperties();
1585
- if (!longhands.length) {
1586
- continue;
1587
- }
1588
- let hasActiveLonghands = false;
1589
- for (const longhand of longhands) {
1590
- const longhandCanonicalName = cssMetadata().canonicalPropertyName(longhand.name);
1591
- const longhandActiveProperty = activeProperties.get(longhandCanonicalName);
1592
- if (!longhandActiveProperty) {
1593
- continue;
1594
- }
1595
- if (longhandActiveProperty.ownerStyle === shorthandStyle) {
1596
- hasActiveLonghands = true;
1597
- break;
1598
- }
1599
- }
1600
- if (hasActiveLonghands) {
1601
- continue;
1602
- }
1603
- activeProperties.delete(canonicalName);
1604
- this.#propertiesState.set(shorthandProperty, PropertyState.OVERLOADED);
1605
- }
1606
-
1607
- // Work inheritance chain backwards to compute visible CSS Variables.
1608
- const accumulatedCSSVariables = new Map<string, CSSVariableValue|null>();
1609
- for (const rule of this.#registeredProperties) {
1610
- const initialValue = rule.initialValue();
1611
- accumulatedCSSVariables.set(
1612
- rule.propertyName(),
1613
- initialValue !== null ? {value: initialValue, declaration: new CSSValueSource(rule)} : null);
1614
- }
1615
- for (let i = this.#nodeCascades.length - 1; i >= 0; --i) {
1616
- const nodeCascade = this.#nodeCascades[i];
1617
- const variableNames = [];
1618
- for (const entry of nodeCascade.activeProperties.entries()) {
1619
- const propertyName = entry[0];
1620
- const property = entry[1];
1621
- if (propertyName.startsWith('--')) {
1622
- accumulatedCSSVariables.set(propertyName, {value: property.value, declaration: new CSSValueSource(property)});
1623
- variableNames.push(propertyName);
1624
- }
1625
- }
1626
- const availableCSSVariablesMap = new Map(accumulatedCSSVariables);
1627
- const computedVariablesMap = new Map();
1628
- this.#availableCSSVariables.set(nodeCascade, availableCSSVariablesMap);
1629
- this.#computedCSSVariables.set(nodeCascade, computedVariablesMap);
1630
- for (const variableName of variableNames) {
1631
- const prevValue = accumulatedCSSVariables.get(variableName);
1632
- accumulatedCSSVariables.delete(variableName);
1633
- const computedValue = this.#computeCSSVariable(nodeCascade, variableName);
1634
- if (prevValue && computedValue?.value === prevValue.value) {
1635
- computedValue.declaration = prevValue.declaration;
1636
- }
1637
- accumulatedCSSVariables.set(variableName, computedValue);
1638
- }
1639
- }
1640
- }
1641
- }
1642
-
1643
- export const enum PropertyState {
1644
- ACTIVE = 'Active',
1645
- OVERLOADED = 'Overloaded',
1646
- }