OLD | NEW |
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 Loading... |
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.NetworkDataGridNode>} */ | 37 /** @type {!Array<!Network.NetworkNode>} */ |
38 this._nodes = []; | 38 this._nodes = []; |
39 | 39 |
40 /** @type {?Network.NetworkDataGridNode} */ | 40 /** @type {?Network.NetworkNode} */ |
41 this._hoveredNode = 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); |
(...skipping 25 matching lines...) Expand all Loading... |
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._hoveredNode) | 82 if (!this._hoveredNode) |
83 return; | 83 return; |
84 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g
et() && !this._calculator.startAtZero; | 84 var useTimingBars = !Common.moduleSetting('networkColorCodeResourceTypes').g
et() && !this._calculator.startAtZero; |
85 if (useTimingBars) { | 85 if (useTimingBars) { |
86 var range = Network.RequestTimingView.calculateRequestTimeRanges(this._hov
eredNode.request(), 0) | 86 var request = this._hoveredNode.request(); |
| 87 if (!request) |
| 88 return; |
| 89 var range = Network.RequestTimingView.calculateRequestTimeRanges(request,
0) |
87 .find(data => data.name === Network.RequestTimeRangeNames.
Total); | 90 .find(data => data.name === Network.RequestTimeRangeNames.
Total); |
88 var start = this._timeToPosition(range.start); | 91 var start = this._timeToPosition(range.start); |
89 var end = this._timeToPosition(range.end); | 92 var end = this._timeToPosition(range.end); |
90 } else { | 93 } else { |
91 var range = this._getSimplifiedBarRange(this._hoveredNode, 0); | 94 var range = this._getSimplifiedBarRange(this.request(), 0); |
92 var start = range.start; | 95 var start = range.start; |
93 var end = range.end; | 96 var end = range.end; |
94 } | 97 } |
95 | 98 |
96 if (end - start < 50) { | 99 if (end - start < 50) { |
97 var halfWidth = (end - start) / 2; | 100 var halfWidth = (end - start) / 2; |
98 start = start + halfWidth - 25; | 101 start = start + halfWidth - 25; |
99 end = end - halfWidth + 25; | 102 end = end - halfWidth + 25; |
100 } | 103 } |
101 | 104 |
(...skipping 15 matching lines...) Expand all Loading... |
117 return anchorBox; | 120 return anchorBox; |
118 } | 121 } |
119 | 122 |
120 /** | 123 /** |
121 * @param {!Element|!AnchorBox} anchor | 124 * @param {!Element|!AnchorBox} anchor |
122 * @param {!UI.Popover} popover | 125 * @param {!UI.Popover} popover |
123 */ | 126 */ |
124 _showPopover(anchor, popover) { | 127 _showPopover(anchor, popover) { |
125 if (!this._hoveredNode) | 128 if (!this._hoveredNode) |
126 return; | 129 return; |
127 var content = | 130 var request = this._hoveredNode.request(); |
128 Network.RequestTimingView.createTimingTable(this._hoveredNode.request(),
this._calculator.minimumBoundary()); | 131 if (!request) |
| 132 return; |
| 133 var content = Network.RequestTimingView.createTimingTable(request, this._cal
culator.minimumBoundary()); |
129 popover.showForAnchor(content, anchor); | 134 popover.showForAnchor(content, anchor); |
130 } | 135 } |
131 | 136 |
132 /** | 137 /** |
133 * @param {?Network.NetworkDataGridNode} node | 138 * @param {?Network.NetworkNode} node |
134 * @param {boolean} highlightInitiatorChain | 139 * @param {boolean} highlightInitiatorChain |
135 */ | 140 */ |
136 setHoveredNode(node, highlightInitiatorChain) { | 141 setHoveredNode(node, highlightInitiatorChain) { |
137 this._hoveredNode = node; | 142 this._hoveredNode = node; |
138 this._initiatorGraph = (highlightInitiatorChain && node) ? node.request().in
itiatorGraph() : null; | 143 this._initiatorGraph = (highlightInitiatorChain && node && node.request()) ?
node.request().initiatorGraph() : null; |
139 this.update(); | 144 this.update(); |
140 } | 145 } |
141 | 146 |
142 /** | 147 /** |
143 * @param {number} height | 148 * @param {number} height |
144 */ | 149 */ |
145 setRowHeight(height) { | 150 setRowHeight(height) { |
146 this._rowHeight = height; | 151 this._rowHeight = height; |
147 } | 152 } |
148 | 153 |
(...skipping 15 matching lines...) Expand all Loading... |
164 /** | 169 /** |
165 * @param {!Network.NetworkTimeCalculator} calculator | 170 * @param {!Network.NetworkTimeCalculator} calculator |
166 */ | 171 */ |
167 setCalculator(calculator) { | 172 setCalculator(calculator) { |
168 this._calculator = calculator; | 173 this._calculator = calculator; |
169 } | 174 } |
170 | 175 |
171 /** | 176 /** |
172 * @param {number} x | 177 * @param {number} x |
173 * @param {number} y | 178 * @param {number} y |
174 * @return {?Network.NetworkDataGridNode} | 179 * @return {?Network.NetworkNode} |
175 */ | 180 */ |
176 getNodeFromPoint(x, y) { | 181 getNodeFromPoint(x, y) { |
177 return this._nodes[Math.floor((this._scrollTop + y - this._headerHeight) / t
his._rowHeight)]; | 182 return this._nodes[Math.floor((this._scrollTop + y - this._headerHeight) / t
his._rowHeight)]; |
178 } | 183 } |
179 | 184 |
180 scheduleDraw() { | 185 scheduleDraw() { |
181 if (this._updateRequestID) | 186 if (this._updateRequestID) |
182 return; | 187 return; |
183 this._updateRequestID = this.element.window().requestAnimationFrame(() => th
is.update()); | 188 this._updateRequestID = this.element.window().requestAnimationFrame(() => th
is.update()); |
184 } | 189 } |
185 | 190 |
186 /** | 191 /** |
187 * @param {number=} scrollTop | 192 * @param {number=} scrollTop |
188 * @param {!Map<string, !Array<number>>=} eventDividers | 193 * @param {!Map<string, !Array<number>>=} eventDividers |
189 * @param {!Array<!Network.NetworkDataGridNode>=} nodes | 194 * @param {!Array<!Network.NetworkNode>=} nodes |
190 */ | 195 */ |
191 update(scrollTop, eventDividers, nodes) { | 196 update(scrollTop, eventDividers, nodes) { |
192 if (scrollTop !== undefined) | 197 if (scrollTop !== undefined) |
193 this._scrollTop = scrollTop; | 198 this._scrollTop = scrollTop; |
194 if (nodes) { | 199 if (nodes) { |
195 this._nodes = nodes; | 200 this._nodes = nodes; |
196 this._calculateCanvasSize(); | 201 this._calculateCanvasSize(); |
197 } | 202 } |
198 if (eventDividers !== undefined) | 203 if (eventDividers !== undefined) |
199 this._eventDividers = eventDividers; | 204 this._eventDividers = eventDividers; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 case types.Blocking: | 351 case types.Blocking: |
347 case types.Push: | 352 case types.Push: |
348 case types.Queueing: | 353 case types.Queueing: |
349 return 7; | 354 return 7; |
350 default: | 355 default: |
351 return 13; | 356 return 13; |
352 } | 357 } |
353 } | 358 } |
354 | 359 |
355 /** | 360 /** |
356 * @param {!Network.NetworkDataGridNode} node | 361 * @param {!SDK.NetworkRequest} request |
357 * @return {string} | 362 * @return {string} |
358 */ | 363 */ |
359 _borderColorForResourceType(node) { | 364 _borderColorForResourceType(request) { |
360 var resourceType = node.request().resourceType(); | 365 var resourceType = request.resourceType(); |
361 if (this._borderColorsForResourceTypeCache.has(resourceType)) | 366 if (this._borderColorsForResourceTypeCache.has(resourceType)) |
362 return this._borderColorsForResourceTypeCache.get(resourceType); | 367 return this._borderColorsForResourceTypeCache.get(resourceType); |
363 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc
eType; | 368 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc
eType; |
364 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; | 369 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; |
365 var parsedColor = Common.Color.parse(color); | 370 var parsedColor = Common.Color.parse(color); |
366 var hsla = parsedColor.hsla(); | 371 var hsla = parsedColor.hsla(); |
367 hsla[1] /= 2; | 372 hsla[1] /= 2; |
368 hsla[2] -= Math.min(hsla[2], 0.2); | 373 hsla[2] -= Math.min(hsla[2], 0.2); |
369 var resultColor = /** @type {string} */ (parsedColor.asString(null)); | 374 var resultColor = /** @type {string} */ (parsedColor.asString(null)); |
370 this._borderColorsForResourceTypeCache.set(resourceType, resultColor); | 375 this._borderColorsForResourceTypeCache.set(resourceType, resultColor); |
371 return resultColor; | 376 return resultColor; |
372 } | 377 } |
373 | 378 |
374 /** | 379 /** |
375 * @param {!CanvasRenderingContext2D} context | 380 * @param {!CanvasRenderingContext2D} context |
376 * @param {!Network.NetworkDataGridNode} node | 381 * @param {!SDK.NetworkRequest} request |
377 * @return {string|!CanvasGradient} | 382 * @return {string|!CanvasGradient} |
378 */ | 383 */ |
379 _colorForResourceType(context, node) { | 384 _colorForResourceType(context, request) { |
380 var request = node.request(); | |
381 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc
eType; | 385 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc
eType; |
382 var resourceType = request.resourceType(); | 386 var resourceType = request.resourceType(); |
383 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; | 387 var color = colorsForResourceType[resourceType] || colorsForResourceType.Oth
er; |
384 if (request.cached()) | 388 if (request.cached()) |
385 return color; | 389 return color; |
386 | 390 |
387 if (this._colorsForResourceTypeCache.has(color)) | 391 if (this._colorsForResourceTypeCache.has(color)) |
388 return this._colorsForResourceTypeCache.get(color); | 392 return this._colorsForResourceTypeCache.get(color); |
389 var parsedColor = Common.Color.parse(color); | 393 var parsedColor = Common.Color.parse(color); |
390 var hsla = parsedColor.hsla(); | 394 var hsla = parsedColor.hsla(); |
391 hsla[1] -= Math.min(hsla[1], 0.28); | 395 hsla[1] -= Math.min(hsla[1], 0.28); |
392 hsla[2] -= Math.min(hsla[2], 0.15); | 396 hsla[2] -= Math.min(hsla[2], 0.15); |
393 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight()); | 397 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight()); |
394 gradient.addColorStop(0, color); | 398 gradient.addColorStop(0, color); |
395 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null)))
; | 399 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null)))
; |
396 this._colorsForResourceTypeCache.set(color, gradient); | 400 this._colorsForResourceTypeCache.set(color, gradient); |
397 return gradient; | 401 return gradient; |
398 } | 402 } |
399 | 403 |
400 /** | 404 /** |
401 * @param {!Network.NetworkDataGridNode} node | 405 * @param {!SDK.NetworkRequest} request |
402 * @param {number} borderOffset | 406 * @param {number} borderOffset |
403 * @return {!{start: number, mid: number, end: number}} | 407 * @return {!{start: number, mid: number, end: number}} |
404 */ | 408 */ |
405 _getSimplifiedBarRange(node, borderOffset) { | 409 _getSimplifiedBarRange(request, borderOffset) { |
406 var drawWidth = this._offsetWidth - this._leftPadding; | 410 var drawWidth = this._offsetWidth - this._leftPadding; |
407 var percentages = this._calculator.computeBarGraphPercentages(node.request()
); | 411 var percentages = this._calculator.computeBarGraphPercentages(request); |
408 return { | 412 return { |
409 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt
h) + borderOffset, | 413 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt
h) + borderOffset, |
410 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth
) + borderOffset, | 414 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth
) + borderOffset, |
411 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset | 415 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset |
412 }; | 416 }; |
413 } | 417 } |
414 | 418 |
415 /** | 419 /** |
416 * @param {!CanvasRenderingContext2D} context | 420 * @param {!CanvasRenderingContext2D} context |
417 * @param {!Network.NetworkDataGridNode} node | 421 * @param {!Network.NetworkNode} node |
418 * @param {number} y | 422 * @param {number} y |
419 */ | 423 */ |
420 _drawSimplifiedBars(context, node, y) { | 424 _drawSimplifiedBars(context, node, y) { |
| 425 // TODO(allada) This should draw bars for groupped requests. |
| 426 var request = node.request(); |
| 427 if (!request) |
| 428 return; |
421 const borderWidth = 1; | 429 const borderWidth = 1; |
422 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; | 430 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; |
423 | 431 |
424 context.save(); | 432 context.save(); |
425 var ranges = this._getSimplifiedBarRange(node, borderOffset); | 433 var ranges = this._getSimplifiedBarRange(request, borderOffset); |
426 var height = this._getBarHeight(); | 434 var height = this._getBarHeight(); |
427 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; | 435 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; |
428 | 436 |
429 context.translate(0, y); | 437 context.translate(0, y); |
430 context.fillStyle = this._colorForResourceType(context, node); | 438 context.fillStyle = this._colorForResourceType(context, request); |
431 context.strokeStyle = this._borderColorForResourceType(node); | 439 context.strokeStyle = this._borderColorForResourceType(request); |
432 context.lineWidth = borderWidth; | 440 context.lineWidth = borderWidth; |
433 | 441 |
434 context.beginPath(); | 442 context.beginPath(); |
435 context.globalAlpha = 0.5; | 443 context.globalAlpha = 0.5; |
436 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt
h); | 444 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt
h); |
437 context.fill(); | 445 context.fill(); |
438 context.stroke(); | 446 context.stroke(); |
439 | 447 |
440 var barWidth = Math.max(2, ranges.end - ranges.mid); | 448 var barWidth = Math.max(2, ranges.end - ranges.mid); |
441 context.beginPath(); | 449 context.beginPath(); |
442 context.globalAlpha = 1; | 450 context.globalAlpha = 1; |
443 context.rect(ranges.mid, 0, barWidth, height - borderWidth); | 451 context.rect(ranges.mid, 0, barWidth, height - borderWidth); |
444 context.fill(); | 452 context.fill(); |
445 context.stroke(); | 453 context.stroke(); |
446 | 454 |
447 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 455 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
448 var labels = null; | 456 var labels = null; |
449 if (node === this._hoveredNode) { | 457 if (node === this._hoveredNode) { |
450 labels = this._calculator.computeBarGraphLabels(node.request()); | 458 labels = this._calculator.computeBarGraphLabels(request); |
451 this._drawSimplifiedBarDetails( | 459 this._drawSimplifiedBarDetails( |
452 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m
id + barWidth + borderOffset); | 460 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m
id + barWidth + borderOffset); |
453 } | 461 } |
454 | 462 |
455 if (!this._calculator.startAtZero) { | 463 if (!this._calculator.startAtZero) { |
456 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(n
ode.request(), 0) | 464 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r
equest, 0) |
457 .find(data => data.name === Network.RequestTimeRan
geNames.Total); | 465 .find(data => data.name === Network.RequestTimeRan
geNames.Total); |
458 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; | 466 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
459 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; | 467 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
460 const wiskerTextPadding = 13; | 468 const wiskerTextPadding = 13; |
461 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; | 469 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; |
462 var queueingStart = this._timeToPosition(queueingRange.start); | 470 var queueingStart = this._timeToPosition(queueingRange.start); |
463 if (ranges.start - textOffset > queueingStart) { | 471 if (ranges.start - textOffset > queueingStart) { |
464 context.beginPath(); | 472 context.beginPath(); |
465 context.globalAlpha = 1; | 473 context.globalAlpha = 1; |
466 context.strokeStyle = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupp
ort.ColorUsage.Foreground); | 474 context.strokeStyle = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupp
ort.ColorUsage.Foreground); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 context.lineWidth = 1; | 530 context.lineWidth = 1; |
523 context.moveTo(endX, Math.floor(height / 2)); | 531 context.moveTo(endX, Math.floor(height / 2)); |
524 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | 532 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
525 context.stroke(); | 533 context.stroke(); |
526 } | 534 } |
527 context.restore(); | 535 context.restore(); |
528 } | 536 } |
529 | 537 |
530 /** | 538 /** |
531 * @param {!CanvasRenderingContext2D} context | 539 * @param {!CanvasRenderingContext2D} context |
532 * @param {!Network.NetworkDataGridNode} node | 540 * @param {!Network.NetworkNode} node |
533 * @param {number} y | 541 * @param {number} y |
534 */ | 542 */ |
535 _drawTimingBars(context, node, y) { | 543 _drawTimingBars(context, node, y) { |
| 544 // TODO(allada) This should draw bars for groupped requests. |
| 545 var request = node.request(); |
| 546 if (!request) |
| 547 return; |
536 context.save(); | 548 context.save(); |
537 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(node.reque
st(), 0); | 549 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0
); |
538 for (var range of ranges) { | 550 for (var range of ranges) { |
539 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N
etwork.RequestTimeRangeNames.Sending || | 551 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N
etwork.RequestTimeRangeNames.Sending || |
540 range.end - range.start === 0) | 552 range.end - range.start === 0) |
541 continue; | 553 continue; |
542 context.beginPath(); | 554 context.beginPath(); |
543 var lineWidth = 0; | 555 var lineWidth = 0; |
544 var color = this._colorForType(range.name); | 556 var color = this._colorForType(range.name); |
545 var borderColor = color; | 557 var borderColor = color; |
546 if (range.name === Network.RequestTimeRangeNames.Queueing) { | 558 if (range.name === Network.RequestTimeRangeNames.Queueing) { |
547 borderColor = 'lightgrey'; | 559 borderColor = 'lightgrey'; |
(...skipping 12 matching lines...) Expand all Loading... |
560 context.strokeStyle = borderColor; | 572 context.strokeStyle = borderColor; |
561 context.stroke(); | 573 context.stroke(); |
562 } | 574 } |
563 context.fill(); | 575 context.fill(); |
564 } | 576 } |
565 context.restore(); | 577 context.restore(); |
566 } | 578 } |
567 | 579 |
568 /** | 580 /** |
569 * @param {!CanvasRenderingContext2D} context | 581 * @param {!CanvasRenderingContext2D} context |
570 * @param {!Network.NetworkDataGridNode} node | 582 * @param {!Network.NetworkNode} node |
571 * @param {number} rowNumber | 583 * @param {number} rowNumber |
572 * @param {number} y | 584 * @param {number} y |
573 */ | 585 */ |
574 _decorateRow(context, node, rowNumber, y) { | 586 _decorateRow(context, node, rowNumber, y) { |
575 var isOddRow = rowNumber % 2 === 1; | 587 var isOddRow = rowNumber % 2 === 1; |
576 if (isOddRow && this._hoveredNode !== node && !node.isNavigationRequest() &&
!this._initiatorGraph) | 588 if (isOddRow && this._hoveredNode !== node && !node.isNavigationRequest() &&
!this._initiatorGraph) |
577 return; | 589 return; |
578 | 590 |
579 var color = getRowColor.call(this); | 591 var color = getRowColor.call(this); |
580 if (color === 'transparent') | 592 if (color === 'transparent') |
581 return; | 593 return; |
582 context.save(); | 594 context.save(); |
583 context.beginPath(); | 595 context.beginPath(); |
584 context.fillStyle = color; | 596 context.fillStyle = color; |
585 context.rect(0, y, this._offsetWidth, this._rowHeight); | 597 context.rect(0, y, this._offsetWidth, this._rowHeight); |
586 context.fill(); | 598 context.fill(); |
587 context.restore(); | 599 context.restore(); |
588 | 600 |
589 /** | 601 /** |
590 * @return {string} | 602 * @return {string} |
591 * @this {Network.NetworkWaterfallColumn} | 603 * @this {Network.NetworkWaterfallColumn} |
592 */ | 604 */ |
593 function getRowColor() { | 605 function getRowColor() { |
594 var request = node.request(); | 606 var request = node.request(); |
595 if (this._hoveredNode === node) | 607 if (this._hoveredNode === node) |
596 return this._rowHoverColor; | 608 return this._rowHoverColor; |
597 if (this._initiatorGraph) { | 609 if (request && this._initiatorGraph) { |
598 if (this._initiatorGraph.initiators.has(request)) | 610 if (this._initiatorGraph.initiators.has(request)) |
599 return this._parentInitiatorColor; | 611 return this._parentInitiatorColor; |
600 if (this._initiatorGraph.initiated.has(request)) | 612 if (this._initiatorGraph.initiated.has(request)) |
601 return this._initiatedColor; | 613 return this._initiatedColor; |
602 } | 614 } |
603 if (node.isNavigationRequest()) | 615 if (node.isNavigationRequest()) |
604 return this._rowNavigationRequestColor; | 616 return this._rowNavigationRequestColor; |
605 if (rowNumber % 2 === 1) | 617 if (rowNumber % 2 === 1) |
606 return 'transparent'; | 618 return 'transparent'; |
607 return this._rowStripeColor; | 619 return this._rowStripeColor; |
608 } | 620 } |
609 } | 621 } |
610 }; | 622 }; |
611 | 623 |
612 Network.NetworkWaterfallColumn._colorsForResourceType = { | 624 Network.NetworkWaterfallColumn._colorsForResourceType = { |
613 document: 'hsl(215, 100%, 80%)', | 625 document: 'hsl(215, 100%, 80%)', |
614 font: 'hsl(8, 100%, 80%)', | 626 font: 'hsl(8, 100%, 80%)', |
615 media: 'hsl(90, 50%, 80%)', | 627 media: 'hsl(90, 50%, 80%)', |
616 image: 'hsl(90, 50%, 80%)', | 628 image: 'hsl(90, 50%, 80%)', |
617 script: 'hsl(31, 100%, 80%)', | 629 script: 'hsl(31, 100%, 80%)', |
618 stylesheet: 'hsl(272, 64%, 80%)', | 630 stylesheet: 'hsl(272, 64%, 80%)', |
619 texttrack: 'hsl(8, 100%, 80%)', | 631 texttrack: 'hsl(8, 100%, 80%)', |
620 websocket: 'hsl(0, 0%, 95%)', | 632 websocket: 'hsl(0, 0%, 95%)', |
621 xhr: 'hsl(53, 100%, 80%)', | 633 xhr: 'hsl(53, 100%, 80%)', |
622 other: 'hsl(0, 0%, 95%)' | 634 other: 'hsl(0, 0%, 95%)' |
623 }; | 635 }; |
OLD | NEW |