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

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

Issue 2726183004: [Devtools] Finished inlining function for _drawSimplifiedBars (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 context.fillStyle = fillColor; 471 context.fillStyle = fillColor;
472 context.rect(ranges.mid, 0, barWidth, height - borderWidth); 472 context.rect(ranges.mid, 0, barWidth, height - borderWidth);
473 context.fill(); 473 context.fill();
474 context.stroke(); 474 context.stroke();
475 475
476 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ 476 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */
477 var labels = null; 477 var labels = null;
478 if (node.hovered()) { 478 if (node.hovered()) {
479 labels = this._calculator.computeBarGraphLabels(request); 479 labels = this._calculator.computeBarGraphLabels(request);
480 480
481 // TODO(allada) This will be inlined in an immidate next patch.
482 const leftText = labels.left;
483 const rightText = labels.right;
484 const startX = ranges.start;
485 const midX = ranges.mid;
486 const endX = ranges.mid + barWidth + borderOffset;
487 const currentY = y;
488
489 const barDotLineLength = 10; 481 const barDotLineLength = 10;
490 context.save(); 482 context.save();
491 var leftLabelWidth = context.measureText(leftText).width; 483 var leftLabelWidth = context.measureText(labels.left).width;
492 var rightLabelWidth = context.measureText(rightText).width; 484 var rightLabelWidth = context.measureText(labels.right).width;
493 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col orUsage.Foreground); 485 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col orUsage.Foreground);
494 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.C olorUsage.Foreground); 486 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.C olorUsage.Foreground);
495 if (leftLabelWidth < midX - startX) { 487 if (leftLabelWidth < ranges.mid - ranges.start) {
496 const midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; 488 const midBarX = ranges.start + (ranges.mid - ranges.start) / 2 - leftLab elWidth / 2;
caseq 2017/03/02 23:30:23 nit: this could really be midBarX = (ranges.star
allada 2017/03/03 04:07:43 Done.
497 this._textLayers.push({text: leftText, x: midBarX, y: currentY + this._f ontSize}); 489 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS ize});
498 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { 490 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges. start) {
499 this._textLayers.push( 491 this._textLayers.push(
500 {text: leftText, x: startX - leftLabelWidth - barDotLineLength - 1, y: currentY + this._fontSize}); 492 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen gth - 1, y: y + this._fontSize});
501 context.beginPath(); 493 context.beginPath();
502 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); 494 context.arc(ranges.start, Math.floor(height / 2), 2, 0, 2 * Math.PI);
503 context.fill(); 495 context.fill();
504 context.beginPath(); 496 context.beginPath();
505 context.lineWidth = 1; 497 context.lineWidth = 1;
506 context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); 498 context.moveTo(ranges.start - barDotLineLength, Math.floor(height / 2));
507 context.lineTo(startX, Math.floor(height / 2)); 499 context.lineTo(ranges.start, Math.floor(height / 2));
508 context.stroke(); 500 context.stroke();
509 } 501 }
510 502
511 if (rightLabelWidth < endX - midX) { 503 const endX = ranges.mid + barWidth + borderOffset;
512 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; 504 if (rightLabelWidth < endX - ranges.mid) {
513 this._textLayers.push({text: rightText, x: midBarX, y: currentY + this._ fontSize}); 505 var midBarX = ranges.mid + (endX - ranges.mid) / 2 - rightLabelWidth / 2 ;
506 this._textLayers.push({text: labels.right, x: midBarX, y: y + this._font Size});
514 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding) { 507 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding) {
515 this._textLayers.push({text: rightText, x: endX + barDotLineLength + 1, y: currentY + this._fontSize}); 508 this._textLayers.push({text: labels.right, x: endX + barDotLineLength + 1, y: y + this._fontSize});
caseq 2017/03/02 23:30:23 ditto. actually, it would perhaps be nice to dedup
allada 2017/03/03 04:07:43 These branches do quite different things. They bot
516 context.beginPath(); 509 context.beginPath();
517 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); 510 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI);
518 context.fill(); 511 context.fill();
519 context.beginPath(); 512 context.beginPath();
520 context.lineWidth = 1; 513 context.lineWidth = 1;
521 context.moveTo(endX, Math.floor(height / 2)); 514 context.moveTo(endX, Math.floor(height / 2));
522 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); 515 context.lineTo(endX + barDotLineLength, Math.floor(height / 2));
523 context.stroke(); 516 context.stroke();
524 } 517 }
525 context.restore(); 518 context.restore();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 script: 'hsl(31, 100%, 80%)', 634 script: 'hsl(31, 100%, 80%)',
642 stylesheet: 'hsl(272, 64%, 80%)', 635 stylesheet: 'hsl(272, 64%, 80%)',
643 texttrack: 'hsl(8, 100%, 80%)', 636 texttrack: 'hsl(8, 100%, 80%)',
644 websocket: 'hsl(0, 0%, 95%)', 637 websocket: 'hsl(0, 0%, 95%)',
645 xhr: 'hsl(53, 100%, 80%)', 638 xhr: 'hsl(53, 100%, 80%)',
646 other: 'hsl(0, 0%, 95%)' 639 other: 'hsl(0, 0%, 95%)'
647 }; 640 };
648 641
649 /** @typedef {!{x: number, y: number, text: string}} */ 642 /** @typedef {!{x: number, y: number, text: string}} */
650 Network.NetworkWaterfallColumn._TextLayer; 643 Network.NetworkWaterfallColumn._TextLayer;
OLDNEW
« 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