Skip to content

Commit 7a1610b

Browse files
author
Michael Mrowetz
committed
show http2-push arrow inline and not as icon
1 parent 8121b25 commit 7a1610b

File tree

6 files changed

+23
-40
lines changed

6 files changed

+23
-40
lines changed

src/ts/helpers/icons.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,3 @@ export function audio(x: number, y: number, title: string, scale: number = 1): S
237237
}
238238
return wrapSvgIcon(x, y, title, "icon-audio", scale, audioIconLazy.cloneNode(false) as SVGPathElement);
239239
}
240-
241-
let pushIconLazy: SVGPathElement;
242-
export function push(x: number | string, y: number, title: string, scale: number = 1): SVGElement {
243-
if (pushIconLazy === undefined) {
244-
const d = `M14.668 9q0 .416-.285.7L9.37 14.716Q9.067 15 8.667 15q-.393 0-.694-.285l-.577
245-
-.578q-.293-.292-.293-.7 0-.41.293-.7l2.256-2.258H4.23q-.4 0-.65-.29t-.25-.698v-.986q0-.408.25
246-
-.697.25-.29.65-.29h5.423L7.397 5.257q-.293-.278-.293-.693 0-.416.293-.694l.577-.576Q8.267 3 8.668
247-
3q.408 0 .7.293l5.015 5.014q.285.27.285.693z`;
248-
pushIconLazy = svgLib.newPath(d);
249-
}
250-
return wrapSvgIcon(x, y, title, "icon-push", scale, pushIconLazy.cloneNode(false) as SVGPathElement);
251-
}

src/ts/transformers/har-heuristics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType:
9191
if (isPush(entry)) {
9292
output.push({
9393
description: "Response was pushed by the server using HTTP2 push.",
94+
displayType: "inline",
9495
icon: "push",
9596
id: "push",
9697
title: "Response was pushed by the server",
@@ -101,6 +102,7 @@ export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType:
101102
if (docIsTLS && !isSecure(entry)) {
102103
output.push({
103104
description: "Insecure request, it should use HTTPS.",
105+
displayType: "icon",
104106
id: "noTls",
105107
title: "Insecure Connection",
106108
type: "error",
@@ -110,6 +112,7 @@ export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType:
110112
if (hasCacheIssue(entry)) {
111113
output.push({
112114
description: "The response is not allow to be cached on the client. Consider setting 'Cache-Control' headers.",
115+
displayType: "icon",
113116
id: "noCache",
114117
title: "Response not cached",
115118
type: "error",
@@ -119,6 +122,7 @@ export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType:
119122
if (hasCompressionIssue(entry, requestType)) {
120123
output.push({
121124
description: "The response is not compressed. Consider enabling HTTP compression on your server.",
125+
displayType: "icon",
122126
id: "noGzip",
123127
title: "no gzip",
124128
type: "error",
@@ -130,6 +134,7 @@ export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType:
130134
entry.response.status !== 204) {
131135
output.push({
132136
description: "Response doesn't contain a 'Content-Type' header.",
137+
displayType: "icon",
133138
id: "warning",
134139
title: "No MIME Type defined",
135140
type: "warning",

src/ts/typing/waterfall.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export type RequestType = "other" | "image" | "video" | "audio" | "font" | "svg"
44

55
export type IndicatorType = "error" | "warning" | "info";
66

7+
export type IndicatorDisplayType = "icon" | "inline";
8+
79
/** Typing for a event, e.g. UserTiming API performance mark from WPT */
810
export interface UserTiming {
911
duration?: number;
@@ -62,6 +64,8 @@ export interface WaterfallEntryIndicator {
6264
description: string;
6365
/** catrgorizes the indicator */
6466
type: IndicatorType;
67+
/** where to show the indicator, defaults to `"icon"` */
68+
displayType: IndicatorDisplayType;
6569
}
6670

6771
/** Time segment of an `WaterfallEntry` */

src/ts/waterfall/row/svg-indicators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function makeIcon(type: string, title: string): Icon {
1919
* @returns {Icon[]}
2020
*/
2121
export function getIndicatorIcons(entry: WaterfallEntry): Icon[] {
22-
const indicators = entry.responseDetails.indicators;
22+
const indicators = entry.responseDetails.indicators.filter((i) => i.displayType === "icon");
2323
if (indicators.length === 0) {
2424
return [];
2525
}

src/ts/waterfall/row/svg-row-subcomponents.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import { getParentByClassName } from "../../helpers/dom";
6-
import { push } from "../../helpers/icons";
76
import * as misc from "../../helpers/misc";
87
import * as svg from "../../helpers/svg";
98
import { timingTypeToCssClass } from "../../transformers/styling-converters";
@@ -107,35 +106,22 @@ function createTimingLabel(rectData: RectData, timeTotal: number, firstX: number
107106
}
108107

109108
function createPushIndicator(rectData: RectData): SVGElement {
110-
const scale = 0.6;
111-
const iconNaturalSize = 12; // default svg size (12px)
112-
const y = rectData.y + ((rectData.height - 4 - (iconNaturalSize * scale)) / 2);
113-
const percStart = (rectData.x + rectData.width) / rectData.unit;
114-
const iconEl = push(`${misc.roundNumber(percStart)}%`, y, "Http2 Push", scale);
115-
116-
const el = svg.newG(`push-inline-wrap`, {
117-
transform: `translate(-${rectData.height / 2})`,
118-
}, {
119-
fillOpacity: "0.5",
120-
});
121-
el.appendChild(iconEl);
109+
const y = rectData.y + rectData.height / 1.5;
110+
const x = `${misc.roundNumber(rectData.x / rectData.unit)}%`;
111+
const el = svg.newG("http2-inidicator-holder");
112+
el.appendChild(svg.newTextEl("→", {
113+
transform: `translate(-5)`,
114+
x,
115+
y,
116+
}, {
117+
"fillOpacity": "0.6",
118+
"text-anchor": "end",
119+
}));
120+
el.appendChild(svg.newTitle("http2 Push"));
122121

123122
return el;
124123
}
125124

126-
// function createPushIndicator(rectData: RectData): SVGElement {
127-
// const y = rectData.y + rectData.height / 1.5;
128-
// const x = `${misc.roundNumber(rectData.x / rectData.unit)}%`;
129-
// return svg.newTextEl("→", {
130-
// transform: `translate(-5)`,
131-
// x,
132-
// y,
133-
// }, {
134-
// "fillOpacity": "0.5",
135-
// "text-anchor": "end",
136-
// });
137-
// }
138-
139125
/**
140126
* Render the block and timings for a request
141127
* @param {RectData} rectData Basic dependencys and globals

src/ts/waterfall/svg-chart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function createWaterfallSvg(data: WaterfallData, options: ChartRenderOpti
129129

130130
if (options.showIndicatorIcons) {
131131
const iconsPerBlock = entriesToShow.map((entry: WaterfallEntry) =>
132-
entry.responseDetails.indicators.length > 0 ? 1 : 0);
132+
entry.responseDetails.indicators.filter((i) => i.displayType === "icon").length > 0 ? 1 : 0);
133133
maxIcons += Math.max.apply(null, iconsPerBlock);
134134
}
135135

0 commit comments

Comments
 (0)