chrome-devtools-frontend 1.0.955092 → 1.0.956812

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 (356) hide show
  1. package/.eslintrc.js +1 -0
  2. package/AUTHORS +1 -0
  3. package/config/gni/devtools_grd_files.gni +0 -2
  4. package/config/owner/COMMON_OWNERS +2 -2
  5. package/front_end/.eslintrc.js +1 -11
  6. package/front_end/Images/generate-css-vars.js +2 -2
  7. package/front_end/core/common/Console.ts +1 -1
  8. package/front_end/core/common/ParsedURL.ts +35 -2
  9. package/front_end/core/common/ResolverBase.ts +1 -1
  10. package/front_end/core/common/Settings.ts +1 -1
  11. package/front_end/core/common/Throttler.ts +1 -1
  12. package/front_end/core/common/Worker.ts +4 -4
  13. package/front_end/core/host/InspectorFrontendHost.ts +3 -2
  14. package/front_end/core/host/ResourceLoader.ts +2 -2
  15. package/front_end/core/i18n/DevToolsLocale.ts +0 -2
  16. package/front_end/core/i18n/i18nImpl.ts +2 -5
  17. package/front_end/core/i18n/locales/en-US.json +3 -3
  18. package/front_end/core/i18n/locales/en-XL.json +3 -3
  19. package/front_end/core/root/Runtime.ts +0 -72
  20. package/front_end/core/root/root-legacy.ts +0 -2
  21. package/front_end/core/sdk/AccessibilityModel.ts +1 -1
  22. package/front_end/core/sdk/CPUProfilerModel.ts +2 -2
  23. package/front_end/core/sdk/CPUThrottlingManager.ts +2 -2
  24. package/front_end/core/sdk/CSSModel.ts +7 -7
  25. package/front_end/core/sdk/CSSProperty.ts +1 -1
  26. package/front_end/core/sdk/CSSStyleDeclaration.ts +1 -1
  27. package/front_end/core/sdk/ChildTargetManager.ts +6 -6
  28. package/front_end/core/sdk/Connections.ts +2 -2
  29. package/front_end/core/sdk/ConsoleModel.ts +1 -1
  30. package/front_end/core/sdk/DOMDebuggerModel.ts +16 -15
  31. package/front_end/core/sdk/DOMModel.ts +17 -17
  32. package/front_end/core/sdk/DebuggerModel.ts +24 -24
  33. package/front_end/core/sdk/EmulationModel.ts +16 -16
  34. package/front_end/core/sdk/EventBreakpointsModel.ts +2 -2
  35. package/front_end/core/sdk/IsolateManager.ts +2 -2
  36. package/front_end/core/sdk/IssuesModel.ts +1 -1
  37. package/front_end/core/sdk/LogModel.ts +3 -3
  38. package/front_end/core/sdk/NetworkManager.ts +25 -25
  39. package/front_end/core/sdk/OverlayModel.ts +23 -23
  40. package/front_end/core/sdk/PageResourceLoader.ts +1 -1
  41. package/front_end/core/sdk/PaintProfiler.ts +1 -1
  42. package/front_end/core/sdk/RemoteObject.ts +2 -2
  43. package/front_end/core/sdk/Resource.ts +2 -2
  44. package/front_end/core/sdk/ResourceTreeModel.ts +5 -5
  45. package/front_end/core/sdk/RuntimeModel.ts +11 -11
  46. package/front_end/core/sdk/ScreenCaptureModel.ts +3 -3
  47. package/front_end/core/sdk/ServiceWorkerCacheModel.ts +7 -7
  48. package/front_end/core/sdk/ServiceWorkerManager.ts +4 -4
  49. package/front_end/core/sdk/SourceMapManager.ts +1 -1
  50. package/front_end/core/sdk/TargetManager.ts +2 -2
  51. package/front_end/core/sdk/TracingManager.ts +1 -1
  52. package/front_end/entrypoints/formatter_worker/FormatterActions.ts +10 -0
  53. package/front_end/entrypoints/formatter_worker/FormatterWorker.ts +3 -4
  54. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +1 -1
  55. package/front_end/entrypoints/inspector_main/InspectorMain.ts +4 -4
  56. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +1 -1
  57. package/front_end/entrypoints/js_app/js_app.ts +2 -2
  58. package/front_end/entrypoints/lighthouse_worker/LighthouseService.ts +4 -7
  59. package/front_end/entrypoints/main/MainImpl.ts +32 -24
  60. package/front_end/entrypoints/main/main-meta.ts +1 -1
  61. package/front_end/entrypoints/node_app/NodeMain.ts +6 -6
  62. package/front_end/entrypoints/worker_app/WorkerMain.ts +1 -1
  63. package/front_end/generated/protocol.d.ts +1 -0
  64. package/front_end/global_typings/global_defs.d.ts +0 -1
  65. package/front_end/models/bindings/BreakpointManager.ts +21 -23
  66. package/front_end/models/bindings/CSSWorkspaceBinding.ts +3 -3
  67. package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
  68. package/front_end/models/bindings/ContentProviderBasedProject.ts +1 -1
  69. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +2 -2
  70. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +3 -3
  71. package/front_end/models/bindings/DefaultScriptMapping.ts +1 -1
  72. package/front_end/models/bindings/FileUtils.ts +5 -5
  73. package/front_end/models/bindings/IgnoreListManager.ts +4 -4
  74. package/front_end/models/bindings/LiveLocation.ts +9 -0
  75. package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +2 -1
  76. package/front_end/models/bindings/ResourceMapping.ts +1 -1
  77. package/front_end/models/bindings/ResourceScriptMapping.ts +9 -9
  78. package/front_end/models/bindings/StylesSourceMapping.ts +3 -3
  79. package/front_end/models/bindings/TempFile.ts +1 -1
  80. package/front_end/models/emulation/DeviceModeModel.ts +5 -5
  81. package/front_end/models/emulation/EmulatedDevices.ts +1 -1
  82. package/front_end/models/extensions/ExtensionPanel.ts +1 -1
  83. package/front_end/models/extensions/ExtensionServer.ts +9 -30
  84. package/front_end/models/formatter/FormatterWorkerPool.ts +2 -12
  85. package/front_end/models/formatter/ScriptFormatter.ts +3 -3
  86. package/front_end/models/formatter/SourceFormatter.ts +2 -2
  87. package/front_end/models/issues_manager/ContrastCheckTrigger.ts +1 -1
  88. package/front_end/models/issues_manager/DeprecationIssue.ts +7 -7
  89. package/front_end/models/issues_manager/SourceFrameIssuesManager.ts +3 -3
  90. package/front_end/models/persistence/Automapping.ts +3 -3
  91. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +3 -3
  92. package/front_end/models/persistence/IsolatedFileSystem.ts +1 -1
  93. package/front_end/models/persistence/IsolatedFileSystemManager.ts +2 -2
  94. package/front_end/models/persistence/NetworkPersistenceManager.ts +11 -11
  95. package/front_end/models/persistence/PersistenceActions.ts +3 -3
  96. package/front_end/models/persistence/PersistenceImpl.ts +2 -2
  97. package/front_end/models/persistence/WorkspaceSettingsTab.ts +1 -1
  98. package/front_end/models/workspace/UISourceCode.ts +2 -2
  99. package/front_end/models/workspace_diff/WorkspaceDiff.ts +2 -2
  100. package/front_end/panels/accessibility/AXBreadcrumbsPane.ts +4 -4
  101. package/front_end/panels/accessibility/AccessibilityNodeView.ts +3 -3
  102. package/front_end/panels/accessibility/AccessibilitySidebarView.ts +7 -7
  103. package/front_end/panels/animation/AnimationModel.ts +6 -6
  104. package/front_end/panels/animation/AnimationTimeline.ts +3 -3
  105. package/front_end/panels/animation/AnimationUI.ts +3 -3
  106. package/front_end/panels/application/AppManifestView.ts +4 -4
  107. package/front_end/panels/application/ApplicationPanelCacheSection.ts +3 -3
  108. package/front_end/panels/application/ApplicationPanelSidebar.ts +15 -15
  109. package/front_end/panels/application/BackgroundServiceModel.ts +3 -3
  110. package/front_end/panels/application/BackgroundServiceView.ts +3 -3
  111. package/front_end/panels/application/CookieItemsView.ts +5 -5
  112. package/front_end/panels/application/DOMStorageItemsView.ts +4 -4
  113. package/front_end/panels/application/DOMStorageModel.ts +4 -4
  114. package/front_end/panels/application/DatabaseModel.ts +2 -2
  115. package/front_end/panels/application/DatabaseQueryView.ts +2 -2
  116. package/front_end/panels/application/DatabaseTableView.ts +1 -1
  117. package/front_end/panels/application/IndexedDBModel.ts +11 -11
  118. package/front_end/panels/application/IndexedDBViews.ts +5 -5
  119. package/front_end/panels/application/OpenedWindowDetailsView.ts +4 -4
  120. package/front_end/panels/application/ReportingApiView.ts +1 -1
  121. package/front_end/panels/application/ResourcesPanel.ts +2 -2
  122. package/front_end/panels/application/ServiceWorkerCacheViews.ts +7 -7
  123. package/front_end/panels/application/ServiceWorkersView.ts +15 -15
  124. package/front_end/panels/application/StorageView.ts +5 -5
  125. package/front_end/panels/application/TrustTokensTreeElement.ts +1 -1
  126. package/front_end/panels/application/components/BackForwardCacheStrings.ts +5 -1
  127. package/front_end/panels/application/components/BackForwardCacheView.ts +4 -4
  128. package/front_end/panels/application/components/FrameDetailsView.ts +3 -3
  129. package/front_end/panels/application/components/PermissionsPolicySection.ts +2 -2
  130. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +1 -1
  131. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +8 -7
  132. package/front_end/panels/browser_debugger/ObjectEventListenersSidebarPane.ts +1 -1
  133. package/front_end/panels/browser_debugger/XHRBreakpointsSidebarPane.ts +4 -4
  134. package/front_end/panels/changes/ChangesView.ts +4 -4
  135. package/front_end/panels/console/ConsoleContextSelector.ts +1 -1
  136. package/front_end/panels/console/ConsolePinPane.ts +4 -4
  137. package/front_end/panels/console/ConsolePrompt.ts +4 -4
  138. package/front_end/panels/console/ConsoleSidebar.ts +9 -9
  139. package/front_end/panels/console/ConsoleView.ts +6 -6
  140. package/front_end/panels/console/ConsoleViewMessage.ts +8 -7
  141. package/front_end/panels/console_counters/WarningErrorCounter.ts +2 -2
  142. package/front_end/panels/coverage/CoverageListView.ts +3 -3
  143. package/front_end/panels/coverage/CoverageModel.ts +3 -3
  144. package/front_end/panels/coverage/CoverageView.ts +6 -6
  145. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +3 -3
  146. package/front_end/panels/css_overview/CSSOverviewModel.ts +2 -2
  147. package/front_end/panels/css_overview/CSSOverviewPanel.ts +1 -1
  148. package/front_end/panels/developer_resources/DeveloperResourcesListView.ts +1 -1
  149. package/front_end/panels/developer_resources/DeveloperResourcesView.ts +1 -1
  150. package/front_end/panels/elements/AccessibilityTreeView.ts +5 -5
  151. package/front_end/panels/elements/ClassesPaneWidget.ts +1 -1
  152. package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +10 -10
  153. package/front_end/panels/elements/ComputedStyleWidget.ts +2 -2
  154. package/front_end/panels/elements/DOMLinkifier.ts +2 -2
  155. package/front_end/panels/elements/ElementsPanel.ts +20 -20
  156. package/front_end/panels/elements/ElementsSidebarPane.ts +1 -1
  157. package/front_end/panels/elements/ElementsTreeElement.ts +14 -13
  158. package/front_end/panels/elements/ElementsTreeElementHighlighter.ts +1 -1
  159. package/front_end/panels/elements/ElementsTreeOutline.ts +4 -4
  160. package/front_end/panels/elements/InspectElementModeController.ts +3 -3
  161. package/front_end/panels/elements/LayoutSidebarPane.ts +2 -2
  162. package/front_end/panels/elements/MetricsSidebarPane.ts +2 -2
  163. package/front_end/panels/elements/StylePropertyHighlighter.ts +1 -1
  164. package/front_end/panels/elements/StylePropertyTreeElement.ts +16 -16
  165. package/front_end/panels/elements/StylesSidebarPane.ts +15 -15
  166. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +1 -1
  167. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +8 -8
  168. package/front_end/panels/elements/components/LayoutPane.ts +1 -1
  169. package/front_end/panels/elements/elementsPanel.css +1 -0
  170. package/front_end/panels/emulation/AdvancedApp.ts +2 -2
  171. package/front_end/panels/emulation/DeviceModeToolbar.ts +1 -1
  172. package/front_end/panels/emulation/DeviceModeView.ts +2 -2
  173. package/front_end/panels/emulation/DeviceModeWrapper.ts +4 -4
  174. package/front_end/panels/emulation/MediaQueryInspector.ts +3 -3
  175. package/front_end/panels/event_listeners/EventListenersView.ts +3 -3
  176. package/front_end/panels/input/InputModel.ts +2 -2
  177. package/front_end/panels/input/InputTimeline.ts +6 -6
  178. package/front_end/panels/issues/AffectedCookiesView.ts +2 -2
  179. package/front_end/panels/issues/AffectedDirectivesView.ts +1 -1
  180. package/front_end/panels/issues/AffectedElementsView.ts +1 -1
  181. package/front_end/panels/issues/AffectedResourcesView.ts +2 -2
  182. package/front_end/panels/issues/AttributionReportingIssueDetailsView.ts +1 -1
  183. package/front_end/panels/issues/ComboBoxOfCheckBoxes.ts +1 -1
  184. package/front_end/panels/issues/IssueView.ts +1 -1
  185. package/front_end/panels/issues/components/HideIssuesMenu.ts +1 -1
  186. package/front_end/panels/layer_viewer/LayerDetailsView.ts +1 -1
  187. package/front_end/panels/layer_viewer/LayerViewHost.ts +1 -1
  188. package/front_end/panels/layer_viewer/Layers3DView.ts +7 -7
  189. package/front_end/panels/layer_viewer/PaintProfilerView.ts +1 -1
  190. package/front_end/panels/layers/LayerPaintProfilerView.ts +3 -3
  191. package/front_end/panels/layers/LayerTreeModel.ts +4 -4
  192. package/front_end/panels/layers/LayersPanel.ts +4 -4
  193. package/front_end/panels/lighthouse/LighthouseController.ts +1 -1
  194. package/front_end/panels/lighthouse/LighthousePanel.ts +5 -5
  195. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +1 -1
  196. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +1 -1
  197. package/front_end/panels/media/MediaModel.ts +1 -1
  198. package/front_end/panels/media/PlayerListView.ts +1 -1
  199. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +1 -1
  200. package/front_end/panels/network/BinaryResourceView.ts +1 -1
  201. package/front_end/panels/network/BlockedURLsPane.ts +5 -5
  202. package/front_end/panels/network/NetworkDataGridNode.ts +1 -1
  203. package/front_end/panels/network/NetworkItemView.ts +2 -2
  204. package/front_end/panels/network/NetworkLogView.ts +4 -4
  205. package/front_end/panels/network/NetworkLogViewColumns.ts +1 -1
  206. package/front_end/panels/network/NetworkPanel.ts +8 -8
  207. package/front_end/panels/network/NetworkTimeCalculator.ts +1 -1
  208. package/front_end/panels/network/RequestHeadersView.ts +4 -3
  209. package/front_end/panels/network/RequestPayloadView.ts +8 -8
  210. package/front_end/panels/network/RequestPreviewView.ts +1 -1
  211. package/front_end/panels/network/RequestResponseView.ts +2 -2
  212. package/front_end/panels/network/ResourceWebSocketFrameView.ts +1 -1
  213. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +4 -3
  214. package/front_end/panels/profiler/CPUProfileView.ts +4 -4
  215. package/front_end/panels/profiler/HeapProfileView.ts +6 -6
  216. package/front_end/panels/profiler/HeapProfilerPanel.ts +2 -2
  217. package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +10 -10
  218. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +9 -8
  219. package/front_end/panels/profiler/HeapSnapshotView.ts +24 -24
  220. package/front_end/panels/profiler/LiveHeapProfileView.ts +4 -4
  221. package/front_end/panels/profiler/ProfileSidebarTreeElement.ts +1 -1
  222. package/front_end/panels/profiler/ProfileView.ts +3 -3
  223. package/front_end/panels/profiler/ProfilesPanel.ts +3 -3
  224. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +3 -3
  225. package/front_end/panels/screencast/InputModel.ts +3 -3
  226. package/front_end/panels/screencast/ScreencastView.ts +10 -10
  227. package/front_end/panels/search/SearchResultsPane.ts +1 -1
  228. package/front_end/panels/search/SearchView.ts +2 -2
  229. package/front_end/panels/security/SecurityModel.ts +1 -1
  230. package/front_end/panels/security/SecurityPanel.ts +2 -2
  231. package/front_end/panels/sensors/SensorsView.ts +3 -2
  232. package/front_end/panels/settings/SettingsScreen.ts +5 -5
  233. package/front_end/panels/settings/components/SyncSection.ts +1 -1
  234. package/front_end/panels/snippets/SnippetsQuickOpen.ts +1 -1
  235. package/front_end/panels/sources/BreakpointEditDialog.ts +2 -2
  236. package/front_end/panels/sources/CallStackSidebarPane.ts +4 -4
  237. package/front_end/panels/sources/CoveragePlugin.ts +3 -3
  238. package/front_end/panels/sources/DebuggerPlugin.ts +12 -12
  239. package/front_end/panels/sources/GoToLineQuickOpen.ts +1 -1
  240. package/front_end/panels/sources/InplaceFormatterEditorAction.ts +3 -3
  241. package/front_end/panels/sources/JavaScriptBreakpointsSidebarPane.ts +3 -3
  242. package/front_end/panels/sources/NavigatorView.ts +6 -6
  243. package/front_end/panels/sources/OpenFileQuickOpen.ts +2 -2
  244. package/front_end/panels/sources/OutlineQuickOpen.ts +1 -1
  245. package/front_end/panels/sources/ScopeChainSidebarPane.ts +3 -3
  246. package/front_end/panels/sources/ScriptFormatterEditorAction.ts +3 -3
  247. package/front_end/panels/sources/SearchSourcesView.ts +2 -2
  248. package/front_end/panels/sources/SourcesNavigator.ts +9 -9
  249. package/front_end/panels/sources/SourcesPanel.ts +28 -25
  250. package/front_end/panels/sources/SourcesSearchScope.ts +2 -2
  251. package/front_end/panels/sources/SourcesView.ts +4 -4
  252. package/front_end/panels/sources/TabbedEditorContainer.ts +1 -1
  253. package/front_end/panels/sources/UISourceCodeFrame.ts +2 -2
  254. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +4 -4
  255. package/front_end/panels/timeline/EventsTimelineTreeView.ts +1 -1
  256. package/front_end/panels/timeline/TimelineController.ts +1 -1
  257. package/front_end/panels/timeline/TimelineDetailsView.ts +2 -2
  258. package/front_end/panels/timeline/TimelineEventOverview.ts +2 -2
  259. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +22 -5
  260. package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +9 -6
  261. package/front_end/panels/timeline/TimelineHistoryManager.ts +1 -1
  262. package/front_end/panels/timeline/TimelineLayersView.ts +1 -1
  263. package/front_end/panels/timeline/TimelineLoader.ts +2 -2
  264. package/front_end/panels/timeline/TimelinePaintProfilerView.ts +4 -4
  265. package/front_end/panels/timeline/TimelinePanel.ts +10 -10
  266. package/front_end/panels/timeline/TimelineUIUtils.ts +2 -2
  267. package/front_end/panels/timeline/components/WebVitalsTimeline.ts +2 -2
  268. package/front_end/panels/web_audio/WebAudioModel.ts +1 -1
  269. package/front_end/panels/web_audio/WebAudioView.ts +1 -1
  270. package/front_end/panels/webauthn/WebauthnPane.ts +7 -7
  271. package/front_end/third_party/acorn/acorn.ts +1 -1
  272. package/front_end/ui/components/buttons/Button.ts +10 -10
  273. package/front_end/ui/components/data_grid/DataGrid.ts +14 -14
  274. package/front_end/ui/components/docs/tree_outline/basic.ts +2 -2
  275. package/front_end/ui/components/docs/tree_outline/custom-renderers.ts +1 -1
  276. package/front_end/ui/components/docs/tree_outline/lazy-children.ts +1 -1
  277. package/front_end/ui/components/helpers/scheduled-render.ts +1 -1
  278. package/front_end/ui/components/icon_button/Icon.ts +1 -1
  279. package/front_end/ui/components/issue_counter/IssueCounter.ts +1 -1
  280. package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +2 -2
  281. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +2 -2
  282. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +5 -2
  283. package/front_end/ui/components/linkifier/LinkifierImpl.ts +1 -1
  284. package/front_end/ui/components/panel_feedback/FeedbackButton.ts +1 -1
  285. package/front_end/ui/components/panel_feedback/PanelFeedback.ts +1 -1
  286. package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +3 -3
  287. package/front_end/ui/components/text_editor/cursor_tooltip.ts +1 -1
  288. package/front_end/ui/components/text_editor/javascript.ts +2 -2
  289. package/front_end/ui/components/tree_outline/TreeOutline.ts +8 -8
  290. package/front_end/ui/legacy/Context.ts +1 -1
  291. package/front_end/ui/legacy/ContextMenu.ts +1 -1
  292. package/front_end/ui/legacy/GlassPane.ts +0 -1
  293. package/front_end/ui/legacy/InspectorView.ts +2 -3
  294. package/front_end/ui/legacy/PopoverHelper.ts +1 -1
  295. package/front_end/ui/legacy/ResizerWidget.ts +4 -2
  296. package/front_end/ui/legacy/ShortcutRegistry.ts +1 -1
  297. package/front_end/ui/legacy/SoftDropDown.ts +2 -1
  298. package/front_end/ui/legacy/TabbedPane.ts +2 -2
  299. package/front_end/ui/legacy/TextPrompt.ts +2 -2
  300. package/front_end/ui/legacy/ThrottledWidget.ts +1 -1
  301. package/front_end/ui/legacy/Toolbar.ts +3 -3
  302. package/front_end/ui/legacy/Treeoutline.ts +15 -21
  303. package/front_end/ui/legacy/UIUtils.ts +17 -24
  304. package/front_end/ui/legacy/ViewManager.ts +10 -10
  305. package/front_end/ui/legacy/Widget.ts +3 -2
  306. package/front_end/ui/legacy/components/color_picker/ContrastOverlay.ts +1 -1
  307. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +7 -7
  308. package/front_end/ui/legacy/components/color_picker/spectrum.css +5 -2
  309. package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +3 -3
  310. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +3 -2
  311. package/front_end/ui/legacy/components/data_grid/ShowMoreDataGridNode.ts +3 -3
  312. package/front_end/ui/legacy/components/inline_editor/CSSAngleEditor.ts +1 -1
  313. package/front_end/ui/legacy/components/inline_editor/FontEditor.ts +4 -4
  314. package/front_end/ui/legacy/components/object_ui/CustomPreviewComponent.ts +3 -3
  315. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +1 -1
  316. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +11 -11
  317. package/front_end/ui/legacy/components/perf_ui/FilmStripView.ts +8 -8
  318. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +13 -18
  319. package/front_end/ui/legacy/components/perf_ui/GCActionDelegate.ts +1 -1
  320. package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +1 -1
  321. package/front_end/ui/legacy/components/perf_ui/LiveHeapProfile.ts +3 -3
  322. package/front_end/ui/legacy/components/perf_ui/OverviewGrid.ts +2 -1
  323. package/front_end/ui/legacy/components/perf_ui/TimelineGrid.ts +3 -6
  324. package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +2 -2
  325. package/front_end/ui/legacy/components/perf_ui/flameChart.css +8 -0
  326. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +5 -5
  327. package/front_end/ui/legacy/components/source_frame/FontView.ts +1 -2
  328. package/front_end/ui/legacy/components/source_frame/ImageView.ts +3 -4
  329. package/front_end/ui/legacy/components/source_frame/JSONView.ts +0 -1
  330. package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +1 -2
  331. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +5 -5
  332. package/front_end/ui/legacy/components/source_frame/XMLView.ts +0 -2
  333. package/front_end/ui/legacy/components/utils/ImagePreview.ts +1 -1
  334. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +1 -1
  335. package/front_end/ui/legacy/components/utils/Linkifier.ts +5 -5
  336. package/front_end/ui/legacy/components/utils/TargetDetachedDialog.ts +2 -2
  337. package/front_end/ui/legacy/inspectorSyntaxHighlight.css +8 -11
  338. package/front_end/ui/legacy/softContextMenu.css +4 -1
  339. package/front_end/ui/legacy/tabbedPane.css +1 -0
  340. package/front_end/ui/legacy/themeColors.css +3 -1
  341. package/front_end/ui/legacy/theme_support/theme_support_impl.ts +24 -234
  342. package/front_end/ui/legacy/toolbar.css +1 -0
  343. package/front_end/ui/legacy/treeoutline.css +0 -4
  344. package/front_end/ui/legacy/utils/create-shadow-root-with-core-styles.ts +3 -2
  345. package/front_end/ui/legacy/utils/inject-core-styles.ts +3 -31
  346. package/front_end/ui/legacy/utils/utils.ts +1 -5
  347. package/front_end/ui/lit-html/lit-html.ts +1 -1
  348. package/package.json +1 -1
  349. package/scripts/build/generate_css_js_files.js +2 -2
  350. package/scripts/build/ninja/generate_css.gni +3 -0
  351. package/scripts/component_server/server.js +2 -2
  352. package/scripts/eslint_rules/lib/no_bound_component_methods.js +116 -0
  353. package/scripts/eslint_rules/tests/no_bound_component_methods_test.js +85 -0
  354. package/front_end/global_typings/intl_display_names.d.ts +0 -111
  355. package/front_end/ui/legacy/inspectorSyntaxHighlightDark.css +0 -270
  356. package/front_end/ui/legacy/utils/append-style.ts +0 -9
