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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 var colorUsage = UI.ThemeSupport.ColorUsage; | 52 var colorUsage = UI.ThemeSupport.ColorUsage; |
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 | |
63 /** @type {!Array<!Network.NetworkWaterfallColumn._TextLayer>} */ | |
64 this._textLayers = []; | |
62 } | 65 } |
63 | 66 |
64 /** | 67 /** |
65 * @param {string} color | 68 * @param {string} color |
66 * @return {string} | 69 * @return {string} |
67 */ | 70 */ |
68 _waitingColorForBaseColor(color) { | 71 _waitingColorForBaseColor(color) { |
69 var parsedColor = Common.Color.parse(color); | 72 var parsedColor = Common.Color.parse(color); |
70 var hsla = parsedColor.hsla(); | 73 var hsla = parsedColor.hsla(); |
71 hsla[2] *= 1.1; | 74 hsla[2] *= 1.1; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 if (eventDividers !== undefined) | 251 if (eventDividers !== undefined) |
249 this._eventDividers = eventDividers; | 252 this._eventDividers = eventDividers; |
250 if (this._updateRequestID) { | 253 if (this._updateRequestID) { |
251 this.element.window().cancelAnimationFrame(this._updateRequestID); | 254 this.element.window().cancelAnimationFrame(this._updateRequestID); |
252 delete this._updateRequestID; | 255 delete this._updateRequestID; |
253 } | 256 } |
254 | 257 |
255 this._startTime = this._calculator.minimumBoundary(); | 258 this._startTime = this._calculator.minimumBoundary(); |
256 this._endTime = this._calculator.maximumBoundary(); | 259 this._endTime = this._calculator.maximumBoundary(); |
257 this._resetCanvas(); | 260 this._resetCanvas(); |
261 this._textLayers = []; | |
258 this._draw(); | 262 this._draw(); |
259 } | 263 } |
260 | 264 |
261 _resetCanvas() { | 265 _resetCanvas() { |
262 var ratio = window.devicePixelRatio; | 266 var ratio = window.devicePixelRatio; |
263 this._canvas.width = this._offsetWidth * ratio; | 267 this._canvas.width = this._offsetWidth * ratio; |
264 this._canvas.height = this._offsetHeight * ratio; | 268 this._canvas.height = this._offsetHeight * ratio; |
265 this._canvas.style.width = this._offsetWidth + 'px'; | 269 this._canvas.style.width = this._offsetWidth + 'px'; |
266 this._canvas.style.height = this._offsetHeight + 'px'; | 270 this._canvas.style.height = this._offsetHeight + 'px'; |
267 } | 271 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 if (node.hasChildren() && !node.expanded) | 351 if (node.hasChildren() && !node.expanded) |
348 drawNodes = /** @type {!Array<!Network.NetworkNode>} */ (node.flatChildr en()); | 352 drawNodes = /** @type {!Array<!Network.NetworkNode>} */ (node.flatChildr en()); |
349 drawNodes.push(node); | 353 drawNodes.push(node); |
350 for (var drawNode of drawNodes) { | 354 for (var drawNode of drawNodes) { |
351 if (useTimingBars) | 355 if (useTimingBars) |
352 this._drawTimingBars(context, drawNode, rowOffset - this._scrollTop); | 356 this._drawTimingBars(context, drawNode, rowOffset - this._scrollTop); |
353 else | 357 else |
354 this._drawSimplifiedBars(context, drawNode, rowOffset - this._scrollTo p); | 358 this._drawSimplifiedBars(context, drawNode, rowOffset - this._scrollTo p); |
355 } | 359 } |
356 } | 360 } |
361 | |
362 context.save(); | |
363 var colorUsage = UI.ThemeSupport.ColorUsage; | |
364 context.fillStyle = UI.themeSupport.patchColor( | |
365 '#888', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgroun d | colorUsage.Selection)); | |
caseq
2017/03/02 23:15:20
Why? It seems neither background nor selection.
allada
2017/03/03 03:49:05
It only appears when a user hovers over it. It's a
caseq
2017/03/03 17:23:24
Right, but this is still a foreground color, not b
allada
2017/03/03 19:31:49
Done.
| |
366 for (var textData of this._textLayers) | |
367 context.fillText(textData.text, textData.x, textData.y); | |
368 context.restore(); | |
369 | |
357 this._drawEventDividers(context); | 370 this._drawEventDividers(context); |
358 context.restore(); | 371 context.restore(); |
359 | 372 |
360 const freeZoneAtLeft = 75; | 373 const freeZoneAtLeft = 75; |
361 const freeZoneAtRight = 18; | 374 const freeZoneAtRight = 18; |
362 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize , this._headerHeight, freeZoneAtLeft); | 375 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize , this._headerHeight, freeZoneAtLeft); |
363 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); | 376 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); |
364 this._didDrawForTest(); | 377 this._didDrawForTest(); |
365 } | 378 } |
366 | 379 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 context.fillStyle = fillColor; | 471 context.fillStyle = fillColor; |
459 context.rect(ranges.mid, 0, barWidth, height - borderWidth); | 472 context.rect(ranges.mid, 0, barWidth, height - borderWidth); |
460 context.fill(); | 473 context.fill(); |
461 context.stroke(); | 474 context.stroke(); |
462 | 475 |
463 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 476 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
464 var labels = null; | 477 var labels = null; |
465 if (node.hovered()) { | 478 if (node.hovered()) { |
466 labels = this._calculator.computeBarGraphLabels(request); | 479 labels = this._calculator.computeBarGraphLabels(request); |
467 this._drawSimplifiedBarDetails( | 480 this._drawSimplifiedBarDetails( |
468 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m id + barWidth + borderOffset); | 481 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m id + barWidth + borderOffset, y); |
469 } | 482 } |
470 | 483 |
471 if (!this._calculator.startAtZero) { | 484 if (!this._calculator.startAtZero) { |
472 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0) | 485 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0) |
473 .find(data => data.name === Network.RequestTimeRan geNames.Total); | 486 .find(data => data.name === Network.RequestTimeRan geNames.Total); |
474 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; | 487 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
475 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; | 488 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
476 const wiskerTextPadding = 13; | 489 const wiskerTextPadding = 13; |
477 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; | 490 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; |
478 var queueingStart = this._timeToPosition(queueingRange.start); | 491 var queueingStart = this._timeToPosition(queueingRange.start); |
(...skipping 14 matching lines...) Expand all Loading... | |
493 context.restore(); | 506 context.restore(); |
494 } | 507 } |
495 | 508 |
496 /** | 509 /** |
497 * @param {!CanvasRenderingContext2D} context | 510 * @param {!CanvasRenderingContext2D} context |
498 * @param {string} leftText | 511 * @param {string} leftText |
499 * @param {string} rightText | 512 * @param {string} rightText |
500 * @param {number} startX | 513 * @param {number} startX |
501 * @param {number} midX | 514 * @param {number} midX |
502 * @param {number} endX | 515 * @param {number} endX |
516 * @param {number} currentY | |
503 */ | 517 */ |
504 _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX) { | 518 _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX, cu rrentY) { |
allada
2017/03/02 02:21:26
This entire function will be inlined in an upcomin
| |
505 /** @const */ | 519 /** @const */ |
506 var barDotLineLength = 10; | 520 var barDotLineLength = 10; |
507 | 521 |
508 context.save(); | 522 context.save(); |
509 var height = this._getBarHeight(); | 523 var height = this._getBarHeight(); |
510 var leftLabelWidth = context.measureText(leftText).width; | 524 var leftLabelWidth = context.measureText(leftText).width; |
511 var rightLabelWidth = context.measureText(rightText).width; | 525 var rightLabelWidth = context.measureText(rightText).width; |
512 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Color Usage.Foreground); | 526 context.fillStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Color Usage.Foreground); |
513 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col orUsage.Foreground); | 527 context.strokeStyle = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Col orUsage.Foreground); |
514 if (leftLabelWidth < midX - startX) { | 528 if (leftLabelWidth < midX - startX) { |
515 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; | 529 const midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; |
caseq
2017/03/02 23:15:20
please keep it a var, we decided on not using cons
allada
2017/03/03 03:49:05
Done.
| |
516 context.fillText(leftText, midBarX, this._fontSize); | 530 this._textLayers.push({text: leftText, x: midBarX, y: currentY + this._fon tSize}); |
517 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { | 531 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { |
532 this._textLayers.push( | |
533 {text: leftText, x: startX - leftLabelWidth - barDotLineLength - 1, y: currentY + this._fontSize}); | |
518 context.beginPath(); | 534 context.beginPath(); |
519 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 535 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
520 context.fill(); | 536 context.fill(); |
521 context.fillText(leftText, startX - leftLabelWidth - barDotLineLength - 1, this._fontSize); | |
522 context.beginPath(); | 537 context.beginPath(); |
523 context.lineWidth = 1; | 538 context.lineWidth = 1; |
524 context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); | 539 context.moveTo(startX - barDotLineLength, Math.floor(height / 2)); |
525 context.lineTo(startX, Math.floor(height / 2)); | 540 context.lineTo(startX, Math.floor(height / 2)); |
526 context.stroke(); | 541 context.stroke(); |
527 } | 542 } |
528 | 543 |
529 if (rightLabelWidth < endX - midX) { | 544 if (rightLabelWidth < endX - midX) { |
530 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; | 545 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2; |
531 context.fillText(rightText, midBarX, this._fontSize); | 546 this._textLayers.push({text: rightText, x: midBarX, y: currentY + this._fo ntSize}); |
532 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - t his._leftPadding) { | 547 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - t his._leftPadding) { |
548 this._textLayers.push({text: rightText, x: endX + barDotLineLength + 1, y: currentY + this._fontSize}); | |
533 context.beginPath(); | 549 context.beginPath(); |
534 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 550 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
535 context.fill(); | 551 context.fill(); |
536 context.fillText(rightText, endX + barDotLineLength + 1, this._fontSize); | |
537 context.beginPath(); | 552 context.beginPath(); |
538 context.lineWidth = 1; | 553 context.lineWidth = 1; |
539 context.moveTo(endX, Math.floor(height / 2)); | 554 context.moveTo(endX, Math.floor(height / 2)); |
540 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); | 555 context.lineTo(endX + barDotLineLength, Math.floor(height / 2)); |
541 context.stroke(); | 556 context.stroke(); |
542 } | 557 } |
543 context.restore(); | 558 context.restore(); |
544 } | 559 } |
545 | 560 |
546 /** | 561 /** |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 font: 'hsl(8, 100%, 80%)', | 646 font: 'hsl(8, 100%, 80%)', |
632 media: 'hsl(90, 50%, 80%)', | 647 media: 'hsl(90, 50%, 80%)', |
633 image: 'hsl(90, 50%, 80%)', | 648 image: 'hsl(90, 50%, 80%)', |
634 script: 'hsl(31, 100%, 80%)', | 649 script: 'hsl(31, 100%, 80%)', |
635 stylesheet: 'hsl(272, 64%, 80%)', | 650 stylesheet: 'hsl(272, 64%, 80%)', |
636 texttrack: 'hsl(8, 100%, 80%)', | 651 texttrack: 'hsl(8, 100%, 80%)', |
637 websocket: 'hsl(0, 0%, 95%)', | 652 websocket: 'hsl(0, 0%, 95%)', |
638 xhr: 'hsl(53, 100%, 80%)', | 653 xhr: 'hsl(53, 100%, 80%)', |
639 other: 'hsl(0, 0%, 95%)' | 654 other: 'hsl(0, 0%, 95%)' |
640 }; | 655 }; |
656 | |
657 /** @typedef {!{x: number, y: number, text: string}} */ | |
658 Network.NetworkWaterfallColumn._TextLayer; | |
OLD | NEW |