Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js b/third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js |
| index b7ff2e6f05623bb3c985be28eb1af4e1d60f9d47..54af4f218bb43dbcd2d61fca7bf1a0f1ed234e0a 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js |
| @@ -477,8 +477,52 @@ Network.NetworkWaterfallColumn = class extends UI.VBox { |
| var labels = null; |
| if (node.hovered()) { |
| labels = this._calculator.computeBarGraphLabels(request); |
| - this._drawSimplifiedBarDetails( |
| - context, labels.left, labels.right, ranges.start, ranges.mid, ranges.mid + barWidth + borderOffset, y); |
| + |
| + // TODO(allada) This will be inlined in an immidate next patch. |
| + const leftText = labels.left; |
|
caseq
2017/03/03 06:03:52
please replaces with vars :(
allada
2017/03/03 19:46:56
Done.
|
| + const rightText = labels.right; |
| + const startX = ranges.start; |
| + const midX = ranges.mid; |
| + const endX = ranges.mid + barWidth + borderOffset; |
| + const currentY = y; |
| + |
| + const barDotLineLength = 10; |
| + context.save(); |
| + var leftLabelWidth = context.measureText(leftText).width; |
| + var rightLabelWidth = context.measureText(rightText).width; |
| + context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.ColorUsage.Foreground); |
| + context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.ColorUsage.Foreground); |
| + if (leftLabelWidth < midX - startX) { |
| + const midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; |
| + this._textLayers.push({text: leftText, x: midBarX, y: currentY + this._fontSize}); |
| + } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { |
| + this._textLayers.push( |
| + {text: leftText, x: startX - leftLabelWidth - barDotLineLength - 1, y: currentY + this._fontSize}); |
| + context.beginPath(); |
| + context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| + context.fill(); |
| + context.beginPath(); |
| + context.lineWidth = 1; |
| + context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); |
| + context.lineTo(startX, Math.floor(height / 2)); |
| + context.stroke(); |
| + } |
| + |
| + if (rightLabelWidth < endX - midX) { |
| + var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; |
| + this._textLayers.push({text: rightText, x: midBarX, y: currentY + this._fontSize}); |
| + } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding) { |
| + this._textLayers.push({text: rightText, x: endX + barDotLineLength + 1, y: currentY + this._fontSize}); |
| + context.beginPath(); |
| + context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| + context.fill(); |
| + context.beginPath(); |
| + context.lineWidth = 1; |
| + context.moveTo(endX, Math.floor(height / 2)); |
| + context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
| + context.stroke(); |
| + } |
| + context.restore(); |
| } |
| if (!this._calculator.startAtZero) { |
| @@ -508,58 +552,6 @@ Network.NetworkWaterfallColumn = class extends UI.VBox { |
| /** |
| * @param {!CanvasRenderingContext2D} context |
| - * @param {string} leftText |
| - * @param {string} rightText |
| - * @param {number} startX |
| - * @param {number} midX |
| - * @param {number} endX |
| - * @param {number} currentY |
| - */ |
| - _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX, currentY) { |
| - /** @const */ |
| - var barDotLineLength = 10; |
| - |
| - context.save(); |
| - var height = this._getBarHeight(); |
| - var leftLabelWidth = context.measureText(leftText).width; |
| - var rightLabelWidth = context.measureText(rightText).width; |
| - context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.ColorUsage.Foreground); |
| - context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.ColorUsage.Foreground); |
| - if (leftLabelWidth < midX - startX) { |
| - const midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; |
| - this._textLayers.push({text: leftText, x: midBarX, y: currentY + this._fontSize}); |
| - } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { |
| - this._textLayers.push( |
| - {text: leftText, x: startX - leftLabelWidth - barDotLineLength - 1, y: currentY + this._fontSize}); |
| - context.beginPath(); |
| - context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| - context.fill(); |
| - context.beginPath(); |
| - context.lineWidth = 1; |
| - context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); |
| - context.lineTo(startX, Math.floor(height / 2)); |
| - context.stroke(); |
| - } |
| - |
| - if (rightLabelWidth < endX - midX) { |
| - var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; |
| - this._textLayers.push({text: rightText, x: midBarX, y: currentY + this._fontSize}); |
| - } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding) { |
| - this._textLayers.push({text: rightText, x: endX + barDotLineLength + 1, y: currentY + this._fontSize}); |
| - context.beginPath(); |
| - context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| - context.fill(); |
| - context.beginPath(); |
| - context.lineWidth = 1; |
| - context.moveTo(endX, Math.floor(height / 2)); |
| - context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
| - context.stroke(); |
| - } |
| - context.restore(); |
| - } |
| - |
| - /** |
| - * @param {!CanvasRenderingContext2D} context |
| * @param {!Network.NetworkNode} node |
| * @param {number} y |
| */ |