chrome-devtools-frontend 1.0.1726686 → 1.0.1730971

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 (490) hide show
  1. package/.agents/rules/tests/test-strict-assertions-and-literal-expectations.md +1 -1
  2. package/.agents/rules/tests/test-view-and-presenter-isolation.md +1 -1
  3. package/.agents/rules/ui-and-widgets/ui-accessibility-and-semantic-html.md +1 -1
  4. package/.agents/rules/ui-and-widgets/ui-css-scoping-and-flex-layout.md +2 -2
  5. package/.agents/rules/ui-and-widgets/ui-declarative-child-widget-composition.md +5 -5
  6. package/.agents/rules/ui-and-widgets/ui-lit-declarative-templates-and-directives.md +2 -2
  7. package/.agents/rules/ui-and-widgets/ui-localization-and-uistrings-hygiene.md +2 -2
  8. package/.agents/rules/ui-and-widgets/ui-modern-component-and-encapsulation-standards.md +3 -3
  9. package/.agents/rules/ui-and-widgets/ui-pure-view-and-presenter-separation.md +2 -2
  10. package/.agents/rules/ui-and-widgets/ui-reactive-widget-update-lifecycle.md +2 -2
  11. package/.agents/rules/ui-and-widgets/ui-view-output-and-callback-contracts.md +2 -2
  12. package/.agents/rules/ui-and-widgets/ui-widget-dom-and-listener-lifecycle.md +2 -2
  13. package/.agents/skills/code-review/SKILL.md +63 -12
  14. package/.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md +38 -10
  15. package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +1 -0
  16. package/.agents/skills/ui-widgets/SKILL.md +8 -2
  17. package/.agents/skills/write-ai-eval-test/SKILL.md +106 -0
  18. package/AUTHORS +2 -0
  19. package/DIR_METADATA +1 -2
  20. package/README.md +48 -26
  21. package/config/typescript/tsconfig.base.json +1 -0
  22. package/config/typescript/tsconfig.eslint.json +1 -0
  23. package/docs/contributing/changes.md +25 -0
  24. package/docs/ui_engineering.md +13 -4
  25. package/eslint.config.mjs +323 -41
  26. package/front_end/core/common/Color.ts +7 -7
  27. package/front_end/core/common/ParsedURL.ts +3 -3
  28. package/front_end/core/common/ResolverBase.ts +3 -3
  29. package/front_end/core/common/SegmentedRange.ts +3 -3
  30. package/front_end/core/common/SimpleHistoryManager.ts +14 -14
  31. package/front_end/core/common/Trie.ts +3 -3
  32. package/front_end/core/common/VersionController.ts +7 -7
  33. package/front_end/core/host/InspectorFrontendHost.ts +2 -2
  34. package/front_end/core/host/InspectorFrontendHostAPI.ts +9 -1
  35. package/front_end/core/host/InspectorFrontendHostStub.ts +1 -1
  36. package/front_end/core/host/UserMetrics.ts +4 -0
  37. package/front_end/core/host/UserMetricsEnums.ts +2 -1
  38. package/front_end/core/platform/StringUtilities.ts +54 -13
  39. package/front_end/core/platform/node/HostRuntime.ts +13 -7
  40. package/front_end/core/protocol_client/DevToolsCDPConnection.ts +4 -5
  41. package/front_end/core/root/Runtime.ts +5 -0
  42. package/front_end/core/sdk/AccessibilityModel.ts +5 -5
  43. package/front_end/core/sdk/AnimationModel.ts +17 -19
  44. package/front_end/core/sdk/CPUProfilerModel.ts +3 -3
  45. package/front_end/core/sdk/CPUThrottlingManager.ts +7 -0
  46. package/front_end/core/sdk/CSSMatchedStyles.ts +73 -13
  47. package/front_end/core/sdk/CSSMetadata.ts +7 -7
  48. package/front_end/core/sdk/CSSModel.ts +33 -33
  49. package/front_end/core/sdk/CSSProperty.ts +5 -5
  50. package/front_end/core/sdk/CSSRule.ts +6 -6
  51. package/front_end/core/sdk/CSSStyleSheetHeader.ts +4 -4
  52. package/front_end/core/sdk/Connections.ts +16 -16
  53. package/front_end/core/sdk/ConsoleModel.ts +44 -47
  54. package/front_end/core/sdk/CookieParser.ts +11 -11
  55. package/front_end/core/sdk/EmulationModel.ts +35 -36
  56. package/front_end/core/sdk/EventBreakpointsModel.ts +11 -11
  57. package/front_end/core/sdk/FrameManager.ts +16 -16
  58. package/front_end/core/sdk/IsolateManager.ts +2 -2
  59. package/front_end/core/sdk/IssuesModel.ts +2 -2
  60. package/front_end/core/sdk/OverlayModel.ts +19 -19
  61. package/front_end/core/sdk/PageResourceLoader.ts +14 -16
  62. package/front_end/core/sdk/RemoteObject.ts +9 -9
  63. package/front_end/core/sdk/Resource.ts +2 -2
  64. package/front_end/core/sdk/RuntimeModel.ts +7 -7
  65. package/front_end/core/sdk/Script.ts +6 -6
  66. package/front_end/core/sdk/ServiceWorkerManager.ts +36 -10
  67. package/front_end/core/sdk/SourceMap.ts +18 -20
  68. package/front_end/core/sdk/SourceMapManager.ts +2 -2
  69. package/front_end/core/sdk/TargetManager.ts +2 -2
  70. package/front_end/devtools_compatibility.js +7 -3
  71. package/front_end/entrypoints/inspector_main/InspectorMain.ts +2 -2
  72. package/front_end/entrypoints/node_app/app/NodeConnectionsPanel.ts +203 -115
  73. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  74. package/front_end/generated/SupportedCSSProperties.ts +1 -3
  75. package/front_end/generated/protocol.ts +1 -0
  76. package/front_end/models/ai_assistance/AiAgent2.ts +36 -12
  77. package/front_end/models/ai_assistance/AiConversation.ts +8 -2
  78. package/front_end/models/ai_assistance/agents/AiAgent.ts +137 -62
  79. package/front_end/models/ai_assistance/agents/ExecuteJavascript.ts +2 -2
  80. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +2 -2
  81. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +149 -2
  82. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +269 -42
  83. package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +3 -0
  84. package/front_end/models/ai_assistance/tools/GetLighthouseAudits.ts +9 -0
  85. package/front_end/models/ai_assistance/tools/ResolveDevtoolsNodePath.ts +13 -2
  86. package/front_end/models/ai_assistance/tools/RunLighthouse.ts +23 -7
  87. package/front_end/models/ai_assistance/tools/Tool.ts +7 -5
  88. package/front_end/models/bindings/CSSWorkspaceBinding.ts +22 -24
  89. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +60 -60
  90. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +24 -24
  91. package/front_end/models/bindings/DefaultScriptMapping.ts +8 -8
  92. package/front_end/models/bindings/FileUtils.ts +13 -13
  93. package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +3 -3
  94. package/front_end/models/bindings/ResourceScriptMapping.ts +23 -23
  95. package/front_end/models/comment_manager/CommentManager.ts +3 -3
  96. package/front_end/models/comment_manager/CommentThread.ts +50 -5
  97. package/front_end/models/cpu_profile/CPUProfileDataModel.ts +14 -14
  98. package/front_end/models/cpu_profile/ProfileTreeModel.ts +4 -4
  99. package/front_end/models/elements/StyleChanges.ts +38 -0
  100. package/front_end/models/emulation/EmulatedDevices.ts +12 -12
  101. package/front_end/models/har/HARFormat.ts +4 -4
  102. package/front_end/models/javascript_metadata/NativeFunctions.ts +5 -1
  103. package/front_end/models/lighthouse/LighthouseReporterTypes.ts +57 -3
  104. package/front_end/models/lighthouse/RunTypes.ts +9 -1
  105. package/front_end/models/logs/LogManager.ts +2 -2
  106. package/front_end/models/persistence/AutomaticFileSystemManager.ts +3 -0
  107. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +24 -24
  108. package/front_end/models/persistence/IsolatedFileSystemManager.ts +6 -0
  109. package/front_end/models/persistence/NetworkPersistenceManager.ts +8 -3
  110. package/front_end/models/trace/LanternComputationData.ts +37 -11
  111. package/front_end/models/trace/Processor.ts +2 -1
  112. package/front_end/models/trace/extras/TraceTree.ts +36 -10
  113. package/front_end/models/trace/handlers/InitiatorsHandler.ts +27 -34
  114. package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +2 -6
  115. package/front_end/models/trace/handlers/SamplesHandler.ts +9 -6
  116. package/front_end/models/workspace/FileManager.ts +6 -0
  117. package/front_end/panels/accessibility/ARIAAttributesView.ts +4 -4
  118. package/front_end/panels/accessibility/AccessibilityAnnouncementRecordingView.ts +8 -1
  119. package/front_end/panels/accessibility/AccessibilityNodeView.ts +15 -17
  120. package/front_end/panels/accessibility/AccessibilitySubPane.ts +1 -1
  121. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +5 -5
  122. package/front_end/panels/ai_assistance/ExternalHandler.ts +10 -1
  123. package/front_end/panels/ai_assistance/components/ChatMessage.ts +27 -22
  124. package/front_end/panels/ai_assistance/components/DisabledWidget.ts +19 -23
  125. package/front_end/panels/ai_assistance/components/ExploreWidget.ts +2 -2
  126. package/front_end/panels/ai_assistance/components/PermissionPrompt.ts +23 -9
  127. package/front_end/panels/ai_assistance/components/chatInput.css +1 -1
  128. package/front_end/panels/animation/AnimationTimeline.ts +37 -17
  129. package/front_end/panels/animation/animationTimeline.css +19 -3
  130. package/front_end/panels/application/AppManifestView.ts +1 -2
  131. package/front_end/panels/application/ApplicationPanelSidebar.ts +143 -128
  132. package/front_end/panels/application/DOMStorageItemsView.ts +14 -14
  133. package/front_end/panels/application/DeviceBoundSessionsView.ts +10 -13
  134. package/front_end/panels/application/ExtensionStorageItemsView.ts +3 -4
  135. package/front_end/panels/application/IndexedDBViews.ts +8 -4
  136. package/front_end/panels/application/KeyValueStorageItemsView.ts +4 -5
  137. package/front_end/panels/application/PrivateVerificationTokensView.ts +53 -0
  138. package/front_end/panels/application/ServiceWorkerCacheViews.ts +12 -8
  139. package/front_end/panels/application/ServiceWorkersView.ts +1 -2
  140. package/front_end/panels/application/StorageItemsToolbar.ts +3 -3
  141. package/front_end/panels/application/StorageView.ts +2 -2
  142. package/front_end/panels/application/WebMCPView.ts +91 -109
  143. package/front_end/panels/application/application.ts +2 -0
  144. package/front_end/panels/application/components/StorageMetadataView.ts +6 -6
  145. package/front_end/panels/application/preloading/PreloadingView.ts +70 -37
  146. package/front_end/panels/application/preloading/components/MismatchedPreloadingGrid.ts +2 -2
  147. package/front_end/panels/application/preloading/components/PreloadingDisabledInfobar.ts +3 -3
  148. package/front_end/panels/application/preloading/components/PreloadingGrid.ts +12 -0
  149. package/front_end/panels/application/preloading/components/RuleSetDetailsView.ts +10 -11
  150. package/front_end/panels/application/privateVerificationTokensView.css +20 -0
  151. package/front_end/panels/application/serviceWorkersView.css +2 -2
  152. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +24 -24
  153. package/front_end/panels/changes/ChangesSidebar.ts +5 -5
  154. package/front_end/panels/changes/ChangesView.ts +10 -11
  155. package/front_end/panels/comments/CommentsPane.ts +292 -102
  156. package/front_end/panels/comments/commentsPane.css +93 -12
  157. package/front_end/panels/common/CommentThreadWidget.ts +69 -0
  158. package/front_end/panels/common/CommentsOverlayWidget.ts +108 -29
  159. package/front_end/panels/common/CommentsStatusBarPill.ts +17 -6
  160. package/front_end/panels/common/DOMLinkifier.ts +37 -12
  161. package/front_end/panels/common/ExtensionPanel.ts +13 -4
  162. package/front_end/panels/common/ExtensionServer.ts +27 -3
  163. package/front_end/panels/common/PersistenceUtils.ts +3 -3
  164. package/front_end/panels/common/commentThreadWidget.css +25 -1
  165. package/front_end/panels/common/common-meta.ts +10 -0
  166. package/front_end/panels/console/ConsolePinPane.ts +13 -15
  167. package/front_end/panels/console/ConsolePrompt.ts +173 -95
  168. package/front_end/panels/console/ConsoleSidebar.ts +2 -2
  169. package/front_end/panels/console/ConsoleView.ts +75 -79
  170. package/front_end/panels/console/ConsoleViewMessage.ts +52 -4
  171. package/front_end/panels/console/SymbolizedErrorWidget.ts +8 -4
  172. package/front_end/panels/console/consolePrompt.css +1 -1
  173. package/front_end/panels/console/consoleView.css +1 -1
  174. package/front_end/panels/console_counters/WarningErrorCounter.ts +3 -4
  175. package/front_end/panels/coverage/CoverageListView.ts +2 -2
  176. package/front_end/panels/coverage/CoverageView.ts +20 -5
  177. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +4 -3
  178. package/front_end/panels/css_overview/CSSOverviewPanel.ts +2 -2
  179. package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +2 -2
  180. package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +2 -2
  181. package/front_end/panels/css_overview/CSSOverviewStartView.ts +2 -2
  182. package/front_end/panels/css_overview/CSSOverviewUnusedDeclarations.ts +8 -8
  183. package/front_end/panels/developer_resources/DeveloperResourcesListView.ts +2 -3
  184. package/front_end/panels/developer_resources/DeveloperResourcesView.ts +4 -5
  185. package/front_end/panels/elements/AccessibilityTreeUtils.ts +6 -7
  186. package/front_end/panels/elements/CSSValueTraceView.ts +3 -3
  187. package/front_end/panels/elements/ClassesPaneWidget.ts +1 -2
  188. package/front_end/panels/elements/ComputedStyleWidget.ts +15 -14
  189. package/front_end/panels/elements/DOMTreeElementWidget.ts +5 -4
  190. package/front_end/panels/elements/DOMTreeWidget.ts +2 -1
  191. package/front_end/panels/elements/ElementStatePaneWidget.ts +2 -2
  192. package/front_end/panels/elements/ElementsPanel.ts +1 -0
  193. package/front_end/panels/elements/EventListenersWidget.ts +2 -2
  194. package/front_end/panels/elements/LayoutPane.ts +2 -2
  195. package/front_end/panels/elements/PlatformFontsWidget.ts +3 -3
  196. package/front_end/panels/elements/PropertiesWidget.ts +9 -10
  197. package/front_end/panels/elements/PropertyRenderer.ts +72 -11
  198. package/front_end/panels/elements/StandaloneStylesContainer.ts +5 -10
  199. package/front_end/panels/elements/StyleEditorWidget.ts +30 -16
  200. package/front_end/panels/elements/StylePropertiesSection.ts +93 -44
  201. package/front_end/panels/elements/StylePropertyTreeElement.ts +230 -302
  202. package/front_end/panels/elements/StylesContainer.ts +2 -3
  203. package/front_end/panels/elements/StylesSidebarPane.ts +4 -13
  204. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +66 -37
  205. package/front_end/panels/elements/components/CSSHintDetailsView.ts +51 -41
  206. package/front_end/panels/elements/components/CSSPropertyDocsView.ts +75 -65
  207. package/front_end/panels/elements/components/CSSQuery.ts +112 -74
  208. package/front_end/panels/elements/components/CSSVariableValueView.ts +109 -68
  209. package/front_end/panels/elements/components/ComputedStyleProperty.ts +64 -45
  210. package/front_end/panels/elements/components/ElementsTreeExpandButton.ts +35 -28
  211. package/front_end/panels/elements/components/QueryContainer.ts +104 -74
  212. package/front_end/panels/elements/components/accessibilityTreeNode.css +22 -20
  213. package/front_end/panels/elements/components/computedStyleProperty.css +2 -0
  214. package/front_end/panels/elements/components/cssHintDetailsView.css +23 -21
  215. package/front_end/panels/elements/components/cssPropertyDocsView.css +38 -36
  216. package/front_end/panels/elements/components/cssVariableValueView.css +42 -40
  217. package/front_end/panels/elements/components/elementsTreeExpandButton.css +5 -2
  218. package/front_end/panels/elements/components/queryContainer.css +23 -21
  219. package/front_end/panels/elements/stylesSidebarPane.css +3 -3
  220. package/front_end/panels/emulation/DeviceModeToolbar.ts +2 -2
  221. package/front_end/panels/emulation/InspectedPagePlaceholder.ts +2 -2
  222. package/front_end/panels/emulation/MediaQueryInspector.ts +9 -10
  223. package/front_end/panels/emulation/mediaQueryInspector.css +1 -1
  224. package/front_end/panels/event_listeners/EventListenersView.ts +2 -2
  225. package/front_end/panels/issues/AffectedCookiesView.ts +144 -101
  226. package/front_end/panels/issues/AffectedDescendantsWithinSelectElementView.ts +83 -31
  227. package/front_end/panels/issues/AffectedDirectivesView.ts +218 -135
  228. package/front_end/panels/issues/AffectedDocumentsInQuirksModeView.ts +84 -34
  229. package/front_end/panels/issues/AffectedElementsView.ts +86 -23
  230. package/front_end/panels/issues/AffectedLazyLoadImagesView.ts +2 -2
  231. package/front_end/panels/issues/AffectedMetadataAllowedSitesView.ts +2 -2
  232. package/front_end/panels/issues/AffectedPartitioningBlobURLView.ts +36 -11
  233. package/front_end/panels/issues/AffectedSharedArrayBufferIssueDetailsView.ts +135 -58
  234. package/front_end/panels/issues/AffectedSourcesView.ts +49 -28
  235. package/front_end/panels/issues/AffectedTrackingSitesView.ts +3 -4
  236. package/front_end/panels/issues/CorsIssueDetailsView.ts +490 -269
  237. package/front_end/panels/issues/GenericIssueDetailsView.ts +2 -2
  238. package/front_end/panels/issues/IssueKindView.ts +63 -48
  239. package/front_end/panels/issues/IssueView.ts +14 -18
  240. package/front_end/panels/issues/components/ElementsPanelLink.ts +70 -34
  241. package/front_end/panels/issues/components/HideIssuesMenu.ts +56 -32
  242. package/front_end/panels/issues/components/elementsPanelLink.css +10 -6
  243. package/front_end/panels/issues/components/hideIssuesMenu.css +16 -14
  244. package/front_end/panels/issues/issues.ts +2 -0
  245. package/front_end/panels/issues/issuesTree.css +4 -4
  246. package/front_end/panels/lighthouse/LighthouseController.ts +6 -6
  247. package/front_end/panels/lighthouse/LighthouseStatusView.ts +12 -13
  248. package/front_end/panels/lighthouse/lighthouseStartView.css +1 -1
  249. package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.ts +159 -161
  250. package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorView.ts +228 -0
  251. package/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.ts +32 -41
  252. package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +2 -2
  253. package/front_end/panels/linear_memory_inspector/linear_memory_inspector.ts +2 -0
  254. package/front_end/panels/media/EventDisplayTable.ts +2 -2
  255. package/front_end/panels/media/MainView.ts +132 -66
  256. package/front_end/panels/media/PlayerDetailView.ts +32 -14
  257. package/front_end/panels/media/PlayerListView.ts +83 -23
  258. package/front_end/panels/media/PlayerPropertiesView.ts +2 -2
  259. package/front_end/panels/media/TickingFlameChart.ts +153 -63
  260. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +2 -2
  261. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +615 -464
  262. package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +43 -0
  263. package/front_end/panels/network/EventSourceMessagesView.ts +3 -3
  264. package/front_end/panels/network/NetworkConfigView.ts +6 -2
  265. package/front_end/panels/network/NetworkDataGridNode.ts +2 -1
  266. package/front_end/panels/network/NetworkItemView.ts +27 -26
  267. package/front_end/panels/network/NetworkManageCustomHeadersView.ts +236 -97
  268. package/front_end/panels/network/NetworkOverview.ts +8 -10
  269. package/front_end/panels/network/RequestConditionsDrawer.ts +8 -4
  270. package/front_end/panels/network/RequestDeviceBoundSessionsView.ts +2 -4
  271. package/front_end/panels/network/RequestHTMLView.ts +26 -7
  272. package/front_end/panels/network/RequestHeadersView.ts +2 -2
  273. package/front_end/panels/network/RequestInitiatorView.ts +21 -22
  274. package/front_end/panels/network/RequestPayloadView.ts +2 -16
  275. package/front_end/panels/network/RequestPreviewView.ts +5 -5
  276. package/front_end/panels/network/RequestTimingView.ts +6 -6
  277. package/front_end/panels/network/ResourceDirectSocketChunkView.ts +5 -6
  278. package/front_end/panels/network/ResourceWebSocketFrameView.ts +4 -3
  279. package/front_end/panels/network/ShowMoreDetailsWidget.ts +11 -12
  280. package/front_end/panels/network/SignedExchangeInfoView.ts +2 -2
  281. package/front_end/panels/network/networkLogView.css +2 -2
  282. package/front_end/panels/network/networkManageCustomHeadersView.css +27 -6
  283. package/front_end/panels/network/requestConditionsDrawer.css +1 -1
  284. package/front_end/panels/network/requestInitiatorView.css +5 -3
  285. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +2 -2
  286. package/front_end/panels/profiler/HeapDetachedElementsView.ts +1 -2
  287. package/front_end/panels/profiler/HeapTimelineOverview.ts +77 -15
  288. package/front_end/panels/profiler/IsolateSelector.ts +258 -187
  289. package/front_end/panels/profiler/ProfileLauncherView.ts +7 -29
  290. package/front_end/panels/profiler/profileLauncherView.css +6 -1
  291. package/front_end/panels/protocol_monitor/JSONEditor.ts +4 -5
  292. package/front_end/panels/recorder/ControlButton.ts +1 -1
  293. package/front_end/panels/recorder/RecordingListView.ts +2 -4
  294. package/front_end/panels/recorder/RecordingView.ts +1 -2
  295. package/front_end/panels/recorder/SelectorPicker.ts +2 -4
  296. package/front_end/panels/recorder/StepView.ts +24 -10
  297. package/front_end/panels/recorder/TimelineSection.ts +1 -1
  298. package/front_end/panels/recorder/recordingView.css +1 -1
  299. package/front_end/panels/screencast/ScreencastApp.ts +1 -1
  300. package/front_end/panels/search/SearchResultsPane.ts +11 -12
  301. package/front_end/panels/search/SearchView.ts +8 -10
  302. package/front_end/panels/security/SecurityPanel.ts +1 -8
  303. package/front_end/panels/security/SecurityPanelSidebar.ts +2 -2
  304. package/front_end/panels/security/mainView.css +1 -1
  305. package/front_end/panels/sensors/LocationsSettingsTab.ts +1 -2
  306. package/front_end/panels/settings/AISettingsTab.ts +1 -1
  307. package/front_end/panels/settings/BackendLinkingSettingsTab.ts +34 -20
  308. package/front_end/panels/settings/EditFileSystemView.ts +2 -2
  309. package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +375 -197
  310. package/front_end/panels/settings/KeybindsSettingsTab.ts +570 -414
  311. package/front_end/panels/settings/SettingsScreen.ts +312 -114
  312. package/front_end/panels/settings/WorkspaceSettingsTab.ts +2 -2
  313. package/front_end/panels/settings/aiSettingsTab.css +1 -4
  314. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +924 -578
  315. package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +9 -2
  316. package/front_end/panels/settings/emulation/devicesSettingsTab.css +39 -0
  317. package/front_end/panels/settings/frameworkIgnoreListSettingsTab.css +37 -8
  318. package/front_end/panels/settings/settingsScreen.css +0 -24
  319. package/front_end/panels/sources/BreakpointEditDialog.ts +9 -6
  320. package/front_end/panels/sources/BreakpointsView.ts +25 -4
  321. package/front_end/panels/sources/CallStackSidebarPane.ts +7 -1
  322. package/front_end/panels/sources/DebuggerPlugin.ts +1 -0
  323. package/front_end/panels/sources/GoToLineQuickOpen.ts +8 -8
  324. package/front_end/panels/sources/NavigatorView.ts +521 -439
  325. package/front_end/panels/sources/PersistenceActions.ts +11 -12
  326. package/front_end/panels/sources/ProfilePlugin.ts +28 -17
  327. package/front_end/panels/sources/ScopeChainSidebarPane.ts +3 -4
  328. package/front_end/panels/sources/SourcesNavigator.ts +9 -9
  329. package/front_end/panels/sources/SourcesPanel.ts +2 -2
  330. package/front_end/panels/sources/SourcesView.ts +3 -3
  331. package/front_end/panels/sources/ThreadsSidebarPane.ts +2 -2
  332. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +2 -2
  333. package/front_end/panels/sources/components/HeadersView.ts +1 -2
  334. package/front_end/panels/timeline/CompatibilityTracksAppender.ts +5 -6
  335. package/front_end/panels/timeline/EventsTimelineTreeView.ts +73 -34
  336. package/front_end/panels/timeline/IsolateSelector.ts +25 -37
  337. package/front_end/panels/timeline/StatusDialog.ts +5 -7
  338. package/front_end/panels/timeline/ThirdPartyTreeView.ts +10 -13
  339. package/front_end/panels/timeline/TimelineDetailsView.ts +40 -21
  340. package/front_end/panels/timeline/TimelineEventOverview.ts +130 -34
  341. package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +1 -1
  342. package/front_end/panels/timeline/TimelineMiniMap.ts +255 -103
  343. package/front_end/panels/timeline/TimelinePaintProfilerView.ts +19 -11
  344. package/front_end/panels/timeline/TimelinePanel.ts +1 -0
  345. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +11 -12
  346. package/front_end/panels/timeline/TimelineTreeView.ts +240 -122
  347. package/front_end/panels/timeline/TimelineUIUtils.ts +12 -0
  348. package/front_end/panels/timeline/components/BreadcrumbsUI.ts +5 -4
  349. package/front_end/panels/timeline/components/DetailsView.ts +97 -65
  350. package/front_end/panels/timeline/components/LayoutShiftDetails.ts +2 -2
  351. package/front_end/panels/timeline/components/MetricCard.ts +2 -2
  352. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +11 -12
  353. package/front_end/panels/timeline/components/NetworkTrackWidget.ts +57 -50
  354. package/front_end/panels/timeline/components/RelatedInsightChips.ts +2 -2
  355. package/front_end/panels/timeline/components/Sidebar.ts +161 -109
  356. package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +33 -12
  357. package/front_end/panels/timeline/components/SidebarInsightsTab.ts +3 -0
  358. package/front_end/panels/timeline/components/insights/LCPDiscovery.ts +11 -11
  359. package/front_end/panels/timeline/components/insights/SlowCSSSelector.ts +6 -7
  360. package/front_end/panels/timeline/components/networkTrackWidget.css +24 -22
  361. package/front_end/panels/timeline/components/sidebarInsightsTab.css +1 -1
  362. package/front_end/panels/timeline/overlays/components/TimespanBreakdownOverlay.ts +15 -10
  363. package/front_end/panels/timeline/overlays/components/entryLabelOverlay.css +1 -1
  364. package/front_end/panels/timeline/timelinePanel.css +5 -0
  365. package/front_end/panels/timeline/timelineStatusDialog.css +1 -1
  366. package/front_end/panels/web_audio/WebAudioView.ts +2 -2
  367. package/front_end/third_party/chromium/README.chromium +1 -1
  368. package/front_end/third_party/legacy-javascript/README.chromium +2 -2
  369. package/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +2 -2
  370. package/front_end/third_party/legacy-javascript/package.json +1 -1
  371. package/front_end/third_party/lighthouse/README.chromium +2 -2
  372. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1983 -2022
  373. package/front_end/third_party/lighthouse/locales/ar-XB.json +157 -142
  374. package/front_end/third_party/lighthouse/locales/ar.json +157 -142
  375. package/front_end/third_party/lighthouse/locales/bg.json +154 -139
  376. package/front_end/third_party/lighthouse/locales/ca.json +157 -142
  377. package/front_end/third_party/lighthouse/locales/cs.json +148 -133
  378. package/front_end/third_party/lighthouse/locales/da.json +153 -138
  379. package/front_end/third_party/lighthouse/locales/de.json +152 -137
  380. package/front_end/third_party/lighthouse/locales/el.json +153 -138
  381. package/front_end/third_party/lighthouse/locales/en-GB.json +160 -145
  382. package/front_end/third_party/lighthouse/locales/en-US.json +239 -218
  383. package/front_end/third_party/lighthouse/locales/en-XL.json +239 -218
  384. package/front_end/third_party/lighthouse/locales/es-419.json +150 -135
  385. package/front_end/third_party/lighthouse/locales/es.json +149 -134
  386. package/front_end/third_party/lighthouse/locales/fi.json +151 -136
  387. package/front_end/third_party/lighthouse/locales/fil.json +154 -139
  388. package/front_end/third_party/lighthouse/locales/fr.json +150 -135
  389. package/front_end/third_party/lighthouse/locales/he.json +160 -145
  390. package/front_end/third_party/lighthouse/locales/hi.json +156 -141
  391. package/front_end/third_party/lighthouse/locales/hr.json +154 -139
  392. package/front_end/third_party/lighthouse/locales/hu.json +111 -96
  393. package/front_end/third_party/lighthouse/locales/id.json +153 -138
  394. package/front_end/third_party/lighthouse/locales/it.json +153 -138
  395. package/front_end/third_party/lighthouse/locales/ja.json +150 -135
  396. package/front_end/third_party/lighthouse/locales/ko.json +42 -27
  397. package/front_end/third_party/lighthouse/locales/lt.json +152 -137
  398. package/front_end/third_party/lighthouse/locales/lv.json +93 -78
  399. package/front_end/third_party/lighthouse/locales/nl.json +149 -134
  400. package/front_end/third_party/lighthouse/locales/no.json +152 -137
  401. package/front_end/third_party/lighthouse/locales/pl.json +153 -138
  402. package/front_end/third_party/lighthouse/locales/pt-PT.json +152 -137
  403. package/front_end/third_party/lighthouse/locales/pt.json +157 -142
  404. package/front_end/third_party/lighthouse/locales/ro.json +149 -134
  405. package/front_end/third_party/lighthouse/locales/ru.json +76 -61
  406. package/front_end/third_party/lighthouse/locales/sk.json +153 -138
  407. package/front_end/third_party/lighthouse/locales/sl.json +149 -134
  408. package/front_end/third_party/lighthouse/locales/sr-Latn.json +151 -136
  409. package/front_end/third_party/lighthouse/locales/sr.json +151 -136
  410. package/front_end/third_party/lighthouse/locales/sv.json +152 -137
  411. package/front_end/third_party/lighthouse/locales/ta.json +156 -141
  412. package/front_end/third_party/lighthouse/locales/te.json +157 -142
  413. package/front_end/third_party/lighthouse/locales/th.json +111 -96
  414. package/front_end/third_party/lighthouse/locales/tr.json +153 -138
  415. package/front_end/third_party/lighthouse/locales/uk.json +149 -134
  416. package/front_end/third_party/lighthouse/locales/vi.json +162 -147
  417. package/front_end/third_party/lighthouse/locales/zh-HK.json +150 -135
  418. package/front_end/third_party/lighthouse/locales/zh-TW.json +154 -139
  419. package/front_end/third_party/lighthouse/locales/zh.json +152 -137
  420. package/front_end/third_party/lighthouse/report/bundle.d.ts +9 -8
  421. package/front_end/third_party/lighthouse/report/bundle.js +10 -10
  422. package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +2 -7
  423. package/front_end/tsconfig.compatibility.json +1 -0
  424. package/front_end/tsconfig.json +3 -2
  425. package/front_end/ui/components/dialogs/TypeToAllowDialog.ts +0 -2
  426. package/front_end/ui/components/dialogs/typeToAllowDialog.css +0 -4
  427. package/front_end/ui/components/icon_button/fileSourceIcon.css +1 -1
  428. package/front_end/ui/components/input/textInput.css +1 -1
  429. package/front_end/ui/components/lists/List.ts +26 -14
  430. package/front_end/ui/components/menus/menus.ts +0 -2
  431. package/front_end/ui/components/suggestion_input/SuggestionInput.ts +351 -138
  432. package/front_end/ui/components/survey_link/surveyLink.css +3 -3
  433. package/front_end/ui/components/switch/switch.css +6 -6
  434. package/front_end/ui/components/text_editor/AiCodeCompletionTeaser.ts +2 -3
  435. package/front_end/ui/components/text_editor/TextEditor.ts +1 -1
  436. package/front_end/ui/components/tooltips/Tooltip.ts +53 -4
  437. package/front_end/ui/components/tree_outline/treeOutline.css +7 -7
  438. package/front_end/ui/helpers/OpenInNewTab.ts +8 -3
  439. package/front_end/ui/legacy/EmptyWidget.ts +4 -4
  440. package/front_end/ui/legacy/ForwardedInputEventHandler.ts +2 -2
  441. package/front_end/ui/legacy/GlassPane.ts +1 -1
  442. package/front_end/ui/legacy/KeyboardShortcut.ts +7 -7
  443. package/front_end/ui/legacy/RemoteDebuggingTerminatedScreen.ts +2 -2
  444. package/front_end/ui/legacy/TabbedPane.ts +198 -66
  445. package/front_end/ui/legacy/TargetCrashedScreen.ts +2 -2
  446. package/front_end/ui/legacy/UIUtils.ts +71 -68
  447. package/front_end/ui/legacy/View.ts +7 -4
  448. package/front_end/ui/legacy/ViewManager.ts +49 -37
  449. package/front_end/ui/legacy/Widget.ts +32 -12
  450. package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +2 -3
  451. package/front_end/ui/legacy/components/inline_editor/AnimationTimingUI.ts +8 -8
  452. package/front_end/ui/legacy/components/inline_editor/BezierUI.ts +8 -9
  453. package/front_end/ui/legacy/components/inline_editor/LinkSwatch.ts +2 -2
  454. package/front_end/ui/legacy/components/inline_editor/cssAngleEditor.css +1 -1
  455. package/front_end/ui/legacy/components/inline_editor/cssAngleSwatch.css +1 -1
  456. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +45 -11
  457. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +10 -12
  458. package/front_end/ui/legacy/components/perf_ui/ChartViewport.ts +102 -29
  459. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +148 -122
  460. package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +20 -14
  461. package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +1 -1
  462. package/front_end/ui/legacy/components/source_frame/FontView.ts +29 -5
  463. package/front_end/ui/legacy/components/source_frame/ImageView.ts +79 -12
  464. package/front_end/ui/legacy/components/source_frame/JSONView.ts +20 -2
  465. package/front_end/ui/legacy/components/source_frame/PreviewFactory.ts +2 -2
  466. package/front_end/ui/legacy/components/source_frame/StreamingContentHexView.ts +6 -10
  467. package/front_end/ui/legacy/components/source_frame/XMLView.ts +11 -11
  468. package/front_end/ui/legacy/components/source_frame/fontView.css +7 -0
  469. package/front_end/ui/legacy/components/source_frame/imageView.css +7 -0
  470. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +14 -3
  471. package/front_end/ui/legacy/components/utils/Linkifier.ts +126 -2
  472. package/front_end/ui/legacy/emptyWidget.css +2 -1
  473. package/front_end/ui/legacy/inspectorCommon.css +3 -3
  474. package/front_end/ui/legacy/smallBubble.css +1 -1
  475. package/front_end/ui/legacy/tabbedPane.css +6 -0
  476. package/front_end/ui/lit/Directives.ts +35 -18
  477. package/front_end/ui/lit/lit.ts +0 -2
  478. package/front_end/ui/lit/render.ts +0 -7
  479. package/front_end/ui/visual_logging/KnownContextValues.ts +5 -0
  480. package/package.json +1 -1
  481. package/vpython.toml +8 -0
  482. package/vpython.toml.uv.lock +3 -0
  483. package/.agents/skills/review-models-core/SKILL.md +0 -73
  484. package/.agents/skills/review-tests/SKILL.md +0 -67
  485. package/.agents/skills/review-ui-widgets/SKILL.md +0 -115
  486. package/front_end/generated/ARIAProperties.ts +0 -2686
  487. package/front_end/ui/components/menus/README.md +0 -119
  488. package/front_end/ui/components/menus/SelectMenu.ts +0 -473
  489. package/front_end/ui/components/menus/selectMenu.css +0 -54
  490. package/front_end/ui/components/menus/selectMenuButton.css +0 -108
