Skip to content

Commit 4a8842f

Browse files
Kateryna ProkopenkoDevtools-frontend LUCI CQ
authored andcommitted
Add accelerators and use native menu in Performance panel except on Mac
Bug: 368240754 Change-Id: I9da724fe5e88d9c7abd836bea526f74102af56c9 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5934530 Reviewed-by: Kim-Anh Tran <[email protected]> Commit-Queue: Kateryna Prokopenko <[email protected]>
1 parent 25cf9b6 commit 4a8842f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

front_end/panels/timeline/TimelineFlameChartDataProvider.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*/
3030

3131
import * as Common from '../../core/common/common.js';
32+
import * as Host from '../../core/host/host.js';
3233
import * as i18n from '../../core/i18n/i18n.js';
3334
import * as Root from '../../core/root/root.js';
3435
import * as Bindings from '../../models/bindings/bindings.js';
@@ -213,7 +214,11 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
213214
return;
214215
}
215216

216-
const contextMenu = new UI.ContextMenu.ContextMenu(event, {useSoftMenu: true});
217+
// Differentiate between Mac and other platforms to use SoftContextMenu or native menus
218+
// while we are gradually landing CLs to enable accelerators for native menus on Mac.
219+
// We will use native menus disregarding of the platform once all CLs are in.
220+
const useSoftMenu = Host.Platform.isMac();
221+
const contextMenu = new UI.ContextMenu.ContextMenu(event, {useSoftMenu});
217222

218223
if (UI.ActionRegistry.ActionRegistry.instance().hasAction('drjones.performance-panel-context')) {
219224
const aiNode = this.getAIEventNodeTreeFromEntryIndex(entryIndex);
@@ -230,6 +235,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
230235
jslogContext: 'hide-function',
231236
});
232237
hideEntryOption.setShortcut('H');
238+
hideEntryOption.setAccelerator(UI.KeyboardShortcut.Keys.H, [UI.KeyboardShortcut.Modifiers.None]);
233239

234240
const hideChildrenOption = contextMenu.defaultSection().appendItem(i18nString(UIStrings.hideChildren), () => {
235241
this.modifyTree(PerfUI.FlameChart.FilterAction.COLLAPSE_FUNCTION, entryIndex);
@@ -238,6 +244,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
238244
jslogContext: 'hide-children',
239245
});
240246
hideChildrenOption.setShortcut('C');
247+
hideChildrenOption.setAccelerator(UI.KeyboardShortcut.Keys.C, [UI.KeyboardShortcut.Modifiers.None]);
241248

242249
const hideRepeatingChildrenOption =
243250
contextMenu.defaultSection().appendItem(i18nString(UIStrings.hideRepeatingChildren), () => {
@@ -247,6 +254,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
247254
jslogContext: 'hide-repeating-children',
248255
});
249256
hideRepeatingChildrenOption.setShortcut('R');
257+
hideRepeatingChildrenOption.setAccelerator(UI.KeyboardShortcut.Keys.R, [UI.KeyboardShortcut.Modifiers.None]);
250258

251259
const resetChildrenOption = contextMenu.defaultSection().appendItem(i18nString(UIStrings.resetChildren), () => {
252260
this.modifyTree(PerfUI.FlameChart.FilterAction.RESET_CHILDREN, entryIndex);
@@ -255,6 +263,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
255263
jslogContext: 'reset-children',
256264
});
257265
resetChildrenOption.setShortcut('U');
266+
resetChildrenOption.setAccelerator(UI.KeyboardShortcut.Keys.U, [UI.KeyboardShortcut.Modifiers.None]);
258267

259268
contextMenu.defaultSection().appendItem(i18nString(UIStrings.resetTrace), () => {
260269
this.modifyTree(PerfUI.FlameChart.FilterAction.UNDO_ALL_ACTIONS, entryIndex);

front_end/ui/legacy/KeyboardShortcut.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,14 @@ export const Keys: {
324324
ArrowDown: downKey,
325325
Delete: {code: 46, name: 'Del'},
326326
Zero: {code: 48, name: '0'},
327+
C: {code: 67, name: 'C'},
327328
H: {code: 72, name: 'H'},
328329
N: {code: 78, name: 'N'},
329330
P: {code: 80, name: 'P'},
331+
R: {code: 82, name: 'R'},
332+
U: {code: 85, name: 'U'},
333+
V: {code: 86, name: 'V'},
334+
X: {code: 88, name: 'X'},
330335
Meta: metaKey,
331336
F1: {code: 112, name: 'F1'},
332337
F2: {code: 113, name: 'F2'},

0 commit comments

Comments
 (0)