Skip to content

Commit d706f5d

Browse files
committed
Add removeAllOverlays to TimelineFlameChartView
This is to help clearing all overlays and also removing dimming
1 parent ff14d4d commit d706f5d

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
lines changed

front_end/panels/timeline/TimelineFlameChartView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
733733
this.bulkAddOverlays(this.#markers);
734734
}
735735

736+
removeAllOverlays(): void {
737+
this.setActiveInsight(null);
738+
}
739+
736740
setOverlays(overlays: Overlays.Overlays.TimelineOverlay[], options: Overlays.Overlays.TimelineOverlaySetOptions):
737741
void {
738742
this.bulkRemoveOverlays(this.#currentInsightOverlays);

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ import {IsolateSelector} from './IsolateSelector.js';
6767
import {AnnotationModifiedEvent, ModificationsManager} from './ModificationsManager.js';
6868
import * as Overlays from './overlays/overlays.js';
6969
import {cpuprofileJsonGenerator, traceJsonGenerator} from './SaveFileFormatter.js';
70-
7170
import type {Client, TimelineController} from './TimelineController.js';
7271
import type {TimelineFlameChartDataProvider} from './TimelineFlameChartDataProvider.js';
7372
import {Events as TimelineFlameChartViewEvents, TimelineFlameChartView} from './TimelineFlameChartView.js';
@@ -152,10 +151,6 @@ const UIStrings = {
152151
*@description Text in Timeline Panel of the Performance panel
153152
*/
154153
processed: 'Processed',
155-
/**
156-
*@description Text to close something
157-
*/
158-
close: 'Close',
159154
/**
160155
*@description Text to download the trace file after an error
161156
*/
@@ -228,37 +223,25 @@ const UIStrings = {
228223
*/
229224
eventSelected: 'Event {PH1} selected',
230225
/**
231-
*@description Text of a hyperlink to documentation.
232-
*/
233-
learnMore: 'Learn more',
234-
/**
235-
* @description Tooltip text for a button that takes the user back to the default view which shows performance metrics that are live.
226+
* @description Description of the Timeline up/down scroll action that appears in the Performance panel shortcuts dialog.
236227
*/
237-
backToLiveMetrics: 'Go back to the live metrics page',
228+
timelineScrollUpDown: 'Move up/down',
238229
/**
239-
* @description Description of the Timeline up/down scroll action that appears in the Performance panel shortcuts dialog.
230+
* @description Description of the Timeline left/right panning action that appears in the Performance panel shortcuts dialog.
240231
*/
241-
timelineScrollUpDown: 'Move up/down',
232+
timelinePanLeftRight: 'Move left/right',
242233
/**
243-
* @description Description of the Timeline left/right panning action that appears in the Performance panel shortcuts dialog.
234+
* @description Description of the Timeline in/out zoom action that appears in the Performance panel shortcuts dialog.
244235
*/
245-
timelinePanLeftRight: 'Move left/right',
236+
timelineZoomInOut: 'Zoom in/out',
246237
/**
247-
* @description Description of the Timeline in/out zoom action that appears in the Performance panel shortcuts dialog.
248-
*/
249-
timelineZoomInOut: 'Zoom in/out',
250-
/**
251-
* @description Description of the Timeline fast in/out zoom action that appears in the Performance panel shortcuts dialog.
238+
* @description Description of the Timeline fast in/out zoom action that appears in the Performance panel shortcuts dialog.
252239
*/
253240
timelineFastZoomInOut: 'Fast zoom in/out',
254241
/**
255242
* @description Title for the Dim 3rd Parties checkbox.
256243
*/
257244
dimThirdParties: 'Dim 3rd parties',
258-
/**
259-
* @description Description for the Dim 3rd Parties checkbox tooltip describing how 3rd parties are classified.
260-
*/
261-
thirdPartiesByThirdPartyWeb: '3rd parties classified by third-party-web',
262245
};
263246
const str_ = i18n.i18n.registerUIStrings('panels/timeline/TimelinePanel.ts', UIStrings);
264247
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -694,6 +677,10 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
694677
})());
695678
});
696679

680+
document.getElementById('-blink-dev-tools')?.addEventListener(ClearActiveOverlaysEvent.eventName, () => {
681+
this.#clearActiveOverlays();
682+
});
683+
697684
this.#sideBar.element.addEventListener(TimelineComponents.Sidebar.RemoveAnnotation.eventName, event => {
698685
const {removedAnnotation} = (event as TimelineComponents.Sidebar.RemoveAnnotation);
699686
ModificationsManager.activeManager()?.removeAnnotation(removedAnnotation);
@@ -768,6 +755,10 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
768755
this.flameChart.setOverlays(overlays, {updateTraceWindow: true});
769756
}
770757

758+
#clearActiveOverlays(): void {
759+
this.flameChart.removeAllOverlays();
760+
}
761+
771762
/**
772763
* This "disables" the 3P checkbox in the toolbar.
773764
* Disabling here does a couple of things:
@@ -2827,33 +2818,37 @@ export const enum Events {
28272818
HighlightEntries = 'highlightentries',
28282819
HighlightLCPImageWithDelay = 'highlightlcpimagewithdelay',
28292820
ShowThirdParties = 'showthirdparties',
2821+
ClearActiveOverlays = 'clearactiveoverlays',
28302822
}
28312823

2832-
export type EventTypes = {
2824+
export interface EventTypes {
28332825
[Events.RawTraceDataLoaded]: {
28342826
rawTraceData: Blob | string | null,
2835-
},
2827+
};
28362828
[Events.LoadTraceFile]: {
28372829
blob: Blob,
2838-
},
2830+
};
28392831
[Events.HighlightLCPImageWithDelay]: {
28402832
navigationId: string,
28412833
entry: {
28422834
entry: Trace.Types.Events.Event,
28432835
start: Trace.Types.Timing.Micro,
28442836
end: Trace.Types.Timing.Micro,
28452837
},
2846-
},
2838+
};
28472839
[Events.HighlightEntries]: {
28482840
navigationId: string,
28492841
entries: Array<Trace.Types.File.EntryLabelAnnotation>,
2850-
},
2842+
};
28512843
[Events.ShowThirdParties]: {
28522844
navigationId: string,
28532845
filterByThirdParty?: string,
28542846
filterByTimestamp?: number,
2855-
},
2856-
};
2847+
};
2848+
[Events.ClearActiveOverlays]: {
2849+
navigationId: string,
2850+
};
2851+
}
28572852

28582853
export class OpenTraceFileEvent extends CustomEvent<Events.OpenTraceFile> {
28592854
static readonly eventName = Events.OpenTraceFile;
@@ -2921,6 +2916,14 @@ export class ShowThirdPartiesEvent extends CustomEvent<EventTypes[Events.ShowThi
29212916
}
29222917
}
29232918

2919+
export class ClearActiveOverlaysEvent extends CustomEvent<EventTypes[Events.ClearActiveOverlays]> {
2920+
static readonly eventName = Events.ClearActiveOverlays;
2921+
2922+
constructor(options: EventTypes[Events.ClearActiveOverlays]) {
2923+
super(ClearActiveOverlaysEvent.eventName, { detail: options });
2924+
}
2925+
}
2926+
29242927
export class StatusPane extends UI.Widget.VBox {
29252928
private status: HTMLElement;
29262929
private time: Element|undefined;

0 commit comments

Comments
 (0)