@@ -34,46 +34,20 @@
34
34
  */
35
35
 
36
36
  import * as Common from '../../../core/common/common.js';
37
- import * as Platform from '../../../core/platform/platform.js';
38
37
 
39
38
  import inspectorSyntaxHighlightStyles from '../inspectorSyntaxHighlight.css.legacy.js';
40
- import inspectorSyntaxHighlightDarkStyles from '../inspectorSyntaxHighlightDark.css.legacy.js';
41
39
 
42
40
  let themeSupportInstance: ThemeSupport;
43
41
 
44
42
  const themeValuesCache = new Map<CSSStyleDeclaration, Map<string, string>>();
45
43
 
46
- export class ThemeSupport {
47
- private readonly themeNameInternal: string;
48
- private themableProperties: Set<string>;
49
- private readonly cachedThemePatches: Map<string, string>;
50
- private readonly setting: Common.Settings.Setting<string>;
51
- private readonly customSheets: Set<string>;
52
- private readonly computedRoot: () => symbol | CSSStyleDeclaration;
53
- private injectingStyleSheet?: boolean;
44
+ export class ThemeSupport extends EventTarget {
45
+ private themeNameInternal = 'systemPreferred';
46
+ private customSheets: Set<string> = new Set();
47
+ private computedRoot = Common.Lazy.lazy(() => window.getComputedStyle(document.documentElement));
54
48
 
55
- private constructor(setting: Common.Settings.Setting<string>) {
56
- const systemPreferredTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default';
57
- this.themeNameInternal = setting.get() === 'systemPreferred' ? systemPreferredTheme : setting.get();
58
- this.themableProperties = new Set([
59
- 'color',
60
- 'box-shadow',
61
- 'text-shadow',
62
- 'outline-color',
63
- 'background-image',
64
- 'background-color',
65
- 'border-left-color',
66
- 'border-right-color',
67
- 'border-top-color',
68
- 'border-bottom-color',
69
- '-webkit-border-image',
70
- 'fill',
71
- 'stroke',
72
- ]);
73
- this.cachedThemePatches = new Map();
74
- this.setting = setting;
75
- this.customSheets = new Set();
76
- this.computedRoot = Common.Lazy.lazy(() => window.getComputedStyle(document.documentElement));
49
+ private constructor(private setting: Common.Settings.Setting<string>) {
50
+ super();
77
51
  }
78
52
 
79
53
  static hasInstance(): boolean {
@@ -139,19 +113,10 @@ export class ThemeSupport {
139
113
  }
140
114
 
141
115
  injectHighlightStyleSheets(element: Element|ShadowRoot): void {
142
- this.injectingStyleSheet = true;
143
116
  this.appendStyle(element, inspectorSyntaxHighlightStyles);
144
- if (this.themeNameInternal === 'dark') {
145
- this.appendStyle(element, inspectorSyntaxHighlightDarkStyles);
146
- }
147
- this.injectingStyleSheet = false;
148
117
  }
149
118
 
150
- /**
151
- * Note: this is a duplicate of the function in ui/utils. It exists here
152
- * so there is no circular dependency between ui/utils and theme_support.
153
- */
154
- private appendStyle(node: Node, {cssContent}: {cssContent: string}): void {
119
+ appendStyle(node: Node, {cssContent}: {cssContent: string}): void {
155
120
  const styleElement = document.createElement('style');
156
121
  styleElement.textContent = cssContent;
157
122
  node.appendChild(styleElement);
@@ -165,212 +130,37 @@ export class ThemeSupport {
165
130
  }
166
131
  }
167
132
 
168
- isForcedColorsMode(): boolean {
169
- return window.matchMedia('(forced-colors: active)').matches;
170
- }
171
-
172
133
  addCustomStylesheet(sheetText: string): void {
173
134
  this.customSheets.add(sheetText);
174
135
  }
175
136
 
176
137
  applyTheme(document: Document): void {
177
- if (!this.hasTheme() || this.isForcedColorsMode()) {
138
+ const isForcedColorsMode = window.matchMedia('(forced-colors: active)').matches;
139
+ if (isForcedColorsMode) {
178
140
  return;
179
141
  }
180
142
 
181
- if (this.themeNameInternal === 'dark') {
182
- document.documentElement.classList.add('-theme-with-dark-background');
183
- }
184
-
185
- const styleSheets = document.styleSheets;
186
- const result = [];
187
- for (let i = 0; i < styleSheets.length; ++i) {
188
- const href = styleSheets[i].href;
189
- if (!href) {
190
- continue;
191
- }
192
- result.push(this.patchForTheme(href, (styleSheets[i] as CSSStyleSheet)));
193
- }
194
- result.push('/*# sourceURL=inspector.css.theme */');
195
-
196
- const styleElement = document.createElement('style');
197
- styleElement.textContent = result.join('\n');
198
- document.head.appendChild(styleElement);
199
- }
200
-
201
- themeStyleSheet(id: string, text: string): string {
202
- if (!this.hasTheme() || this.injectingStyleSheet || this.isForcedColorsMode()) {
203
- return '';
204
- }
205
-
206
- let patch = this.cachedThemePatches.get(id);
207
- if (!patch) {
208
- const styleElement = document.createElement('style');
209
- styleElement.textContent = text;
210
- document.body.appendChild(styleElement);
211
-
212
- const {sheet} = styleElement;
213
- if (!sheet) {
214
- throw new Error('No sheet in stylesheet object');
215
- }
216
- patch = this.patchForTheme(id, sheet);
217
- document.body.removeChild(styleElement);
218
- }
219
- return patch;
220
- }
221
-
222
- private patchForTheme(id: string, styleSheet: CSSStyleSheet): string {
223
- const cached = this.cachedThemePatches.get(id);
224
- if (cached) {
225
- return cached;
226
- }
227
-
228
- try {
229
- const rules = styleSheet.cssRules;
230
- const result = [];
231
- for (let j = 0; j < rules.length; ++j) {
232
- const rule = rules[j];
233
- if (rule instanceof CSSImportRule) {
234
- result.push(this.patchForTheme(rule.styleSheet.href || '', rule.styleSheet));
235
- continue;
236
- }
237
-
238
- if (!(rule instanceof CSSStyleRule)) {
239
- continue;
240
- }
241
-
242
- const output: string[] = [];
243
- const style = rule.style;
244
- const selectorText = rule.selectorText;
245
- for (let i = 0; style && i < style.length; ++i) {
246
- this.patchProperty(selectorText, style, style[i], output);
247
- }
248
- if (output.length) {
249
- result.push(rule.selectorText + '{' + output.join('') + '}');
250
- }
251
- }
252
-
253
- const fullText = result.join('\n');
254
- this.cachedThemePatches.set(id, fullText);
255
- return fullText;
256
- } catch (e) {
257
- this.setting.set('default');
258
- return '';
259
- }
260
- }
261
-
262
- /**
263
- * Theming API is primarily targeted at making dark theme look good.
264
- * - If rule has ".-theme-preserve" in selector, it won't be affected.
265
- * - One can create specializations for dark themes via body.-theme-with-dark-background selector in host context.
266
- */
267
- private patchProperty(selectorText: string, style: CSSStyleDeclaration, name: string, output: string[]): void {
268
- if (!this.themableProperties.has(name)) {
269
- return;
270
- }
271
-
272
- const value = style.getPropertyValue(name);
273
- if (!value || value === 'none' || value === 'inherit' || value === 'initial' || value === 'transparent') {
274
- return;
275
- }
276
- if (name === 'background-image' && value.indexOf('gradient') === -1) {
277
- return;
278
- }
143
+ const systemPreferredTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default';
144
+ this.themeNameInternal = this.setting.get() === 'systemPreferred' ? systemPreferredTheme : this.setting.get();
279
145
 
280
- if (selectorText.indexOf('-theme-') !== -1) {
281
- return;
282
- }
146
+ const wasDarkThemed = document.documentElement.classList.contains('-theme-with-dark-background');
147
+ document.documentElement.classList.toggle('-theme-with-dark-background', this.themeNameInternal === 'dark');
283
148
 
284
- let colorUsage = ThemeSupport.ColorUsage.Unknown;
285
- if (name.indexOf('background') === 0 || name.indexOf('border') === 0) {
286
- colorUsage |= ThemeSupport.ColorUsage.Background;
287
- }
288
- if (name.indexOf('background') === -1) {
289
- colorUsage |= ThemeSupport.ColorUsage.Foreground;
290
- }
149
+ const isDarkThemed = document.documentElement.classList.contains('-theme-with-dark-background');
291
150
 
292
- output.push(name);
293
- output.push(':');
294
- if (/^var\(.*\)$/.test(value)) {
295
- // Don't translate CSS variables.
296
- output.push(value);
297
- } else {
298
- const items = value.replace(Common.Color.Regex, '\0$1\0').split('\0');
299
- for (const item of items) {
300
- output.push(this.patchColorText(item, (colorUsage as number)));
301
- }
151
+ // In the event the theme changes we need to clear caches and notify subscribers.
152
+ if (wasDarkThemed !== isDarkThemed) {
153
+ themeValuesCache.clear();
154
+ this.customSheets.clear();
155
+ this.dispatchEvent(new ThemeChangeEvent());
302
156
  }
303
- if (style.getPropertyPriority(name)) {
304
- output.push(' !important');
305
- }
306
- output.push(';');
307
- }
308
-
309
- /**
310
- * This legacy function has been supeseded by CSS custom properties. Wherever possible, please use
311
- * the values declared in global stylesheets.
312
- *
313
- * @deprecated
314
- */
315
- patchColorText(text: string, colorUsage: number): string {
316
- const color = Common.Color.Color.parse(text);
317
- if (!color) {
318
- return text;
319
- }
320
- const outColor = this.patchColor(color, colorUsage);
321
- let outText = outColor.asString(null);
322
- if (!outText) {
323
- outText = outColor.asString(outColor.hasAlpha() ? Common.Color.Format.RGBA : Common.Color.Format.RGB);
324
- }
325
- return outText || text;
326
- }
327
-
328
- /**
329
- * This legacy function has been supeseded by CSS custom properties. Wherever possible, please use
330
- * the values declared in global stylesheets.
331
- *
332
- * @deprecated
333
- */
334
- patchColor(color: Common.Color.Color, colorUsage: number): Common.Color.Color {
335
- const hsla = color.hsla();
336
- this.patchHSLA(hsla, colorUsage);
337
-
338
- const rgba: number[] = [];
339
- Common.Color.Color.hsl2rgb(hsla, rgba);
340
- return new Common.Color.Color(rgba, color.format());
341
157
  }
158
+ }
342
159
 
343
- private patchHSLA(hsla: number[], colorUsage: number): void {
344
- const hue = hsla[0];
345
- const sat = hsla[1];
346
- let lit: number = hsla[2];
347
- const alpha = hsla[3];
160
+ export class ThemeChangeEvent extends Event {
161
+ static readonly eventName = 'themechange';
348
162
 
349
- switch (this.themeNameInternal) {
350
- case 'dark': {
351
- const minCap = colorUsage & ThemeSupport.ColorUsage.Background ? 0.14 : 0;
352
- const maxCap = colorUsage & ThemeSupport.ColorUsage.Foreground ? 0.9 : 1;
353
- lit = 1 - lit;
354
- if (lit < minCap * 2) {
355
- lit = minCap + lit / 2;
356
- } else if (lit > 2 * maxCap - 1) {
357
- lit = maxCap - 1 / 2 + lit / 2;
358
- }
359
- break;
360
- }
361
- }
362
- hsla[0] = Platform.NumberUtilities.clamp(hue, 0, 1);
363
- hsla[1] = Platform.NumberUtilities.clamp(sat, 0, 1);
364
- hsla[2] = Platform.NumberUtilities.clamp(lit, 0, 1);
365
- hsla[3] = Platform.NumberUtilities.clamp(alpha, 0, 1);
366
- }
367
- }
368
- export namespace ThemeSupport {
369
- // TODO(crbug.com/1167717): Make this a const enum again
370
- // eslint-disable-next-line rulesdir/const_enum
371
- export enum ColorUsage {
372
- Unknown = 0,
373
- Foreground = 1,
374
- Background = 2,
163
+ constructor() {
164
+ super(ThemeChangeEvent.eventName, {bubbles: true, composed: true});
375
165
  }
376
166
  }
@@ -294,6 +294,7 @@ select.toolbar-item:disabled {
294
294
  opacity: 50%;
295
295
  }
296
296
 
297
+ button.toolbar-item:focus-visible,
297
298
  select.toolbar-item:focus-visible {
298
299
  background: var(--color-background-elevation-2);
299
300
  border-radius: 2px;
@@ -93,10 +93,6 @@ ol.tree-outline:not(.hide-selection-when-blurred) li.selected:focus * {
93
93
  color: inherit;
94
94
  }
95
95
 
96
- .tree-outline .tree-element-content {
97
- display: flex;
98
- }
99
-
100
96
  .tree-outline li .icons-container {
101
97
  align-self: center;
102
98
  display: flex;
@@ -2,7 +2,8 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import {appendStyle} from './append-style.js';
5
+ import * as ThemeSupport from '../theme_support/theme_support.js';
6
+
6
7
  import {focusChanged} from './focus-changed.js';
7
8
  import {injectCoreStyles} from './inject-core-styles.js';
8
9
 
@@ -24,7 +25,7 @@ export function createShadowRootWithCoreStyles(element: Element, options: Option
24
25
  injectCoreStyles(shadowRoot);
25
26
  if (cssFile) {
26
27
  if ('cssContent' in cssFile) {
27
- appendStyle(shadowRoot, cssFile);
28
+ ThemeSupport.ThemeSupport.instance().appendStyle(shadowRoot, cssFile);
28
29
  } else {
29
30
  shadowRoot.adoptedStyleSheets = cssFile;
30
31
  }
@@ -7,39 +7,11 @@ import textButtonStyles from '../textButton.css.legacy.js';
7
7
  import * as ThemeSupport from '../theme_support/theme_support.js';
8
8
  import themeColorsStyles from '../themeColors.css.legacy.js';
9
9
 
10
- import {appendStyle} from './append-style.js';
11
-
12
10
  export function injectCoreStyles(root: Element|ShadowRoot): void {
13
- appendStyle(root, inspectorCommonStyles);
14
- appendStyle(root, textButtonStyles);
15
- appendStyle(root, themeColorsStyles);
11
+ ThemeSupport.ThemeSupport.instance().appendStyle(root, inspectorCommonStyles);
12
+ ThemeSupport.ThemeSupport.instance().appendStyle(root, textButtonStyles);
13
+ ThemeSupport.ThemeSupport.instance().appendStyle(root, themeColorsStyles);
16
14
 
17
15
  ThemeSupport.ThemeSupport.instance().injectHighlightStyleSheets(root);
18
16
  ThemeSupport.ThemeSupport.instance().injectCustomStyleSheets(root);
19
17
  }
20
-
21
- let bodyComputedStylesCached: CSSStyleDeclaration|null = null;
22
- export function getThemeColorValue(variableName: string): string {
23
- if (!bodyComputedStylesCached) {
24
- /**
25
- * We are safe to cache this value as we're only using this code to look up
26
- * theme variables, and they do not change during runtime. And if the user
27
- * swaps from light => dark theme, or vice-versa, DevTools is entirely
28
- * reloaded, removing this cache.
29
- */
30
- bodyComputedStylesCached = window.getComputedStyle(document.body);
31
- }
32
-
33
- const colorValue = bodyComputedStylesCached.getPropertyValue(variableName);
34
- if (!colorValue) {
35
- throw new Error(`Could not find theme color for variable ${variableName}.`);
36
- }
37
- return colorValue;
38
- }
39
-
40
- export function getCurrentTheme(): 'light'|'dark' {
41
- if (document.documentElement.classList.contains('-theme-with-dark-background')) {
42
- return 'dark';
43
- }
44
- return 'light';
45
- }
@@ -4,19 +4,15 @@
4
4
 
5
5
  /* eslint-disable rulesdir/es_modules_import */
6
6
 
7
- import {appendStyle} from './append-style.js';
8
7
  import {createShadowRootWithCoreStyles} from './create-shadow-root-with-core-styles.js';
9
8
  import {focusChanged} from './focus-changed.js';
10
- import {getCurrentTheme, getThemeColorValue, injectCoreStyles} from './inject-core-styles.js';
9
+ import {injectCoreStyles} from './inject-core-styles.js';
11
10
  import {measuredScrollbarWidth, resetMeasuredScrollbarWidthForTest} from './measured-scrollbar-width.js';
12
11
  import {registerCustomElement} from './register-custom-element.js';
13
12
 
14
13
  export {
15
- appendStyle,
16
14
  createShadowRootWithCoreStyles,
17
15
  focusChanged,
18
- getCurrentTheme,
19
- getThemeColorValue,
20
16
  injectCoreStyles,
21
17
  measuredScrollbarWidth,
22
18
  registerCustomElement,
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as LitHtml from '../../third_party/lit-html/lit-html.js';
6
6
  import * as Static from './static.js';
7
- export {Directive, TemplateResult} from '../../third_party/lit-html/lit-html.js';
7
+ export {Directive, type TemplateResult} from '../../third_party/lit-html/lit-html.js';
8
8
 
9
9
  const {render, svg, Directives, nothing, noChange} = LitHtml;
10
10
  const {html, literal, flattenTemplate} = Static;
package/package.json CHANGED
@@ -53,5 +53,5 @@
53
53
  "unittest": "scripts/test/run_unittests.py --no-text-coverage",
54
54
  "watch": "third_party/node/node.py --output scripts/watch_build.js"
55
55
  },
56
- "version": "1.0.955092"
56
+ "version": "1.0.956812"
57
57
  }
@@ -4,7 +4,7 @@
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const CleanCSS = require('clean-css');
7
- const [, , isDebugString, legacyString, targetName, srcDir, targetGenDir, files] = process.argv;
7
+ const [, , buildTimestamp, isDebugString, legacyString, targetName, srcDir, targetGenDir, files] = process.argv;
8
8
 
9
9
  const filenames = files.split(',');
10
10
  const configFiles = [];
@@ -37,7 +37,7 @@ export default styles;`;
37
37
 
38
38
  fs.writeFileSync(
39
39
  path.join(targetGenDir, generatedFileName),
40
- `// Copyright ${new Date().getFullYear()} The Chromium Authors. All rights reserved.
40
+ `// Copyright ${new Date(Number(buildTimestamp) * 1000).getFullYear()} The Chromium Authors. All rights reserved.
41
41
  // Use of this source code is governed by a BSD-style license that can be
42
42
  // found in the LICENSE file.
43
43
  // IMPORTANT: this file is auto generated. Please do not edit this file.
@@ -2,8 +2,10 @@
2
2
  # Use of this source code is governed by a BSD-style license that can be
3
3
  # found in the LICENSE file.
4
4
 
5
+ import("//build/timestamp.gni")
5
6
  import("./node.gni")
6
7
  import("./vars.gni")
8
+
7
9
  template("generate_css") {
8
10
  node_action(target_name) {
9
11
  forward_variables_from(invoker, [ "sources" ])
@@ -17,6 +19,7 @@ template("generate_css") {
17
19
  [ devtools_location_prepend + "node_modules/clean-css/package.json" ]
18
20
 
19
21
  args = [
22
+ build_timestamp,
20
23
  "$is_debug",
21
24
  "${invoker.legacy}",
22
25
  target_name,
@@ -150,8 +150,8 @@ function createServerIndexFile(componentNames) {
150
150
  <meta charset="UTF-8" />
151
151
  <meta name="viewport" content="width=device-width" />
152
152
  <title>DevTools components</title>
153
- <link rel="stylesheet" href="/front_end/ui/legacy/themeColors.css" />
154
- <link rel="stylesheet" href="/front_end/ui/components/docs/component_docs_styles.css" />
153
+ <link rel="stylesheet" href="${sharedResourcesBase}front_end/ui/legacy/themeColors.css" />
154
+ <link rel="stylesheet" href="${sharedResourcesBase}front_end/ui/components/docs/component_docs_styles.css" />
155
155
  </head>
156
156
  <body id="index-page">
157
157
  <h1>DevTools components</h1>
@@ -0,0 +1,116 @@
1
+ // Copyright 2021 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ 'use strict';
5
+
6
+ module.exports = {
7
+ meta: {
8
+ type: 'problem',
9
+ docs: {
10
+ description: 'Enforce that no methods that are used as LitHtml events are bound.',
11
+ category: 'Possible Errors',
12
+ },
13
+ fixable: 'code',
14
+ schema: [], // no options
15
+ messages: {
16
+ nonRenderBindFound:
17
+ 'Found bound method name {{ methodName }} on {{ componentName }} that was not `render`. Lit-Html binds all event handlers for you automatically so this is not required.',
18
+ },
19
+ },
20
+ create: function(context) {
21
+ function nodeIsHTMLElementClassDeclaration(node) {
22
+ return node.type === 'ClassDeclaration' && node.superClass && node.superClass.name === 'HTMLElement';
23
+ }
24
+
25
+ const classesToCheck = new Set();
26
+
27
+ // Store any method names that were passed to addEventListener.
28
+ // With the following code:
29
+ // window.addEventListener('click', this.boundOnClick)
30
+ // we would add `boundOnClick` to this set.
31
+ const addEventListenerCallPropertyNames = new Set();
32
+
33
+ function checkPropertyDeclarationForBinding(className, node) {
34
+ if (!node.value || node.value.type !== 'CallExpression') {
35
+ return;
36
+ }
37
+ if (node.value.callee.type !== 'MemberExpression') {
38
+ return;
39
+ }
40
+ if (node.value.callee.property.name !== 'bind') {
41
+ return;
42
+ }
43
+ // At this point we know it's a property of the form:
44
+ // someBoundThing = this.thing.bind(X)
45
+ // and now we want to check that the argument passed to bind is `this`.
46
+ // If the argument to bind is not `this`, we leave it be and move on.
47
+ if (node.value.arguments[0]?.type !== 'ThisExpression') {
48
+ return;
49
+ }
50
+
51
+ // At this point it's definitely of the form:
52
+ // someBoundThing = this.thing.bind(this)
53
+ // But we know that `render` may be bound for the scheduler, so if it's render we can move on
54
+ if (node.value.callee.object.property.name === 'render') {
55
+ return;
56
+ }
57
+
58
+ // Now it's an error UNLESS we found a call to
59
+ // addEventListener(x, this.#boundFoo),
60
+ // in which case it's allowed.
61
+
62
+ // Get the property name for the bound method
63
+ // #boundFoo = this.foo.bind(this);
64
+ // node.key.name === 'boundFoo';
65
+ const boundPropertyName = node.key.name;
66
+ if (addEventListenerCallPropertyNames.has(boundPropertyName)) {
67
+ return;
68
+ }
69
+
70
+ context.report({
71
+ node: node,
72
+ messageId: 'nonRenderBindFound',
73
+ data: {componentName: className, methodName: node.value.callee.object.property.name}
74
+ });
75
+ }
76
+
77
+ function checkClassForBoundMethods(classDeclarationNode) {
78
+ const classPropertyDeclarations = classDeclarationNode.body.body.filter(node => {
79
+ return node.type === 'PropertyDefinition';
80
+ });
81
+ for (const decl of classPropertyDeclarations) {
82
+ checkPropertyDeclarationForBinding(classDeclarationNode.id.name, decl);
83
+ }
84
+ }
85
+
86
+ return {
87
+ ClassDeclaration(classDeclarationNode) {
88
+ if (!nodeIsHTMLElementClassDeclaration(classDeclarationNode)) {
89
+ return;
90
+ }
91
+
92
+ classesToCheck.add(classDeclarationNode);
93
+ },
94
+ 'CallExpression[callee.type=\'MemberExpression\'][callee.property.name=\'addEventListener\']'(
95
+ callExpressionNode) {
96
+ const methodArg = callExpressionNode.arguments[1];
97
+ // Confirm that the argument is this.X, otherwise skip it
98
+ if (methodArg.type !== 'MemberExpression') {
99
+ return;
100
+ }
101
+
102
+ // Get the property from the addEventListener call
103
+ // window.addEventListener('click', this.#boundFoo)
104
+ // This will be the node representing `#boundFoo`
105
+ // and its `.name` property will be `boundFoo`
106
+ const propertyArg = methodArg.property;
107
+ addEventListenerCallPropertyNames.add(propertyArg.name);
108
+ },
109
+ 'Program:exit'() {
110
+ for (const classNode of classesToCheck) {
111
+ checkClassForBoundMethods(classNode);
112
+ }
113
+ }
114
+ };
115
+ }
116
+ };
@@ -0,0 +1,85 @@
1
+ // Copyright 2021 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ 'use strict';
5
+
6
+ const rule = require('../lib/no_bound_component_methods.js');
7
+ const ruleTester = new (require('eslint').RuleTester)({
8
+ parserOptions: {ecmaVersion: 9, sourceType: 'module'},
9
+ parser: require.resolve('@typescript-eslint/parser'),
10
+ });
11
+
12
+ ruleTester.run('no_bound_component_methods', rule, {
13
+ valid: [
14
+ {
15
+ code: `export class FeedbackButton extends SomeOtherNonElementThing {
16
+ readonly #boundClick = this.onClick.bind(this);
17
+ }`,
18
+ filename: 'front_end/components/test.ts',
19
+ },
20
+ {
21
+ code: `export class FeedbackButton extends HTMLElement {
22
+ readonly #boundRender = this.render.bind(this);
23
+ private readonly shadow = this.attachShadow({mode: 'open'});
24
+ private frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
25
+ }`,
26
+ filename: 'front_end/components/test.ts',
27
+ },
28
+ {
29
+ code: `export class FeedbackButton extends HTMLElement {
30
+ readonly #boundRender = this.render.bind(this);
31
+ #globalBoundThing = this.someEvent.bind(this);
32
+ private readonly shadow = this.attachShadow({mode: 'open'});
33
+
34
+ constructor() {
35
+ window.addEventListener('click', this.#globalBoundThing);
36
+ }
37
+ }`,
38
+ filename: 'front_end/components/test.ts',
39
+ },
40
+ {
41
+ code: `export class FeedbackButton extends HTMLElement {
42
+ readonly #boundRender = this.render.bind(this);
43
+ private globalBoundThing = this.someEvent.bind(this);
44
+ private readonly shadow = this.attachShadow({mode: 'open'});
45
+
46
+ constructor() {
47
+ window.addEventListener('click', this.globalBoundThing);
48
+ }
49
+ }`,
50
+ filename: 'front_end/components/test.ts',
51
+ },
52
+ ],
53
+ invalid: [
54
+ {
55
+ code: `export class FeedbackButton extends HTMLElement {
56
+ static readonly litTagName = LitHtml.literal\`devtools-feedback-button\`;
57
+ readonly #boundRender = this.render.bind(this);
58
+ readonly #boundClick = this.onClick.bind(this);
59
+ }`,
60
+ filename: 'front_end/components/test.ts',
61
+ errors: [{messageId: 'nonRenderBindFound', data: {componentName: 'FeedbackButton', methodName: 'onClick'}}]
62
+ },
63
+ {
64
+ code: `export class FeedbackButton extends HTMLElement {
65
+ static readonly litTagName = LitHtml.literal\`devtools-feedback-button\`;
66
+ private readonly boundClick = this.onClick.bind(this);
67
+ }`,
68
+ filename: 'front_end/components/test.ts',
69
+ errors: [{messageId: 'nonRenderBindFound', data: {componentName: 'FeedbackButton', methodName: 'onClick'}}]
70
+ },
71
+ {
72
+ code: `export class FeedbackButton extends HTMLElement {
73
+ static readonly litTagName = LitHtml.literal\`devtools-feedback-button\`;
74
+ private readonly boundClick = this.onClick.bind(this);
75
+ private readonly boundFocus = this.onFocus.bind(this);
76
+
77
+ constructor() {
78
+ this.addEventListener('click', this.boundClick);
79
+ }
80
+ }`,
81
+ filename: 'front_end/components/test.ts',
82
+ errors: [{messageId: 'nonRenderBindFound', data: {componentName: 'FeedbackButton', methodName: 'onFocus'}}]
83
+ },
84
+ ]
85
+ });