blob: 52507c239d49db099a7e9d3583838672bce2ecda [file] [log] [blame]
Blink Reformat4c46d092018-04-07 15:32:371/*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
Paul Lewis17e384e2020-01-08 15:46:5131import * as Common from '../common/common.js';
Paul Lewis0fd43712020-01-08 17:07:3632import * as Host from '../host/host.js';
33
Tim van der Lippeaa76aa22020-02-14 14:38:2434import * as ARIAUtils from './ARIAUtils.js';
35import {Descriptor, KeyboardShortcut, Keys, Modifiers} from './KeyboardShortcut.js'; // eslint-disable-line no-unused-vars
Paul Lewis9950e182019-12-16 16:06:0736import {createDocumentationLink} from './UIUtils.js';
37import {Widget} from './Widget.js';
38
Blink Reformat4c46d092018-04-07 15:32:3739/**
40 * @unrestricted
41 */
Paul Lewis9950e182019-12-16 16:06:0742export class ShortcutsScreen {
Blink Reformat4c46d092018-04-07 15:32:3743 constructor() {
Tim van der Lippe0830b3d2019-10-03 13:20:0744 /** @type {!Object.<string, !ShortcutsSection>} */
Blink Reformat4c46d092018-04-07 15:32:3745 this._sections = {};
46 }
47
48 static registerShortcuts() {
49 // Elements panel
Paul Lewis21533b02020-01-24 14:56:3450 const elementsSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Elements Panel'));
Blink Reformat4c46d092018-04-07 15:32:3751
Tim van der Lippe0830b3d2019-10-03 13:20:0752 const navigate = ElementsPanelShortcuts.NavigateUp.concat(ElementsPanelShortcuts.NavigateDown);
Paul Lewis17e384e2020-01-08 15:46:5153 elementsSection.addRelatedKeys(navigate, Common.UIString.UIString('Navigate elements'));
Blink Reformat4c46d092018-04-07 15:32:3754
Tim van der Lippe0830b3d2019-10-03 13:20:0755 const expandCollapse = ElementsPanelShortcuts.Expand.concat(ElementsPanelShortcuts.Collapse);
Paul Lewis17e384e2020-01-08 15:46:5156 elementsSection.addRelatedKeys(expandCollapse, Common.UIString.UIString('Expand/collapse'));
Blink Reformat4c46d092018-04-07 15:32:3757
Paul Lewis17e384e2020-01-08 15:46:5158 elementsSection.addAlternateKeys(ElementsPanelShortcuts.EditAttribute, Common.UIString.UIString('Edit attribute'));
Blink Reformat4c46d092018-04-07 15:32:3759 elementsSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:4060 self.UI.shortcutRegistry.shortcutDescriptorsForAction('elements.hide-element'),
Paul Lewis17e384e2020-01-08 15:46:5161 Common.UIString.UIString('Hide element'));
Blink Reformat4c46d092018-04-07 15:32:3762 elementsSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:4063 self.UI.shortcutRegistry.shortcutDescriptorsForAction('elements.edit-as-html'),
Paul Lewis17e384e2020-01-08 15:46:5164 Common.UIString.UIString('Toggle edit as HTML'));
Blink Reformat4c46d092018-04-07 15:32:3765
Fabio Rochaf0d95472019-05-28 21:35:1966 // Styles pane
Paul Lewis21533b02020-01-24 14:56:3467 const stylesPaneSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Styles Pane'));
Blink Reformat4c46d092018-04-07 15:32:3768
Tim van der Lippe0830b3d2019-10-03 13:20:0769 const nextPreviousProperty = ElementsPanelShortcuts.NextProperty.concat(ElementsPanelShortcuts.PreviousProperty);
Paul Lewis17e384e2020-01-08 15:46:5170 stylesPaneSection.addRelatedKeys(nextPreviousProperty, Common.UIString.UIString('Next/previous property'));
Blink Reformat4c46d092018-04-07 15:32:3771
Paul Lewis17e384e2020-01-08 15:46:5172 stylesPaneSection.addRelatedKeys(
73 ElementsPanelShortcuts.IncrementValue, Common.UIString.UIString('Increment value'));
74 stylesPaneSection.addRelatedKeys(
75 ElementsPanelShortcuts.DecrementValue, Common.UIString.UIString('Decrement value'));
Blink Reformat4c46d092018-04-07 15:32:3776
Paul Lewis17e384e2020-01-08 15:46:5177 stylesPaneSection.addAlternateKeys(
78 ElementsPanelShortcuts.IncrementBy10, Common.UIString.UIString('Increment by %f', 10));
79 stylesPaneSection.addAlternateKeys(
80 ElementsPanelShortcuts.DecrementBy10, Common.UIString.UIString('Decrement by %f', 10));
Blink Reformat4c46d092018-04-07 15:32:3781
Paul Lewis17e384e2020-01-08 15:46:5182 stylesPaneSection.addAlternateKeys(
83 ElementsPanelShortcuts.IncrementBy100, Common.UIString.UIString('Increment by %f', 100));
84 stylesPaneSection.addAlternateKeys(
85 ElementsPanelShortcuts.DecrementBy100, Common.UIString.UIString('Decrement by %f', 100));
Blink Reformat4c46d092018-04-07 15:32:3786
Paul Lewis17e384e2020-01-08 15:46:5187 stylesPaneSection.addAlternateKeys(
88 ElementsPanelShortcuts.IncrementBy01, Common.UIString.UIString('Increment by %f', 0.1));
89 stylesPaneSection.addAlternateKeys(
90 ElementsPanelShortcuts.DecrementBy01, Common.UIString.UIString('Decrement by %f', 0.1));
Blink Reformat4c46d092018-04-07 15:32:3791
Fabio Rochaf0d95472019-05-28 21:35:1992 // Console
Paul Lewis21533b02020-01-24 14:56:3493 const consoleSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Console'));
Blink Reformat4c46d092018-04-07 15:32:3794
Fabio Rochaf0d95472019-05-28 21:35:1995 consoleSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:4096 self.UI.shortcutRegistry.shortcutDescriptorsForAction('console.clear'),
97 Common.UIString.UIString('Clear console'));
Paul Lewis17e384e2020-01-08 15:46:5198 consoleSection.addRelatedKeys(
99 ConsolePanelShortcuts.AcceptSuggestion, Common.UIString.UIString('Accept suggestion'));
100 consoleSection.addAlternateKeys(
101 ConsolePanelShortcuts.ClearConsolePrompt, Common.UIString.UIString('Clear console prompt'));
102 consoleSection.addRelatedKeys(
103 ConsolePanelShortcuts.NextPreviousLine, Common.UIString.UIString('Next/previous line'));
Fabio Rochaf0d95472019-05-28 21:35:19104
Paul Lewis0fd43712020-01-08 17:07:36105 if (Host.Platform.isMac()) {
Fabio Rochaf0d95472019-05-28 21:35:19106 consoleSection.addRelatedKeys(
Paul Lewis17e384e2020-01-08 15:46:51107 ConsolePanelShortcuts.NextPreviousCommand, Common.UIString.UIString('Next/previous command'));
Fabio Rochaf0d95472019-05-28 21:35:19108 }
109
Paul Lewis17e384e2020-01-08 15:46:51110 consoleSection.addKey(ConsolePanelShortcuts.ExecuteCommand, Common.UIString.UIString('Execute command'));
Fabio Rochaf0d95472019-05-28 21:35:19111
112 // Debugger
Paul Lewis21533b02020-01-24 14:56:34113 const debuggerSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Debugger'));
Fabio Rochaf0d95472019-05-28 21:35:19114
115 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40116 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-pause'),
Paul Lewis17e384e2020-01-08 15:46:51117 Common.UIString.UIString('Pause/ Continue'));
Fabio Rochaf0d95472019-05-28 21:35:19118 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40119 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-over'),
120 Common.UIString.UIString('Step over'));
Fabio Rochaf0d95472019-05-28 21:35:19121 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40122 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-into'),
123 Common.UIString.UIString('Step into'));
Fabio Rochaf0d95472019-05-28 21:35:19124 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40125 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.step-out'),
126 Common.UIString.UIString('Step out'));
Blink Reformat4c46d092018-04-07 15:32:37127
128 const nextAndPrevFrameKeys =
Paul Lewis05eb37f2020-01-24 14:31:40129 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.next-call-frame')
130 .concat(self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.previous-call-frame'));
Paul Lewis17e384e2020-01-08 15:46:51131 debuggerSection.addRelatedKeys(nextAndPrevFrameKeys, Common.UIString.UIString('Next/previous call frame'));
Blink Reformat4c46d092018-04-07 15:32:37132
Fabio Rochaf0d95472019-05-28 21:35:19133 debuggerSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51134 SourcesPanelShortcuts.EvaluateSelectionInConsole, Common.UIString.UIString('Evaluate selection in console'));
Fabio Rochaf0d95472019-05-28 21:35:19135 debuggerSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51136 SourcesPanelShortcuts.AddSelectionToWatch, Common.UIString.UIString('Add selection to watch'));
Fabio Rochaf0d95472019-05-28 21:35:19137 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40138 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint'),
Paul Lewis17e384e2020-01-08 15:46:51139 Common.UIString.UIString('Toggle breakpoint'));
Fabio Rochaf0d95472019-05-28 21:35:19140 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40141 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoint-enabled'),
Paul Lewis17e384e2020-01-08 15:46:51142 Common.UIString.UIString('Toggle breakpoint enabled'));
Fabio Rochaf0d95472019-05-28 21:35:19143 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40144 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.toggle-breakpoints-active'),
Paul Lewis17e384e2020-01-08 15:46:51145 Common.UIString.UIString('Toggle all breakpoints'));
Olivia Flynn8e746e02019-06-19 17:06:23146 debuggerSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40147 self.UI.shortcutRegistry.shortcutDescriptorsForAction('debugger.breakpoint-input-window'),
Olivia Flynn8e746e02019-06-19 17:06:23148 ls`Open breakpoint editor`);
Blink Reformat4c46d092018-04-07 15:32:37149
150 // Editing
Paul Lewis21533b02020-01-24 14:56:34151 const editingSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Text Editor'));
Fabio Rochaf0d95472019-05-28 21:35:19152
153 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40154 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-member'),
Paul Lewis17e384e2020-01-08 15:46:51155 Common.UIString.UIString('Go to member'));
Fabio Rochaf0d95472019-05-28 21:35:19156 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51157 SourcesPanelShortcuts.ToggleAutocompletion, Common.UIString.UIString('Autocompletion'));
158 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40159 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.go-to-line'),
160 Common.UIString.UIString('Go to line'));
Fabio Rochaf0d95472019-05-28 21:35:19161 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40162 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-previous-location'),
Paul Lewis17e384e2020-01-08 15:46:51163 Common.UIString.UIString('Jump to previous editing location'));
Fabio Rochaf0d95472019-05-28 21:35:19164 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40165 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.jump-to-next-location'),
Paul Lewis17e384e2020-01-08 15:46:51166 Common.UIString.UIString('Jump to next editing location'));
167 editingSection.addAlternateKeys(SourcesPanelShortcuts.ToggleComment, Common.UIString.UIString('Toggle comment'));
Fabio Rochaf0d95472019-05-28 21:35:19168 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51169 SourcesPanelShortcuts.IncreaseCSSUnitByOne, Common.UIString.UIString('Increment CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19170 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51171 SourcesPanelShortcuts.DecreaseCSSUnitByOne, Common.UIString.UIString('Decrement CSS unit by 1'));
Fabio Rochaf0d95472019-05-28 21:35:19172 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51173 SourcesPanelShortcuts.IncreaseCSSUnitByTen, Common.UIString.UIString('Increment CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19174 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51175 SourcesPanelShortcuts.DecreaseCSSUnitByTen, Common.UIString.UIString('Decrement CSS unit by 10'));
Fabio Rochaf0d95472019-05-28 21:35:19176 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51177 SourcesPanelShortcuts.SelectNextOccurrence, Common.UIString.UIString('Select next occurrence'));
178 editingSection.addAlternateKeys(SourcesPanelShortcuts.SoftUndo, Common.UIString.UIString('Soft undo'));
Fabio Rochaf0d95472019-05-28 21:35:19179 editingSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51180 SourcesPanelShortcuts.GotoMatchingBracket, Common.UIString.UIString('Go to matching bracket'));
Fabio Rochaf0d95472019-05-28 21:35:19181 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40182 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.close-editor-tab'),
Paul Lewis17e384e2020-01-08 15:46:51183 Common.UIString.UIString('Close editor tab'));
Fabio Rochaf0d95472019-05-28 21:35:19184 editingSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40185 self.UI.shortcutRegistry.shortcutDescriptorsForAction('sources.switch-file'),
Paul Lewis17e384e2020-01-08 15:46:51186 Common.UIString.UIString('Switch between files with the same name and different extensions.'));
Blink Reformat4c46d092018-04-07 15:32:37187
188 // Performance panel
Paul Lewis21533b02020-01-24 14:56:34189 const performanceSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Performance Panel'));
Fabio Rochaf0d95472019-05-28 21:35:19190
191 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40192 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.toggle-recording'),
Paul Lewis17e384e2020-01-08 15:46:51193 Common.UIString.UIString('Start/stop recording'));
Fabio Rochaf0d95472019-05-28 21:35:19194 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40195 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.record-reload'),
Paul Lewis17e384e2020-01-08 15:46:51196 Common.UIString.UIString('Record page reload'));
Fabio Rochaf0d95472019-05-28 21:35:19197 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40198 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.save-to-file'),
Paul Lewis17e384e2020-01-08 15:46:51199 Common.UIString.UIString('Save profile'));
Fabio Rochaf0d95472019-05-28 21:35:19200 performanceSection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40201 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.load-from-file'),
Paul Lewis17e384e2020-01-08 15:46:51202 Common.UIString.UIString('Load profile'));
Fabio Rochaf0d95472019-05-28 21:35:19203 performanceSection.addRelatedKeys(
Paul Lewis05eb37f2020-01-24 14:31:40204 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-previous-frame')
205 .concat(self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.jump-to-next-frame')),
Paul Lewis17e384e2020-01-08 15:46:51206 Common.UIString.UIString('Jump to previous/next frame'));
Fabio Rochaf0d95472019-05-28 21:35:19207 performanceSection.addRelatedKeys(
Paul Lewis05eb37f2020-01-24 14:31:40208 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.show-history'),
Paul Lewis17e384e2020-01-08 15:46:51209 Common.UIString.UIString('Pick a recording from history'));
Fabio Rochaf0d95472019-05-28 21:35:19210 performanceSection.addRelatedKeys(
Paul Lewis05eb37f2020-01-24 14:31:40211 self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.previous-recording')
212 .concat(self.UI.shortcutRegistry.shortcutDescriptorsForAction('timeline.next-recording')),
Paul Lewis17e384e2020-01-08 15:46:51213 Common.UIString.UIString('Show previous/next recording'));
Blink Reformat4c46d092018-04-07 15:32:37214
215 // Memory panel
Paul Lewis21533b02020-01-24 14:56:34216 const memorySection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Memory Panel'));
Fabio Rochaf0d95472019-05-28 21:35:19217
218 memorySection.addAlternateKeys(
Paul Lewis05eb37f2020-01-24 14:31:40219 self.UI.shortcutRegistry.shortcutDescriptorsForAction('profiler.heap-toggle-recording'),
Paul Lewis17e384e2020-01-08 15:46:51220 Common.UIString.UIString('Start/stop recording'));
Blink Reformat4c46d092018-04-07 15:32:37221
222 // Layers panel
Paul Lewis21533b02020-01-24 14:56:34223 const layersSection = self.UI.shortcutsScreen.section(Common.UIString.UIString('Layers Panel'));
Fabio Rochaf0d95472019-05-28 21:35:19224
Paul Lewis17e384e2020-01-08 15:46:51225 layersSection.addAlternateKeys(LayersPanelShortcuts.ResetView, Common.UIString.UIString('Reset view'));
226 layersSection.addAlternateKeys(LayersPanelShortcuts.PanMode, Common.UIString.UIString('Switch to pan mode'));
227 layersSection.addAlternateKeys(LayersPanelShortcuts.RotateMode, Common.UIString.UIString('Switch to rotate mode'));
Fabio Rochaf0d95472019-05-28 21:35:19228 layersSection.addAlternateKeys(
Paul Lewis17e384e2020-01-08 15:46:51229 LayersPanelShortcuts.TogglePanRotate,
230 Common.UIString.UIString('Temporarily toggle pan/rotate mode while held'));
231 layersSection.addAlternateKeys(LayersPanelShortcuts.ZoomIn, Common.UIString.UIString('Zoom in'));
232 layersSection.addAlternateKeys(LayersPanelShortcuts.ZoomOut, Common.UIString.UIString('Zoom out'));
Fabio Rochaf0d95472019-05-28 21:35:19233 layersSection.addRelatedKeys(
Paul Lewis17e384e2020-01-08 15:46:51234 LayersPanelShortcuts.Up.concat(LayersPanelShortcuts.Down), Common.UIString.UIString('Pan or rotate up/down'));
Fabio Rochaf0d95472019-05-28 21:35:19235 layersSection.addRelatedKeys(
Paul Lewis17e384e2020-01-08 15:46:51236 LayersPanelShortcuts.Left.concat(LayersPanelShortcuts.Right),
237 Common.UIString.UIString('Pan or rotate left/right'));
Blink Reformat4c46d092018-04-07 15:32:37238 }
239
240 /**
241 * @param {string} name
Tim van der Lippe0830b3d2019-10-03 13:20:07242 * @return {!ShortcutsSection}
Blink Reformat4c46d092018-04-07 15:32:37243 */
244 section(name) {
245 let section = this._sections[name];
Tim van der Lippe1d6e57a2019-09-30 11:55:34246 if (!section) {
Tim van der Lippe0830b3d2019-10-03 13:20:07247 this._sections[name] = section = new ShortcutsSection(name);
Tim van der Lippe1d6e57a2019-09-30 11:55:34248 }
Blink Reformat4c46d092018-04-07 15:32:37249 return section;
250 }
251
252 /**
Paul Lewis9950e182019-12-16 16:06:07253 * @return {!Widget}
Blink Reformat4c46d092018-04-07 15:32:37254 */
255 createShortcutsTabView() {
256 const orderedSections = [];
Tim van der Lippe1d6e57a2019-09-30 11:55:34257 for (const section in this._sections) {
Blink Reformat4c46d092018-04-07 15:32:37258 orderedSections.push(this._sections[section]);
Tim van der Lippe1d6e57a2019-09-30 11:55:34259 }
Blink Reformat4c46d092018-04-07 15:32:37260 function compareSections(a, b) {
261 return a.order - b.order;
262 }
263 orderedSections.sort(compareSections);
264
Paul Lewis9950e182019-12-16 16:06:07265 const widget = new Widget();
Blink Reformat4c46d092018-04-07 15:32:37266
267 widget.element.className = 'settings-tab-container'; // Override
Chandani Shrestha83bd7c92019-06-11 21:21:59268 widget.element.createChild('header').createChild('h1').createTextChild(ls`Shortcuts`);
Blink Reformat4c46d092018-04-07 15:32:37269 const scrollPane = widget.element.createChild('div', 'settings-container-wrapper');
270 const container = scrollPane.createChild('div');
271 container.className = 'settings-content settings-container';
Tim van der Lippe1d6e57a2019-09-30 11:55:34272 for (let i = 0; i < orderedSections.length; ++i) {
Blink Reformat4c46d092018-04-07 15:32:37273 orderedSections[i].renderSection(container);
Tim van der Lippe1d6e57a2019-09-30 11:55:34274 }
Blink Reformat4c46d092018-04-07 15:32:37275
276 const note = scrollPane.createChild('p', 'settings-footnote');
Paul Lewis9950e182019-12-16 16:06:07277 note.appendChild(createDocumentationLink(
Paul Lewis17e384e2020-01-08 15:46:51278 'iterate/inspect-styles/shortcuts',
279 Common.UIString.UIString('Full list of DevTools keyboard shortcuts and gestures')));
Blink Reformat4c46d092018-04-07 15:32:37280
281 return widget;
282 }
Tim van der Lippe0830b3d2019-10-03 13:20:07283}
Blink Reformat4c46d092018-04-07 15:32:37284
285/**
Blink Reformat4c46d092018-04-07 15:32:37286 * @unrestricted
287 */
Tim van der Lippec96ccd92019-11-29 16:23:54288class ShortcutsSection {
Blink Reformat4c46d092018-04-07 15:32:37289 /**
290 * @param {string} name
291 */
292 constructor(name) {
293 this.name = name;
294 this._lines = /** @type {!Array.<!{key: !Node, text: string}>} */ ([]);
Tim van der Lippe0830b3d2019-10-03 13:20:07295 this.order = ++ShortcutsSection._sequenceNumber;
Blink Reformat4c46d092018-04-07 15:32:37296 }
297
298 /**
Tim van der Lippeaa76aa22020-02-14 14:38:24299 * @param {!Descriptor} key
Blink Reformat4c46d092018-04-07 15:32:37300 * @param {string} description
301 */
302 addKey(key, description) {
303 this._addLine(this._renderKey(key), description);
304 }
305
306 /**
Tim van der Lippeaa76aa22020-02-14 14:38:24307 * @param {!Array.<!Descriptor>} keys
Blink Reformat4c46d092018-04-07 15:32:37308 * @param {string} description
309 */
310 addRelatedKeys(keys, description) {
311 this._addLine(this._renderSequence(keys, '/'), description);
312 }
313
314 /**
Tim van der Lippeaa76aa22020-02-14 14:38:24315 * @param {!Array.<!Descriptor>} keys
Blink Reformat4c46d092018-04-07 15:32:37316 * @param {string} description
317 */
318 addAlternateKeys(keys, description) {
Paul Lewis17e384e2020-01-08 15:46:51319 this._addLine(this._renderSequence(keys, Common.UIString.UIString('or')), description);
Blink Reformat4c46d092018-04-07 15:32:37320 }
321
322 /**
323 * @param {!Node} keyElement
324 * @param {string} description
325 */
326 _addLine(keyElement, description) {
327 this._lines.push({key: keyElement, text: description});
328 }
329
330 /**
331 * @param {!Element} container
332 */
333 renderSection(container) {
334 const parent = container.createChild('div', 'settings-block');
335
336 const headLine = parent.createChild('div', 'settings-line');
337 headLine.createChild('div', 'settings-key-cell');
338 headLine.createChild('div', 'settings-section-title settings-cell').textContent = this.name;
Tim van der Lippeaa76aa22020-02-14 14:38:24339 ARIAUtils.markAsHeading(headLine, /* level */ 2);
Blink Reformat4c46d092018-04-07 15:32:37340
341 for (let i = 0; i < this._lines.length; ++i) {
342 const line = parent.createChild('div', 'settings-line');
343 const keyCell = line.createChild('div', 'settings-key-cell');
344 keyCell.appendChild(this._lines[i].key);
345 keyCell.appendChild(this._createSpan('settings-key-delimiter', ':'));
346 line.createChild('div', 'settings-cell').textContent = this._lines[i].text;
347 }
348 }
349
350 /**
Tim van der Lippeaa76aa22020-02-14 14:38:24351 * @param {!Array.<!Descriptor>} sequence
Blink Reformat4c46d092018-04-07 15:32:37352 * @param {string} delimiter
353 * @return {!Node}
354 */
355 _renderSequence(sequence, delimiter) {
356 const delimiterSpan = this._createSpan('settings-key-delimiter', delimiter);
357 return this._joinNodes(sequence.map(this._renderKey.bind(this)), delimiterSpan);
358 }
359
360 /**
Tim van der Lippeaa76aa22020-02-14 14:38:24361 * @param {!Descriptor} key
Blink Reformat4c46d092018-04-07 15:32:37362 * @return {!Node}
363 */
364 _renderKey(key) {
365 const keyName = key.name;
366 const plus = this._createSpan('settings-combine-keys', '+');
367 return this._joinNodes(keyName.split(' + ').map(this._createSpan.bind(this, 'settings-key')), plus);
368 }
369
370 /**
371 * @param {string} className
372 * @param {string} textContent
373 * @return {!Element}
374 */
375 _createSpan(className, textContent) {
376 const node = createElement('span');
377 node.className = className;
378 node.textContent = textContent;
379 return node;
380 }
381
382 /**
383 * @param {!Array.<!Element>} nodes
384 * @param {!Element} delimiter
385 * @return {!Node}
386 */
387 _joinNodes(nodes, delimiter) {
388 const result = createDocumentFragment();
389 for (let i = 0; i < nodes.length; ++i) {
Tim van der Lippe1d6e57a2019-09-30 11:55:34390 if (i > 0) {
Blink Reformat4c46d092018-04-07 15:32:37391 result.appendChild(delimiter.cloneNode(true));
Tim van der Lippe1d6e57a2019-09-30 11:55:34392 }
Blink Reformat4c46d092018-04-07 15:32:37393 result.appendChild(nodes[i]);
394 }
395 return result;
396 }
Tim van der Lippe0830b3d2019-10-03 13:20:07397}
Blink Reformat4c46d092018-04-07 15:32:37398
Tim van der Lippe0830b3d2019-10-03 13:20:07399ShortcutsSection._sequenceNumber = 0;
Blink Reformat4c46d092018-04-07 15:32:37400
401
Tim van der Lippec96ccd92019-11-29 16:23:54402const ElementsPanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07403 NavigateUp: [KeyboardShortcut.makeDescriptor(Keys.Up)],
Blink Reformat4c46d092018-04-07 15:32:37404
Paul Lewis9950e182019-12-16 16:06:07405 NavigateDown: [KeyboardShortcut.makeDescriptor(Keys.Down)],
Blink Reformat4c46d092018-04-07 15:32:37406
Paul Lewis9950e182019-12-16 16:06:07407 Expand: [KeyboardShortcut.makeDescriptor(Keys.Right)],
Blink Reformat4c46d092018-04-07 15:32:37408
Paul Lewis9950e182019-12-16 16:06:07409 Collapse: [KeyboardShortcut.makeDescriptor(Keys.Left)],
Blink Reformat4c46d092018-04-07 15:32:37410
Paul Lewis9950e182019-12-16 16:06:07411 EditAttribute: [KeyboardShortcut.makeDescriptor(Keys.Enter)],
Blink Reformat4c46d092018-04-07 15:32:37412
Paul Lewis9950e182019-12-16 16:06:07413 NextProperty: [KeyboardShortcut.makeDescriptor(Keys.Tab)],
Blink Reformat4c46d092018-04-07 15:32:37414
Paul Lewis9950e182019-12-16 16:06:07415 PreviousProperty: [KeyboardShortcut.makeDescriptor(Keys.Tab, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37416
Paul Lewis9950e182019-12-16 16:06:07417 IncrementValue: [KeyboardShortcut.makeDescriptor(Keys.Up)],
Blink Reformat4c46d092018-04-07 15:32:37418
Paul Lewis9950e182019-12-16 16:06:07419 DecrementValue: [KeyboardShortcut.makeDescriptor(Keys.Down)],
Blink Reformat4c46d092018-04-07 15:32:37420
Paul Lewis9950e182019-12-16 16:06:07421 IncrementBy10:
422 [KeyboardShortcut.makeDescriptor(Keys.PageUp), KeyboardShortcut.makeDescriptor(Keys.Up, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37423
Paul Lewis9950e182019-12-16 16:06:07424 DecrementBy10:
425 [KeyboardShortcut.makeDescriptor(Keys.PageDown), KeyboardShortcut.makeDescriptor(Keys.Down, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37426
Paul Lewis9950e182019-12-16 16:06:07427 IncrementBy100: [KeyboardShortcut.makeDescriptor(Keys.PageUp, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37428
Paul Lewis9950e182019-12-16 16:06:07429 DecrementBy100: [KeyboardShortcut.makeDescriptor(Keys.PageDown, Modifiers.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37430
Paul Lewis9950e182019-12-16 16:06:07431 IncrementBy01: [KeyboardShortcut.makeDescriptor(Keys.Up, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37432
Paul Lewis9950e182019-12-16 16:06:07433 DecrementBy01: [KeyboardShortcut.makeDescriptor(Keys.Down, Modifiers.Alt)]
Blink Reformat4c46d092018-04-07 15:32:37434};
435
Tim van der Lippec96ccd92019-11-29 16:23:54436const ConsolePanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07437 AcceptSuggestion: [KeyboardShortcut.makeDescriptor(Keys.Tab), KeyboardShortcut.makeDescriptor(Keys.Right)],
Fabio Rochaf0d95472019-05-28 21:35:19438
Paul Lewis9950e182019-12-16 16:06:07439 ClearConsolePrompt: [KeyboardShortcut.makeDescriptor('u', Modifiers.Ctrl)],
Fabio Rochaf0d95472019-05-28 21:35:19440
Paul Lewis9950e182019-12-16 16:06:07441 ExecuteCommand: KeyboardShortcut.makeDescriptor(Keys.Enter),
Fabio Rochaf0d95472019-05-28 21:35:19442
Paul Lewis9950e182019-12-16 16:06:07443 NextPreviousLine: [KeyboardShortcut.makeDescriptor(Keys.Down), KeyboardShortcut.makeDescriptor(Keys.Up)],
Fabio Rochaf0d95472019-05-28 21:35:19444
Paul Lewis9950e182019-12-16 16:06:07445 NextPreviousCommand:
446 [KeyboardShortcut.makeDescriptor('N', Modifiers.Alt), KeyboardShortcut.makeDescriptor('P', Modifiers.Alt)],
Fabio Rochaf0d95472019-05-28 21:35:19447};
448
Tim van der Lippe0830b3d2019-10-03 13:20:07449export const SourcesPanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07450 SelectNextOccurrence: [KeyboardShortcut.makeDescriptor('d', Modifiers.CtrlOrMeta)],
Blink Reformat4c46d092018-04-07 15:32:37451
Paul Lewis9950e182019-12-16 16:06:07452 SoftUndo: [KeyboardShortcut.makeDescriptor('u', Modifiers.CtrlOrMeta)],
Blink Reformat4c46d092018-04-07 15:32:37453
Paul Lewis9950e182019-12-16 16:06:07454 GotoMatchingBracket: [KeyboardShortcut.makeDescriptor('m', Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37455
Paul Lewis9950e182019-12-16 16:06:07456 ToggleAutocompletion: [KeyboardShortcut.makeDescriptor(Keys.Space, Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37457
Paul Lewis9950e182019-12-16 16:06:07458 IncreaseCSSUnitByOne: [KeyboardShortcut.makeDescriptor(Keys.Up, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37459
Paul Lewis9950e182019-12-16 16:06:07460 DecreaseCSSUnitByOne: [KeyboardShortcut.makeDescriptor(Keys.Down, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37461
Paul Lewis9950e182019-12-16 16:06:07462 IncreaseCSSUnitByTen: [KeyboardShortcut.makeDescriptor(Keys.PageUp, Modifiers.Alt)],
Blink Reformat4c46d092018-04-07 15:32:37463
Paul Lewis9950e182019-12-16 16:06:07464 DecreaseCSSUnitByTen: [KeyboardShortcut.makeDescriptor(Keys.PageDown, Modifiers.Alt)],
465 EvaluateSelectionInConsole: [KeyboardShortcut.makeDescriptor('e', Modifiers.Shift | Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37466
Paul Lewis9950e182019-12-16 16:06:07467 AddSelectionToWatch: [KeyboardShortcut.makeDescriptor('a', Modifiers.Shift | Modifiers.Ctrl)],
Blink Reformat4c46d092018-04-07 15:32:37468
Paul Lewis9950e182019-12-16 16:06:07469 ToggleComment: [KeyboardShortcut.makeDescriptor(Keys.Slash, Modifiers.CtrlOrMeta)],
Blink Reformat4c46d092018-04-07 15:32:37470};
471
Tim van der Lippe0830b3d2019-10-03 13:20:07472export const LayersPanelShortcuts = {
Paul Lewis9950e182019-12-16 16:06:07473 ResetView: [KeyboardShortcut.makeDescriptor('0')],
Blink Reformat4c46d092018-04-07 15:32:37474
Paul Lewis9950e182019-12-16 16:06:07475 PanMode: [KeyboardShortcut.makeDescriptor('x')],
Blink Reformat4c46d092018-04-07 15:32:37476
Paul Lewis9950e182019-12-16 16:06:07477 RotateMode: [KeyboardShortcut.makeDescriptor('v')],
Blink Reformat4c46d092018-04-07 15:32:37478
Paul Lewis9950e182019-12-16 16:06:07479 TogglePanRotate: [KeyboardShortcut.makeDescriptor(Keys.Shift)],
Blink Reformat4c46d092018-04-07 15:32:37480
Paul Lewis9950e182019-12-16 16:06:07481 ZoomIn:
482 [KeyboardShortcut.makeDescriptor(Keys.Plus, Modifiers.Shift), KeyboardShortcut.makeDescriptor(Keys.NumpadPlus)],
Blink Reformat4c46d092018-04-07 15:32:37483
Paul Lewis9950e182019-12-16 16:06:07484 ZoomOut:
485 [KeyboardShortcut.makeDescriptor(Keys.Minus, Modifiers.Shift), KeyboardShortcut.makeDescriptor(Keys.NumpadMinus)],
Blink Reformat4c46d092018-04-07 15:32:37486
Paul Lewis9950e182019-12-16 16:06:07487 Up: [KeyboardShortcut.makeDescriptor(Keys.Up), KeyboardShortcut.makeDescriptor('w')],
Blink Reformat4c46d092018-04-07 15:32:37488
Paul Lewis9950e182019-12-16 16:06:07489 Down: [KeyboardShortcut.makeDescriptor(Keys.Down), KeyboardShortcut.makeDescriptor('s')],
Blink Reformat4c46d092018-04-07 15:32:37490
Paul Lewis9950e182019-12-16 16:06:07491 Left: [KeyboardShortcut.makeDescriptor(Keys.Left), KeyboardShortcut.makeDescriptor('a')],
Blink Reformat4c46d092018-04-07 15:32:37492
Paul Lewis9950e182019-12-16 16:06:07493 Right: [KeyboardShortcut.makeDescriptor(Keys.Right), KeyboardShortcut.makeDescriptor('d')]
Blink Reformat4c46d092018-04-07 15:32:37494};