Skip to content

Commit efbc447

Browse files
Nancy LiDevtools-frontend LUCI CQ
authored andcommitted
[RPP bi-direction hover] Dimming the time marker outside the highlight bounds
Fixed: 377902632 Change-Id: Id10baa34d6794a697820a8686042c49bddf14129 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6032065 Commit-Queue: Paul Irish <[email protected]> Reviewed-by: Paul Irish <[email protected]>
1 parent 565718c commit efbc447

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

front_end/panels/timeline/TimelineMiniMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class TimelineMiniMap extends
240240
}
241241

242242
#setMarkers(parsedTrace: Trace.Handlers.Types.ParsedTrace): void {
243-
const markers = new Map<number, Element>();
243+
const markers = new Map<number, HTMLDivElement>();
244244

245245
const {Meta, PageLoadMetrics} = parsedTrace;
246246

front_end/panels/timeline/TimelineUIUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,7 @@ export class TimelineUIUtils {
21802180
return stylesContainer;
21812181
}
21822182

2183-
static createEventDivider(event: Trace.Types.Events.Event, zeroTime: number): Element {
2183+
static createEventDivider(event: Trace.Types.Events.Event, zeroTime: number): HTMLDivElement {
21842184
const eventDivider = document.createElement('div');
21852185
eventDivider.classList.add('resources-event-divider');
21862186
const {startTime: eventStartTime} = Trace.Helpers.Timing.eventTimingsMilliSeconds(event);

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
4545
private readonly cursorArea: HTMLElement;
4646
private cursorElement: HTMLElement;
4747
private overviewControls: TimelineOverview[];
48-
private markers: Map<number, Element>;
48+
private markers: Map<number, HTMLDivElement>;
4949
private readonly overviewInfo: OverviewInfo;
5050
private readonly updateThrottler: Common.Throttler.Throttler;
5151
private cursorEnabled: boolean;
@@ -209,14 +209,33 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
209209
this.updateWindow();
210210
}
211211

212-
setMarkers(markers: Map<number, Element>): void {
212+
setMarkers(markers: Map<number, HTMLDivElement>): void {
213213
this.markers = markers;
214214
}
215215

216-
getMarkers(): Map<number, Element> {
216+
getMarkers(): Map<number, HTMLDivElement> {
217217
return this.markers;
218218
}
219219

220+
/**
221+
* Dim the time marker outside the highlight time bounds.
222+
*
223+
* @param highlightBounds the time bounds to highlight, if it is empty, it means to highlight everything.
224+
*/
225+
#dimMarkers(highlightBounds?: Trace.Types.Timing.TraceWindowMicroSeconds): void {
226+
for (const time of this.markers.keys()) {
227+
const marker = this.markers.get(time);
228+
if (!marker) {
229+
continue;
230+
}
231+
const timeInMicroSeconds = Trace.Helpers.Timing.millisecondsToMicroseconds(Trace.Types.Timing.MilliSeconds(time));
232+
const dim = highlightBounds && !Trace.Helpers.Timing.timestampIsInBounds(highlightBounds, timeInMicroSeconds);
233+
234+
// `filter: grayscale(1)` will make the element fully completely grayscale.
235+
marker.style.filter = `grayscale(${dim ? 1 : 0})`;
236+
}
237+
}
238+
220239
private updateMarkers(): void {
221240
const filteredMarkers = new Map<number, Element>();
222241
for (const time of this.markers.keys()) {
@@ -383,7 +402,7 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
383402
highlightBounds(bounds: Trace.Types.Timing.TraceWindowMicroSeconds, withBracket: boolean): void {
384403
const left = this.overviewCalculator.computePosition(Trace.Helpers.Timing.microSecondsToMilliseconds(bounds.min));
385404
const right = this.overviewCalculator.computePosition(Trace.Helpers.Timing.microSecondsToMilliseconds(bounds.max));
386-
405+
this.#dimMarkers(bounds);
387406
// Update the punch out rectangle to the not-to-desaturate time range.
388407
const punchRect = this.#dimHighlightSVG.querySelector('rect.punch');
389408
punchRect?.setAttribute('x', left.toString());
@@ -399,6 +418,7 @@ export class TimelineOverviewPane extends Common.ObjectWrapper.eventMixin<EventT
399418
}
400419

401420
clearBoundsHighlight(): void {
421+
this.#dimMarkers();
402422
this.#dimHighlightSVG.classList.add('hidden');
403423
}
404424
}

0 commit comments

Comments
 (0)