Skip to content

Commit 6e220c0

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Add scroll on 'Shift + Up/Down keys' and zoom on '+/-'
Those Shortcuts were initially proposed for the ‘Modern’ navigation only, however there is no reason to not also make them work with the ‘Classic’ navigation. Therefore, this cl adds them to both navigation options. Bug: 313757601 Change-Id: Id13fc93f220c4fe2d539a7b12284eb014b7ea5d4 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6063882 Reviewed-by: Jack Franklin <[email protected]> Commit-Queue: Jack Franklin <[email protected]> Auto-Submit: Alina Varkki <[email protected]>
1 parent 39884c0 commit 6e220c0

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,8 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11391139
#getShortcutsInfo(isNavClassic: boolean): Dialogs.ShortcutDialog.Shortcut[] {
11401140
if (isNavClassic) {
11411141
return [
1142-
{title: i18nString(UIStrings.timelineScrollUpDown), bindings: [['Shift', 'Scroll']]},
1143-
{title: i18nString(UIStrings.timelineZoomInOut), bindings: [['Scroll'], ['W/S']]},
1142+
{title: i18nString(UIStrings.timelineScrollUpDown), bindings: [['Shift', 'Scroll'], ['Shift', '↑/↓']]},
1143+
{title: i18nString(UIStrings.timelineZoomInOut), bindings: [['Scroll'], ['W/S'], ['+/-']]},
11441144
{title: i18nString(UIStrings.timelineFastZoomInOut), bindings: [['Shift', 'W/S']]},
11451145
{title: i18nString(UIStrings.timelinePanLeftRight), bindings: [['A/D']]},
11461146
];
@@ -1155,7 +1155,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11551155
{title: i18nString(UIStrings.timelineFastZoomInOut), bindings: [['Shift', 'W/S'], ['Shift', '+/-']]},
11561156
{
11571157
title: i18nString(UIStrings.timelinePanLeftRight),
1158-
bindings: [['A/D'], ['Shift', 'Scroll'], ['Shift', '←/→']],
1158+
bindings: [['Shift', 'Scroll'], ['Shift', '←/→'], ['A/D']],
11591159
},
11601160
];
11611161
}

front_end/ui/legacy/components/perf_ui/ChartViewport.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,42 +364,52 @@ export class ChartViewport extends UI.Widget.VBox {
364364
this.cursorElement.classList.toggle('hidden', !visible || this.isDraggingInternal);
365365
}
366366

367-
private onChartKeyDown(e: Event): void {
368-
const mouseEvent = (e as MouseEvent);
369-
this.showCursor(mouseEvent.shiftKey);
370-
this.handleZoomPanKeys(e);
367+
private onChartKeyDown(keyboardEvent: KeyboardEvent): void {
368+
this.showCursor(keyboardEvent.shiftKey);
369+
this.handleZoomPanScrollKeys(keyboardEvent);
371370
}
372371

373-
private onChartKeyUp(e: Event): void {
374-
const mouseEvent = (e as MouseEvent);
375-
this.showCursor(mouseEvent.shiftKey);
372+
private onChartKeyUp(keyboardEvent: KeyboardEvent): void {
373+
this.showCursor(keyboardEvent.shiftKey);
376374
}
377375

378-
private handleZoomPanKeys(e: Event): void {
379-
const keyboardEvent = (e as KeyboardEvent);
380-
// Do not zoom if the key combination has any modifiers other than shift key
381-
if (UI.KeyboardShortcut.KeyboardShortcut.hasAtLeastOneModifier(e) && !keyboardEvent.shiftKey) {
376+
private handleZoomPanScrollKeys(keyboardEvent: KeyboardEvent): void {
377+
// Do not zoom, pan or scroll if the key combination has any modifiers other than shift key
378+
if (UI.KeyboardShortcut.KeyboardShortcut.hasAtLeastOneModifier(keyboardEvent) && !keyboardEvent.shiftKey) {
382379
return;
383380
}
384381
const zoomFactor = keyboardEvent.shiftKey ? 0.8 : 0.3;
385382
const panOffset = keyboardEvent.shiftKey ? 320 : 160;
383+
const scrollOffset = 50;
386384
switch (keyboardEvent.code) {
387385
case 'KeyA':
388386
this.handlePanGesture(-panOffset, /* animate */ true);
389387
break;
390388
case 'KeyD':
391389
this.handlePanGesture(panOffset, /* animate */ true);
392390
break;
391+
case 'Equal': // '+' key for zoom in
393392
case 'KeyW':
394393
this.handleZoomGesture(-zoomFactor);
395394
break;
395+
case 'Minus': // '-' key for zoom out
396396
case 'KeyS':
397397
this.handleZoomGesture(zoomFactor);
398398
break;
399+
case 'ArrowUp':
400+
if (keyboardEvent.shiftKey) {
401+
this.vScrollElement.scrollTop -= scrollOffset;
402+
}
403+
break;
404+
case 'ArrowDown':
405+
if (keyboardEvent.shiftKey) {
406+
this.vScrollElement.scrollTop += scrollOffset;
407+
}
408+
break;
399409
default:
400410
return;
401411
}
402-
e.consume(true);
412+
keyboardEvent.consume(true);
403413
}
404414

405415
private handleZoomGesture(zoom: number): void {

0 commit comments

Comments
 (0)