@@ -329,6 +329,10 @@ const UIStrings = {
329329 * @description Description of the Timeline right/left panning action that appears in the Performance panel shortcuts dialog.
330330 */
331331 timelinePanLeftRight : 'Timeline right/left' ,
332+ /**
333+ * @description Title for the Dim 3rd Parties checkbox.
334+ */
335+ dimThirdParties : 'Dim 3rd Parties' ,
332336} ;
333337const str_ = i18n . i18n . registerUIStrings ( 'panels/timeline/TimelinePanel.ts' , UIStrings ) ;
334338const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
@@ -374,6 +378,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
374378 private readonly timelinePane : UI . Widget . VBox ;
375379 readonly #minimapComponent = new TimelineMiniMap ( ) ;
376380 #viewMode: ViewMode = { mode : 'LANDING_PAGE' } ;
381+ readonly #dimThirdPartiesSetting: Common . Settings . Setting < boolean > | null = null ;
377382
378383 /**
379384 * We get given any filters for a new trace when it is recorded/imported.
@@ -424,6 +429,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
424429
425430 #traceEngineModel: Trace . TraceModel . Model ;
426431 #sourceMapsResolver: Utils . SourceMapsResolver . SourceMapsResolver | null = null ;
432+ #entityMapper: Utils . EntityMapper . EntityMapper | null = null ;
427433 #onSourceMapsNodeNamesResolvedBound = this . #onSourceMapsNodeNamesResolved. bind ( this ) ;
428434 readonly #onChartPlayableStateChangeBound: ( event : Common . EventTarget . EventTargetEvent < boolean > ) => void ;
429435 #sidebarToggleButton = this . #splitWidget. createShowHideSidebarButton (
@@ -533,6 +539,13 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
533539 this . showMemorySetting . setTitle ( i18nString ( UIStrings . memory ) ) ;
534540 this . showMemorySetting . addChangeListener ( this . onMemoryModeChanged , this ) ;
535541
542+ if ( Root . Runtime . experiments . isEnabled ( Root . Runtime . ExperimentName . TIMELINE_THIRD_PARTY_DEPENDENCIES ) ) {
543+ this . #dimThirdPartiesSetting =
544+ Common . Settings . Settings . instance ( ) . createSetting ( 'timeline-dim-third-parties' , false ) ;
545+ this . #dimThirdPartiesSetting. setTitle ( i18nString ( UIStrings . dimThirdParties ) ) ;
546+ this . #dimThirdPartiesSetting. addChangeListener ( this . onDimThirdPartiesChanged , this ) ;
547+ }
548+
536549 this . #thirdPartyTracksSetting = TimelinePanel . extensionDataVisibilitySetting ( ) ;
537550 this . #thirdPartyTracksSetting. addChangeListener ( this . #extensionDataVisibilityChanged, this ) ;
538551 this . #thirdPartyTracksSetting. setTitle ( i18nString ( UIStrings . showCustomtracks ) ) ;
@@ -879,6 +892,7 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
879892 this . #setModelForActiveTrace( ) ;
880893 this . #removeStatusPane( ) ;
881894 this . #showSidebarIfRequired( ) ;
895+ this . #dimThirdPartiesIfRequired( newMode . traceIndex ) ;
882896 return ;
883897 }
884898
@@ -1106,6 +1120,13 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
11061120 this . panelToolbar . appendToolbarItem ( new UI . Toolbar . ToolbarItem ( showIgnoreListSetting ) ) ;
11071121 }
11081122
1123+ if ( Root . Runtime . experiments . isEnabled ( Root . Runtime . ExperimentName . TIMELINE_THIRD_PARTY_DEPENDENCIES ) &&
1124+ this . #dimThirdPartiesSetting) {
1125+ const dimThirdPartiesCheckbox =
1126+ this . createSettingCheckbox ( this . #dimThirdPartiesSetting, i18nString ( UIStrings . dimThirdParties ) ) ;
1127+ this . panelToolbar . appendToolbarItem ( dimThirdPartiesCheckbox ) ;
1128+ }
1129+
11091130 // Isolate selector
11101131 if ( isNode ) {
11111132 const isolateSelector = new IsolateSelector ( ) ;
@@ -1491,6 +1512,13 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
14911512 this . select ( null ) ;
14921513 }
14931514
1515+ private onDimThirdPartiesChanged ( ) : void {
1516+ if ( this . #viewMode. mode !== 'VIEWING_TRACE' ) {
1517+ return ;
1518+ }
1519+ this . #dimThirdPartiesIfRequired( this . #viewMode. traceIndex ) ;
1520+ }
1521+
14941522 #extensionDataVisibilityChanged( ) : void {
14951523 this . flameChart . extensionDataVisibilityChanged ( ) ;
14961524 }
@@ -2002,6 +2030,9 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
20022030 Utils . SourceMapsResolver . SourceMappingsUpdated . eventName , this . #onSourceMapsNodeNamesResolvedBound) ;
20032031 void this . #sourceMapsResolver. install ( ) ;
20042032
2033+ // Initialize EntityMapper
2034+ this . #entityMapper = new Utils . EntityMapper . EntityMapper ( parsedTrace ) ;
2035+
20052036 this . statusPane ?. updateProgressBar ( i18nString ( UIStrings . processed ) , 80 ) ;
20062037 this . updateMiniMap ( ) ;
20072038 this . statusPane ?. updateProgressBar ( i18nString ( UIStrings . processed ) , 90 ) ;
@@ -2085,6 +2116,20 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
20852116 this . #restoreSidebarVisibilityOnTraceLoad = false ;
20862117 }
20872118
2119+ #dimThirdPartiesIfRequired( traceIndex : number ) : void {
2120+ const parsedTrace = this . #traceEngineModel. parsedTrace ( traceIndex ) ;
2121+ if ( ! parsedTrace ) {
2122+ return ;
2123+ }
2124+ const thirdPartyEvents = this . #entityMapper?. thirdPartyEvents ( ) ?? [ ] ;
2125+ if ( this . #dimThirdPartiesSetting?. get ( ) && thirdPartyEvents . length ) {
2126+ this . flameChart . dimEvents ( thirdPartyEvents ) ;
2127+ } else {
2128+ // Ensure dimming stores are cleared, and there is no dimming.
2129+ this . flameChart . disableAllDimming ( ) ;
2130+ }
2131+ }
2132+
20882133 // Build a map mapping annotated entries to the colours that are used to display them in the FlameChart.
20892134 // We need this map to display the entries in the sidebar with the same colours.
20902135 private buildColorsAnnotationsMap ( annotations : Trace . Types . File . Annotation [ ] ) : Map < Trace . Types . Events . Event , string > {
0 commit comments