Chromium Code Reviews| 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(); | |
|
caseq
2017/03/09 00:44:12
Is there any reason for this to be a map? Why not
allada
2017/03/09 01:29:53
Because in a follow up patch it'll lookup the Path
| |
| 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 var colorUsage = UI.ThemeSupport.ColorUsage; | 367 var colorUsage = UI.ThemeSupport.ColorUsage; |
| 364 context.fillStyle = UI.themeSupport.patchColor( | 368 context.fillStyle = UI.themeSupport.patchColor( |
| 365 '#888', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgroun d | colorUsage.Selection)); | 369 '#888', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgroun d | colorUsage.Selection)); |
| 366 for (var textData of this._textLayers) | 370 for (var textData of this._textLayers) |
| 367 context.fillText(textData.text, textData.x, textData.y); | 371 context.fillText(textData.text, textData.x, textData.y); |
| 368 context.restore(); | 372 context.restore(); |
| 369 | 373 |
| 370 this._drawEventDividers(context); | 374 this._drawEventDividers(context); |
| 371 context.restore(); | 375 context.restore(); |
| 372 | 376 |
| 373 const freeZoneAtLeft = 75; | 377 const freeZoneAtLeft = 75; |
| 374 const freeZoneAtRight = 18; | 378 const freeZoneAtRight = 18; |
| 375 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize , this._headerHeight, freeZoneAtLeft); | 379 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize , this._headerHeight, freeZoneAtLeft); |
| 376 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); | 380 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); |
| 377 this._didDrawForTest(); | 381 this._didDrawForTest(); |
| 378 } | 382 } |
| 379 | 383 |
| 380 /** | 384 /** |
| 381 * @param {!CanvasRenderingContext2D} context | 385 * @param {!CanvasRenderingContext2D} context |
| 382 */ | 386 */ |
| 387 _drawLayers(context) { | |
| 388 for (var style of this._pathForStyle.keys()) { | |
| 389 var path = /** @type {!Path2D} */ (this._pathForStyle.get(style)); | |
| 390 context.save(); | |
| 391 context.beginPath(); | |
| 392 if (style.lineWidth) { | |
| 393 context.lineWidth = style.lineWidth; | |
| 394 context.strokeStyle = style.borderColor; | |
| 395 context.stroke(path); | |
| 396 } | |
| 397 if (style.fillStyle) { | |
| 398 context.fillStyle = style.fillStyle; | |
| 399 context.fill(path); | |
| 400 } | |
| 401 context.restore(); | |
| 402 } | |
| 403 } | |
| 404 | |
| 405 /** | |
| 406 * @param {!CanvasRenderingContext2D} context | |
| 407 */ | |
| 383 _drawEventDividers(context) { | 408 _drawEventDividers(context) { |
| 384 context.save(); | 409 context.save(); |
| 385 context.lineWidth = 1; | 410 context.lineWidth = 1; |
| 386 for (var color of this._eventDividers.keys()) { | 411 for (var color of this._eventDividers.keys()) { |
| 387 context.strokeStyle = color; | 412 context.strokeStyle = color; |
| 388 for (var time of this._eventDividers.get(color)) { | 413 for (var time of this._eventDividers.get(color)) { |
| 389 context.beginPath(); | 414 context.beginPath(); |
| 390 var x = this._timeToPosition(time); | 415 var x = this._timeToPosition(time); |
| 391 context.moveTo(x, 0); | 416 context.moveTo(x, 0); |
| 392 context.lineTo(x, this._offsetHeight); | 417 context.lineTo(x, this._offsetHeight); |
| 393 } | 418 } |
| 394 context.stroke(); | 419 context.stroke(); |
| 395 } | 420 } |
| 396 context.restore(); | 421 context.restore(); |
| 397 } | 422 } |
| 398 | 423 |
| 399 /** | 424 /** |
| 400 * @return {number} | |
|
allada
2017/03/03 01:45:14
Unused function.
| |
| 401 */ | |
| 402 _waterfallDuration() { | |
| 403 return this._calculator.maximumBoundary() - this._calculator.minimumBoundary (); | |
| 404 } | |
| 405 | |
| 406 /** | |
| 407 * @param {!Network.RequestTimeRangeNames=} type | 425 * @param {!Network.RequestTimeRangeNames=} type |
| 408 * @return {number} | 426 * @return {number} |
| 409 */ | 427 */ |
| 410 _getBarHeight(type) { | 428 _getBarHeight(type) { |
| 411 var types = Network.RequestTimeRangeNames; | 429 var types = Network.RequestTimeRangeNames; |
| 412 switch (type) { | 430 switch (type) { |
| 413 case types.Connecting: | 431 case types.Connecting: |
| 414 case types.SSL: | 432 case types.SSL: |
| 415 case types.DNS: | 433 case types.DNS: |
| 416 case types.Proxy: | 434 case types.Proxy: |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 436 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth ) + borderOffset, | 454 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth ) + borderOffset, |
| 437 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) + borderOffset | 455 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) + borderOffset |
| 438 }; | 456 }; |
| 439 } | 457 } |
| 440 | 458 |
| 441 /** | 459 /** |
| 442 * @param {!CanvasRenderingContext2D} context | 460 * @param {!CanvasRenderingContext2D} context |
| 443 * @param {!Network.NetworkNode} node | 461 * @param {!Network.NetworkNode} node |
| 444 * @param {number} y | 462 * @param {number} y |
| 445 */ | 463 */ |
| 446 _drawSimplifiedBars(context, node, y) { | 464 _buildSimplifiedBarLayers(context, node, y) { |
| 447 var request = node.request(); | 465 var request = node.request(); |
| 448 if (!request) | 466 if (!request) |
| 449 return; | 467 return; |
| 450 const borderWidth = 1; | 468 const borderWidth = 1; |
| 451 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; | 469 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; |
| 452 | 470 |
| 453 context.save(); | |
| 454 var ranges = this._getSimplifiedBarRange(request, borderOffset); | 471 var ranges = this._getSimplifiedBarRange(request, borderOffset); |
| 455 var height = this._getBarHeight(); | 472 var height = this._getBarHeight(); |
| 456 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2; | 473 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2; |
| 457 | 474 |
| 458 context.translate(0, y); | |
|
allada
2017/03/03 01:45:14
Important to remember that we are no longer offset
| |
| 459 var fillColor = this._colorForResourceType(request); | 475 var fillColor = this._colorForResourceType(request); |
| 460 context.strokeStyle = this._borderColorForBaseColor(fillColor); | 476 var waitingPath = new Path2D(); |
| 461 context.lineWidth = borderWidth; | 477 waitingPath.rect(ranges.start, y, ranges.mid - ranges.start, height - border Width); |
| 462 | 478 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 463 context.beginPath(); | 479 var waitingStyle = { |
| 464 context.fillStyle = this._waitingColorForBaseColor(fillColor); | 480 fillStyle: this._waitingColorForBaseColor(fillColor), |
| 465 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt h); | 481 lineWidth: borderWidth, |
| 466 context.fill(); | 482 borderColor: this._borderColorForBaseColor(fillColor) |
| 467 context.stroke(); | 483 }; |
| 484 this._pathForStyle.set(waitingStyle, waitingPath); | |
| 468 | 485 |
| 469 var barWidth = Math.max(2, ranges.end - ranges.mid); | 486 var barWidth = Math.max(2, ranges.end - ranges.mid); |
| 470 context.beginPath(); | 487 var downloadingPath = new Path2D(); |
| 471 context.fillStyle = fillColor; | 488 downloadingPath.rect(ranges.mid, y, barWidth, height - borderWidth); |
| 472 context.rect(ranges.mid, 0, barWidth, height - borderWidth); | 489 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 473 context.fill(); | 490 var downloadingStyle = { |
| 474 context.stroke(); | 491 fillStyle: fillColor, |
| 492 lineWidth: borderWidth, | |
| 493 borderColor: this._borderColorForBaseColor(fillColor) | |
| 494 }; | |
| 495 this._pathForStyle.set(downloadingStyle, downloadingPath); | |
| 475 | 496 |
| 476 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 497 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
| 477 var labels = null; | 498 var labels = null; |
| 478 if (node.hovered()) { | 499 if (node.hovered()) { |
| 479 labels = this._calculator.computeBarGraphLabels(request); | 500 labels = this._calculator.computeBarGraphLabels(request); |
| 480 | 501 |
| 481 const barDotLineLength = 10; | 502 const barDotLineLength = 10; |
| 482 context.save(); | |
| 483 var leftLabelWidth = context.measureText(labels.left).width; | 503 var leftLabelWidth = context.measureText(labels.left).width; |
| 484 var rightLabelWidth = context.measureText(labels.right).width; | 504 var rightLabelWidth = context.measureText(labels.right).width; |
| 485 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col orUsage.Foreground); | 505 |
| 486 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.C olorUsage.Foreground); | 506 var hoverLinePath = new Path2D(); |
| 507 var hoverLineColor = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Co lorUsage.Foreground); | |
| 508 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | |
| 509 var hoverLineStyles = {fillStyle: hoverLineColor, lineWidth: 1, borderColo r: hoverLineColor}; | |
| 510 this._pathForStyle.set(hoverLineStyles, hoverLinePath); | |
| 511 | |
| 487 if (leftLabelWidth < ranges.mid - ranges.start) { | 512 if (leftLabelWidth < ranges.mid - ranges.start) { |
| 488 const midBarX = ranges.start + (ranges.mid - ranges.start) / 2 - leftLab elWidth / 2; | 513 const midBarX = ranges.start + (ranges.mid - ranges.start) / 2 - leftLab elWidth / 2; |
| 489 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS ize}); | 514 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS ize}); |
| 490 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges. start) { | 515 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges. start) { |
| 491 this._textLayers.push( | 516 this._textLayers.push( |
| 492 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen gth - 1, y: y + this._fontSize}); | 517 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen gth - 1, y: y + this._fontSize}); |
| 493 context.beginPath(); | 518 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei ght / 2)); |
|
allada
2017/03/03 01:45:14
This is needed because arc will try and connect th
| |
| 494 context.arc(ranges.start, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 519 hoverLinePath.arc(ranges.start, y + Math.floor(height / 2), 2, 0, 2 * Ma th.PI); |
| 495 context.fill(); | 520 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei ght / 2)); |
| 496 context.beginPath(); | 521 hoverLinePath.lineTo(ranges.start, y + Math.floor(height / 2)); |
| 497 context.lineWidth = 1; | |
| 498 context.moveTo(ranges.start - barDotLineLength, Math.floor(height / 2)); | |
| 499 context.lineTo(ranges.start, Math.floor(height / 2)); | |
| 500 context.stroke(); | |
| 501 } | 522 } |
| 502 | 523 |
| 503 const endX = ranges.mid + barWidth + borderOffset; | 524 const endX = ranges.mid + barWidth + borderOffset; |
| 504 if (rightLabelWidth < endX - ranges.mid) { | 525 if (rightLabelWidth < endX - ranges.mid) { |
| 505 var midBarX = ranges.mid + (endX - ranges.mid) / 2 - rightLabelWidth / 2 ; | 526 var midBarX = ranges.mid + (endX - ranges.mid) / 2 - rightLabelWidth / 2 ; |
| 506 this._textLayers.push({text: labels.right, x: midBarX, y: y + this._font Size}); | 527 this._textLayers.push({text: labels.right, x: midBarX, y: y + this._font Size}); |
| 507 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding) { | 528 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding) { |
| 508 this._textLayers.push({text: labels.right, x: endX + barDotLineLength + 1, y: y + this._fontSize}); | 529 this._textLayers.push({text: labels.right, x: endX + barDotLineLength + 1, y: y + this._fontSize}); |
| 509 context.beginPath(); | 530 hoverLinePath.moveTo(endX, y + Math.floor(height / 2)); |
|
allada
2017/03/03 01:45:14
Same as above.
| |
| 510 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 531 hoverLinePath.arc(endX, y + Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 511 context.fill(); | 532 hoverLinePath.moveTo(endX, y + Math.floor(height / 2)); |
| 512 context.beginPath(); | 533 hoverLinePath.lineTo(endX + barDotLineLength, y + Math.floor(height / 2) ); |
| 513 context.lineWidth = 1; | |
| 514 context.moveTo(endX, Math.floor(height / 2)); | |
| 515 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | |
| 516 context.stroke(); | |
| 517 } | 534 } |
| 518 context.restore(); | |
| 519 } | 535 } |
| 520 | 536 |
| 521 if (!this._calculator.startAtZero) { | 537 if (!this._calculator.startAtZero) { |
| 522 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0) | 538 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0) |
| 523 .find(data => data.name === Network.RequestTimeRan geNames.Total); | 539 .find(data => data.name === Network.RequestTimeRan geNames.Total); |
| 524 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; | 540 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
| 525 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; | 541 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
| 526 const wiskerTextPadding = 13; | 542 const wiskerTextPadding = 13; |
| 527 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; | 543 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; |
| 528 var queueingStart = this._timeToPosition(queueingRange.start); | 544 var queueingStart = this._timeToPosition(queueingRange.start); |
| 529 if (ranges.start - textOffset > queueingStart) { | 545 if (ranges.start - textOffset > queueingStart) { |
| 530 context.beginPath(); | 546 var wiskerPath = new Path2D(); |
| 531 context.globalAlpha = 1; | 547 var wiskerColor = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupport. ColorUsage.Foreground); |
| 532 context.strokeStyle = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupp ort.ColorUsage.Foreground); | 548 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ |
| 533 context.moveTo(queueingStart, Math.floor(height / 2)); | 549 var wiskerStyles = {lineWidth: 1, borderColor: wiskerColor}; |
| 534 context.lineTo(ranges.start - textOffset, Math.floor(height / 2)); | 550 this._pathForStyle.set(wiskerStyles, wiskerPath); |
| 535 | 551 |
| 552 wiskerPath.moveTo(queueingStart, y + Math.floor(height / 2)); | |
| 553 wiskerPath.lineTo(ranges.start - textOffset, y + Math.floor(height / 2)) ; | |
| 554 | |
| 555 // TODO(allada) This needs to be floored. | |
| 536 const wiskerHeight = height / 2; | 556 const wiskerHeight = height / 2; |
| 537 context.moveTo(queueingStart + borderOffset, wiskerHeight / 2); | 557 wiskerPath.moveTo(queueingStart + borderOffset, y + wiskerHeight / 2); |
| 538 context.lineTo(queueingStart + borderOffset, height - wiskerHeight / 2 - 1); | 558 wiskerPath.lineTo(queueingStart + borderOffset, y + height - wiskerHeigh t / 2 - 1); |
| 539 context.stroke(); | |
| 540 } | 559 } |
| 541 } | 560 } |
| 542 | |
| 543 context.restore(); | |
| 544 } | 561 } |
| 545 | 562 |
| 546 /** | 563 /** |
| 547 * @param {!CanvasRenderingContext2D} context | |
| 548 * @param {!Network.NetworkNode} node | 564 * @param {!Network.NetworkNode} node |
| 549 * @param {number} y | 565 * @param {number} y |
| 550 */ | 566 */ |
| 551 _drawTimingBars(context, node, y) { | 567 _buildTimingBarLayers(node, y) { |
| 552 var request = node.request(); | 568 var request = node.request(); |
| 553 if (!request) | 569 if (!request) |
| 554 return; | 570 return; |
| 555 context.save(); | |
| 556 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0 ); | 571 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0 ); |
| 557 for (var range of ranges) { | 572 for (var range of ranges) { |
| 558 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N etwork.RequestTimeRangeNames.Sending || | 573 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N etwork.RequestTimeRangeNames.Sending || |
| 559 range.end - range.start === 0) | 574 range.end - range.start === 0) |
| 560 continue; | 575 continue; |
| 561 context.beginPath(); | |
| 562 var lineWidth = 0; | 576 var lineWidth = 0; |
| 563 var color = this._colorForType(range.name); | 577 var color = this._colorForType(range.name); |
| 564 var borderColor = color; | 578 var borderColor = color; |
| 565 if (range.name === Network.RequestTimeRangeNames.Queueing) { | 579 if (range.name === Network.RequestTimeRangeNames.Queueing) { |
| 566 borderColor = 'lightgrey'; | 580 borderColor = 'lightgrey'; |
| 567 lineWidth = 2; | 581 lineWidth = 2; |
| 568 } | 582 } |
| 569 if (range.name === Network.RequestTimeRangeNames.Receiving) | 583 if (range.name === Network.RequestTimeRangeNames.Receiving) |
| 570 lineWidth = 2; | 584 lineWidth = 2; |
| 571 context.fillStyle = color; | 585 |
| 586 var path = new Path2D(); | |
| 587 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | |
| 588 var style = {fillStyle: color, lineWidth: lineWidth, borderColor: borderCo lor}; | |
| 589 this._pathForStyle.set(style, path); | |
| 572 var height = this._getBarHeight(range.name); | 590 var height = this._getBarHeight(range.name); |
| 573 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi dth / 2; | 591 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi dth / 2; |
| 574 var start = this._timeToPosition(range.start); | 592 var start = this._timeToPosition(range.start); |
| 575 var end = this._timeToPosition(range.end); | 593 var end = this._timeToPosition(range.end); |
| 576 context.rect(start, middleBarY, end - start, height - lineWidth); | 594 path.rect(start, middleBarY, end - start, height - lineWidth); |
| 577 if (lineWidth) { | |
| 578 context.lineWidth = lineWidth; | |
| 579 context.strokeStyle = borderColor; | |
| 580 context.stroke(); | |
| 581 } | |
| 582 context.fill(); | |
| 583 } | 595 } |
| 584 context.restore(); | |
| 585 } | 596 } |
| 586 | 597 |
| 587 /** | 598 /** |
| 588 * @param {!CanvasRenderingContext2D} context | 599 * @param {!CanvasRenderingContext2D} context |
| 589 * @param {!Network.NetworkNode} node | 600 * @param {!Network.NetworkNode} node |
| 590 * @param {number} y | 601 * @param {number} y |
| 591 */ | 602 */ |
| 592 _decorateRow(context, node, y) { | 603 _decorateRow(context, node, y) { |
| 593 var isStriped = node.isStriped(); | 604 var isStriped = node.isStriped(); |
| 594 if (!isStriped && !node.hovered() && !node.isNavigationRequest() && !node.is OnInitiatorPath() && | 605 if (!isStriped && !node.hovered() && !node.isNavigationRequest() && !node.is OnInitiatorPath() && |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 media: 'hsl(90, 50%, 80%)', | 643 media: 'hsl(90, 50%, 80%)', |
| 633 image: 'hsl(90, 50%, 80%)', | 644 image: 'hsl(90, 50%, 80%)', |
| 634 script: 'hsl(31, 100%, 80%)', | 645 script: 'hsl(31, 100%, 80%)', |
| 635 stylesheet: 'hsl(272, 64%, 80%)', | 646 stylesheet: 'hsl(272, 64%, 80%)', |
| 636 texttrack: 'hsl(8, 100%, 80%)', | 647 texttrack: 'hsl(8, 100%, 80%)', |
| 637 websocket: 'hsl(0, 0%, 95%)', | 648 websocket: 'hsl(0, 0%, 95%)', |
| 638 xhr: 'hsl(53, 100%, 80%)', | 649 xhr: 'hsl(53, 100%, 80%)', |
| 639 other: 'hsl(0, 0%, 95%)' | 650 other: 'hsl(0, 0%, 95%)' |
| 640 }; | 651 }; |
| 641 | 652 |
| 653 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */ | |
| 654 Network.NetworkWaterfallColumn._LayerStyles; | |
| 655 | |
| 642 /** @typedef {!{x: number, y: number, text: string}} */ | 656 /** @typedef {!{x: number, y: number, text: string}} */ |
| 643 Network.NetworkWaterfallColumn._TextLayer; | 657 Network.NetworkWaterfallColumn._TextLayer; |
| OLD | NEW |