Skip to content

Commit 77ad71a

Browse files
Nancy LiDevtools-frontend LUCI CQ
authored andcommitted
[RPP Insight] Add the visual effect when hovering the last network request of a chain
This CL add these effect only when hovering the last network request of a chain - Highlight the chain in the sidebar - Only highlight the requests in the chain in network flame chart There is no change for those non-last requests. Bug: 372897712 Change-Id: Ic87205d580071c65c97f723eb6afbbf2449654d6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6298131 Reviewed-by: Jack Franklin <[email protected]> Commit-Queue: Nancy Li <[email protected]>
1 parent cea485a commit 77ad71a

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

front_end/models/trace/insights/NetworkDependencyTree.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ describeWithEnvironment('NetworkDependencyTree', function() {
5959
// The |app.css| is not in the longest chain
6060
assert.isNotTrue(child0.isLongest);
6161
});
62+
63+
it('Store the chain in the last request of the chain', async () => {
64+
const root = insight.rootNodes[0];
65+
const [child0, child1] = root.children;
66+
67+
// There are three chains from Lantern:
68+
// |index.html(root)|
69+
// |index.html(root) -> app.css(child0)|
70+
// |index.html(root) -> app.js(child1)|
71+
assert.deepEqual(root.chain, [root.request]);
72+
assert.deepEqual(child0.chain, [root.request, child0.request]);
73+
assert.deepEqual(child1.chain, [root.request, child1.request]);
74+
});
6275
});

front_end/models/trace/insights/NetworkDependencyTree.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface CriticalRequestNode {
5656
timeFromInitialRequest: Types.Timing.Micro;
5757
children: CriticalRequestNode[];
5858
isLongest?: boolean;
59+
chain?: Types.Events.SyntheticNetworkRequest[];
5960
}
6061

6162
export type NetworkDependencyTreeInsightModel = InsightModel<typeof UIStrings, {
@@ -155,6 +156,11 @@ export function generateInsight(
155156
};
156157
currentNodes.push(found);
157158
}
159+
160+
if (networkRequest === lastRequest) {
161+
found.chain = path;
162+
}
163+
158164
currentNodes = found.children;
159165
}
160166
}

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export class NetworkDependencyTree extends BaseInsightComponent<NetworkDependenc
2828
static override readonly litTagName = Lit.StaticHtml.literal`devtools-performance-long-critical-network-tree`;
2929
override internalName = 'long-critical-network-tree';
3030

31+
hoveredChain: Trace.Types.Events.SyntheticNetworkRequest[] = [];
32+
3133
override connectedCallback(): void {
3234
super.connectedCallback();
3335
this.shadow.adoptedStyleSheets.push(networkDependencyTreeInsightComponentStyles);
@@ -44,24 +46,53 @@ export class NetworkDependencyTree extends BaseInsightComponent<NetworkDependenc
4446
return overlays;
4547
}
4648

49+
#createOverlayForChain(chain: Trace.Types.Events.SyntheticNetworkRequest[]): Overlays.Overlays.EntryOutline[] {
50+
return chain.map(entry => ({
51+
type: 'ENTRY_OUTLINE',
52+
entry,
53+
outlineReason: 'ERROR',
54+
}));
55+
}
56+
57+
#onMouseOver(chain: Trace.Types.Events.SyntheticNetworkRequest[]|undefined): void {
58+
this.hoveredChain = chain ?? [];
59+
const overlays = this.#createOverlayForChain(this.hoveredChain);
60+
this.toggleTemporaryOverlays(overlays, {
61+
// The trace window doesn't need to be updated because the request is being hovered.
62+
updateTraceWindow: false,
63+
});
64+
this.scheduleRender();
65+
}
66+
67+
#onMouseOut(): void {
68+
this.hoveredChain = [];
69+
this.toggleTemporaryOverlays(null, {
70+
updateTraceWindow: false,
71+
});
72+
this.scheduleRender();
73+
}
74+
4775
renderTree(nodes: CriticalRequestNode[]): Lit.LitTemplate|null {
4876
if (nodes.length === 0) {
4977
return null;
5078
}
5179
// clang-format off
5280
return html`
5381
<ul>
54-
${nodes.map(({request, timeFromInitialRequest, children, isLongest}) => {
82+
${nodes.map(({request, timeFromInitialRequest, children, isLongest, chain}) => {
5583
const hasChildren = children.length > 0;
5684
5785
const requestClasses = Lit.Directives.classMap({
5886
request: true,
5987
longest: Boolean(isLongest),
88+
highlighted: this.hoveredChain.includes(request),
6089
});
6190
6291
return html`
6392
<li>
64-
<div class=${requestClasses}>
93+
<div class=${requestClasses}
94+
@mouseover=${hasChildren ? null : this.#onMouseOver.bind(this, chain)}
95+
@mouseout=${hasChildren ? null : this.#onMouseOut.bind(this)}>
6596
<span class="url">${eventRef(request)}</span>
6697
${
6798
// If this is the last request, show the chain time

front_end/panels/timeline/components/insights/networkDependencyTreeInsight.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
color: var(--sys-color-error);
4242
}
4343

44+
&.highlighted {
45+
background-color: var(--sys-color-state-hover-on-subtle);
46+
}
47+
4448
.url {
4549
flex: auto;
4650
}

0 commit comments

Comments
 (0)