Skip to content

Commit d593a7b

Browse files
Nancy LiDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Update the initiator when an entry is revealed
Bug: none Change-Id: I3bb4b7e1d3d4665b560e97a0ccd7d0a74d44d32b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6280787 Reviewed-by: Adam Raine <[email protected]> Commit-Queue: Nancy Li <[email protected]>
1 parent 9a5496d commit d593a7b

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

front_end/panels/timeline/TimelineFlameChartView.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
1717

1818
import {getAnnotationEntries, getAnnotationWindow} from './AnnotationHelpers.js';
1919
import type * as TimelineComponents from './components/components.js';
20+
import * as TimelineInsights from './components/insights/insights.js';
2021
import {CountersGraph} from './CountersGraph.js';
2122
import {SHOULD_SHOW_EASTER_EGG} from './EasterEgg.js';
2223
import {ModificationsManager} from './ModificationsManager.js';
@@ -410,12 +411,19 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
410411
this.updateLinkSelectionAnnotationWithToEntry(this.networkDataProvider, event.data);
411412
}, this);
412413

414+
// This listener is used for timings marker, when they are clicked, open the details view for them. They are
415+
// rendered in the overlays system, not in flame chart (canvas), so need this extra handling.
413416
this.#overlays.addEventListener(Overlays.Overlays.EventReferenceClick.eventName, event => {
414417
const eventRef = (event as Overlays.Overlays.EventReferenceClick);
415418
const fromTraceEvent = selectionFromEvent(eventRef.event);
416419
this.openSelectionDetailsView(fromTraceEvent);
417420
});
418421

422+
// This is for the detail view of layout shift.
423+
this.element.addEventListener(TimelineInsights.EventRef.EventReferenceClick.eventName, event => {
424+
this.setSelectionAndReveal(selectionFromEvent(event.event));
425+
});
426+
419427
this.element.addEventListener('keydown', this.#keydownHandler.bind(this));
420428
this.element.addEventListener('pointerdown', this.#pointerDownHandler.bind(this));
421429
this.#boundRefreshAfterIgnoreList = this.#refreshAfterIgnoreList.bind(this);
@@ -1361,10 +1369,6 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
13611369

13621370
setSelectionAndReveal(selection: TimelineSelection|null): void {
13631371
this.#currentSelection = selection;
1364-
const mainIndex = this.mainDataProvider.entryIndexForSelection(selection);
1365-
const networkIndex = this.networkDataProvider.entryIndexForSelection(selection);
1366-
this.mainFlameChart.setSelectedEntry(mainIndex);
1367-
this.networkFlameChart.setSelectedEntry(networkIndex);
13681372

13691373
// Clear any existing entry selection.
13701374
this.#overlays.removeOverlaysOfType('ENTRY_SELECTED');
@@ -1379,10 +1383,17 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
13791383
this.#timeRangeSelectionAnnotation = null;
13801384
}
13811385

1382-
let index = this.mainDataProvider.entryIndexForSelection(selection);
1383-
this.mainFlameChart.setSelectedEntry(index);
1384-
index = this.networkDataProvider.entryIndexForSelection(selection);
1385-
this.networkFlameChart.setSelectedEntry(index);
1386+
// Check if this is an entry from main flame chart or network flame chart.
1387+
// If so build the initiators and select the entry.
1388+
// Otherwise clear the initiators and the selection.
1389+
// - This is done by the same functions, when the index is -1, it will clear everything.
1390+
const mainIndex = this.mainDataProvider.entryIndexForSelection(selection);
1391+
this.mainDataProvider.buildFlowForInitiator(mainIndex);
1392+
this.mainFlameChart.setSelectedEntry(mainIndex);
1393+
const networkIndex = this.networkDataProvider.entryIndexForSelection(selection);
1394+
this.networkDataProvider.buildFlowForInitiator(networkIndex);
1395+
this.networkFlameChart.setSelectedEntry(networkIndex);
1396+
13861397
if (this.detailsView) {
13871398
// TODO(crbug.com/1459265): Change to await after migration work.
13881399
void this.detailsView.setSelection(selection);

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,6 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
660660
}
661661
});
662662

663-
this.flameChart.element.addEventListener(TimelineInsights.EventRef.EventReferenceClick.eventName, event => {
664-
const fromTraceEvent = selectionFromEvent(event.event);
665-
this.flameChart.setSelectionAndReveal(fromTraceEvent);
666-
});
667-
668663
this.#sideBar.contentElement.addEventListener(TimelineInsights.EventRef.EventReferenceClick.eventName, event => {
669664
this.select(selectionFromEvent(event.event));
670665
});

0 commit comments

Comments
 (0)