Skip to content

Commit c4b03eb

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Continue updating vertical timestamp marker when mouse down
The vertical timestamp line that aligns the mouse cursor over the minimap with a position in the flame chart was not updating when the mouse was held down. This made it difficult to select an exact end position relative to something visible in the chart. The fix was to not use mousemove, which doesn't fire during drag, and instead use pointermove. Also, capture the pointer during this interaction and hide the overview info pane until the interaction ends. Fixed: 393411231 Change-Id: I1218213a706593e06f36726ab7089c0ce86cfd6e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6217297 Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Connor Clark <[email protected]> Auto-Submit: Connor Clark <[email protected]>
1 parent 43fda93 commit c4b03eb

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

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

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
5656
private windowStartTime = Trace.Types.Timing.Milli(0);
5757
private windowEndTime = Trace.Types.Timing.Milli(Infinity);
5858
private muteOnWindowChanged = false;
59+
private hasPointer = false;
5960
#dimHighlightSVG: Element;
6061
readonly #boundOnThemeChanged = this.#onThemeChanged.bind(this);
6162

@@ -70,8 +71,11 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
7071
this.element.appendChild(this.overviewGrid.element);
7172
this.cursorArea = this.overviewGrid.element.createChild('div', 'overview-grid-cursor-area');
7273
this.cursorElement = this.overviewGrid.element.createChild('div', 'overview-grid-cursor-position');
73-
this.cursorArea.addEventListener('mousemove', this.onMouseMove.bind(this), true);
74-
this.cursorArea.addEventListener('mouseleave', this.hideCursor.bind(this), true);
74+
this.cursorArea.addEventListener('pointerdown', this.onMouseDown.bind(this), true);
75+
this.cursorArea.addEventListener('pointerup', this.onMouseCancel.bind(this), true);
76+
this.cursorArea.addEventListener('pointercancel', this.onMouseCancel.bind(this), true);
77+
this.cursorArea.addEventListener('pointermove', this.onMouseMove.bind(this), true);
78+
this.cursorArea.addEventListener('pointerleave', this.hideCursor.bind(this), true);
7579

7680
this.overviewGrid.setResizeEnabled(false);
7781
this.overviewGrid.addEventListener(OverviewGridEvents.WINDOW_CHANGED_WITH_POSITION, this.onWindowChanged, this);
@@ -86,8 +90,31 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
8690

8791
enableCreateBreadcrumbsButton(): void {
8892
const breadcrumbsElement = this.overviewGrid.enableCreateBreadcrumbsButton();
89-
breadcrumbsElement.addEventListener('mousemove', this.onMouseMove.bind(this), true);
90-
breadcrumbsElement.addEventListener('mouseleave', this.hideCursor.bind(this), true);
93+
breadcrumbsElement.addEventListener('pointerdown', this.onMouseDown.bind(this), true);
94+
breadcrumbsElement.addEventListener('pointerup', this.onMouseCancel.bind(this), true);
95+
breadcrumbsElement.addEventListener('pointercancel', this.onMouseCancel.bind(this), true);
96+
breadcrumbsElement.addEventListener('pointermove', this.onMouseMove.bind(this), true);
97+
breadcrumbsElement.addEventListener('pointerleave', this.hideCursor.bind(this), true);
98+
}
99+
100+
private onMouseDown(event: PointerEvent): void {
101+
if (!(event.target instanceof HTMLElement)) {
102+
return;
103+
}
104+
105+
event.target.setPointerCapture(event.pointerId);
106+
this.overviewInfo.hide();
107+
this.hasPointer = true;
108+
}
109+
110+
private onMouseCancel(event: PointerEvent): void {
111+
if (!(event.target instanceof HTMLElement)) {
112+
return;
113+
}
114+
115+
event.target.releasePointerCapture(event.pointerId);
116+
this.overviewInfo.show();
117+
this.hasPointer = false;
91118
}
92119

93120
private onMouseMove(event: Event): void {
@@ -114,7 +141,9 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
114141
this.dispatchEventToListeners(Events.OVERVIEW_PANE_MOUSE_LEAVE);
115142
}
116143

117-
void this.overviewInfo.setContent(this.buildOverviewInfo());
144+
if (!this.hasPointer) {
145+
void this.overviewInfo.setContent(this.buildOverviewInfo());
146+
}
118147
}
119148

120149
private async buildOverviewInfo(): Promise<DocumentFragment> {
@@ -564,4 +593,9 @@ export class OverviewInfo {
564593
this.visible = false;
565594
this.glassPane.hide();
566595
}
596+
597+
show(): void {
598+
this.visible = true;
599+
this.glassPane.show(window.document);
600+
}
567601
}

0 commit comments

Comments
 (0)