Skip to content

Commit efd1ad5

Browse files
Nancy LiDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Change the name of CursorTimestampMarker to TimestampMarker
We can reuse the same overlay in the bi-directional hovering feature, rename to make it more clear Bug: 376659383 Change-Id: Ibfe08ceb8632230b244903453fbcd672c8fd4796 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5987921 Reviewed-by: Jack Franklin <[email protected]> Commit-Queue: Nancy Li <[email protected]>
1 parent 67d4aec commit efd1ad5

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

front_end/panels/timeline/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ To remove one or some overlays, check out the `remove()` or `removeOverlaysOfTyp
100100

101101
### Creating a new overlay
102102

103-
To create a new overlay, first define its type. This is done as an interface, and must contain a `type` field.
103+
To create a new overlay, add it in the `OverlaysImpl.ts` file, first define its type. This is done as an interface, and must contain a `type` field.
104104

105105
All other fields are completely custom and depend on the specifics of the overlay.
106106

@@ -115,6 +115,7 @@ export interface EntrySelected {
115115
```
116116

117117
Once you have done this, add the interface to the union type `TimelineOverlay`. This will likely trigger some TypeScript errors because there are some places in the code where we check we have exhaustively dealt with every possible overlay type.
118+
Also if you want to make this overlay a singleton, add the interface to the union type `SingletonOverlay`.
118119

119120
When you create an overlay by default it will be created as a `div` with a class, and no contents. Sometimes this is all you need (for example, the `ENTRY_SELECTED` outline has no other HTML), but if you need more you can tell the Overlays class what DOM to create for your overlay. To do this, modify the `#createElementForNewOverlay` method. You will see examples there of how we use custom elements to build out overlays.
120121

