33 */
44
55import { getParentByClassName } from "../../helpers/dom" ;
6+ import { push } from "../../helpers/icons" ;
67import * as misc from "../../helpers/misc" ;
78import * as svg from "../../helpers/svg" ;
89import { timingTypeToCssClass } from "../../transformers/styling-converters" ;
910import { RectData } from "../../typing/rect-data" ;
10- import { WaterfallEntryTiming } from "../../typing/waterfall" ;
11+ import { WaterfallEntry , WaterfallEntryTiming } from "../../typing/waterfall" ;
1112import {
1213 onHoverInShowTooltip ,
1314 onHoverOutShowTooltip ,
@@ -105,14 +106,45 @@ function createTimingLabel(rectData: RectData, timeTotal: number, firstX: number
105106 return txtEl ;
106107}
107108
109+ 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 ) ;
122+
123+ return el ;
124+ }
125+
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+
108139/**
109140 * Render the block and timings for a request
110141 * @param {RectData } rectData Basic dependencys and globals
111- * @param {WaterfallEntryTiming[] } segments Request and Timing Data
112- * @param {number } timeTotal - total time of the request
113- * @return {SVGElement } Renerated SVG (rect or g element)
142+ * @param {WaterfallEntry } entry Request Details, e.g. Request and Timing Data
143+ * @return {SVGElement } Renerated SVG (rect or g element)
114144 */
115- export function createRect ( rectData : RectData , segments : WaterfallEntryTiming [ ] , timeTotal : number ) : SVGElement {
145+ export function createRect ( rectData : RectData , entry : WaterfallEntry ) : SVGElement {
146+ // entry.responseDetails.indicators;
147+ const segments = entry . segments ;
116148 const rect = makeBlock ( rectData , `time-block ${ rectData . cssClass } ` ) ;
117149 const rectHolder = svg . newG ( "rect-holder" ) ;
118150 let firstX = rectData . x ;
@@ -129,7 +161,10 @@ export function createRect(rectData: RectData, segments: WaterfallEntryTiming[],
129161 }
130162 } ) ;
131163
132- rectHolder . appendChild ( createTimingLabel ( rectData , timeTotal , firstX ) ) ;
164+ if ( misc . find ( entry . responseDetails . indicators , ( indicator ) => indicator . id === "push" ) ) {
165+ rectHolder . appendChild ( createPushIndicator ( rectData ) ) ;
166+ }
167+ rectHolder . appendChild ( createTimingLabel ( rectData , entry . total , firstX ) ) ;
133168 }
134169
135170 return rectHolder ;
0 commit comments