@@ -31,7 +31,14 @@ import {
3131import { TimelineFlameChartNetworkDataProvider } from './TimelineFlameChartNetworkDataProvider.js' ;
3232import timelineFlameChartViewStyles from './timelineFlameChartView.css.js' ;
3333import type { TimelineModeViewDelegate } from './TimelinePanel.js' ;
34- import { TimelineSelection } from './TimelineSelection.js' ;
34+ import {
35+ rangeForSelection ,
36+ selectionFromEvent ,
37+ selectionFromRangeMilliSeconds ,
38+ selectionIsEvent ,
39+ selectionIsRange ,
40+ type TimelineSelection ,
41+ } from './TimelineSelection.js' ;
3542import { AggregatedTimelineTreeView } from './TimelineTreeView.js' ;
3643import type { TimelineMarkerStyle } from './TimelineUIUtils.js' ;
3744
@@ -607,7 +614,7 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
607614 let startTime = visibleWindow . min ;
608615 // Prefer the start time of the selected event, if there is one.
609616 if ( this . #currentSelection) {
610- startTime = Trace . Helpers . Timing . millisecondsToMicroseconds ( this . #currentSelection. startTime ) ;
617+ startTime = rangeForSelection ( this . #currentSelection) . min ;
611618 }
612619 this . #createNewTimeRangeFromKeyboard(
613620 startTime , Trace . Types . Timing . MicroSeconds ( startTime + timeRangeIncrementValue ) ) ;
@@ -808,7 +815,9 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
808815 * TODO(crbug.com/346312365): update the type definitions in ChartViewport.ts
809816 */
810817 updateRangeSelection ( startTime : number , endTime : number ) : void {
811- this . delegate . select ( TimelineSelection . fromRange ( startTime , endTime ) ) ;
818+ this . delegate . select ( selectionFromRangeMilliSeconds (
819+ Trace . Types . Timing . MilliSeconds ( startTime ) , Trace . Types . Timing . MilliSeconds ( endTime ) ) ) ;
820+
812821 if ( Root . Runtime . experiments . isEnabled ( Root . Runtime . ExperimentName . TIMELINE_ANNOTATIONS ) ) {
813822 const bounds = Trace . Helpers . Timing . traceWindowFromMilliSeconds (
814823 Trace . Types . Timing . MilliSeconds ( startTime ) ,
@@ -1008,8 +1017,7 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
10081017 }
10091018
10101019 highlightEvent ( event : Trace . Types . Events . Event | null ) : void {
1011- const entryIndex =
1012- event ? this . mainDataProvider . entryIndexForSelection ( TimelineSelection . fromTraceEvent ( event ) ) : - 1 ;
1020+ const entryIndex = event ? this . mainDataProvider . entryIndexForSelection ( selectionFromEvent ( event ) ) : - 1 ;
10131021 if ( entryIndex >= 0 ) {
10141022 this . mainFlameChart . highlightEntry ( entryIndex ) ;
10151023 } else {
@@ -1075,8 +1083,8 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
10751083 // AND 2. we have an active time range selection overlay
10761084 // AND 3. The label of the selection is empty
10771085 // then we need to remove it.
1078- if ( ( selection === null || ! TimelineSelection . isRangeSelection ( selection . object ) ) &&
1079- this . #timeRangeSelectionAnnotation && ! this . #timeRangeSelectionAnnotation. label ) {
1086+ if ( ( selection === null || ! selectionIsRange ( selection ) ) && this . #timeRangeSelectionAnnotation &&
1087+ ! this . #timeRangeSelectionAnnotation. label ) {
10801088 ModificationsManager . activeManager ( ) ?. removeAnnotation ( this . #timeRangeSelectionAnnotation) ;
10811089 this . #timeRangeSelectionAnnotation = null ;
10821090 }
@@ -1090,14 +1098,11 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
10901098 void this . detailsView . setSelection ( selection ) ;
10911099 }
10921100
1093- // Create the entry selected overlay if the selection represents a frame or trace event (either network, or anything else)
1094- if ( selection &&
1095- ( TimelineSelection . isTraceEventSelection ( selection . object ) ||
1096- TimelineSelection . isSyntheticNetworkRequestDetailsEventSelection ( selection . object ) ||
1097- TimelineSelection . isLegacyTimelineFrame ( selection . object ) ) ) {
1101+ // Create the entry selected overlay if the selection represents a trace event
1102+ if ( selectionIsEvent ( selection ) ) {
10981103 this . addOverlay ( {
10991104 type : 'ENTRY_SELECTED' ,
1100- entry : selection . object ,
1105+ entry : selection . event ,
11011106 } ) ;
11021107 }
11031108
@@ -1151,14 +1156,11 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
11511156 dataProvider : TimelineFlameChartDataProvider | TimelineFlameChartNetworkDataProvider ,
11521157 event : Common . EventTarget . EventTargetEvent < { entryIndex : number , withLinkCreationButton : boolean } > ) : void {
11531158 const selection = dataProvider . createSelection ( event . data . entryIndex ) ;
1154- if ( selection &&
1155- ( TimelineSelection . isTraceEventSelection ( selection . object ) ||
1156- TimelineSelection . isSyntheticNetworkRequestDetailsEventSelection ( selection . object ) ||
1157- TimelineSelection . isLegacyTimelineFrame ( selection . object ) ) ) {
1159+ if ( selectionIsEvent ( selection ) ) {
11581160 this . setSelectionAndReveal ( selection ) ;
11591161 ModificationsManager . activeManager ( ) ?. createAnnotation ( {
11601162 type : 'ENTRY_LABEL' ,
1161- entry : selection . object ,
1163+ entry : selection . event ,
11621164 label : '' ,
11631165 } ) ;
11641166 if ( event . data . withLinkCreationButton ) {
@@ -1187,22 +1189,9 @@ export class TimelineFlameChartView extends UI.Widget.VBox implements PerfUI.Fla
11871189
11881190 #selectionIfTraceEvent(
11891191 index : number , dataProvider : TimelineFlameChartDataProvider | TimelineFlameChartNetworkDataProvider ) :
1190- Trace . Types . Events . Event | Trace . Types . Events . SyntheticNetworkRequest | null {
1192+ Trace . Types . Events . Event | null {
11911193 const selection = dataProvider . createSelection ( index ) ;
1192- if ( ! selection ) {
1193- return null ;
1194- }
1195-
1196- if ( TimelineSelection . isTraceEventSelection ( selection . object ) ||
1197- TimelineSelection . isSyntheticNetworkRequestDetailsEventSelection ( selection . object ) ) {
1198- return selection . object ;
1199- }
1200-
1201- if ( TimelineSelection . isLegacyTimelineFrame ( selection . object ) ) {
1202- return selection . object as Trace . Types . Events . LegacyTimelineFrame ;
1203- }
1204-
1205- return null ;
1194+ return selectionIsEvent ( selection ) ? selection . event : null ;
12061195 }
12071196
12081197 /**
0 commit comments