@@ -1,22 +1,25 @@
1
1
  // Copyright 2020 The Chromium Authors
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
- /* eslint-disable @devtools/no-imperative-dom-api */
4
+
5
+ import '../../ui/kit/kit.js';
5
6
 
6
7
  import * as Common from '../../core/common/common.js';
7
8
  import * as Host from '../../core/host/host.js';
8
9
  import * as i18n from '../../core/i18n/i18n.js';
9
10
  import * as Platform from '../../core/platform/platform.js';
10
11
  import * as Buttons from '../../ui/components/buttons/buttons.js';
11
- import {createIcon, type Icon, Link} from '../../ui/kit/kit.js';
12
12
  import * as SettingsUI from '../../ui/legacy/components/settings_ui/settings_ui.js';
13
13
  import * as UI from '../../ui/legacy/legacy.js';
14
+ import * as Lit from '../../ui/lit/lit.js';
14
15
  import * as Settings from '../../ui/settings/settings.js';
15
16
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
16
17
 
17
18
  import keybindsSettingsTabStyles from './keybindsSettingsTab.css.js';
18
19
  import settingsScreenStyles from './settingsScreen.css.js';
19
20
 
21
+ const {html, nothing, render, Directives: {classMap, repeat}} = Lit;
22
+
20
23
  const UIStrings = {
21
24
  /**
22
25
  * @description Text for keyboard shortcuts.
@@ -105,93 +108,442 @@ const UIStrings = {
105
108
  const str_ = i18n.i18n.registerUIStrings('panels/settings/KeybindsSettingsTab.ts', UIStrings);
106
109
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
107
110
 
108
- export class KeybindsSettingsTab extends UI.Widget.VBox implements UI.ListControl.ListDelegate<KeybindsItem> {
109
- private readonly items: UI.ListModel.ListModel<KeybindsItem>;
110
- private list: UI.ListControl.ListControl<string|UI.ActionRegistration.Action>;
111
- private editingItem: UI.ActionRegistration.Action|null;
112
- private editingRow: ShortcutListItem|null;
111
+ export interface ShortcutRowViewData {
112
+ shortcut: UI.KeyboardShortcut.KeyboardShortcut;
113
+ isModified: boolean;
114
+ value: string;
115
+ keys: string[];
116
+ isInvalid: boolean;
117
+ isAutofocus: boolean;
118
+ }
113
119
 
114
- constructor() {
115
- super({
116
- jslog: `${VisualLogging.pane('keybinds')}`,
117
- useShadowDom: true,
118
- });
119
- this.registerRequiredCSS(keybindsSettingsTabStyles, settingsScreenStyles);
120
+ export interface ActionRowViewData {
121
+ action: UI.ActionRegistration.Action;
122
+ actionId: string;
123
+ actionTitle: string;
124
+ isEditing: boolean;
125
+ isAutofocus: boolean;
126
+ tabIndex: number;
127
+ hasEmptyInfo: boolean;
128
+ hasDefaultShortcutWhenEmpty: boolean;
129
+ rows: ShortcutRowViewData[];
130
+ errorMessage: string|null;
131
+ isConfirmDisabled: boolean;
132
+ }
120
133
 
121
- const settingsContent =
122
- this.contentElement.createChild('div', 'settings-card-container-wrapper').createChild('div');
123
- settingsContent.classList.add('settings-card-container');
134
+ export type KeybindsViewItem = UI.ActionRegistration.ActionCategory|ActionRowViewData;
135
+
136
+ export interface ViewInput {
137
+ keybindsSetSetting: Common.Settings.Setting<string>;
138
+ items: KeybindsViewItem[];
139
+ onRestoreDefaultShortcuts: () => void;
140
+ onListKeyDown: (event: KeyboardEvent) => void;
141
+ onActionFocused: (action: UI.ActionRegistration.Action) => void;
142
+ onStartEditing: (action: UI.ActionRegistration.Action) => void;
143
+ onAddShortcut: () => void;
144
+ onResetShortcutsToDefaults: () => void;
145
+ onConfirmChanges: () => void;
146
+ onDiscardChanges: () => void;
147
+ onEditingRowKeyDown: (event: KeyboardEvent) => void;
148
+ onShortcutInputKeyDown: (shortcut: UI.KeyboardShortcut.KeyboardShortcut, event: KeyboardEvent) => void;
149
+ onShortcutInputFocus: (shortcut: UI.KeyboardShortcut.KeyboardShortcut) => void;
150
+ onShortcutInputBlur: () => void;
151
+ onDeleteShortcut: (shortcut: UI.KeyboardShortcut.KeyboardShortcut) => void;
152
+ }
124
153
 
125
- const keybindsSetSetting =
154
+ export type View = (input: ViewInput, output: undefined, target: HTMLElement|DocumentFragment) => void;
155
+
156
+ function renderActionRow(item: ActionRowViewData, input: ViewInput): Lit.LitTemplate {
157
+ const renderEditButton = (): Lit.LitTemplate => html`
158
+ <devtools-button
159
+ class="keybinds-edit-button"
160
+ title=${i18nString(UIStrings.editShortcut)}
161
+ aria-label=${i18nString(UIStrings.editShortcut)}
162
+ .iconName=${'edit'}
163
+ .variant=${Buttons.Button.Variant.ICON}
164
+ .jslogContext=${'edit'}
165
+ @click=${() => input.onStartEditing(item.action)}>
166
+ </devtools-button>
167
+ `;
168
+
169
+ // clang-format off
170
+ return html`
171
+ <div
172
+ class="keybinds-list-item-wrapper"
173
+ @focusin=${() => input.onActionFocused(item.action)}>
174
+ <div
175
+ class=${classMap({
176
+ 'keybinds-list-item': true,
177
+ 'keybinds-editing': item.isEditing,
178
+ })}
179
+ role="listitem"
180
+ aria-level="2"
181
+ tabindex=${item.tabIndex}
182
+ ?autofocus=${item.isAutofocus}
183
+ jslog=${VisualLogging.item().context(item.actionId).track({keydown: 'Escape', resize: true})}
184
+ @keydown=${item.isEditing ? input.onEditingRowKeyDown : nothing}>
185
+ <div class="keybinds-action-name keybinds-list-text">${item.actionTitle}</div>
186
+ ${repeat(item.rows, row => row.shortcut, (row, index) => html`
187
+ ${row.isModified ? html`
188
+ <devtools-icon
189
+ class="keybinds-modified"
190
+ name="keyboard-pen"
191
+ aria-label=${i18nString(UIStrings.shortcutModified)}>
192
+ </devtools-icon>
193
+ ` : nothing}
194
+ <div class="keybinds-shortcut keybinds-list-text">
195
+ ${item.isEditing ? html`
196
+ <input
197
+ class=${classMap({
198
+ 'harmony-input': true,
199
+ 'error-input': row.isInvalid,
200
+ })}
201
+ jslog=${VisualLogging.textField().track({change: true})}
202
+ placeholder=${i18nString(UIStrings.recordingKeys)}
203
+ .spellcheck=${false}
204
+ maxlength="0"
205
+ ?autofocus=${row.isAutofocus}
206
+ aria-invalid=${row.isInvalid ? 'true' : 'false'}
207
+ .value=${row.value}
208
+ @keydown=${(event: KeyboardEvent) => input.onShortcutInputKeyDown(row.shortcut, event)}
209
+ @focus=${() => input.onShortcutInputFocus(row.shortcut)}
210
+ @blur=${input.onShortcutInputBlur}
211
+ />
212
+ <devtools-button
213
+ class="keybinds-delete-button"
214
+ title=${i18nString(UIStrings.removeShortcut)}
215
+ aria-label=${i18nString(UIStrings.removeShortcut)}
216
+ .iconName=${'bin'}
217
+ .variant=${Buttons.Button.Variant.ICON}
218
+ .jslogContext=${'delete'}
219
+ @click=${() => input.onDeleteShortcut(row.shortcut)}>
220
+ </devtools-button>
221
+ ` : html`
222
+ ${row.keys.map(key => html`
223
+ <div class="keybinds-key"><span>${key}</span></div>
224
+ `)}
225
+ `}
226
+ </div>
227
+ ${!item.isEditing && index === 0 ? renderEditButton() : nothing}
228
+ `)}
229
+ ${item.hasEmptyInfo ? html`
230
+ ${item.hasDefaultShortcutWhenEmpty ? html`
231
+ <devtools-icon
232
+ class="keybinds-modified"
233
+ name="keyboard-pen"
234
+ aria-label=${i18nString(UIStrings.shortcutModified)}>
235
+ </devtools-icon>
236
+ ` : nothing}
237
+ ${!item.isEditing ? html`
238
+ <div
239
+ class="keybinds-shortcut keybinds-list-text"
240
+ aria-label=${i18nString(UIStrings.noShortcutForAction)}>
241
+ </div>
242
+ ${renderEditButton()}
243
+ ` : nothing}
244
+ ` : nothing}
245
+ ${item.isEditing ? html`
246
+ <div class="keybinds-shortcut">
247
+ <devtools-button
248
+ .variant=${Buttons.Button.Variant.OUTLINED}
249
+ .jslogContext=${'add-shortcut'}
250
+ ?autofocus=${item.rows.length === 0}
251
+ @click=${input.onAddShortcut}>
252
+ ${i18nString(UIStrings.addAShortcut)}
253
+ </devtools-button>
254
+ </div>
255
+ <div
256
+ class=${classMap({
257
+ 'keybinds-info': true,
258
+ 'keybinds-error': true,
259
+ hidden: !item.errorMessage,
260
+ })}
261
+ role="alert"
262
+ aria-live="polite">
263
+ ${item.errorMessage ?? ''}
264
+ </div>
265
+ <devtools-button
266
+ title=${i18nString(UIStrings.ResetShortcutsForAction)}
267
+ aria-label=${i18nString(UIStrings.ResetShortcutsForAction)}
268
+ .iconName=${'undo'}
269
+ .variant=${Buttons.Button.Variant.ICON}
270
+ .jslogContext=${'undo'}
271
+ @click=${input.onResetShortcutsToDefaults}>
272
+ </devtools-button>
273
+ <devtools-button
274
+ class="keybinds-confirm-button"
275
+ title=${i18nString(UIStrings.confirmChanges)}
276
+ aria-label=${i18nString(UIStrings.confirmChanges)}
277
+ .iconName=${'checkmark'}
278
+ .variant=${Buttons.Button.Variant.ICON}
279
+ .jslogContext=${'confirm'}
280
+ .disabled=${item.isConfirmDisabled}
281
+ @click=${input.onConfirmChanges}>
282
+ </devtools-button>
283
+ <devtools-button
284
+ class="keybinds-cancel-button"
285
+ title=${i18nString(UIStrings.discardChanges)}
286
+ aria-label=${i18nString(UIStrings.discardChanges)}
287
+ .iconName=${'cross'}
288
+ .variant=${Buttons.Button.Variant.ICON}
289
+ .jslogContext=${'cancel'}
290
+ @click=${input.onDiscardChanges}>
291
+ </devtools-button>
292
+ ` : nothing}
293
+ </div>
294
+ </div>
295
+ `;
296
+ // clang-format on
297
+ }
298
+
299
+ export const DEFAULT_VIEW: View = (input, _output, target) => {
300
+ // clang-format off
301
+ render(
302
+ html`
303
+ <style>${keybindsSettingsTabStyles}</style>
304
+ <style>${settingsScreenStyles}</style>
305
+ <div class="settings-card-container-wrapper">
306
+ <div class="settings-card-container">
307
+ <devtools-card heading=${i18nString(UIStrings.shortcuts)}>
308
+ <div class="keybinds-set-select">
309
+ ${SettingsUI.SettingsUI.renderControlForSetting(
310
+ input.keybindsSetSetting, i18nString(UIStrings.matchShortcutsFromPreset))}
311
+ </div>
312
+ <div
313
+ class="shortcut-list"
314
+ role="list"
315
+ aria-label=${i18nString(UIStrings.keyboardShortcutsList)}
316
+ @keydown=${input.onListKeyDown}>
317
+ ${repeat(
318
+ input.items,
319
+ item => typeof item === 'string' ? item : item.actionId,
320
+ item => {
321
+ if (typeof item === 'string') {
322
+ return html`
323
+ <div
324
+ class="keybinds-category-header"
325
+ role="listitem"
326
+ aria-level="1"
327
+ tabindex="-1">
328
+ ${UI.ActionRegistration.getLocalizedActionCategory(item)}
329
+ </div>
330
+ `;
331
+ }
332
+ return renderActionRow(item, input);
333
+ })}
334
+ </div>
335
+ <div class="keybinds-footer">
336
+ <devtools-link
337
+ class="docs-link"
338
+ href="https://developer.chrome.com/docs/devtools/shortcuts/"
339
+ jslogcontext="learn-more">
340
+ ${i18nString(UIStrings.FullListOfDevtoolsKeyboard)}
341
+ </devtools-link>
342
+ <devtools-button
343
+ .variant=${Buttons.Button.Variant.OUTLINED}
344
+ .jslogContext=${'restore-default-shortcuts'}
345
+ @click=${input.onRestoreDefaultShortcuts}>
346
+ ${i18nString(UIStrings.RestoreDefaultShortcuts)}
347
+ </devtools-button>
348
+ </div>
349
+ </devtools-card>
350
+ </div>
351
+ </div>
352
+ `,
353
+ target,
354
+ {
355
+ container: {
356
+ classes: ['flex-auto'],
357
+ attributes: {
358
+ jslog: `${VisualLogging.pane('keybinds')}`,
359
+ },
360
+ },
361
+ });
362
+ // clang-format on
363
+ };
364
+
365
+ export class KeybindsSettingsTab extends UI.Widget.VBox<ShadowRoot> {
366
+ readonly #items: KeybindsItem[];
367
+ readonly #actions: UI.ActionRegistration.Action[];
368
+ #selectedItem: UI.ActionRegistration.Action|null = null;
369
+ #editingItem: UI.ActionRegistration.Action|null = null;
370
+ #editingShortcuts: UI.KeyboardShortcut.KeyboardShortcut[] = [];
371
+ readonly #editedShortcuts = new Map<UI.KeyboardShortcut.KeyboardShortcut, UI.KeyboardShortcut.Descriptor[]|null>();
372
+ #focusedShortcut: UI.KeyboardShortcut.KeyboardShortcut|null = null;
373
+ #validated = false;
374
+ #secondKeyTimeout: number|null = null;
375
+ readonly #keybindsSetSetting: Common.Settings.Setting<string>;
376
+ readonly #userShortcutsSetting: Common.Settings.Setting<unknown>;
377
+ readonly #view: View;
378
+
379
+ constructor(view: View = DEFAULT_VIEW) {
380
+ super({useShadowDom: 'pure'});
381
+ this.#view = view;
382
+
383
+ this.#keybindsSetSetting =
126
384
  Common.Settings.Settings.instance().resolve(Settings.MainSettings.activeKeybindSetSettingDescriptor);
127
- const userShortcutsSetting =
385
+ this.#userShortcutsSetting =
128
386
  Common.Settings.Settings.instance().resolve(Settings.MainSettings.userShortcutsSettingDescriptor);
129
- keybindsSetSetting.addChangeListener(this.update, this);
130
- const keybindsSetSelect = SettingsUI.SettingsUI.createControlForSetting(
131
- keybindsSetSetting, i18nString(UIStrings.matchShortcutsFromPreset));
387
+ this.#keybindsSetSetting.addChangeListener(this.update, this);
388
+
389
+ this.#items = this.#createListItems();
390
+ this.#actions = this.#items.filter((item): item is UI.ActionRegistration.Action =>
391
+ item instanceof UI.ActionRegistration.Action);
392
+ this.#selectedItem = this.#actions[0] ?? null;
393
+
394
+ this.requestUpdate();
395
+ }
396
+
397
+ override wasShown(): void {
398
+ super.wasShown();
399
+ this.performUpdate();
400
+ }
132
401
 
133
- const card = settingsContent.createChild('devtools-card');
134
- card.heading = i18nString(UIStrings.shortcuts);
402
+ #onRestoreDefaultShortcuts(): void {
403
+ this.#userShortcutsSetting.set([]);
404
+ this.#keybindsSetSetting.set(UI.ShortcutRegistry.DefaultShortcutSetting);
405
+ }
406
+
407
+ #buildActionRowViewData(item: UI.ActionRegistration.Action): ActionRowViewData {
408
+ const isEditing = item === this.#editingItem;
409
+ const isSelected = item === this.#selectedItem;
410
+ const isAutofocus = isSelected && !this.#editingItem;
411
+ const tabIndex = isSelected && !isEditing ? 0 : -1;
412
+ const shortcuts = isEditing ? this.#editingShortcuts :
413
+ UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction(item.id());
414
+
415
+ const separator = Host.Platform.isMac() ? '\u2004' : ' + ';
416
+ let errorMessage: string|null = null;
417
+ let isConfirmDisabled = false;
418
+ const rows: ShortcutRowViewData[] = [];
419
+
420
+ for (const shortcut of shortcuts) {
421
+ if (isEditing && this.#editedShortcuts.has(shortcut) && !this.#editedShortcuts.get(shortcut)) {
422
+ continue;
423
+ }
424
+ const isModified = shortcut.type !== UI.KeyboardShortcut.Type.UNSET_SHORTCUT && !shortcut.isDefault();
425
+ const userDescriptors = isEditing ? this.#editedShortcuts.get(shortcut) : undefined;
426
+ const value = userDescriptors ? this.#shortcutInputTextForDescriptors(userDescriptors) : shortcut.title();
427
+ const keys = shortcut.descriptors.flatMap(descriptor => descriptor.name.split(separator));
428
+
429
+ let isInvalid = false;
430
+ if (isEditing && this.#validated && userDescriptors) {
431
+ if (userDescriptors.some(descriptor => UI.KeyboardShortcut.KeyboardShortcut.isModifier(descriptor.key))) {
432
+ isConfirmDisabled = true;
433
+ isInvalid = true;
434
+ errorMessage = i18nString(UIStrings.shortcutsCannotContainOnly);
435
+ } else {
436
+ const conflicts = UI.ShortcutRegistry.ShortcutRegistry.instance()
437
+ .actionsForDescriptors(userDescriptors)
438
+ .filter(actionId => actionId !== item.id());
439
+ if (conflicts.length) {
440
+ isConfirmDisabled = true;
441
+ isInvalid = true;
442
+ if (UI.ActionRegistry.ActionRegistry.instance().hasAction(conflicts[0])) {
443
+ const action = UI.ActionRegistry.ActionRegistry.instance().getAction(conflicts[0]);
444
+ errorMessage =
445
+ i18nString(UIStrings.thisShortcutIsInUseByS, {PH1: action.category(), PH2: action.title()});
446
+ }
447
+ }
448
+ }
449
+ }
135
450
 
136
- if (keybindsSetSelect) {
137
- keybindsSetSelect.classList.add('keybinds-set-select');
451
+ rows.push({
452
+ shortcut,
453
+ isModified,
454
+ value,
455
+ keys,
456
+ isInvalid,
457
+ isAutofocus: false,
458
+ });
138
459
  }
139
460
 
140
- this.items = new UI.ListModel.ListModel();
141
- this.list = new UI.ListControl.ListControl(this.items, this, UI.ListControl.ListMode.NonViewport);
142
- this.list.element.classList.add('shortcut-list');
143
- this.items.replaceAll(this.createListItems());
144
- UI.ARIAUtils.markAsList(this.list.element);
145
-
146
- UI.ARIAUtils.setLabel(this.list.element, i18nString(UIStrings.keyboardShortcutsList));
147
- const footer = document.createElement('div');
148
- footer.classList.add('keybinds-footer');
149
- const docsLink = Link.create(
150
- 'https://developer.chrome.com/docs/devtools/shortcuts/', i18nString(UIStrings.FullListOfDevtoolsKeyboard),
151
- undefined, 'learn-more');
152
- docsLink.classList.add('docs-link');
153
- footer.appendChild(docsLink);
154
- const restoreDefaultShortcutsButton =
155
- UI.UIUtils.createTextButton(i18nString(UIStrings.RestoreDefaultShortcuts), () => {
156
- userShortcutsSetting.set([]);
157
- keybindsSetSetting.set(UI.ShortcutRegistry.DefaultShortcutSetting);
158
- }, {jslogContext: 'restore-default-shortcuts'});
159
- footer.appendChild(restoreDefaultShortcutsButton);
160
- this.editingItem = null;
161
- this.editingRow = null;
162
-
163
- if (keybindsSetSelect) {
164
- card.append(keybindsSetSelect);
461
+ if (isEditing && rows.length > 0) {
462
+ const autofocusRow = rows.find(row => row.shortcut === this.#focusedShortcut) ?? rows[0];
463
+ autofocusRow.isAutofocus = true;
165
464
  }
166
- card.append(this.list.element, footer);
167
465
 
168
- this.update();
466
+ return {
467
+ action: item,
468
+ actionId: item.id(),
469
+ actionTitle: item.title(),
470
+ isEditing,
471
+ isAutofocus,
472
+ tabIndex,
473
+ hasEmptyInfo: shortcuts.length === 0,
474
+ hasDefaultShortcutWhenEmpty:
475
+ shortcuts.length === 0 && UI.ShortcutRegistry.ShortcutRegistry.instance().actionHasDefaultShortcut(item.id()),
476
+ rows,
477
+ errorMessage,
478
+ isConfirmDisabled,
479
+ };
169
480
  }
170
481
 
171
- createElementForItem(item: KeybindsItem): Element {
172
- const element = document.createElement('div');
173
-
174
- let itemContent;
175
- if (typeof item === 'string') {
176
- itemContent = element;
177
- itemContent.classList.add('keybinds-category-header');
178
- itemContent.textContent = UI.ActionRegistration.getLocalizedActionCategory(item);
179
- UI.ARIAUtils.setLevel(itemContent, 1);
180
- } else {
181
- const listItem = new ShortcutListItem(item, this, item === this.editingItem);
182
- itemContent = listItem.element;
183
- UI.ARIAUtils.setLevel(itemContent, 2);
184
- if (item === this.editingItem) {
185
- this.editingRow = listItem;
186
- }
187
- itemContent.classList.add('keybinds-list-item');
188
- element.classList.add('keybinds-list-item-wrapper');
189
- element.appendChild(itemContent);
482
+ override performUpdate(): void {
483
+ const viewItems: KeybindsViewItem[] =
484
+ this.#items.map(item => typeof item === 'string' ? item : this.#buildActionRowViewData(item));
485
+ this.#view(
486
+ {
487
+ keybindsSetSetting: this.#keybindsSetSetting,
488
+ items: viewItems,
489
+ onRestoreDefaultShortcuts: this.#onRestoreDefaultShortcuts.bind(this),
490
+ onListKeyDown: this.#onListKeyDown.bind(this),
491
+ onActionFocused: this.#onActionFocused.bind(this),
492
+ onStartEditing: this.startEditing.bind(this),
493
+ onAddShortcut: this.#addShortcut.bind(this),
494
+ onResetShortcutsToDefaults: this.#resetShortcutsToDefaults.bind(this),
495
+ onConfirmChanges: this.#onConfirmChanges.bind(this),
496
+ onDiscardChanges: this.#onDiscardChanges.bind(this),
497
+ onEditingRowKeyDown: this.#onEditingRowKeyDown.bind(this),
498
+ onShortcutInputKeyDown: this.#onShortcutInputKeyDown.bind(this),
499
+ onShortcutInputFocus: this.#onShortcutInputFocus.bind(this),
500
+ onShortcutInputBlur: this.#onShortcutInputBlur.bind(this),
501
+ onDeleteShortcut: this.#onDeleteShortcut.bind(this),
502
+ },
503
+ undefined,
504
+ this.contentElement,
505
+ );
506
+ }
507
+
508
+ #onActionFocused(action: UI.ActionRegistration.Action): void {
509
+ if (this.#selectedItem === action) {
510
+ return;
190
511
  }
512
+ this.#selectedItem = action;
513
+ this.performUpdate();
514
+ }
191
515
 
192
- UI.ARIAUtils.markAsListitem(itemContent);
193
- itemContent.tabIndex = item === this.list.selectedItem() && item !== this.editingItem ? 0 : -1;
194
- return element;
516
+ #onListKeyDown(event: KeyboardEvent): void {
517
+ if (this.#editingItem || this.#actions.length === 0) {
518
+ return;
519
+ }
520
+ const currentIndex = this.#selectedItem ? this.#actions.indexOf(this.#selectedItem) : -1;
521
+ let nextIndex = -1;
522
+ switch (event.key) {
523
+ case 'ArrowDown':
524
+ case 'PageDown':
525
+ nextIndex = currentIndex < this.#actions.length - 1 ? currentIndex + 1 : this.#actions.length - 1;
526
+ break;
527
+ case 'ArrowUp':
528
+ case 'PageUp':
529
+ nextIndex = currentIndex > 0 ? currentIndex - 1 : 0;
530
+ break;
531
+ case 'Home':
532
+ nextIndex = 0;
533
+ break;
534
+ case 'End':
535
+ nextIndex = this.#actions.length - 1;
536
+ break;
537
+ default:
538
+ return;
539
+ }
540
+ event.consume(true);
541
+ const nextAction = this.#actions[nextIndex];
542
+ if (nextAction) {
543
+ this.#selectedItem = nextAction;
544
+ this.performUpdate();
545
+ this.focus();
546
+ }
195
547
  }
196
548
 
197
549
  commitChanges(
@@ -217,337 +569,132 @@ export class KeybindsSettingsTab extends UI.Widget.VBox implements UI.ListContro
217
569
  this.stopEditing(item);
218
570
  }
219
571
 
220
- /**
221
- * This method will never be called.
222
- */
223
- heightForItem(_item: KeybindsItem): number {
224
- return 0;
225
- }
226
-
227
- isItemSelectable(item: KeybindsItem): boolean {
228
- // Category headers (UI.ActionRegistration.ActionCategory) should not be selectable
229
- return item instanceof UI.ActionRegistration.Action;
230
- }
231
-
232
- selectedItemChanged(
233
- _from: KeybindsItem|null, to: KeybindsItem|null, fromElement: HTMLElement|null,
234
- toElement: HTMLElement|null): void {
235
- if (fromElement) {
236
- fromElement.tabIndex = -1;
237
- }
238
- if (toElement) {
239
- if (to === this.editingItem && this.editingRow) {
240
- this.editingRow.focus();
241
- } else {
242
- toElement.tabIndex = 0;
243
- if (this.list.element.hasFocus()) {
244
- toElement.focus();
245
- }
246
- }
247
- this.setDefaultFocusedElement(toElement);
248
- }
249
- }
250
-
251
- updateSelectedItemARIA(_fromElement: Element|null, _toElement: Element|null): boolean {
252
- return true;
253
- }
254
-
255
572
  startEditing(action: UI.ActionRegistration.Action): void {
256
- this.list.selectItem(action);
257
-
258
- if (this.editingItem) {
259
- this.stopEditing(this.editingItem);
573
+ this.#selectedItem = action;
574
+ if (this.#editingItem) {
575
+ this.stopEditing(this.#editingItem);
260
576
  }
261
- UI.UIUtils.markBeingEdited(this.list.element, true);
262
- this.editingItem = action;
263
- this.list.refreshItem(action);
264
- }
265
-
266
- stopEditing(action: UI.ActionRegistration.Action): void {
267
- UI.UIUtils.markBeingEdited(this.list.element, false);
268
- this.editingItem = null;
269
- this.editingRow = null;
270
- this.list.refreshItem(action);
577
+ UI.UIUtils.markBeingEdited(this.element, true);
578
+ this.#editingItem = action;
579
+ this.#editedShortcuts.clear();
580
+ this.#focusedShortcut = null;
581
+ this.#validated = false;
582
+ this.#editingShortcuts = UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction(action.id());
583
+ this.performUpdate();
271
584
  this.focus();
272
585
  }
273
586
 
274
- private createListItems(): KeybindsItem[] {
275
- const actions = UI.ActionRegistry.ActionRegistry.instance()
276
- .actions()
277
- .filter(action => action.configurableBindings())
278
- .sort((actionA, actionB) => {
279
- if (actionA.category() < actionB.category()) {
280
- return -1;
281
- }
282
- if (actionA.category() > actionB.category()) {
283
- return 1;
284
- }
285
- if (actionA.id() < actionB.id()) {
286
- return -1;
287
- }
288
- if (actionA.id() > actionB.id()) {
289
- return 1;
290
- }
291
- return 0;
292
- });
293
-
294
- const items: KeybindsItem[] = [];
295
-
296
- let currentCategory: UI.ActionRegistration.ActionCategory;
297
- actions.forEach(action => {
298
- if (currentCategory !== action.category()) {
299
- items.push(action.category());
300
- }
301
- items.push(action);
302
- currentCategory = action.category();
303
- });
304
- return items;
305
- }
306
-
307
- onEscapeKeyPressed(event: Event): void {
308
- const deepActiveElement = UI.DOMUtilities.deepActiveElement(document);
309
- if (this.editingRow && deepActiveElement?.nodeName === 'INPUT') {
310
- this.editingRow.onEscapeKeyPressed(event);
587
+ stopEditing(_action: UI.ActionRegistration.Action): void {
588
+ if (this.#secondKeyTimeout !== null) {
589
+ clearTimeout(this.#secondKeyTimeout);
590
+ this.#secondKeyTimeout = null;
311
591
  }
592
+ UI.UIUtils.markBeingEdited(this.element, false);
593
+ this.#editingItem = null;
594
+ this.#editingShortcuts = [];
595
+ this.#editedShortcuts.clear();
596
+ this.#focusedShortcut = null;
597
+ this.#validated = false;
598
+ this.performUpdate();
599
+ this.focus();
312
600
  }
313
601
 
314
- update(): void {
315
- if (this.editingItem) {
316
- this.stopEditing(this.editingItem);
317
- }
318
- this.list.refreshAllItems();
319
- if (!this.list.selectedItem()) {
320
- this.list.selectFirstItem();
321
- }
322
- }
323
-
324
- override willHide(): void {
325
- super.willHide();
326
- if (this.editingItem) {
327
- this.stopEditing(this.editingItem);
328
- }
329
- }
330
- }
331
-
332
- export class ShortcutListItem {
333
- private isEditing: boolean;
334
- private settingsTab: KeybindsSettingsTab;
335
- private item: UI.ActionRegistration.Action;
336
- element: HTMLDivElement;
337
- private editedShortcuts: Map<UI.KeyboardShortcut.KeyboardShortcut, UI.KeyboardShortcut.Descriptor[]|null>;
338
- private readonly shortcutInputs: Map<UI.KeyboardShortcut.KeyboardShortcut, Element>;
339
- private readonly shortcuts: UI.KeyboardShortcut.KeyboardShortcut[];
340
- private elementToFocus: HTMLElement|null;
341
- private confirmButton: Buttons.Button.Button|null;
342
- private addShortcutLinkContainer: Element|null;
343
- private errorMessageElement: Element|null;
344
- private secondKeyTimeout: number|null;
345
- constructor(item: UI.ActionRegistration.Action, settingsTab: KeybindsSettingsTab, isEditing?: boolean) {
346
- this.isEditing = Boolean(isEditing);
347
- this.settingsTab = settingsTab;
348
- this.item = item;
349
- this.element = document.createElement('div');
350
- this.element.setAttribute(
351
- 'jslog', `${VisualLogging.item().context(item.id()).track({keydown: 'Escape', resize: true})}`);
352
- this.editedShortcuts = new Map();
353
- this.shortcutInputs = new Map();
354
- this.shortcuts = UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction(item.id());
355
- this.elementToFocus = null;
356
- this.confirmButton = null;
357
- this.addShortcutLinkContainer = null;
358
- this.errorMessageElement = null;
359
- this.secondKeyTimeout = null;
360
-
361
- this.update();
362
- }
363
-
364
- focus(): void {
365
- if (this.elementToFocus) {
366
- this.elementToFocus.focus();
602
+ #onConfirmChanges(): void {
603
+ if (!this.#editingItem) {
604
+ return;
367
605
  }
606
+ const item = this.#editingItem;
607
+ this.commitChanges(item, this.#editedShortcuts);
608
+ UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutChangesApplied, {PH1: item.title()}));
368
609
  }
369
610
 
370
- private update(): void {
371
- this.element.removeChildren();
372
- this.elementToFocus = null;
373
- this.shortcutInputs.clear();
374
-
375
- this.element.classList.toggle('keybinds-editing', this.isEditing);
376
- this.element.createChild('div', 'keybinds-action-name keybinds-list-text').textContent = this.item.title();
377
- this.shortcuts.forEach(this.createShortcutRow, this);
378
- if (this.shortcuts.length === 0) {
379
- this.createEmptyInfo();
380
- }
381
- if (this.isEditing) {
382
- this.setupEditor();
611
+ #onDiscardChanges(): void {
612
+ if (!this.#editingItem) {
613
+ return;
383
614
  }
615
+ this.stopEditing(this.#editingItem);
616
+ UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutChangesDiscarded));
384
617
  }
385
618
 
386
- private createEmptyInfo(): void {
387
- if (UI.ShortcutRegistry.ShortcutRegistry.instance().actionHasDefaultShortcut(this.item.id())) {
388
- const icon = createIcon('keyboard-pen', 'keybinds-modified');
389
- UI.ARIAUtils.setLabel(icon, i18nString(UIStrings.shortcutModified));
390
- this.element.appendChild(icon);
391
- }
392
- if (!this.isEditing) {
393
- const emptyElement = this.element.createChild('div', 'keybinds-shortcut keybinds-list-text');
394
- UI.ARIAUtils.setLabel(emptyElement, i18nString(UIStrings.noShortcutForAction));
395
- this.element.appendChild(this.createEditButton());
619
+ #onEditingRowKeyDown(event: KeyboardEvent): void {
620
+ if (this.#editingItem && Platform.KeyboardUtilities.isEscKey(event)) {
621
+ this.stopEditing(this.#editingItem);
622
+ event.consume(true);
396
623
  }
397
624
  }
398
625
 
399
- private setupEditor(): void {
400
- this.addShortcutLinkContainer = this.element.createChild('div', 'keybinds-shortcut');
401
- const addShortcutButton = UI.UIUtils.createTextButton(
402
- i18nString(UIStrings.addAShortcut), this.addShortcut.bind(this), {jslogContext: 'add-shortcut'});
403
- this.addShortcutLinkContainer.appendChild(addShortcutButton);
404
- if (!this.elementToFocus) {
405
- this.elementToFocus = addShortcutButton;
406
- }
407
-
408
- this.errorMessageElement = this.element.createChild('div', 'keybinds-info keybinds-error hidden');
409
- UI.ARIAUtils.markAsAlert(this.errorMessageElement);
410
- this.element.appendChild(this.createIconButton(
411
- i18nString(UIStrings.ResetShortcutsForAction), 'undo', '', 'undo', this.resetShortcutsToDefaults.bind(this)));
412
- this.confirmButton = this.createIconButton(
413
- i18nString(UIStrings.confirmChanges), 'checkmark', 'keybinds-confirm-button', 'confirm', () => {
414
- this.settingsTab.commitChanges(this.item, this.editedShortcuts);
415
- UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutChangesApplied, {PH1: this.item.title()}));
416
- });
417
- this.element.appendChild(this.confirmButton);
418
- this.element.appendChild(
419
- this.createIconButton(i18nString(UIStrings.discardChanges), 'cross', 'keybinds-cancel-button', 'cancel', () => {
420
- this.settingsTab.stopEditing(this.item);
421
- UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutChangesDiscarded));
422
- }));
423
- this.element.addEventListener('keydown', event => {
424
- if (Platform.KeyboardUtilities.isEscKey(event)) {
425
- this.settingsTab.stopEditing(this.item);
426
- event.consume(true);
427
- }
428
- });
626
+ #onShortcutInputFocus(shortcut: UI.KeyboardShortcut.KeyboardShortcut): void {
627
+ this.#focusedShortcut = shortcut;
429
628
  }
430
629
 
431
- private addShortcut(): void {
432
- const shortcut =
433
- new UI.KeyboardShortcut.KeyboardShortcut([], this.item.id(), UI.KeyboardShortcut.Type.UNSET_SHORTCUT);
434
- this.shortcuts.push(shortcut);
435
- this.update();
436
- const shortcutInput = this.shortcutInputs.get(shortcut) as HTMLElement;
437
- if (shortcutInput) {
438
- shortcutInput.focus();
630
+ #onShortcutInputBlur(): void {
631
+ this.#focusedShortcut = null;
632
+ if (this.#secondKeyTimeout !== null) {
633
+ clearTimeout(this.#secondKeyTimeout);
634
+ this.#secondKeyTimeout = null;
439
635
  }
440
636
  }
441
637
 
442
- private createShortcutRow(shortcut: UI.KeyboardShortcut.KeyboardShortcut, index?: number): void {
443
- if (this.editedShortcuts.has(shortcut) && !this.editedShortcuts.get(shortcut)) {
638
+ #onDeleteShortcut(shortcut: UI.KeyboardShortcut.KeyboardShortcut): void {
639
+ if (!this.#editingItem) {
444
640
  return;
445
641
  }
446
- let icon: Icon;
447
- if (shortcut.type !== UI.KeyboardShortcut.Type.UNSET_SHORTCUT && !shortcut.isDefault()) {
448
- icon = createIcon('keyboard-pen', 'keybinds-modified');
449
- UI.ARIAUtils.setLabel(icon, i18nString(UIStrings.shortcutModified));
450
- this.element.appendChild(icon);
642
+ const index = this.#editingShortcuts.indexOf(shortcut);
643
+ if (!shortcut.isDefault() && index !== -1) {
644
+ this.#editingShortcuts.splice(index, 1);
451
645
  }
452
- const shortcutElement = this.element.createChild('div', 'keybinds-shortcut keybinds-list-text');
453
- if (this.isEditing) {
454
- const shortcutInput = shortcutElement.createChild('input', 'harmony-input');
455
- shortcutInput.setAttribute('jslog', `${VisualLogging.textField().track({change: true})}`);
456
- shortcutInput.setAttribute('placeholder', i18nString(UIStrings.recordingKeys));
457
- shortcutInput.spellcheck = false;
458
- shortcutInput.maxLength = 0;
459
- this.shortcutInputs.set(shortcut, shortcutInput);
460
- if (!this.elementToFocus) {
461
- this.elementToFocus = shortcutInput;
462
- }
463
- shortcutInput.value = shortcut.title();
464
- const userDescriptors = this.editedShortcuts.get(shortcut);
465
- if (userDescriptors) {
466
- shortcutInput.value = this.shortcutInputTextForDescriptors(userDescriptors);
467
- }
468
- shortcutInput.addEventListener('keydown', this.onShortcutInputKeyDown.bind(this, shortcut, shortcutInput));
469
- shortcutInput.addEventListener('blur', () => {
470
- if (this.secondKeyTimeout !== null) {
471
- clearTimeout(this.secondKeyTimeout);
472
- this.secondKeyTimeout = null;
473
- }
474
- });
475
- shortcutElement.appendChild(
476
- this.createIconButton(i18nString(UIStrings.removeShortcut), 'bin', 'keybinds-delete-button', 'delete', () => {
477
- const index = this.shortcuts.indexOf(shortcut);
478
- if (!shortcut.isDefault()) {
479
- this.shortcuts.splice(index, 1);
480
- }
481
- this.editedShortcuts.set(shortcut, null);
482
- this.update();
483
- this.focus();
484
- this.validateInputs();
485
- UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutRemoved, {PH1: this.item.title()}));
486
- }));
487
- } else {
488
- const separator = Host.Platform.isMac() ? '\u2004' : ' + ';
489
- const keys = shortcut.descriptors.flatMap(descriptor => descriptor.name.split(separator));
490
- keys.forEach(key => {
491
- shortcutElement.createChild('div', 'keybinds-key').createChild('span').textContent = key;
492
- });
493
- if (index === 0) {
494
- this.element.appendChild(this.createEditButton());
495
- }
496
- }
497
- }
498
-
499
- private createEditButton(): HTMLElement {
500
- return this.createIconButton(
501
- i18nString(UIStrings.editShortcut), 'edit', 'keybinds-edit-button', 'edit',
502
- () => this.settingsTab.startEditing(this.item));
646
+ this.#editedShortcuts.set(shortcut, null);
647
+ this.#focusedShortcut = null;
648
+ this.#validated = true;
649
+ this.performUpdate();
650
+ this.focus();
651
+ UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutRemoved, {PH1: this.#editingItem.title()}));
503
652
  }
504
653
 
505
- private createIconButton(
506
- label: string, iconName: string, className: string, jslogContext: string,
507
- listener: () => void): Buttons.Button.Button {
508
- const button = new Buttons.Button.Button();
509
- button.data = {variant: Buttons.Button.Variant.ICON, iconName, jslogContext, title: label};
510
- button.addEventListener('click', listener);
511
- UI.ARIAUtils.setLabel(button, label);
512
- if (className) {
513
- button.classList.add(className);
654
+ #addShortcut(): void {
655
+ if (!this.#editingItem) {
656
+ return;
514
657
  }
515
- return button;
658
+ const shortcut =
659
+ new UI.KeyboardShortcut.KeyboardShortcut([], this.#editingItem.id(), UI.KeyboardShortcut.Type.UNSET_SHORTCUT);
660
+ this.#editingShortcuts.push(shortcut);
661
+ this.#focusedShortcut = shortcut;
662
+ this.performUpdate();
663
+ this.focus();
516
664
  }
517
665
 
518
- private onShortcutInputKeyDown(
519
- shortcut: UI.KeyboardShortcut.KeyboardShortcut, shortcutInput: HTMLInputElement, event: Event): void {
666
+ #onShortcutInputKeyDown(shortcut: UI.KeyboardShortcut.KeyboardShortcut, event: Event): void {
520
667
  if ((event as KeyboardEvent).key !== 'Tab') {
521
- const eventDescriptor = this.descriptorForEvent(event as KeyboardEvent);
522
- const userDescriptors = this.editedShortcuts.get(shortcut) || [];
523
- this.editedShortcuts.set(shortcut, userDescriptors);
668
+ const eventDescriptor = this.#descriptorForEvent(event as KeyboardEvent);
669
+ const userDescriptors = this.#editedShortcuts.get(shortcut) || [];
670
+ this.#editedShortcuts.set(shortcut, userDescriptors);
524
671
  const isLastKeyOfShortcut =
525
672
  userDescriptors.length === 2 && UI.KeyboardShortcut.KeyboardShortcut.isModifier(userDescriptors[1].key);
526
673
  const shouldClearOldShortcut = userDescriptors.length === 2 && !isLastKeyOfShortcut;
527
674
  if (shouldClearOldShortcut) {
528
675
  userDescriptors.splice(0, 2);
529
676
  }
530
- if (this.secondKeyTimeout) {
531
- clearTimeout(this.secondKeyTimeout);
532
- this.secondKeyTimeout = null;
677
+ if (this.#secondKeyTimeout) {
678
+ clearTimeout(this.#secondKeyTimeout);
679
+ this.#secondKeyTimeout = null;
533
680
  userDescriptors.push(eventDescriptor);
534
681
  } else if (isLastKeyOfShortcut) {
535
682
  userDescriptors[1] = eventDescriptor;
536
683
  } else if (!UI.KeyboardShortcut.KeyboardShortcut.isModifier(eventDescriptor.key)) {
537
684
  userDescriptors[0] = eventDescriptor;
538
- this.secondKeyTimeout = window.setTimeout(() => {
539
- this.secondKeyTimeout = null;
685
+ this.#secondKeyTimeout = window.setTimeout(() => {
686
+ this.#secondKeyTimeout = null;
540
687
  }, UI.ShortcutRegistry.KeyTimeout);
541
688
  } else {
542
689
  userDescriptors[0] = eventDescriptor;
543
690
  }
544
- shortcutInput.value = this.shortcutInputTextForDescriptors(userDescriptors);
545
- this.validateInputs();
691
+ this.#validated = true;
692
+ this.performUpdate();
546
693
  event.consume(true);
547
694
  }
548
695
  }
549
696
 
550
- private descriptorForEvent(event: KeyboardEvent): UI.KeyboardShortcut.Descriptor {
697
+ #descriptorForEvent(event: KeyboardEvent): UI.KeyboardShortcut.Descriptor {
551
698
  const userKey = UI.KeyboardShortcut.KeyboardShortcut.makeKeyFromEvent(event);
552
699
  const codeAndModifiers = UI.KeyboardShortcut.KeyboardShortcut.keyCodeAndModifiersFromKey(userKey);
553
700
  let key: UI.KeyboardShortcut.Key|string =
@@ -567,86 +714,95 @@ export class ShortcutListItem {
567
714
  return UI.KeyboardShortcut.KeyboardShortcut.makeDescriptor(key || event.key, codeAndModifiers.modifiers);
568
715
  }
569
716
 
570
- private shortcutInputTextForDescriptors(descriptors: UI.KeyboardShortcut.Descriptor[]): string {
717
+ #shortcutInputTextForDescriptors(descriptors: UI.KeyboardShortcut.Descriptor[]): string {
571
718
  return descriptors.map(descriptor => descriptor.name).join(' ');
572
719
  }
573
720
 
574
- private resetShortcutsToDefaults(): void {
575
- this.editedShortcuts.clear();
576
- for (const shortcut of this.shortcuts) {
721
+ #resetShortcutsToDefaults(): void {
722
+ if (!this.#editingItem) {
723
+ return;
724
+ }
725
+ this.#editedShortcuts.clear();
726
+ for (const shortcut of this.#editingShortcuts) {
577
727
  if (shortcut.type === UI.KeyboardShortcut.Type.UNSET_SHORTCUT) {
578
- const index = this.shortcuts.indexOf(shortcut);
579
- this.shortcuts.splice(index, 1);
728
+ const index = this.#editingShortcuts.indexOf(shortcut);
729
+ this.#editingShortcuts.splice(index, 1);
580
730
  } else if (shortcut.type === UI.KeyboardShortcut.Type.USER_SHORTCUT) {
581
- this.editedShortcuts.set(shortcut, null);
731
+ this.#editedShortcuts.set(shortcut, null);
582
732
  }
583
733
  }
584
- const disabledDefaults = UI.ShortcutRegistry.ShortcutRegistry.instance().disabledDefaultsForAction(this.item.id());
734
+ const disabledDefaults =
735
+ UI.ShortcutRegistry.ShortcutRegistry.instance().disabledDefaultsForAction(this.#editingItem.id());
585
736
  disabledDefaults.forEach(shortcut => {
586
- if (this.shortcuts.includes(shortcut)) {
737
+ if (this.#editingShortcuts.includes(shortcut)) {
587
738
  return;
588
739
  }
589
740
 
590
- this.shortcuts.push(shortcut);
591
- this.editedShortcuts.set(shortcut, shortcut.descriptors);
741
+ this.#editingShortcuts.push(shortcut);
742
+ this.#editedShortcuts.set(shortcut, shortcut.descriptors);
592
743
  });
593
- this.update();
744
+ this.#focusedShortcut = null;
745
+ this.#validated = false;
746
+ this.performUpdate();
594
747
  this.focus();
595
- UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutChangesRestored, {PH1: this.item.title()}));
748
+ UI.ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.shortcutChangesRestored, {PH1: this.#editingItem.title()}));
596
749
  }
597
750
 
598
- onEscapeKeyPressed(event: Event): void {
599
- const activeElement = UI.DOMUtilities.deepActiveElement(document);
600
- for (const [shortcut, shortcutInput] of this.shortcutInputs.entries()) {
601
- if (activeElement === shortcutInput) {
602
- this.onShortcutInputKeyDown(shortcut, shortcutInput as HTMLInputElement, event);
751
+ #createListItems(): KeybindsItem[] {
752
+ const actions = UI.ActionRegistry.ActionRegistry.instance()
753
+ .actions()
754
+ .filter(action => action.configurableBindings())
755
+ .sort((actionA, actionB) => {
756
+ if (actionA.category() < actionB.category()) {
757
+ return -1;
758
+ }
759
+ if (actionA.category() > actionB.category()) {
760
+ return 1;
761
+ }
762
+ if (actionA.id() < actionB.id()) {
763
+ return -1;
764
+ }
765
+ if (actionA.id() > actionB.id()) {
766
+ return 1;
767
+ }
768
+ return 0;
769
+ });
770
+
771
+ const items: KeybindsItem[] = [];
772
+
773
+ let currentCategory: UI.ActionRegistration.ActionCategory;
774
+ actions.forEach(action => {
775
+ if (currentCategory !== action.category()) {
776
+ items.push(action.category());
603
777
  }
778
+ items.push(action);
779
+ currentCategory = action.category();
780
+ });
781
+ return items;
782
+ }
783
+
784
+ onEscapeKeyPressed(event: Event): void {
785
+ if (this.#editingItem && this.#focusedShortcut &&
786
+ UI.DOMUtilities.deepActiveElement(document)?.nodeName === 'INPUT') {
787
+ this.#onShortcutInputKeyDown(this.#focusedShortcut, event);
604
788
  }
605
789
  }
606
790
 
607
- private validateInputs(): void {
608
- const confirmButton = this.confirmButton;
609
- const errorMessageElement = this.errorMessageElement;
610
- if (!confirmButton || !errorMessageElement) {
611
- return;
791
+ update(): void {
792
+ if (this.#editingItem) {
793
+ this.stopEditing(this.#editingItem);
794
+ }
795
+ if (!this.#selectedItem && this.#actions.length > 0) {
796
+ this.#selectedItem = this.#actions[0];
612
797
  }
798
+ this.performUpdate();
799
+ }
613
800
 
614
- confirmButton.disabled = false;
615
- errorMessageElement.classList.add('hidden');
616
- this.shortcutInputs.forEach((shortcutInput, shortcut) => {
617
- const userDescriptors = this.editedShortcuts.get(shortcut);
618
- if (!userDescriptors) {
619
- return;
620
- }
621
- if (userDescriptors.some(descriptor => UI.KeyboardShortcut.KeyboardShortcut.isModifier(descriptor.key))) {
622
- confirmButton.disabled = true;
623
- shortcutInput.classList.add('error-input');
624
- UI.ARIAUtils.setInvalid(shortcutInput, true);
625
- errorMessageElement.classList.remove('hidden');
626
- errorMessageElement.textContent = i18nString(UIStrings.shortcutsCannotContainOnly);
627
- return;
628
- }
629
- const conflicts = UI.ShortcutRegistry.ShortcutRegistry.instance()
630
- .actionsForDescriptors(userDescriptors)
631
- .filter(actionId => actionId !== this.item.id());
632
- if (conflicts.length) {
633
- confirmButton.disabled = true;
634
- shortcutInput.classList.add('error-input');
635
- UI.ARIAUtils.setInvalid(shortcutInput, true);
636
- errorMessageElement.classList.remove('hidden');
637
- if (!UI.ActionRegistry.ActionRegistry.instance().hasAction(conflicts[0])) {
638
- return;
639
- }
640
- const action = UI.ActionRegistry.ActionRegistry.instance().getAction(conflicts[0]);
641
- const actionTitle = action.title();
642
- const actionCategory = action.category();
643
- errorMessageElement.textContent =
644
- i18nString(UIStrings.thisShortcutIsInUseByS, {PH1: actionCategory, PH2: actionTitle});
645
- return;
646
- }
647
- shortcutInput.classList.remove('error-input');
648
- UI.ARIAUtils.setInvalid(shortcutInput, false);
649
- });
801
+ override willHide(): void {
802
+ super.willHide();
803
+ if (this.#editingItem) {
804
+ this.stopEditing(this.#editingItem);
805
+ }
650
806
  }
651
807
  }
652
808