Skip to content

Commit 51e8478

Browse files
Kateryna ProkopenkoDevtools-frontend LUCI CQ
authored andcommitted
Add isDevToolsPerformanceMenuItem flag to context menus
Bug: 368240754 Change-Id: I6a1db0ca9e8ecd54f5cb3c7052b2b2fb51aff129 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5934531 Reviewed-by: Kim-Anh Tran <[email protected]> Commit-Queue: Kateryna Prokopenko <[email protected]>
1 parent cba0a0c commit 51e8478

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

front_end/core/host/InspectorFrontendHostAPI.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ export interface ContextMenuDescriptor {
392392
isExperimentalFeature?: boolean;
393393
enabled?: boolean;
394394
checked?: boolean;
395+
isDevToolsPerformanceMenuItem?: boolean;
395396
subItems?: ContextMenuDescriptor[];
396397
shortcut?: string;
397398
jslogContext?: string;

front_end/ui/legacy/ContextMenu.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class Item {
4747
protected readonly previewFeature: boolean;
4848
protected disabled: boolean|undefined;
4949
private readonly checked: boolean|undefined;
50+
protected isDevToolsPerformanceMenuItem: boolean;
5051
protected contextMenu: ContextMenu|null;
5152
protected idInternal: number|undefined;
5253
customElement?: Element;
@@ -65,6 +66,7 @@ export class Item {
6566
this.accelerator = accelerator;
6667
this.disabled = disabled;
6768
this.checked = checked;
69+
this.isDevToolsPerformanceMenuItem = false;
6870
this.contextMenu = contextMenu;
6971
this.idInternal = undefined;
7072
this.#tooltip = tooltip;
@@ -119,6 +121,9 @@ export class Item {
119121
}
120122
if (this.accelerator) {
121123
result.accelerator = this.accelerator;
124+
if (this.isDevToolsPerformanceMenuItem) {
125+
result.isDevToolsPerformanceMenuItem = true;
126+
}
122127
}
123128
return result;
124129
}
@@ -157,6 +162,13 @@ export class Item {
157162
this.accelerator = {keyCode: key.code, modifiers: modifierSum};
158163
}
159164

165+
// This influences whether accelerators will be shown for native menus on Mac.
166+
// Use this ONLY for performance menus and ONLY where accelerators are critical
167+
// for a smooth user journey and heavily context dependent.
168+
setIsDevToolsPerformanceMenuItem(isDevToolsPerformanceMenuItem: boolean): void {
169+
this.isDevToolsPerformanceMenuItem = isDevToolsPerformanceMenuItem;
170+
}
171+
160172
setShortcut(shortcut: string): void {
161173
this.shortcut = shortcut;
162174
}
@@ -331,6 +343,7 @@ export class SubMenu extends Item {
331343
type: 'subMenu',
332344
label: this.label,
333345
accelerator: this.accelerator,
346+
isDevToolsPerformanceMenuItem: this.accelerator ? this.isDevToolsPerformanceMenuItem : undefined,
334347
isExperimentalFeature: this.previewFeature,
335348
enabled: !this.disabled,
336349
subItems: [],

front_end/ui/legacy/SoftContextMenu.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ export interface SoftContextMenuDescriptor {
644644
isExperimentalFeature?: boolean;
645645
enabled?: boolean;
646646
checked?: boolean;
647+
isDevToolsPerformanceMenuItem?: boolean;
647648
subItems?: SoftContextMenuDescriptor[];
648649
element?: Element;
649650
shortcut?: string;

0 commit comments

Comments
 (0)