Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js

Issue 2523633003: [Devtools] Prepare network log view for grouping support (Closed)
Patch Set: changes Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Network.NetworkWaterfallColumn = class extends UI.VBox { 7 Network.NetworkWaterfallColumn = class extends UI.VBox {
8 /** 8 /**
9 * @param {number} rowHeight 9 * @param {number} rowHeight
10 * @param {!Network.NetworkTimeCalculator} calculator 10 * @param {!Network.NetworkTimeCalculator} calculator
(...skipping 16 matching lines...) Expand all
27 this._rightPadding = 0; 27 this._rightPadding = 0;
28 28
29 this._rowHeight = rowHeight; 29 this._rowHeight = rowHeight;
30 this._headerHeight = 0; 30 this._headerHeight = 0;
31 this._calculator = calculator; 31 this._calculator = calculator;
32 32
33 this._popoverHelper = new UI.PopoverHelper(this.element); 33 this._popoverHelper = new UI.PopoverHelper(this.element);
34 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t his._showPopover.bind(this)); 34 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this), t his._showPopover.bind(this));
35 this._popoverHelper.setTimeout(300, 300); 35 this._popoverHelper.setTimeout(300, 300);
36 36
37 /** @type {!Array<!Network.NetworkLogEntry>} */ 37 /** @type {!Array<!Network.NetworkDataGridNode>} */
38 this._logEntries = []; 38 this._nodes = [];
39 39
40 /** @type {?Network.NetworkLogEntry} */ 40 /** @type {?Network.NetworkDataGridNode} */
41 this._hoveredLogEntry = null; 41 this._hoveredNode = null;
42 /** @type {?SDK.NetworkRequest.InitiatorGraph} */ 42 /** @type {?SDK.NetworkRequest.InitiatorGraph} */
43 this._initiatorGraph = null; 43 this._initiatorGraph = null;
44 44
45 /** @type {!Map<string, !Array<number>>} */ 45 /** @type {!Map<string, !Array<number>>} */
46 this._eventDividers = new Map(); 46 this._eventDividers = new Map();
47 47
48 var colorUsage = UI.ThemeSupport.ColorUsage; 48 var colorUsage = UI.ThemeSupport.ColorUsage;
49 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs age.Background); 49 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs age.Background);
50 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back ground); 50 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back ground);
51 this._rowHoverColor = UI.themeSupport.patchColor( 51 this._rowHoverColor = UI.themeSupport.patchColor(
(...skipping 20 matching lines...) Expand all
72 wasShown() { 72 wasShown() {
73 this.update(); 73 this.update();
74 } 74 }
75 75
76 /** 76 /**
77 * @param {!Element} element 77 * @param {!Element} element
78 * @param {!Event} event 78 * @param {!Event} event
79 * @return {!AnchorBox|undefined} 79 * @return {!AnchorBox|undefined}
80 */ 80 */
81 _getPopoverAnchor(element, event) { 81 _getPopoverAnchor(element, event) {
82 if (!this._hoveredLogEntry) 82 var request = this._hoveredNode ? this._hoveredNode.request() : null;
83 if (!this._hoveredNode || !request)
dgozman 2016/11/30 00:25:26 Just !request
allada 2016/11/30 01:38:24 Done.
83 return; 84 return;
84 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g et() && !this._calculator.startAtZero; 85 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g et() && !this._calculator.startAtZero;
85 if (useTimingBars) { 86 if (useTimingBars) {
86 var range = Network.RequestTimingView.calculateRequestTimeRanges(this._hov eredLogEntry.request(), 0) 87 var range = Network.RequestTimingView.calculateRequestTimeRanges(request, 0)
87 .find(data => data.name === Network.RequestTimeRangeNames. Total); 88 .find(data => data.name === Network.RequestTimeRangeNames. Total);
88 var start = this._timeToPosition(range.start); 89 var start = this._timeToPosition(range.start);
89 var end = this._timeToPosition(range.end); 90 var end = this._timeToPosition(range.end);
90 } else { 91 } else {
91 var range = this._getSimplifiedBarRange(this._hoveredLogEntry, 0); 92 var range = this._getSimplifiedBarRange(request, 0);
92 var start = range.start; 93 var start = range.start;
93 var end = range.end; 94 var end = range.end;
94 } 95 }
95 96
96 if (end - start < 50) { 97 if (end - start < 50) {
97 var halfWidth = (end - start) / 2; 98 var halfWidth = (end - start) / 2;
98 start = start + halfWidth - 25; 99 start = start + halfWidth - 25;
99 end = end - halfWidth + 25; 100 end = end - halfWidth + 25;
100 } 101 }
101 102
102 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi s._canvasPosition.left + end) 103 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi s._canvasPosition.left + end)
103 return; 104 return;
104 105
105 var rowIndex = this._logEntries.findIndex(logEntry => this._hoveredLogEntry === logEntry); 106 var rowIndex = this._nodes.findIndex(node => this._hoveredNode === node);
106 var barHeight = this._getBarHeight(range.name); 107 var barHeight = this._getBarHeight(range.name);
107 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop) + ((this._rowHeight - barHeight) / 2); 108 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop) + ((this._rowHeight - barHeight) / 2);
108 109
109 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca nvasPosition.top + y + barHeight) 110 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca nvasPosition.top + y + barHeight)
110 return; 111 return;
111 112
112 var anchorBox = this.element.boxInWindow(); 113 var anchorBox = this.element.boxInWindow();
113 anchorBox.x += start; 114 anchorBox.x += start;
114 anchorBox.y += y; 115 anchorBox.y += y;
115 anchorBox.width = end - start; 116 anchorBox.width = end - start;
116 anchorBox.height = barHeight; 117 anchorBox.height = barHeight;
117 return anchorBox; 118 return anchorBox;
118 } 119 }
119 120
120 /** 121 /**
121 * @param {!Element|!AnchorBox} anchor 122 * @param {!Element|!AnchorBox} anchor
122 * @param {!UI.Popover} popover 123 * @param {!UI.Popover} popover
123 */ 124 */
124 _showPopover(anchor, popover) { 125 _showPopover(anchor, popover) {
125 if (!this._hoveredLogEntry) 126 var request = this._hoveredNode ? this._hoveredNode.request() : null;
127 if (!request)
126 return; 128 return;
127 var content = Network.RequestTimingView.createTimingTable( 129 var content = Network.RequestTimingView.createTimingTable(request, this._cal culator.minimumBoundary());
128 this._hoveredLogEntry.request(), this._calculator.minimumBoundary());
129 popover.showForAnchor(content, anchor); 130 popover.showForAnchor(content, anchor);
130 } 131 }
131 132
132 /** 133 /**
133 * @param {?Network.NetworkLogEntry} logEntry 134 * @param {?Network.NetworkDataGridNode} node
134 * @param {boolean} highlightInitiatorChain 135 * @param {boolean} highlightInitiatorChain
135 */ 136 */
136 setHoveredLogEntry(logEntry, highlightInitiatorChain) { 137 setHoveredNode(node, highlightInitiatorChain) {
137 this._hoveredLogEntry = logEntry; 138 this._hoveredNode = node;
138 this._initiatorGraph = (highlightInitiatorChain && logEntry) ? logEntry.requ est().initiatorGraph() : null; 139 this._initiatorGraph = null;
140 var request = node ? node.request() : null;
141 if (highlightInitiatorChain && request)
142 this._initiatorGraph = request.initiatorGraph();
139 this.update(); 143 this.update();
140 } 144 }
141 145
142 /** 146 /**
143 * @param {number} height 147 * @param {number} height
144 */ 148 */
145 setRowHeight(height) { 149 setRowHeight(height) {
146 this._rowHeight = height; 150 this._rowHeight = height;
147 } 151 }
148 152
(...skipping 15 matching lines...) Expand all
164 /** 168 /**
165 * @param {!Network.NetworkTimeCalculator} calculator 169 * @param {!Network.NetworkTimeCalculator} calculator
166 */ 170 */
167 setCalculator(calculator) { 171 setCalculator(calculator) {
168 this._calculator = calculator; 172 this._calculator = calculator;
169 } 173 }
170 174
171 /** 175 /**
172 * @param {number} x 176 * @param {number} x
173 * @param {number} y 177 * @param {number} y
174 * @return {?Network.NetworkLogEntry} 178 * @return {?Network.NetworkDataGridNode}
175 */ 179 */
176 getLogEntryFromPoint(x, y) { 180 getNodeFromPoint(x, y) {
177 return this._logEntries[Math.floor((this._scrollTop + y - this._headerHeight ) / this._rowHeight)]; 181 return this._nodes[Math.floor((this._scrollTop + y - this._headerHeight) / t his._rowHeight)];
178 } 182 }
179 183
180 scheduleDraw() { 184 scheduleDraw() {
181 if (this._updateRequestID) 185 if (this._updateRequestID)
182 return; 186 return;
183 this._updateRequestID = this.element.window().requestAnimationFrame(() => th is.update()); 187 this._updateRequestID = this.element.window().requestAnimationFrame(() => th is.update());
184 } 188 }
185 189
186 /** 190 /**
187 * @param {number=} scrollTop 191 * @param {number=} scrollTop
188 * @param {!Map<string, !Array<number>>=} eventDividers 192 * @param {!Map<string, !Array<number>>=} eventDividers
189 * @param {!Array<!Network.NetworkLogEntry>=} logEntries 193 * @param {!Array<!Network.NetworkDataGridNode>=} nodes
190 */ 194 */
191 update(scrollTop, eventDividers, logEntries) { 195 update(scrollTop, eventDividers, nodes) {
192 if (scrollTop !== undefined) 196 if (scrollTop !== undefined)
193 this._scrollTop = scrollTop; 197 this._scrollTop = scrollTop;
194 if (logEntries) { 198 if (nodes) {
195 this._logEntries = logEntries; 199 this._nodes = nodes;
196 this._calculateCanvasSize(); 200 this._calculateCanvasSize();
197 } 201 }
198 if (eventDividers !== undefined) 202 if (eventDividers !== undefined)
199 this._eventDividers = eventDividers; 203 this._eventDividers = eventDividers;
200 this.element.window().cancelAnimationFrame(this._updateRequestID); 204 this.element.window().cancelAnimationFrame(this._updateRequestID);
201 this._updateRequestID = null; 205 this._updateRequestID = null;
202 206
203 this._startTime = this._calculator.minimumBoundary(); 207 this._startTime = this._calculator.minimumBoundary();
204 this._endTime = this._calculator.maximumBoundary(); 208 this._endTime = this._calculator.maximumBoundary();
205 this._resetCanvas(); 209 this._resetCanvas();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 var availableWidth = this._offsetWidth - this._leftPadding; 275 var availableWidth = this._offsetWidth - this._leftPadding;
272 var timeToPixel = availableWidth / (this._endTime - this._startTime); 276 var timeToPixel = availableWidth / (this._endTime - this._startTime);
273 return Math.floor(this._leftPadding + (time - this._startTime) * timeToPixel ); 277 return Math.floor(this._leftPadding + (time - this._startTime) * timeToPixel );
274 } 278 }
275 279
276 _didDrawForTest() { 280 _didDrawForTest() {
277 } 281 }
278 282
279 _draw() { 283 _draw() {
280 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g et() && !this._calculator.startAtZero; 284 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g et() && !this._calculator.startAtZero;
281 var logEntries = this._logEntries; 285 var nodes = this._nodes;
282 var context = this._canvas.getContext('2d'); 286 var context = this._canvas.getContext('2d');
283 context.save(); 287 context.save();
284 context.scale(window.devicePixelRatio, window.devicePixelRatio); 288 context.scale(window.devicePixelRatio, window.devicePixelRatio);
285 context.translate(0, this._headerHeight); 289 context.translate(0, this._headerHeight);
286 context.rect(0, 0, this._offsetWidth, this._offsetHeight); 290 context.rect(0, 0, this._offsetWidth, this._offsetHeight);
287 context.clip(); 291 context.clip();
288 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); 292 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight);
289 var lastRequestIndex = 293 var lastRequestIndex = Math.min(nodes.length, firstRequestIndex + Math.ceil( this._offsetHeight / this._rowHeight));
290 Math.min(logEntries.length, firstRequestIndex + Math.ceil(this._offsetHe ight / this._rowHeight));
291 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { 294 for (var i = firstRequestIndex; i < lastRequestIndex; i++) {
292 var rowOffset = this._rowHeight * i; 295 var rowOffset = this._rowHeight * i;
293 var logEntry = logEntries[i]; 296 var node = nodes[i];
294 this._decorateRow(context, logEntry, i, rowOffset - this._scrollTop); 297 this._decorateRow(context, node, i, rowOffset - this._scrollTop);
295 if (useTimingBars) 298 if (useTimingBars)
296 this._drawTimingBars(context, logEntry, rowOffset - this._scrollTop); 299 this._drawTimingBars(context, node, rowOffset - this._scrollTop);
297 else 300 else
298 this._drawSimplifiedBars(context, logEntry, rowOffset - this._scrollTop) ; 301 this._drawSimplifiedBars(context, node, rowOffset - this._scrollTop);
299 } 302 }
300 this._drawEventDividers(context); 303 this._drawEventDividers(context);
301 context.restore(); 304 context.restore();
302 305
303 const freeZoneAtLeft = 75; 306 const freeZoneAtLeft = 75;
304 const freeZoneAtRight = 18; 307 const freeZoneAtRight = 18;
305 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize, th is._headerHeight, freeZoneAtLeft); 308 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize, th is._headerHeight, freeZoneAtLeft);
306 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); 309 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight);
307 this._didDrawForTest(); 310 this._didDrawForTest();
308 } 311 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 case types.Blocking: 350 case types.Blocking:
348 case types.Push: 351 case types.Push:
349 case types.Queueing: 352 case types.Queueing:
350 return 7; 353 return 7;
351 default: 354 default:
352 return 13; 355 return 13;
353 } 356 }
354 } 357 }
355 358
356 /** 359 /**
357 * @param {!Network.NetworkLogEntry} logEntry 360 * @param {!SDK.NetworkRequest} request
358 * @return {string} 361 * @return {string}
359 */ 362 */
360 _borderColorForResourceType(logEntry) { 363 _borderColorForResourceType(request) {
361 var resourceType = logEntry.request().resourceType(); 364 var resourceType = request.resourceType();
362 if (this._borderColorsForResourceTypeCache.has(resourceType)) 365 if (this._borderColorsForResourceTypeCache.has(resourceType))
363 return this._borderColorsForResourceTypeCache.get(resourceType); 366 return this._borderColorsForResourceTypeCache.get(resourceType);
364 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc eType; 367 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc eType;
365 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth er; 368 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth er;
366 var parsedColor = Common.Color.parse(color); 369 var parsedColor = Common.Color.parse(color);
367 var hsla = parsedColor.hsla(); 370 var hsla = parsedColor.hsla();
368 hsla[1] /= 2; 371 hsla[1] /= 2;
369 hsla[2] -= Math.min(hsla[2], 0.2); 372 hsla[2] -= Math.min(hsla[2], 0.2);
370 var resultColor = /** @type {string} */ (parsedColor.asString(null)); 373 var resultColor = /** @type {string} */ (parsedColor.asString(null));
371 this._borderColorsForResourceTypeCache.set(resourceType, resultColor); 374 this._borderColorsForResourceTypeCache.set(resourceType, resultColor);
372 return resultColor; 375 return resultColor;
373 } 376 }
374 377
375 /** 378 /**
376 * @param {!CanvasRenderingContext2D} context 379 * @param {!CanvasRenderingContext2D} context
377 * @param {!Network.NetworkLogEntry} logEntry 380 * @param {!SDK.NetworkRequest} request
378 * @return {string|!CanvasGradient} 381 * @return {string|!CanvasGradient}
379 */ 382 */
380 _colorForResourceType(context, logEntry) { 383 _colorForResourceType(context, request) {
381 var request = logEntry.request();
382 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc eType; 384 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc eType;
383 var resourceType = request.resourceType(); 385 var resourceType = request.resourceType();
384 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth er; 386 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth er;
385 if (request.cached()) 387 if (request.cached())
386 return color; 388 return color;
387 389
388 if (this._colorsForResourceTypeCache.has(color)) 390 if (this._colorsForResourceTypeCache.has(color))
389 return this._colorsForResourceTypeCache.get(color); 391 return this._colorsForResourceTypeCache.get(color);
390 var parsedColor = Common.Color.parse(color); 392 var parsedColor = Common.Color.parse(color);
391 var hsla = parsedColor.hsla(); 393 var hsla = parsedColor.hsla();
392 hsla[1] -= Math.min(hsla[1], 0.28); 394 hsla[1] -= Math.min(hsla[1], 0.28);
393 hsla[2] -= Math.min(hsla[2], 0.15); 395 hsla[2] -= Math.min(hsla[2], 0.15);
394 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight()); 396 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight());
395 gradient.addColorStop(0, color); 397 gradient.addColorStop(0, color);
396 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null))) ; 398 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null))) ;
397 this._colorsForResourceTypeCache.set(color, gradient); 399 this._colorsForResourceTypeCache.set(color, gradient);
398 return gradient; 400 return gradient;
399 } 401 }
400 402
401 /** 403 /**
402 * @param {!Network.NetworkLogEntry} logEntry 404 * @param {!SDK.NetworkRequest} request
403 * @param {number} borderOffset 405 * @param {number} borderOffset
404 * @return {!{start: number, mid: number, end: number}} 406 * @return {!{start: number, mid: number, end: number}}
405 */ 407 */
406 _getSimplifiedBarRange(logEntry, borderOffset) { 408 _getSimplifiedBarRange(request, borderOffset) {
407 var drawWidth = this._offsetWidth - this._leftPadding; 409 var drawWidth = this._offsetWidth - this._leftPadding;
408 var percentages = this._calculator.computeBarGraphPercentages(logEntry.reque st()); 410 var percentages = this._calculator.computeBarGraphPercentages(request);
409 return { 411 return {
410 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt h) + borderOffset, 412 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt h) + borderOffset,
411 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth ) + borderOffset, 413 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth ) + borderOffset,
412 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) + borderOffset 414 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) + borderOffset
413 }; 415 };
414 } 416 }
415 417
416 /** 418 /**
417 * @param {!CanvasRenderingContext2D} context 419 * @param {!CanvasRenderingContext2D} context
418 * @param {!Network.NetworkLogEntry} logEntry 420 * @param {!Network.NetworkDataGridNode} node
419 * @param {number} y 421 * @param {number} y
420 */ 422 */
421 _drawSimplifiedBars(context, logEntry, y) { 423 _drawSimplifiedBars(context, node, y) {
424 var request = node.request();
425 if (!request)
426 return;
422 const borderWidth = 1; 427 const borderWidth = 1;
423 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; 428 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5;
424 429
425 context.save(); 430 context.save();
426 var ranges = this._getSimplifiedBarRange(logEntry, borderOffset); 431 var ranges = this._getSimplifiedBarRange(request, borderOffset);
427 var height = this._getBarHeight(); 432 var height = this._getBarHeight();
428 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2; 433 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2;
429 434
430 context.translate(0, y); 435 context.translate(0, y);
431 context.fillStyle = this._colorForResourceType(context, logEntry); 436 context.fillStyle = this._colorForResourceType(context, request);
432 context.strokeStyle = this._borderColorForResourceType(logEntry); 437 context.strokeStyle = this._borderColorForResourceType(request);
433 context.lineWidth = borderWidth; 438 context.lineWidth = borderWidth;
434 439
435 context.beginPath(); 440 context.beginPath();
436 context.globalAlpha = 0.5; 441 context.globalAlpha = 0.5;
437 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt h); 442 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt h);
438 context.fill(); 443 context.fill();
439 context.stroke(); 444 context.stroke();
440 445
441 var barWidth = Math.max(2, ranges.end - ranges.mid); 446 var barWidth = Math.max(2, ranges.end - ranges.mid);
442 context.beginPath(); 447 context.beginPath();
443 context.globalAlpha = 1; 448 context.globalAlpha = 1;
444 context.rect(ranges.mid, 0, barWidth, height - borderWidth); 449 context.rect(ranges.mid, 0, barWidth, height - borderWidth);
445 context.fill(); 450 context.fill();
446 context.stroke(); 451 context.stroke();
447 452
448 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ 453 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */
449 var labels = null; 454 var labels = null;
450 if (logEntry === this._hoveredLogEntry) { 455 if (node === this._hoveredNode) {
451 labels = this._calculator.computeBarGraphLabels(logEntry.request()); 456 labels = this._calculator.computeBarGraphLabels(request);
452 this._drawSimplifiedBarDetails( 457 this._drawSimplifiedBarDetails(
453 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m id + barWidth + borderOffset); 458 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m id + barWidth + borderOffset);
454 } 459 }
455 460
456 if (!this._calculator.startAtZero) { 461 if (!this._calculator.startAtZero) {
457 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(l ogEntry.request(), 0) 462 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0)
458 .find(data => data.name === Network.RequestTimeRan geNames.Total); 463 .find(data => data.name === Network.RequestTimeRan geNames.Total);
459 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; 464 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0;
460 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; 465 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start;
461 const wiskerTextPadding = 13; 466 const wiskerTextPadding = 13;
462 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; 467 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0;
463 var queueingStart = this._timeToPosition(queueingRange.start); 468 var queueingStart = this._timeToPosition(queueingRange.start);
464 if (ranges.start - textOffset > queueingStart) { 469 if (ranges.start - textOffset > queueingStart) {
465 context.beginPath(); 470 context.beginPath();
466 context.globalAlpha = 1; 471 context.globalAlpha = 1;
467 context.strokeStyle = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupp ort.ColorUsage.Foreground); 472 context.strokeStyle = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupp ort.ColorUsage.Foreground);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 context.lineWidth = 1; 528 context.lineWidth = 1;
524 context.moveTo(endX, Math.floor(height / 2)); 529 context.moveTo(endX, Math.floor(height / 2));
525 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); 530 context.lineTo(endX + barDotLineLength, Math.floor(height / 2));
526 context.stroke(); 531 context.stroke();
527 } 532 }
528 context.restore(); 533 context.restore();
529 } 534 }
530 535
531 /** 536 /**
532 * @param {!CanvasRenderingContext2D} context 537 * @param {!CanvasRenderingContext2D} context
533 * @param {!Network.NetworkLogEntry} logEntry 538 * @param {!Network.NetworkDataGridNode} node
534 * @param {number} y 539 * @param {number} y
535 */ 540 */
536 _drawTimingBars(context, logEntry, y) { 541 _drawTimingBars(context, node, y) {
542 var request = node.request();
543 if (!request)
544 return;
537 context.save(); 545 context.save();
538 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(logEntry.r equest(), 0); 546 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0 );
539 for (var range of ranges) { 547 for (var range of ranges) {
540 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N etwork.RequestTimeRangeNames.Sending || 548 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N etwork.RequestTimeRangeNames.Sending ||
541 range.end - range.start === 0) 549 range.end - range.start === 0)
542 continue; 550 continue;
543 context.beginPath(); 551 context.beginPath();
544 var lineWidth = 0; 552 var lineWidth = 0;
545 var color = this._colorForType(range.name); 553 var color = this._colorForType(range.name);
546 var borderColor = color; 554 var borderColor = color;
547 if (range.name === Network.RequestTimeRangeNames.Queueing) { 555 if (range.name === Network.RequestTimeRangeNames.Queueing) {
548 borderColor = 'lightgrey'; 556 borderColor = 'lightgrey';
(...skipping 12 matching lines...) Expand all
561 context.strokeStyle = borderColor; 569 context.strokeStyle = borderColor;
562 context.stroke(); 570 context.stroke();
563 } 571 }
564 context.fill(); 572 context.fill();
565 } 573 }
566 context.restore(); 574 context.restore();
567 } 575 }
568 576
569 /** 577 /**
570 * @param {!CanvasRenderingContext2D} context 578 * @param {!CanvasRenderingContext2D} context
571 * @param {!Network.NetworkLogEntry} logEntry 579 * @param {!Network.NetworkDataGridNode} node
572 * @param {number} rowNumber 580 * @param {number} rowNumber
573 * @param {number} y 581 * @param {number} y
574 */ 582 */
575 _decorateRow(context, logEntry, rowNumber, y) { 583 _decorateRow(context, node, rowNumber, y) {
576 var isOddRow = rowNumber % 2 === 1; 584 var isOddRow = rowNumber % 2 === 1;
577 if (isOddRow && this._hoveredLogEntry !== logEntry && !logEntry.isNavigation Request() && !this._initiatorGraph) 585 if (isOddRow && this._hoveredNode !== node && !node.hasNavigationRequest() & & !this._initiatorGraph)
578 return; 586 return;
579 587
580 var color = getRowColor.call(this); 588 var color = getRowColor.call(this);
581 if (color === 'transparent') 589 if (color === 'transparent')
582 return; 590 return;
583 context.save(); 591 context.save();
584 context.beginPath(); 592 context.beginPath();
585 context.fillStyle = color; 593 context.fillStyle = color;
586 context.rect(0, y, this._offsetWidth, this._rowHeight); 594 context.rect(0, y, this._offsetWidth, this._rowHeight);
587 context.fill(); 595 context.fill();
588 context.restore(); 596 context.restore();
589 597
590 /** 598 /**
591 * @return {string} 599 * @return {string}
592 * @this {Network.NetworkWaterfallColumn} 600 * @this {Network.NetworkWaterfallColumn}
593 */ 601 */
594 function getRowColor() { 602 function getRowColor() {
595 var request = logEntry.request(); 603 // TODO(allada) Move this into NetworkDataGridNode.
596 if (this._hoveredLogEntry === logEntry) 604 if (this._hoveredNode === node)
597 return this._rowHoverColor; 605 return this._rowHoverColor;
598 if (this._initiatorGraph) { 606 var request = node.request();
607 if (request && this._initiatorGraph) {
599 if (this._initiatorGraph.initiators.has(request)) 608 if (this._initiatorGraph.initiators.has(request))
600 return this._parentInitiatorColor; 609 return this._parentInitiatorColor;
601 if (this._initiatorGraph.initiated.has(request)) 610 if (this._initiatorGraph.initiated.has(request))
602 return this._initiatedColor; 611 return this._initiatedColor;
603 } 612 }
604 if (logEntry.isNavigationRequest()) 613 if (node.hasNavigationRequest())
605 return this._rowNavigationRequestColor; 614 return this._rowNavigationRequestColor;
606 if (rowNumber % 2 === 1) 615 if (rowNumber % 2 === 1)
607 return 'transparent'; 616 return 'transparent';
608 return this._rowStripeColor; 617 return this._rowStripeColor;
609 } 618 }
610 } 619 }
611 }; 620 };
612 621
613 Network.NetworkWaterfallColumn._colorsForResourceType = { 622 Network.NetworkWaterfallColumn._colorsForResourceType = {
614 document: 'hsl(215, 100%, 80%)', 623 document: 'hsl(215, 100%, 80%)',
615 font: 'hsl(8, 100%, 80%)', 624 font: 'hsl(8, 100%, 80%)',
616 media: 'hsl(90, 50%, 80%)', 625 media: 'hsl(90, 50%, 80%)',
617 image: 'hsl(90, 50%, 80%)', 626 image: 'hsl(90, 50%, 80%)',
618 script: 'hsl(31, 100%, 80%)', 627 script: 'hsl(31, 100%, 80%)',
619 stylesheet: 'hsl(272, 64%, 80%)', 628 stylesheet: 'hsl(272, 64%, 80%)',
620 texttrack: 'hsl(8, 100%, 80%)', 629 texttrack: 'hsl(8, 100%, 80%)',
621 websocket: 'hsl(0, 0%, 95%)', 630 websocket: 'hsl(0, 0%, 95%)',
622 xhr: 'hsl(53, 100%, 80%)', 631 xhr: 'hsl(53, 100%, 80%)',
623 other: 'hsl(0, 0%, 95%)' 632 other: 'hsl(0, 0%, 95%)'
624 }; 633 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698