front_end/panels/timeline/TimelineFlameChartView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
528528
const {mouseEvent, timeInMicroSeconds} = data;
529529
// If the user is no longer holding shift, remove any existing marker.
530530
if (!mouseEvent.shiftKey) {
531-
const removedCount = this.#overlays.removeOverlaysOfType('CURSOR_TIMESTAMP_MARKER');
531+
const removedCount = this.#overlays.removeOverlaysOfType('TIMESTAMP_MARKER');
532532
if (removedCount > 0) {
533533
// Don't trigger lots of updates on a mouse move if we didn't actually
534534
// remove any overlays.
@@ -537,10 +537,10 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
537537
}
538538

539539
if (!mouseEvent.metaKey && mouseEvent.shiftKey) {
540-
// CURSOR_TIMESTAMP_MARKER is a singleton; if one already exists it will
540+
// TIMESTAMP_MARKER is a singleton; if one already exists it will
541541
// be updated rather than create an entirely new one.
542542
this.addOverlay({
543-
type: 'CURSOR_TIMESTAMP_MARKER',
543+
type: 'TIMESTAMP_MARKER',
544544
timestamp: timeInMicroSeconds,
545545
});
546546
}

front_end/panels/timeline/overlays/OverlaysImpl.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ describeWithEnvironment('Overlays', () => {
398398
assert.isOk(overlayDOM);
399399
});
400400

401-
it('only renders one CURSOR_TIMESTAMP_MARKER as it is a singleton', async function() {
401+
it('only renders one TIMESTAMP_MARKER as it is a singleton', async function() {
402402
const {parsedTrace} = await TraceLoader.traceEngine(this, 'web-dev.json.gz');
403403
const {overlays, container} = setupChartWithDimensionsAndAnnotationOverlayListeners(parsedTrace);
404404
overlays.add({
405-
type: 'CURSOR_TIMESTAMP_MARKER',
405+
type: 'TIMESTAMP_MARKER',
406406
timestamp: parsedTrace.Meta.traceBounds.min,
407407
});
408408
overlays.add({
409-
type: 'CURSOR_TIMESTAMP_MARKER',
409+
type: 'TIMESTAMP_MARKER',
410410
timestamp: parsedTrace.Meta.traceBounds.max,
411411
});
412412
await overlays.update();
@@ -979,8 +979,8 @@ describeWithEnvironment('Overlays', () => {
979979
});
980980

981981
it('defines a log for cursor timestamp marker', () => {
982-
const overlay: Overlays.Overlays.CursorTimestampMarker = {
983-
type: 'CURSOR_TIMESTAMP_MARKER',
982+
const overlay: Overlays.Overlays.TimestampMarker = {
983+
type: 'TIMESTAMP_MARKER',
984984
timestamp: 1_000 as Trace.Types.Timing.MicroSeconds,
985985
};
986986
const context = Overlays.Overlays.jsLogContext(overlay);

front_end/panels/timeline/overlays/OverlaysImpl.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function traceWindowForOverlay(overlay: TimelineOverlay): Trace.Types.Timing.Tra
155155
}
156156
break;
157157
}
158-
case 'CURSOR_TIMESTAMP_MARKER': {
158+
case 'TIMESTAMP_MARKER': {
159159
overlayMinBounds.push(overlay.timestamp);
160160
break;
161161
}
@@ -212,7 +212,8 @@ export function entriesForOverlay(overlay: TimelineOverlay): readonly OverlayEnt
212212
}
213213
break;
214214
}
215-
case 'CURSOR_TIMESTAMP_MARKER': {
215+
case 'TIMESTAMP_MARKER': {
216+
// This overlay type isn't associated to any entry, so just break here.
216217
break;
217218
}
218219
case 'CANDY_STRIPED_TIME_RANGE': {
@@ -255,16 +256,16 @@ export interface TimespanBreakdown {
255256
renderLocation?: 'BOTTOM_OF_TIMELINE'|'BELOW_EVENT'|'ABOVE_EVENT';
256257
}
257258

258-
export interface CursorTimestampMarker {
259-
type: 'CURSOR_TIMESTAMP_MARKER';
259+
export interface TimestampMarker {
260+
type: 'TIMESTAMP_MARKER';
260261
timestamp: Trace.Types.Timing.MicroSeconds;
261262
}
262263

263264
/**
264265
* All supported overlay types.
265266
*/
266267
export type TimelineOverlay = EntrySelected|EntryOutline|TimeRangeLabel|EntryLabel|EntriesLink|TimespanBreakdown|
267-
CursorTimestampMarker|CandyStripedTimeRange;
268+
TimestampMarker|CandyStripedTimeRange;
268269

269270
export interface TimelineOverlaySetOptions {
270271
updateTraceWindow: boolean;
@@ -275,9 +276,9 @@ export interface TimelineOverlaySetOptions {
275276
* exist at any given time. If one exists and the add() method is called, the
276277
* new overlay will replace the existing one.
277278
*/
278-
type SingletonOverlay = EntrySelected|CursorTimestampMarker;
279+
type SingletonOverlay = EntrySelected|TimestampMarker;
279280
export function overlayIsSingleton(overlay: TimelineOverlay): overlay is SingletonOverlay {
280-
return overlay.type === 'CURSOR_TIMESTAMP_MARKER' || overlay.type === 'ENTRY_SELECTED';
281+
return overlay.type === 'TIMESTAMP_MARKER' || overlay.type === 'ENTRY_SELECTED';
281282
}
282283

283284
/**
@@ -790,7 +791,7 @@ export class Overlays extends EventTarget {
790791
break;
791792
}
792793

793-
case 'CURSOR_TIMESTAMP_MARKER': {
794+
case 'TIMESTAMP_MARKER': {
794795
const {visibleWindow} = this.#dimensions.trace;
795796
// Only update the position if the timestamp of this marker is within
796797
// the visible bounds.
@@ -827,7 +828,7 @@ export class Overlays extends EventTarget {
827828
}
828829
}
829830

830-
#positionTimestampMarker(overlay: CursorTimestampMarker, element: HTMLElement): void {
831+
#positionTimestampMarker(overlay: TimestampMarker, element: HTMLElement): void {
831832
// Because we are adjusting the x position, we can use either chart here.
832833
const x = this.#xPixelForMicroSeconds('main', overlay.timestamp);
833834
element.style.left = `${x}px`;
@@ -1470,7 +1471,7 @@ export class Overlays extends EventTarget {
14701471
}
14711472
break;
14721473
}
1473-
case 'CURSOR_TIMESTAMP_MARKER':
1474+
case 'TIMESTAMP_MARKER':
14741475
break;
14751476
case 'CANDY_STRIPED_TIME_RANGE':
14761477
break;
@@ -1504,7 +1505,7 @@ export class Overlays extends EventTarget {
15041505
component?.checkSectionLabelPositioning();
15051506
break;
15061507
}
1507-
case 'CURSOR_TIMESTAMP_MARKER':
1508+
case 'TIMESTAMP_MARKER':
15081509
break;
15091510
case 'CANDY_STRIPED_TIME_RANGE':
15101511
break;
@@ -1830,7 +1831,7 @@ export function jsLogContext(overlay: TimelineOverlay): string|null {
18301831
case 'TIMESPAN_BREAKDOWN': {
18311832
return 'timeline.overlays.timespan-breakdown';
18321833
}
1833-
case 'CURSOR_TIMESTAMP_MARKER': {
1834+
case 'TIMESTAMP_MARKER': {
18341835
return 'timeline.overlays.cursor-timestamp-marker';
18351836
}
18361837
case 'CANDY_STRIPED_TIME_RANGE': {

front_end/panels/timeline/timelineFlameChartView.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
}
112112
}
113113

114-
.overlay-type-CURSOR_TIMESTAMP_MARKER {
114+
.overlay-type-TIMESTAMP_MARKER {
115115
top: 0;
116116
bottom: 0;
117117
width: 2px;

0 commit comments

Comments
 (0)