| 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 Network.NetworkWaterfallColumn = class extends UI.VBox { | 4 Network.NetworkWaterfallColumn = class extends UI.VBox { |
| 5 /** | 5 /** |
| 6 * @param {number} rowHeight | 6 * @param {number} rowHeight |
| 7 * @param {!Network.NetworkTimeCalculator} calculator | 7 * @param {!Network.NetworkTimeCalculator} calculator |
| 8 */ | 8 */ |
| 9 constructor(rowHeight, calculator) { | 9 constructor(rowHeight, calculator) { |
| 10 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m
oved into NetworkLogViewColumns. | 10 // TODO(allada) Make this a shadowDOM when the NetworkWaterfallColumn gets m
oved into NetworkLogViewColumns. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs
age.Background); | 53 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs
age.Background); |
| 54 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back
ground); | 54 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back
ground); |
| 55 this._rowHoverColor = UI.themeSupport.patchColor( | 55 this._rowHoverColor = UI.themeSupport.patchColor( |
| 56 '#ebf2fc', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgr
ound | colorUsage.Selection)); | 56 '#ebf2fc', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgr
ound | colorUsage.Selection)); |
| 57 this._parentInitiatorColor = UI.themeSupport.patchColor('hsla(120, 68%, 54%,
0.2)', colorUsage.Background); | 57 this._parentInitiatorColor = UI.themeSupport.patchColor('hsla(120, 68%, 54%,
0.2)', colorUsage.Background); |
| 58 this._initiatedColor = UI.themeSupport.patchColor('hsla(0, 68%, 54%, 0.2)',
colorUsage.Background); | 58 this._initiatedColor = UI.themeSupport.patchColor('hsla(0, 68%, 54%, 0.2)',
colorUsage.Background); |
| 59 | 59 |
| 60 this.element.addEventListener('mousemove', this._onMouseMove.bind(this), tru
e); | 60 this.element.addEventListener('mousemove', this._onMouseMove.bind(this), tru
e); |
| 61 this.element.addEventListener('mouseleave', event => this._setHoveredNode(nu
ll, false), true); | 61 this.element.addEventListener('mouseleave', event => this._setHoveredNode(nu
ll, false), true); |
| 62 | 62 |
| 63 /** @type {!Map<!Network.NetworkWaterfallColumn._LayerStyles, !Path2D>} */ |
| 64 this._pathForStyle = new Map(); |
| 63 /** @type {!Array<!Network.NetworkWaterfallColumn._TextLayer>} */ | 65 /** @type {!Array<!Network.NetworkWaterfallColumn._TextLayer>} */ |
| 64 this._textLayers = []; | 66 this._textLayers = []; |
| 65 } | 67 } |
| 66 | 68 |
| 67 /** | 69 /** |
| 68 * @param {string} color | 70 * @param {string} color |
| 69 * @return {string} | 71 * @return {string} |
| 70 */ | 72 */ |
| 71 _waitingColorForBaseColor(color) { | 73 _waitingColorForBaseColor(color) { |
| 72 var parsedColor = Common.Color.parse(color); | 74 var parsedColor = Common.Color.parse(color); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if (eventDividers !== undefined) | 253 if (eventDividers !== undefined) |
| 252 this._eventDividers = eventDividers; | 254 this._eventDividers = eventDividers; |
| 253 if (this._updateRequestID) { | 255 if (this._updateRequestID) { |
| 254 this.element.window().cancelAnimationFrame(this._updateRequestID); | 256 this.element.window().cancelAnimationFrame(this._updateRequestID); |
| 255 delete this._updateRequestID; | 257 delete this._updateRequestID; |
| 256 } | 258 } |
| 257 | 259 |
| 258 this._startTime = this._calculator.minimumBoundary(); | 260 this._startTime = this._calculator.minimumBoundary(); |
| 259 this._endTime = this._calculator.maximumBoundary(); | 261 this._endTime = this._calculator.maximumBoundary(); |
| 260 this._resetCanvas(); | 262 this._resetCanvas(); |
| 263 this._pathForStyle.clear(); |
| 261 this._textLayers = []; | 264 this._textLayers = []; |
| 262 this._draw(); | 265 this._draw(); |
| 263 } | 266 } |
| 264 | 267 |
| 265 _resetCanvas() { | 268 _resetCanvas() { |
| 266 var ratio = window.devicePixelRatio; | 269 var ratio = window.devicePixelRatio; |
| 267 this._canvas.width = this._offsetWidth * ratio; | 270 this._canvas.width = this._offsetWidth * ratio; |
| 268 this._canvas.height = this._offsetHeight * ratio; | 271 this._canvas.height = this._offsetHeight * ratio; |
| 269 this._canvas.style.width = this._offsetWidth + 'px'; | 272 this._canvas.style.width = this._offsetWidth + 'px'; |
| 270 this._canvas.style.height = this._offsetHeight + 'px'; | 273 this._canvas.style.height = this._offsetHeight + 'px'; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 349 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
| 347 var rowOffset = this._rowHeight * i; | 350 var rowOffset = this._rowHeight * i; |
| 348 var node = nodes[i]; | 351 var node = nodes[i]; |
| 349 this._decorateRow(context, node, rowOffset - this._scrollTop); | 352 this._decorateRow(context, node, rowOffset - this._scrollTop); |
| 350 var drawNodes = []; | 353 var drawNodes = []; |
| 351 if (node.hasChildren() && !node.expanded) | 354 if (node.hasChildren() && !node.expanded) |
| 352 drawNodes = /** @type {!Array<!Network.NetworkNode>} */ (node.flatChildr
en()); | 355 drawNodes = /** @type {!Array<!Network.NetworkNode>} */ (node.flatChildr
en()); |
| 353 drawNodes.push(node); | 356 drawNodes.push(node); |
| 354 for (var drawNode of drawNodes) { | 357 for (var drawNode of drawNodes) { |
| 355 if (useTimingBars) | 358 if (useTimingBars) |
| 356 this._drawTimingBars(context, drawNode, rowOffset - this._scrollTop); | 359 this._buildTimingBarLayers(drawNode, rowOffset - this._scrollTop); |
| 357 else | 360 else |
| 358 this._drawSimplifiedBars(context, drawNode, rowOffset - this._scrollTo
p); | 361 this._buildSimplifiedBarLayers(context, drawNode, rowOffset - this._sc
rollTop); |
| 359 } | 362 } |
| 360 } | 363 } |
| 364 this._drawLayers(context); |
| 361 | 365 |
| 362 context.save(); | 366 context.save(); |
| 363 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Color
Usage.Foreground); | 367 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Color
Usage.Foreground); |
| 364 for (var textData of this._textLayers) | 368 for (var textData of this._textLayers) |
| 365 context.fillText(textData.text, textData.x, textData.y); | 369 context.fillText(textData.text, textData.x, textData.y); |
| 366 context.restore(); | 370 context.restore(); |
| 367 | 371 |
| 368 this._drawEventDividers(context); | 372 this._drawEventDividers(context); |
| 369 context.restore(); | 373 context.restore(); |
| 370 | 374 |
| 371 const freeZoneAtLeft = 75; | 375 const freeZoneAtLeft = 75; |
| 372 const freeZoneAtRight = 18; | 376 const freeZoneAtRight = 18; |
| 373 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize
, this._headerHeight, freeZoneAtLeft); | 377 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize
, this._headerHeight, freeZoneAtLeft); |
| 374 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t
his._headerHeight); | 378 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t
his._headerHeight); |
| 375 this._didDrawForTest(); | 379 this._didDrawForTest(); |
| 376 } | 380 } |
| 377 | 381 |
| 378 /** | 382 /** |
| 379 * @param {!CanvasRenderingContext2D} context | 383 * @param {!CanvasRenderingContext2D} context |
| 380 */ | 384 */ |
| 385 _drawLayers(context) { |
| 386 for (var style of this._pathForStyle.keys()) { |
| 387 var path = /** @type {!Path2D} */ (this._pathForStyle.get(style)); |
| 388 context.save(); |
| 389 context.beginPath(); |
| 390 if (style.lineWidth) { |
| 391 context.lineWidth = style.lineWidth; |
| 392 context.strokeStyle = style.borderColor; |
| 393 context.stroke(path); |
| 394 } |
| 395 if (style.fillStyle) { |
| 396 context.fillStyle = style.fillStyle; |
| 397 context.fill(path); |
| 398 } |
| 399 context.restore(); |
| 400 } |
| 401 } |
| 402 |
| 403 /** |
| 404 * @param {!CanvasRenderingContext2D} context |
| 405 */ |
| 381 _drawEventDividers(context) { | 406 _drawEventDividers(context) { |
| 382 context.save(); | 407 context.save(); |
| 383 context.lineWidth = 1; | 408 context.lineWidth = 1; |
| 384 for (var color of this._eventDividers.keys()) { | 409 for (var color of this._eventDividers.keys()) { |
| 385 context.strokeStyle = color; | 410 context.strokeStyle = color; |
| 386 for (var time of this._eventDividers.get(color)) { | 411 for (var time of this._eventDividers.get(color)) { |
| 387 context.beginPath(); | 412 context.beginPath(); |
| 388 var x = this._timeToPosition(time); | 413 var x = this._timeToPosition(time); |
| 389 context.moveTo(x, 0); | 414 context.moveTo(x, 0); |
| 390 context.lineTo(x, this._offsetHeight); | 415 context.lineTo(x, this._offsetHeight); |
| 391 } | 416 } |
| 392 context.stroke(); | 417 context.stroke(); |
| 393 } | 418 } |
| 394 context.restore(); | 419 context.restore(); |
| 395 } | 420 } |
| 396 | 421 |
| 397 /** | 422 /** |
| 398 * @return {number} | |
| 399 */ | |
| 400 _waterfallDuration() { | |
| 401 return this._calculator.maximumBoundary() - this._calculator.minimumBoundary
(); | |
| 402 } | |
| 403 | |
| 404 /** | |
| 405 * @param {!Network.RequestTimeRangeNames=} type | 423 * @param {!Network.RequestTimeRangeNames=} type |
| 406 * @return {number} | 424 * @return {number} |
| 407 */ | 425 */ |
| 408 _getBarHeight(type) { | 426 _getBarHeight(type) { |
| 409 var types = Network.RequestTimeRangeNames; | 427 var types = Network.RequestTimeRangeNames; |
| 410 switch (type) { | 428 switch (type) { |
| 411 case types.Connecting: | 429 case types.Connecting: |
| 412 case types.SSL: | 430 case types.SSL: |
| 413 case types.DNS: | 431 case types.DNS: |
| 414 case types.Proxy: | 432 case types.Proxy: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 434 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth
) + borderOffset, | 452 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth
) + borderOffset, |
| 435 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset | 453 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset |
| 436 }; | 454 }; |
| 437 } | 455 } |
| 438 | 456 |
| 439 /** | 457 /** |
| 440 * @param {!CanvasRenderingContext2D} context | 458 * @param {!CanvasRenderingContext2D} context |
| 441 * @param {!Network.NetworkNode} node | 459 * @param {!Network.NetworkNode} node |
| 442 * @param {number} y | 460 * @param {number} y |
| 443 */ | 461 */ |
| 444 _drawSimplifiedBars(context, node, y) { | 462 _buildSimplifiedBarLayers(context, node, y) { |
| 445 var request = node.request(); | 463 var request = node.request(); |
| 446 if (!request) | 464 if (!request) |
| 447 return; | 465 return; |
| 448 const borderWidth = 1; | 466 const borderWidth = 1; |
| 449 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; | 467 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; |
| 450 | 468 |
| 451 context.save(); | |
| 452 var ranges = this._getSimplifiedBarRange(request, borderOffset); | 469 var ranges = this._getSimplifiedBarRange(request, borderOffset); |
| 453 var height = this._getBarHeight(); | 470 var height = this._getBarHeight(); |
| 454 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; | 471 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; |
| 455 | 472 |
| 456 context.translate(0, y); | |
| 457 var fillColor = this._colorForResourceType(request); | 473 var fillColor = this._colorForResourceType(request); |
| 458 context.strokeStyle = this._borderColorForBaseColor(fillColor); | 474 var waitingPath = new Path2D(); |
| 459 context.lineWidth = borderWidth; | 475 waitingPath.rect(ranges.start, y, ranges.mid - ranges.start, height - border
Width); |
| 460 | 476 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 461 context.beginPath(); | 477 var waitingStyle = { |
| 462 context.fillStyle = this._waitingColorForBaseColor(fillColor); | 478 fillStyle: this._waitingColorForBaseColor(fillColor), |
| 463 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt
h); | 479 lineWidth: borderWidth, |
| 464 context.fill(); | 480 borderColor: this._borderColorForBaseColor(fillColor) |
| 465 context.stroke(); | 481 }; |
| 482 this._pathForStyle.set(waitingStyle, waitingPath); |
| 466 | 483 |
| 467 var barWidth = Math.max(2, ranges.end - ranges.mid); | 484 var barWidth = Math.max(2, ranges.end - ranges.mid); |
| 468 context.beginPath(); | 485 var downloadingPath = new Path2D(); |
| 469 context.fillStyle = fillColor; | 486 downloadingPath.rect(ranges.mid, y, barWidth, height - borderWidth); |
| 470 context.rect(ranges.mid, 0, barWidth, height - borderWidth); | 487 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 471 context.fill(); | 488 var downloadingStyle = { |
| 472 context.stroke(); | 489 fillStyle: fillColor, |
| 490 lineWidth: borderWidth, |
| 491 borderColor: this._borderColorForBaseColor(fillColor) |
| 492 }; |
| 493 this._pathForStyle.set(downloadingStyle, downloadingPath); |
| 473 | 494 |
| 474 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 495 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
| 475 var labels = null; | 496 var labels = null; |
| 476 if (node.hovered()) { | 497 if (node.hovered()) { |
| 477 labels = this._calculator.computeBarGraphLabels(request); | 498 labels = this._calculator.computeBarGraphLabels(request); |
| 478 const barDotLineLength = 10; | 499 const barDotLineLength = 10; |
| 479 context.save(); | |
| 480 var leftLabelWidth = context.measureText(labels.left).width; | 500 var leftLabelWidth = context.measureText(labels.left).width; |
| 481 var rightLabelWidth = context.measureText(labels.right).width; | 501 var rightLabelWidth = context.measureText(labels.right).width; |
| 482 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col
orUsage.Foreground); | 502 |
| 483 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.C
olorUsage.Foreground); | 503 var hoverLinePath = new Path2D(); |
| 504 var hoverLineColor = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Co
lorUsage.Foreground); |
| 505 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 506 var hoverLineStyles = {fillStyle: hoverLineColor, lineWidth: 1, borderColo
r: hoverLineColor}; |
| 507 this._pathForStyle.set(hoverLineStyles, hoverLinePath); |
| 508 |
| 484 if (leftLabelWidth < ranges.mid - ranges.start) { | 509 if (leftLabelWidth < ranges.mid - ranges.start) { |
| 485 var midBarX = ranges.start + (ranges.mid - ranges.start - leftLabelWidth
) / 2; | 510 var midBarX = ranges.start + (ranges.mid - ranges.start - leftLabelWidth
) / 2; |
| 486 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS
ize}); | 511 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS
ize}); |
| 487 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges.
start) { | 512 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges.
start) { |
| 488 this._textLayers.push( | 513 this._textLayers.push( |
| 489 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen
gth - 1, y: y + this._fontSize}); | 514 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen
gth - 1, y: y + this._fontSize}); |
| 490 context.beginPath(); | 515 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei
ght / 2)); |
| 491 context.arc(ranges.start, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 516 hoverLinePath.arc(ranges.start, y + Math.floor(height / 2), 2, 0, 2 * Ma
th.PI); |
| 492 context.fill(); | 517 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei
ght / 2)); |
| 493 context.beginPath(); | 518 hoverLinePath.lineTo(ranges.start, y + Math.floor(height / 2)); |
| 494 context.lineWidth = 1; | |
| 495 context.moveTo(ranges.start - barDotLineLength, Math.floor(height / 2)); | |
| 496 context.lineTo(ranges.start, Math.floor(height / 2)); | |
| 497 context.stroke(); | |
| 498 } | 519 } |
| 499 | 520 |
| 500 var endX = ranges.mid + barWidth + borderOffset; | 521 var endX = ranges.mid + barWidth + borderOffset; |
| 501 if (rightLabelWidth < endX - ranges.mid) { | 522 if (rightLabelWidth < endX - ranges.mid) { |
| 502 var midBarX = ranges.mid + (endX - ranges.mid - rightLabelWidth) / 2; | 523 var midBarX = ranges.mid + (endX - ranges.mid - rightLabelWidth) / 2; |
| 503 this._textLayers.push({text: labels.right, x: midBarX, y: y + this._font
Size}); | 524 this._textLayers.push({text: labels.right, x: midBarX, y: y + this._font
Size}); |
| 504 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth -
this._leftPadding) { | 525 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth -
this._leftPadding) { |
| 505 this._textLayers.push({text: labels.right, x: endX + barDotLineLength +
1, y: y + this._fontSize}); | 526 this._textLayers.push({text: labels.right, x: endX + barDotLineLength +
1, y: y + this._fontSize}); |
| 506 context.beginPath(); | 527 hoverLinePath.moveTo(endX, y + Math.floor(height / 2)); |
| 507 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 528 hoverLinePath.arc(endX, y + Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 508 context.fill(); | 529 hoverLinePath.moveTo(endX, y + Math.floor(height / 2)); |
| 509 context.beginPath(); | 530 hoverLinePath.lineTo(endX + barDotLineLength, y + Math.floor(height / 2)
); |
| 510 context.lineWidth = 1; | |
| 511 context.moveTo(endX, Math.floor(height / 2)); | |
| 512 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | |
| 513 context.stroke(); | |
| 514 } | 531 } |
| 515 context.restore(); | |
| 516 } | 532 } |
| 517 | 533 |
| 518 if (!this._calculator.startAtZero) { | 534 if (!this._calculator.startAtZero) { |
| 519 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r
equest, 0) | 535 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r
equest, 0) |
| 520 .find(data => data.name === Network.RequestTimeRan
geNames.Total); | 536 .find(data => data.name === Network.RequestTimeRan
geNames.Total); |
| 521 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; | 537 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
| 522 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; | 538 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
| 523 const wiskerTextPadding = 13; | 539 const wiskerTextPadding = 13; |
| 524 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; | 540 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; |
| 525 var queueingStart = this._timeToPosition(queueingRange.start); | 541 var queueingStart = this._timeToPosition(queueingRange.start); |
| 526 if (ranges.start - textOffset > queueingStart) { | 542 if (ranges.start - textOffset > queueingStart) { |
| 527 context.beginPath(); | 543 var wiskerPath = new Path2D(); |
| 528 context.globalAlpha = 1; | 544 var wiskerColor = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupport.
ColorUsage.Foreground); |
| 529 context.strokeStyle = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupp
ort.ColorUsage.Foreground); | 545 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 530 context.moveTo(queueingStart, Math.floor(height / 2)); | 546 var wiskerStyles = {lineWidth: 1, borderColor: wiskerColor}; |
| 531 context.lineTo(ranges.start - textOffset, Math.floor(height / 2)); | 547 this._pathForStyle.set(wiskerStyles, wiskerPath); |
| 532 | 548 |
| 549 wiskerPath.moveTo(queueingStart, y + Math.floor(height / 2)); |
| 550 wiskerPath.lineTo(ranges.start - textOffset, y + Math.floor(height / 2))
; |
| 551 |
| 552 // TODO(allada) This needs to be floored. |
| 533 const wiskerHeight = height / 2; | 553 const wiskerHeight = height / 2; |
| 534 context.moveTo(queueingStart + borderOffset, wiskerHeight / 2); | 554 wiskerPath.moveTo(queueingStart + borderOffset, y + wiskerHeight / 2); |
| 535 context.lineTo(queueingStart + borderOffset, height - wiskerHeight / 2 -
1); | 555 wiskerPath.lineTo(queueingStart + borderOffset, y + height - wiskerHeigh
t / 2 - 1); |
| 536 context.stroke(); | |
| 537 } | 556 } |
| 538 } | 557 } |
| 539 | |
| 540 context.restore(); | |
| 541 } | 558 } |
| 542 | 559 |
| 543 /** | 560 /** |
| 544 * @param {!CanvasRenderingContext2D} context | |
| 545 * @param {!Network.NetworkNode} node | 561 * @param {!Network.NetworkNode} node |
| 546 * @param {number} y | 562 * @param {number} y |
| 547 */ | 563 */ |
| 548 _drawTimingBars(context, node, y) { | 564 _buildTimingBarLayers(node, y) { |
| 549 var request = node.request(); | 565 var request = node.request(); |
| 550 if (!request) | 566 if (!request) |
| 551 return; | 567 return; |
| 552 context.save(); | |
| 553 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0
); | 568 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0
); |
| 554 for (var range of ranges) { | 569 for (var range of ranges) { |
| 555 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N
etwork.RequestTimeRangeNames.Sending || | 570 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N
etwork.RequestTimeRangeNames.Sending || |
| 556 range.end - range.start === 0) | 571 range.end - range.start === 0) |
| 557 continue; | 572 continue; |
| 558 context.beginPath(); | |
| 559 var lineWidth = 0; | 573 var lineWidth = 0; |
| 560 var color = this._colorForType(range.name); | 574 var color = this._colorForType(range.name); |
| 561 var borderColor = color; | 575 var borderColor = color; |
| 562 if (range.name === Network.RequestTimeRangeNames.Queueing) { | 576 if (range.name === Network.RequestTimeRangeNames.Queueing) { |
| 563 borderColor = 'lightgrey'; | 577 borderColor = 'lightgrey'; |
| 564 lineWidth = 2; | 578 lineWidth = 2; |
| 565 } | 579 } |
| 566 if (range.name === Network.RequestTimeRangeNames.Receiving) | 580 if (range.name === Network.RequestTimeRangeNames.Receiving) |
| 567 lineWidth = 2; | 581 lineWidth = 2; |
| 568 context.fillStyle = color; | 582 |
| 583 var path = new Path2D(); |
| 584 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 585 var style = {fillStyle: color, lineWidth: lineWidth, borderColor: borderCo
lor}; |
| 586 this._pathForStyle.set(style, path); |
| 569 var height = this._getBarHeight(range.name); | 587 var height = this._getBarHeight(range.name); |
| 570 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi
dth / 2; | 588 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi
dth / 2; |
| 571 var start = this._timeToPosition(range.start); | 589 var start = this._timeToPosition(range.start); |
| 572 var end = this._timeToPosition(range.end); | 590 var end = this._timeToPosition(range.end); |
| 573 context.rect(start, middleBarY, end - start, height - lineWidth); | 591 path.rect(start, middleBarY, end - start, height - lineWidth); |
| 574 if (lineWidth) { | |
| 575 context.lineWidth = lineWidth; | |
| 576 context.strokeStyle = borderColor; | |
| 577 context.stroke(); | |
| 578 } | |
| 579 context.fill(); | |
| 580 } | 592 } |
| 581 context.restore(); | |
| 582 } | 593 } |
| 583 | 594 |
| 584 /** | 595 /** |
| 585 * @param {!CanvasRenderingContext2D} context | 596 * @param {!CanvasRenderingContext2D} context |
| 586 * @param {!Network.NetworkNode} node | 597 * @param {!Network.NetworkNode} node |
| 587 * @param {number} y | 598 * @param {number} y |
| 588 */ | 599 */ |
| 589 _decorateRow(context, node, y) { | 600 _decorateRow(context, node, y) { |
| 590 var isStriped = node.isStriped(); | 601 var isStriped = node.isStriped(); |
| 591 if (!isStriped && !node.hovered() && !node.isNavigationRequest() && !node.is
OnInitiatorPath() && | 602 if (!isStriped && !node.hovered() && !node.isNavigationRequest() && !node.is
OnInitiatorPath() && |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 media: 'hsl(90, 50%, 80%)', | 640 media: 'hsl(90, 50%, 80%)', |
| 630 image: 'hsl(90, 50%, 80%)', | 641 image: 'hsl(90, 50%, 80%)', |
| 631 script: 'hsl(31, 100%, 80%)', | 642 script: 'hsl(31, 100%, 80%)', |
| 632 stylesheet: 'hsl(272, 64%, 80%)', | 643 stylesheet: 'hsl(272, 64%, 80%)', |
| 633 texttrack: 'hsl(8, 100%, 80%)', | 644 texttrack: 'hsl(8, 100%, 80%)', |
| 634 websocket: 'hsl(0, 0%, 95%)', | 645 websocket: 'hsl(0, 0%, 95%)', |
| 635 xhr: 'hsl(53, 100%, 80%)', | 646 xhr: 'hsl(53, 100%, 80%)', |
| 636 other: 'hsl(0, 0%, 95%)' | 647 other: 'hsl(0, 0%, 95%)' |
| 637 }; | 648 }; |
| 638 | 649 |
| 650 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo
rderColor: (string|undefined)}} */ |
| 651 Network.NetworkWaterfallColumn._LayerStyles; |
| 652 |
| 639 /** @typedef {!{x: number, y: number, text: string}} */ | 653 /** @typedef {!{x: number, y: number, text: string}} */ |
| 640 Network.NetworkWaterfallColumn._TextLayer; | 654 Network.NetworkWaterfallColumn._TextLayer; |
| OLD | NEW |