Skip to content

Commit c399bd0

Browse files
Adriana IxbaDevtools-frontend LUCI CQ
authored andcommitted
[RPP]: Add focus button for multi navigation traces
This adds a button to the navigations that when clicked, adjusts the tracebounds of the given navigation. http://screencast/cast/NTUzMTI0OTkyMDcwNDUxMnw4MDdjZjAyYy0xMQ Bug:372858594 Change-Id: I7562a95342a558151b772c697a125ccb96d63f40 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5936136 Commit-Queue: Adriana Ixba <[email protected]> Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Paul Irish <[email protected]>
1 parent a561611 commit c399bd0

File tree

7 files changed

+87
-2
lines changed

7 files changed

+87
-2
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ grd_files_release_sources = [
6060
"front_end/Images/bundle.svg",
6161
"front_end/Images/button-magic.svg",
6262
"front_end/Images/calendar-today.svg",
63+
"front_end/Images/center-focus-weak.svg",
6364
"front_end/Images/check-circle.svg",
6465
"front_end/Images/check-double.svg",
6566
"front_end/Images/checker.svg",

config/gni/devtools_image_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ devtools_svg_sources = [
6767
"bundle.svg",
6868
"button-magic.svg",
6969
"calendar-today.svg",
70+
"center-focus-weak.svg",
7071
"check-circle.svg",
7172
"check-double.svg",
7273
"checker.svg",
Lines changed: 1 addition & 0 deletions
Loading

front_end/panels/timeline/TimelinePanel.ts

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

608+
this.#sideBar.element.addEventListener(TimelineInsights.SidebarInsight.InsightSetZoom.eventName, event => {
609+
TraceBounds.TraceBounds.BoundsManager.instance().setTimelineVisibleWindow(
610+
event.bounds, {ignoreMiniMapBounds: true, shouldAnimate: true});
611+
});
612+
608613
this.onModeChanged();
609614
this.populateToolbar();
610615
// The viewMode is set by default to the landing page, so we don't call

front_end/panels/timeline/components/SidebarInsightsTab.ts

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,52 @@ export class SidebarInsightsTab extends HTMLElement {
132132
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(FEEDBACK_URL);
133133
}
134134

135+
#onZoomClick(event: Event, id: string): void {
136+
event.stopPropagation();
137+
const data = this.#insights?.get(id);
138+
if (!data) {
139+
return;
140+
}
141+
this.dispatchEvent(new Insights.SidebarInsight.InsightSetZoom(data.bounds));
142+
}
143+
144+
#renderZoomButton(insightSetToggled: boolean): LitHtml.TemplateResult {
145+
const classes = LitHtml.Directives.classMap({
146+
'zoom-icon': true,
147+
active: insightSetToggled,
148+
});
149+
150+
// clang-format off
151+
return html`
152+
<div class=${classes}>
153+
<devtools-button .data=${{
154+
variant: Buttons.Button.Variant.ICON,
155+
iconName: 'center-focus-weak',
156+
size: Buttons.Button.Size.SMALL,
157+
} as Buttons.Button.ButtonData}
158+
></devtools-button></div>`;
159+
// clang-format on
160+
}
161+
162+
#renderDropdownIcon(insightSetToggled: boolean): LitHtml.TemplateResult {
163+
const containerClasses = LitHtml.Directives.classMap({
164+
'dropdown-icon': true,
165+
active: insightSetToggled,
166+
});
167+
168+
// clang-format off
169+
return html`
170+
<div class=${containerClasses}>
171+
<devtools-button .data=${{
172+
variant: Buttons.Button.Variant.ICON,
173+
iconName: 'chevron-right',
174+
size: Buttons.Button.Size.SMALL,
175+
} as Buttons.Button.ButtonData}
176+
></devtools-button></div>
177+
`;
178+
// clang-format on
179+
}
180+
135181
#render(): void {
136182
if (!this.#parsedTrace || !this.#insights) {
137183
LitHtml.render(LitHtml.nothing, this.#shadow, {host: this});
@@ -168,8 +214,11 @@ export class SidebarInsightsTab extends HTMLElement {
168214
@click=${() => this.#insightSetToggled(id)}
169215
@mouseenter=${() => this.#insightSetHovered(id)}
170216
@mouseleave=${() => this.#insightSetUnhovered()}
171-
title=${url.href}
172-
>${labels[index]}</summary>
217+
title=${url.href}>
218+
${this.#renderDropdownIcon(id === this.#insightSetKey)}
219+
<span>${labels[index]}</span>
220+
<span class='zoom-button' @click=${(event: Event) => this.#onZoomClick(event, id)}>${this.#renderZoomButton(id === this.#insightSetKey)}</span>
221+
</summary>
173222
${contents}
174223
</details>`;
175224
}

front_end/panels/timeline/components/insights/SidebarInsight.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ export class InsightSetHovered extends Event {
7070
}
7171
}
7272

73+
export class InsightSetZoom extends Event {
74+
static readonly eventName = 'insightsetzoom';
75+
constructor(public bounds: Trace.Types.Timing.TraceWindowMicroSeconds) {
76+
super(InsightSetZoom.eventName, {bubbles: true, composed: true});
77+
}
78+
}
79+
7380
export class InsightProvideOverlays extends Event {
7481
static readonly eventName = 'insightprovideoverlays';
7582

@@ -94,6 +101,7 @@ declare global {
94101
[InsightActivated.eventName]: InsightActivated;
95102
[InsightDeactivated.eventName]: InsightDeactivated;
96103
[InsightSetHovered.eventName]: InsightSetHovered;
104+
[InsightSetZoom.eventName]: InsightSetZoom;
97105
[InsightProvideOverlays.eventName]: InsightProvideOverlays;
98106
[InsightProvideRelatedEvents.eventName]: InsightProvideRelatedEvents;
99107
}

front_end/panels/timeline/components/sidebarInsightsTab.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
text-overflow: ellipsis;
3333
white-space: nowrap;
3434
font: var(--sys-typescale-body4-medium);
35+
display: flex;
36+
align-items: center;
3537

3638
&:focus {
3739
background-color: var(--sys-color-tonal-container);
@@ -47,6 +49,24 @@
4749
details:first-child & {
4850
border-top: 1px solid var(--sys-color-divider);
4951
}
52+
}
53+
}
54+
55+
.zoom-button {
56+
margin-left: auto;
57+
}
58+
59+
.zoom-icon {
60+
visibility: hidden;
61+
62+
&.active devtools-button {
63+
visibility: visible;
64+
}
65+
}
66+
67+
.dropdown-icon {
68+
&.active devtools-button {
69+
transform: rotate(90deg);
5070
}
5171
}
5272

0 commit comments

Comments
 (0)