| 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 context.beginPath(); | 468 context.beginPath(); |
| 469 context.fillStyle = fillColor; | 469 context.fillStyle = fillColor; |
| 470 context.rect(ranges.mid, 0, barWidth, height - borderWidth); | 470 context.rect(ranges.mid, 0, barWidth, height - borderWidth); |
| 471 context.fill(); | 471 context.fill(); |
| 472 context.stroke(); | 472 context.stroke(); |
| 473 | 473 |
| 474 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 474 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
| 475 var labels = null; | 475 var labels = null; |
| 476 if (node.hovered()) { | 476 if (node.hovered()) { |
| 477 labels = this._calculator.computeBarGraphLabels(request); | 477 labels = this._calculator.computeBarGraphLabels(request); |
| 478 // TODO(allada) This will be inlined in an immidate next patch. | 478 const barDotLineLength = 10; |
| 479 var leftText = labels.left; | |
| 480 var rightText = labels.right; | |
| 481 var startX = ranges.start; | |
| 482 var midX = ranges.mid; | |
| 483 var endX = ranges.mid + barWidth + borderOffset; | |
| 484 var currentY = y; | |
| 485 | |
| 486 var barDotLineLength = 10; | |
| 487 context.save(); | 479 context.save(); |
| 488 var leftLabelWidth = context.measureText(leftText).width; | 480 var leftLabelWidth = context.measureText(labels.left).width; |
| 489 var rightLabelWidth = context.measureText(rightText).width; | 481 var rightLabelWidth = context.measureText(labels.right).width; |
| 490 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col
orUsage.Foreground); | 482 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col
orUsage.Foreground); |
| 491 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.C
olorUsage.Foreground); | 483 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.C
olorUsage.Foreground); |
| 492 if (leftLabelWidth < midX - startX) { | 484 if (leftLabelWidth < ranges.mid - ranges.start) { |
| 493 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; | 485 var midBarX = ranges.start + (ranges.mid - ranges.start - leftLabelWidth
) / 2; |
| 494 this._textLayers.push({text: leftText, x: midBarX, y: currentY + this._f
ontSize}); | 486 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS
ize}); |
| 495 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX)
{ | 487 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges.
start) { |
| 496 this._textLayers.push( | 488 this._textLayers.push( |
| 497 {text: leftText, x: startX - leftLabelWidth - barDotLineLength - 1,
y: currentY + this._fontSize}); | 489 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen
gth - 1, y: y + this._fontSize}); |
| 498 context.beginPath(); | 490 context.beginPath(); |
| 499 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 491 context.arc(ranges.start, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 500 context.fill(); | 492 context.fill(); |
| 501 context.beginPath(); | 493 context.beginPath(); |
| 502 context.lineWidth = 1; | 494 context.lineWidth = 1; |
| 503 context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); | 495 context.moveTo(ranges.start - barDotLineLength, Math.floor(height / 2)); |
| 504 context.lineTo(startX, Math.floor(height / 2)); | 496 context.lineTo(ranges.start, Math.floor(height / 2)); |
| 505 context.stroke(); | 497 context.stroke(); |
| 506 } | 498 } |
| 507 | 499 |
| 508 if (rightLabelWidth < endX - midX) { | 500 var endX = ranges.mid + barWidth + borderOffset; |
| 509 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; | 501 if (rightLabelWidth < endX - ranges.mid) { |
| 510 this._textLayers.push({text: rightText, x: midBarX, y: currentY + this._
fontSize}); | 502 var midBarX = ranges.mid + (endX - ranges.mid - rightLabelWidth) / 2; |
| 503 this._textLayers.push({text: labels.right, x: midBarX, y: y + this._font
Size}); |
| 511 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth -
this._leftPadding) { | 504 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth -
this._leftPadding) { |
| 512 this._textLayers.push({text: rightText, x: endX + barDotLineLength + 1,
y: currentY + this._fontSize}); | 505 this._textLayers.push({text: labels.right, x: endX + barDotLineLength +
1, y: y + this._fontSize}); |
| 513 context.beginPath(); | 506 context.beginPath(); |
| 514 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 507 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 515 context.fill(); | 508 context.fill(); |
| 516 context.beginPath(); | 509 context.beginPath(); |
| 517 context.lineWidth = 1; | 510 context.lineWidth = 1; |
| 518 context.moveTo(endX, Math.floor(height / 2)); | 511 context.moveTo(endX, Math.floor(height / 2)); |
| 519 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | 512 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
| 520 context.stroke(); | 513 context.stroke(); |
| 521 } | 514 } |
| 522 context.restore(); | 515 context.restore(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 script: 'hsl(31, 100%, 80%)', | 631 script: 'hsl(31, 100%, 80%)', |
| 639 stylesheet: 'hsl(272, 64%, 80%)', | 632 stylesheet: 'hsl(272, 64%, 80%)', |
| 640 texttrack: 'hsl(8, 100%, 80%)', | 633 texttrack: 'hsl(8, 100%, 80%)', |
| 641 websocket: 'hsl(0, 0%, 95%)', | 634 websocket: 'hsl(0, 0%, 95%)', |
| 642 xhr: 'hsl(53, 100%, 80%)', | 635 xhr: 'hsl(53, 100%, 80%)', |
| 643 other: 'hsl(0, 0%, 95%)' | 636 other: 'hsl(0, 0%, 95%)' |
| 644 }; | 637 }; |
| 645 | 638 |
| 646 /** @typedef {!{x: number, y: number, text: string}} */ | 639 /** @typedef {!{x: number, y: number, text: string}} */ |
| 647 Network.NetworkWaterfallColumn._TextLayer; | 640 Network.NetworkWaterfallColumn._TextLayer; |
| OLD | NEW |