Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Unified Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkWaterfallColumn.js

Issue 2730633002: [Devtools] Inline _drawSimplifiedBarDetails in NetworkWaterfallColumn.js (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
*/
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698