Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs age.Background); | 54 this._rowNavigationRequestColor = UI.themeSupport.patchColor('#def', colorUs age.Background); |
| 55 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back ground); | 55 this._rowStripeColor = UI.themeSupport.patchColor('#f5f5f5', colorUsage.Back ground); |
| 56 this._rowHoverColor = UI.themeSupport.patchColor( | 56 this._rowHoverColor = UI.themeSupport.patchColor( |
| 57 '#ebf2fc', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgr ound | colorUsage.Selection)); | 57 '#ebf2fc', /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage.Backgr ound | colorUsage.Selection)); |
| 58 this._parentInitiatorColor = UI.themeSupport.patchColor('hsla(120, 68%, 54%, 0.2)', colorUsage.Background); | 58 this._parentInitiatorColor = UI.themeSupport.patchColor('hsla(120, 68%, 54%, 0.2)', colorUsage.Background); |
| 59 this._initiatedColor = UI.themeSupport.patchColor('hsla(0, 68%, 54%, 0.2)', colorUsage.Background); | 59 this._initiatedColor = UI.themeSupport.patchColor('hsla(0, 68%, 54%, 0.2)', colorUsage.Background); |
| 60 | 60 |
| 61 this.element.addEventListener('mousemove', this._onMouseMove.bind(this), tru e); | 61 this.element.addEventListener('mousemove', this._onMouseMove.bind(this), tru e); |
| 62 this.element.addEventListener('mouseleave', event => this._setHoveredNode(nu ll, false), true); | 62 this.element.addEventListener('mouseleave', event => this._setHoveredNode(nu ll, false), true); |
| 63 | 63 |
| 64 /** @type {!Map<!Network.NetworkWaterfallColumn._LayerStyles, !Path2D>} */ | 64 this._styleForTimeRangeName = this._buildRequestTimeRangeStyle(); |
| 65 | |
| 66 var resourceStyleTuple = this._buildResourceTypeStyle(); | |
| 67 /** @type {!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn._Layer Style>} */ | |
| 68 this._styleForWaitingResourceType = resourceStyleTuple[0]; | |
| 69 /** @type {!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn._Layer Style>} */ | |
| 70 this._styleForDownloadingResourceType = resourceStyleTuple[1]; | |
| 71 | |
| 72 var baseLineColor = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupport.Co lorUsage.Foreground); | |
| 73 /** @type {!Network.NetworkWaterfallColumn._LayerStyle} */ | |
| 74 this._wiskerStyle = {borderColor: baseLineColor, lineWidth: 1}; | |
| 75 /** @type {!Network.NetworkWaterfallColumn._LayerStyle} */ | |
| 76 this._hoverDetailsStyle = {fillStyle: baseLineColor, lineWidth: 1, borderCol or: baseLineColor}; | |
| 77 | |
| 78 /** @type {!Map<!Network.NetworkWaterfallColumn._LayerStyle, !Path2D>} */ | |
| 65 this._pathForStyle = new Map(); | 79 this._pathForStyle = new Map(); |
| 66 /** @type {!Array<!Network.NetworkWaterfallColumn._TextLayer>} */ | 80 /** @type {!Array<!Network.NetworkWaterfallColumn._TextLayer>} */ |
| 67 this._textLayers = []; | 81 this._textLayers = []; |
| 68 } | 82 } |
| 69 | 83 |
| 70 /** | 84 /** |
| 71 * @param {string} color | 85 * @return {!Map<!Network.RequestTimeRangeNames, !Network.NetworkWaterfallColu mn._LayerStyle>} |
| 72 * @return {string} | |
| 73 */ | 86 */ |
| 74 _waitingColorForBaseColor(color) { | 87 _buildRequestTimeRangeStyle() { |
|
caseq
2017/03/15 00:41:30
let's make it static
allada
2017/03/15 01:28:40
Done.
| |
| 75 var parsedColor = Common.Color.parse(color); | 88 const types = Network.RequestTimeRangeNames; |
| 76 var hsla = parsedColor.hsla(); | 89 var styleMap = new Map(); |
| 77 hsla[2] *= 1.1; | 90 styleMap.set(types.Connecting, {fillStyle: '#FF9800'}); |
| 78 return /** @type {string} */ (parsedColor.asString(null)); | 91 styleMap.set(types.SSL, {fillStyle: '#9C27B0'}); |
| 92 styleMap.set(types.DNS, {fillStyle: '#009688'}); | |
| 93 styleMap.set(types.Proxy, {fillStyle: '#A1887F'}); | |
| 94 styleMap.set(types.Blocking, {fillStyle: '#AAAAAA'}); | |
| 95 styleMap.set(types.Push, {fillStyle: '#8CDBff'}); | |
| 96 styleMap.set(types.Queueing, {fillStyle: 'white', lineWidth: 2, borderColor: 'lightgrey'}); | |
| 97 // This ensures we always show at least 2 px for a request. | |
| 98 styleMap.set(types.Receiving, {fillStyle: '#03A9F4', lineWidth: 2, borderCol or: '#03A9F4'}); | |
| 99 styleMap.set(types.Waiting, {fillStyle: '#00C853'}); | |
| 100 styleMap.set(types.ReceivingPush, {fillStyle: '#03A9F4'}); | |
| 101 styleMap.set(types.ServiceWorker, {fillStyle: 'orange'}); | |
| 102 styleMap.set(types.ServiceWorkerPreparation, {fillStyle: 'orange'}); | |
| 103 return styleMap; | |
| 79 } | 104 } |
| 80 | 105 |
| 81 /** | 106 /** |
| 82 * @param {string} color | 107 * @return {!Array<!Map<!Common.ResourceType, !Network.NetworkWaterfallColumn. _LayerStyle>>} |
| 83 * @return {string} | |
| 84 */ | 108 */ |
| 85 _borderColorForBaseColor(color) { | 109 _buildResourceTypeStyle() { |
|
caseq
2017/03/15 00:41:29
ditto.
allada
2017/03/15 01:28:40
Done.
| |
| 86 var parsedColor = Common.Color.parse(color); | 110 const baseResourceTypeColors = new Map([ |
| 87 var hsla = parsedColor.hsla(); | 111 ['document', 'hsl(215, 100%, 80%)'], |
| 88 hsla[1] /= 2; | 112 ['font', 'hsl(8, 100%, 80%)'], |
| 89 hsla[2] -= Math.min(hsla[2], 0.2); | 113 ['media', 'hsl(90, 50%, 80%)'], |
| 90 return /** @type {string} */ (parsedColor.asString(null)); | 114 ['image', 'hsl(90, 50%, 80%)'], |
| 115 ['script', 'hsl(31, 100%, 80%)'], | |
| 116 ['stylesheet', 'hsl(272, 64%, 80%)'], | |
| 117 ['texttrack', 'hsl(8, 100%, 80%)'], | |
| 118 ['websocket', 'hsl(0, 0%, 95%)'], | |
| 119 ['xhr', 'hsl(53, 100%, 80%)'], | |
| 120 ['fetch', 'hsl(53, 100%, 80%)'], | |
| 121 ['other', 'hsl(0, 0%, 95%)'], | |
| 122 ]); | |
| 123 var waitingStyleMap = new Map(); | |
| 124 var downloadingStyleMap = new Map(); | |
| 125 | |
| 126 for (var resourceType of Object.values(Common.resourceTypes)) { | |
| 127 var color = baseResourceTypeColors.get(resourceType.name()); | |
| 128 if (!color) | |
|
caseq
2017/03/15 00:41:29
console.assert(color) before this?
allada
2017/03/15 01:28:40
There are a quite a few that are not colored and d
| |
| 129 color = baseResourceTypeColors.get('other'); | |
| 130 var borderColor = toBorderColor(color); | |
| 131 | |
| 132 waitingStyleMap.set(resourceType, {fillStyle: toWaitingColor(color), lineW idth: 1, borderColor: borderColor}); | |
| 133 downloadingStyleMap.set(resourceType, {fillStyle: color, lineWidth: 1, bor derColor: borderColor}); | |
| 134 } | |
| 135 return [waitingStyleMap, downloadingStyleMap]; | |
| 136 | |
| 137 /** | |
| 138 * @param {string} color | |
| 139 */ | |
| 140 function toBorderColor(color) { | |
| 141 var parsedColor = Common.Color.parse(color); | |
| 142 var hsla = parsedColor.hsla(); | |
| 143 hsla[1] /= 2; | |
| 144 hsla[2] -= Math.min(hsla[2], 0.2); | |
| 145 return parsedColor.asString(null); | |
| 146 } | |
| 147 | |
| 148 /** | |
| 149 * @param {string} color | |
| 150 */ | |
| 151 function toWaitingColor(color) { | |
| 152 var parsedColor = Common.Color.parse(color); | |
| 153 var hsla = parsedColor.hsla(); | |
| 154 hsla[2] *= 1.1; | |
| 155 return parsedColor.asString(null); | |
| 156 } | |
| 157 } | |
| 158 | |
| 159 _setupPathDrawOrder() { | |
|
caseq
2017/03/15 00:41:29
rename to something like _clearPaths() or _resetPa
allada
2017/03/15 01:28:40
Done.
| |
| 160 this._pathForStyle.set(this._wiskerStyle, new Path2D()); | |
| 161 this._styleForTimeRangeName.forEach(style => this._pathForStyle.set(style, n ew Path2D())); | |
| 162 this._styleForWaitingResourceType.forEach(style => this._pathForStyle.set(st yle, new Path2D())); | |
| 163 this._styleForDownloadingResourceType.forEach(style => this._pathForStyle.se t(style, new Path2D())); | |
| 164 this._pathForStyle.set(this._hoverDetailsStyle, new Path2D()); | |
| 91 } | 165 } |
| 92 | 166 |
| 93 /** | 167 /** |
| 94 * @param {!SDK.NetworkRequest} request | |
| 95 * @return {string} | |
| 96 */ | |
| 97 _colorForResourceType(request) { | |
| 98 var colorsForResourceType = Network.NetworkWaterfallColumn._colorsForResourc eType; | |
| 99 return colorsForResourceType[request.resourceType()] || colorsForResourceTyp e.other; | |
| 100 } | |
| 101 | |
| 102 /** | |
| 103 * @override | 168 * @override |
| 104 */ | 169 */ |
| 105 willHide() { | 170 willHide() { |
| 106 this._popoverHelper.hidePopover(); | 171 this._popoverHelper.hidePopover(); |
| 107 } | 172 } |
| 108 | 173 |
| 109 /** | 174 /** |
| 110 * @override | 175 * @override |
| 111 */ | 176 */ |
| 112 wasShown() { | 177 wasShown() { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 this._eventDividers = eventDividers; | 322 this._eventDividers = eventDividers; |
| 258 if (this._updateRequestID) { | 323 if (this._updateRequestID) { |
| 259 this.element.window().cancelAnimationFrame(this._updateRequestID); | 324 this.element.window().cancelAnimationFrame(this._updateRequestID); |
| 260 delete this._updateRequestID; | 325 delete this._updateRequestID; |
| 261 } | 326 } |
| 262 | 327 |
| 263 this._startTime = this._calculator.minimumBoundary(); | 328 this._startTime = this._calculator.minimumBoundary(); |
| 264 this._endTime = this._calculator.maximumBoundary(); | 329 this._endTime = this._calculator.maximumBoundary(); |
| 265 this._resetCanvas(); | 330 this._resetCanvas(); |
| 266 this._pathForStyle.clear(); | 331 this._pathForStyle.clear(); |
| 332 this._setupPathDrawOrder(); | |
| 267 this._textLayers = []; | 333 this._textLayers = []; |
| 268 this._draw(); | 334 this._draw(); |
| 269 } | 335 } |
| 270 | 336 |
| 271 _resetCanvas() { | 337 _resetCanvas() { |
| 272 var ratio = window.devicePixelRatio; | 338 var ratio = window.devicePixelRatio; |
| 273 this._canvas.width = this._offsetWidth * ratio; | 339 this._canvas.width = this._offsetWidth * ratio; |
| 274 this._canvas.height = this._offsetHeight * ratio; | 340 this._canvas.height = this._offsetHeight * ratio; |
| 275 this._canvas.style.width = this._offsetWidth + 'px'; | 341 this._canvas.style.width = this._offsetWidth + 'px'; |
| 276 this._canvas.style.height = this._offsetHeight + 'px'; | 342 this._canvas.style.height = this._offsetHeight + 'px'; |
| 277 } | 343 } |
| 278 | 344 |
| 279 /** | 345 /** |
| 280 * @override | 346 * @override |
| 281 */ | 347 */ |
| 282 onResize() { | 348 onResize() { |
| 283 super.onResize(); | 349 super.onResize(); |
| 284 this._calculateCanvasSize(); | 350 this._calculateCanvasSize(); |
| 285 this.scheduleDraw(); | 351 this.scheduleDraw(); |
| 286 } | 352 } |
| 287 | 353 |
| 288 _calculateCanvasSize() { | 354 _calculateCanvasSize() { |
| 289 this._offsetWidth = this.contentElement.offsetWidth - this._rightPadding; | 355 this._offsetWidth = this.contentElement.offsetWidth - this._rightPadding; |
| 290 this._offsetHeight = this.contentElement.offsetHeight; | 356 this._offsetHeight = this.contentElement.offsetHeight; |
| 291 this._calculator.setDisplayWidth(this._offsetWidth); | 357 this._calculator.setDisplayWidth(this._offsetWidth); |
| 292 this._canvasPosition = this._canvas.getBoundingClientRect(); | 358 this._canvasPosition = this._canvas.getBoundingClientRect(); |
| 293 } | 359 } |
| 294 | 360 |
| 295 /** | 361 /** |
| 296 * @param {!Network.RequestTimeRangeNames} type | |
| 297 * @return {string} | |
| 298 */ | |
| 299 _colorForType(type) { | |
| 300 var types = Network.RequestTimeRangeNames; | |
| 301 switch (type) { | |
| 302 case types.Receiving: | |
| 303 case types.ReceivingPush: | |
| 304 return '#03A9F4'; | |
| 305 case types.Waiting: | |
| 306 return '#00C853'; | |
| 307 case types.Connecting: | |
| 308 return '#FF9800'; | |
| 309 case types.SSL: | |
| 310 return '#9C27B0'; | |
| 311 case types.DNS: | |
| 312 return '#009688'; | |
| 313 case types.Proxy: | |
| 314 return '#A1887F'; | |
| 315 case types.Blocking: | |
| 316 return '#AAAAAA'; | |
| 317 case types.Push: | |
| 318 return '#8CDBff'; | |
| 319 case types.Queueing: | |
| 320 return 'white'; | |
| 321 case types.ServiceWorker: | |
| 322 case types.ServiceWorkerPreparation: | |
| 323 default: | |
| 324 return 'orange'; | |
| 325 } | |
| 326 } | |
| 327 | |
| 328 /** | |
| 329 * @param {number} time | 362 * @param {number} time |
| 330 * @return {number} | 363 * @return {number} |
| 331 */ | 364 */ |
| 332 _timeToPosition(time) { | 365 _timeToPosition(time) { |
| 333 var availableWidth = this._offsetWidth - this._leftPadding; | 366 var availableWidth = this._offsetWidth - this._leftPadding; |
| 334 var timeToPixel = availableWidth / (this._endTime - this._startTime); | 367 var timeToPixel = availableWidth / (this._endTime - this._startTime); |
| 335 return Math.floor(this._leftPadding + (time - this._startTime) * timeToPixel ); | 368 return Math.floor(this._leftPadding + (time - this._startTime) * timeToPixel ); |
| 336 } | 369 } |
| 337 | 370 |
| 338 _didDrawForTest() { | 371 _didDrawForTest() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 const freeZoneAtRight = 18; | 412 const freeZoneAtRight = 18; |
| 380 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize , this._headerHeight, freeZoneAtLeft); | 413 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize , this._headerHeight, freeZoneAtLeft); |
| 381 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); | 414 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t his._headerHeight); |
| 382 this._didDrawForTest(); | 415 this._didDrawForTest(); |
| 383 } | 416 } |
| 384 | 417 |
| 385 /** | 418 /** |
| 386 * @param {!CanvasRenderingContext2D} context | 419 * @param {!CanvasRenderingContext2D} context |
| 387 */ | 420 */ |
| 388 _drawLayers(context) { | 421 _drawLayers(context) { |
| 389 for (var style of this._pathForStyle.keys()) { | 422 for (var value of this._pathForStyle) { |
|
caseq
2017/03/15 00:41:30
s/value/entry/ -- entry is [key, value], so using
allada
2017/03/15 01:28:40
Done.
| |
| 390 var path = /** @type {!Path2D} */ (this._pathForStyle.get(style)); | 423 var style = /** @type {!Network.NetworkWaterfallColumn._LayerStyle} */ (va lue[0]); |
| 424 var path = /** @type {!Path2D} */ (value[1]); | |
| 391 context.save(); | 425 context.save(); |
| 392 context.beginPath(); | 426 context.beginPath(); |
| 393 if (style.lineWidth) { | 427 if (style.lineWidth) { |
| 394 context.lineWidth = style.lineWidth; | 428 context.lineWidth = style.lineWidth; |
| 395 context.strokeStyle = style.borderColor; | 429 context.strokeStyle = style.borderColor; |
| 396 context.stroke(path); | 430 context.stroke(path); |
| 397 } | 431 } |
| 398 if (style.fillStyle) { | 432 if (style.fillStyle) { |
| 399 context.fillStyle = style.fillStyle; | 433 context.fillStyle = style.fillStyle; |
| 400 context.fill(path); | 434 context.fill(path); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 var request = node.request(); | 500 var request = node.request(); |
| 467 if (!request) | 501 if (!request) |
| 468 return; | 502 return; |
| 469 const borderWidth = 1; | 503 const borderWidth = 1; |
| 470 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; | 504 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; |
| 471 | 505 |
| 472 var ranges = this._getSimplifiedBarRange(request, borderOffset); | 506 var ranges = this._getSimplifiedBarRange(request, borderOffset); |
| 473 var height = this._getBarHeight(); | 507 var height = this._getBarHeight(); |
| 474 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2; | 508 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2; |
| 475 | 509 |
| 476 var fillColor = this._colorForResourceType(request); | 510 var waitingStyle = /** @type {!Network.NetworkWaterfallColumn._LayerStyle} * / ( |
|
caseq
2017/03/15 00:41:30
nit: if the case is here just to keep closure comp
allada
2017/03/15 01:28:40
Done.
| |
| 477 var waitingPath = new Path2D(); | 511 this._styleForWaitingResourceType.get(request.resourceType())); |
| 512 var waitingPath = /** @type {!Path2D} */ (this._pathForStyle.get(waitingStyl e)); | |
| 478 waitingPath.rect(ranges.start, y, ranges.mid - ranges.start, height - border Width); | 513 waitingPath.rect(ranges.start, y, ranges.mid - ranges.start, height - border Width); |
| 479 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | |
| 480 var waitingStyle = { | |
| 481 fillStyle: this._waitingColorForBaseColor(fillColor), | |
| 482 lineWidth: borderWidth, | |
| 483 borderColor: this._borderColorForBaseColor(fillColor) | |
| 484 }; | |
| 485 this._pathForStyle.set(waitingStyle, waitingPath); | |
| 486 | 514 |
| 487 var barWidth = Math.max(2, ranges.end - ranges.mid); | 515 var barWidth = Math.max(2, ranges.end - ranges.mid); |
| 488 var downloadingPath = new Path2D(); | 516 var downloadingStyle = /** @type {!Network.NetworkWaterfallColumn._LayerStyl e} */ ( |
|
caseq
2017/03/15 00:41:30
ditto.
allada
2017/03/15 01:28:40
Done.
| |
| 517 this._styleForDownloadingResourceType.get(request.resourceType())); | |
| 518 var downloadingPath = /** @type {!Path2D} */ (this._pathForStyle.get(downloa dingStyle)); | |
| 489 downloadingPath.rect(ranges.mid, y, barWidth, height - borderWidth); | 519 downloadingPath.rect(ranges.mid, y, barWidth, height - borderWidth); |
| 490 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | |
| 491 var downloadingStyle = { | |
| 492 fillStyle: fillColor, | |
| 493 lineWidth: borderWidth, | |
| 494 borderColor: this._borderColorForBaseColor(fillColor) | |
| 495 }; | |
| 496 this._pathForStyle.set(downloadingStyle, downloadingPath); | |
| 497 | 520 |
| 498 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ | 521 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
| 499 var labels = null; | 522 var labels = null; |
| 500 if (node.hovered()) { | 523 if (node.hovered()) { |
| 501 labels = this._calculator.computeBarGraphLabels(request); | 524 labels = this._calculator.computeBarGraphLabels(request); |
| 502 const barDotLineLength = 10; | 525 const barDotLineLength = 10; |
| 503 var leftLabelWidth = context.measureText(labels.left).width; | 526 var leftLabelWidth = context.measureText(labels.left).width; |
| 504 var rightLabelWidth = context.measureText(labels.right).width; | 527 var rightLabelWidth = context.measureText(labels.right).width; |
| 505 | 528 var hoverLinePath = /** @type {!Path2D} */ (this._pathForStyle.get(this._h overDetailsStyle)); |
| 506 var hoverLinePath = new Path2D(); | |
| 507 var hoverLineColor = UI.themeSupport.patchColor('#888', UI.ThemeSupport.Co lorUsage.Foreground); | |
| 508 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | |
| 509 var hoverLineStyles = {fillStyle: hoverLineColor, lineWidth: 1, borderColo r: hoverLineColor}; | |
| 510 this._pathForStyle.set(hoverLineStyles, hoverLinePath); | |
| 511 | 529 |
| 512 if (leftLabelWidth < ranges.mid - ranges.start) { | 530 if (leftLabelWidth < ranges.mid - ranges.start) { |
| 513 var midBarX = ranges.start + (ranges.mid - ranges.start - leftLabelWidth ) / 2; | 531 var midBarX = ranges.start + (ranges.mid - ranges.start - leftLabelWidth ) / 2; |
| 514 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS ize}); | 532 this._textLayers.push({text: labels.left, x: midBarX, y: y + this._fontS ize}); |
| 515 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges. start) { | 533 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < ranges. start) { |
| 516 this._textLayers.push( | 534 this._textLayers.push( |
| 517 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen gth - 1, y: y + this._fontSize}); | 535 {text: labels.left, x: ranges.start - leftLabelWidth - barDotLineLen gth - 1, y: y + this._fontSize}); |
| 518 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei ght / 2)); | 536 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei ght / 2)); |
| 519 hoverLinePath.arc(ranges.start, y + Math.floor(height / 2), 2, 0, 2 * Ma th.PI); | 537 hoverLinePath.arc(ranges.start, y + Math.floor(height / 2), 2, 0, 2 * Ma th.PI); |
| 520 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei ght / 2)); | 538 hoverLinePath.moveTo(ranges.start - barDotLineLength, y + Math.floor(hei ght / 2)); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 536 | 554 |
| 537 if (!this._calculator.startAtZero) { | 555 if (!this._calculator.startAtZero) { |
| 538 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0) | 556 var queueingRange = Network.RequestTimingView.calculateRequestTimeRanges(r equest, 0) |
| 539 .find(data => data.name === Network.RequestTimeRan geNames.Total); | 557 .find(data => data.name === Network.RequestTimeRan geNames.Total); |
| 540 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; | 558 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
| 541 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; | 559 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
| 542 const wiskerTextPadding = 13; | 560 const wiskerTextPadding = 13; |
| 543 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; | 561 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske rTextPadding : 0; |
| 544 var queueingStart = this._timeToPosition(queueingRange.start); | 562 var queueingStart = this._timeToPosition(queueingRange.start); |
| 545 if (ranges.start - textOffset > queueingStart) { | 563 if (ranges.start - textOffset > queueingStart) { |
| 546 var wiskerPath = new Path2D(); | 564 var wiskerPath = /** @type {!Path2D} */ (this._pathForStyle.get(this._wi skerStyle)); |
| 547 var wiskerColor = UI.themeSupport.patchColor('#a5a5a5', UI.ThemeSupport. ColorUsage.Foreground); | |
| 548 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | |
| 549 var wiskerStyles = {lineWidth: 1, borderColor: wiskerColor}; | |
| 550 this._pathForStyle.set(wiskerStyles, wiskerPath); | |
| 551 | |
| 552 wiskerPath.moveTo(queueingStart, y + Math.floor(height / 2)); | 565 wiskerPath.moveTo(queueingStart, y + Math.floor(height / 2)); |
| 553 wiskerPath.lineTo(ranges.start - textOffset, y + Math.floor(height / 2)) ; | 566 wiskerPath.lineTo(ranges.start - textOffset, y + Math.floor(height / 2)) ; |
| 554 | 567 |
| 555 // TODO(allada) This needs to be floored. | 568 // TODO(allada) This needs to be floored. |
| 556 const wiskerHeight = height / 2; | 569 const wiskerHeight = height / 2; |
| 557 wiskerPath.moveTo(queueingStart + borderOffset, y + wiskerHeight / 2); | 570 wiskerPath.moveTo(queueingStart + borderOffset, y + wiskerHeight / 2); |
| 558 wiskerPath.lineTo(queueingStart + borderOffset, y + height - wiskerHeigh t / 2 - 1); | 571 wiskerPath.lineTo(queueingStart + borderOffset, y + height - wiskerHeigh t / 2 - 1); |
| 559 } | 572 } |
| 560 } | 573 } |
| 561 } | 574 } |
| 562 | 575 |
| 563 /** | 576 /** |
| 564 * @param {!Network.NetworkNode} node | 577 * @param {!Network.NetworkNode} node |
| 565 * @param {number} y | 578 * @param {number} y |
| 566 */ | 579 */ |
| 567 _buildTimingBarLayers(node, y) { | 580 _buildTimingBarLayers(node, y) { |
| 568 var request = node.request(); | 581 var request = node.request(); |
| 569 if (!request) | 582 if (!request) |
| 570 return; | 583 return; |
| 571 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0 ); | 584 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0 ); |
| 572 for (var range of ranges) { | 585 for (var range of ranges) { |
| 573 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N etwork.RequestTimeRangeNames.Sending || | 586 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N etwork.RequestTimeRangeNames.Sending || |
| 574 range.end - range.start === 0) | 587 range.end - range.start === 0) |
| 575 continue; | 588 continue; |
| 576 var lineWidth = 0; | |
| 577 var color = this._colorForType(range.name); | |
| 578 var borderColor = color; | |
| 579 if (range.name === Network.RequestTimeRangeNames.Queueing) { | |
| 580 borderColor = 'lightgrey'; | |
| 581 lineWidth = 2; | |
| 582 } | |
| 583 if (range.name === Network.RequestTimeRangeNames.Receiving) | |
| 584 lineWidth = 2; | |
| 585 | 589 |
| 586 var path = new Path2D(); | 590 var style = |
| 587 /** @type {!Network.NetworkWaterfallColumn._LayerStyles} */ | 591 /** @type {!Network.NetworkWaterfallColumn._LayerStyle} */ (this._styl eForTimeRangeName.get(range.name)); |
| 588 var style = {fillStyle: color, lineWidth: lineWidth, borderColor: borderCo lor}; | 592 var path = /** @type {!Path2D} */ (this._pathForStyle.get(style)); |
| 589 this._pathForStyle.set(style, path); | 593 var lineWidth = style.lineWidth || 0; |
| 590 var height = this._getBarHeight(range.name); | 594 var height = this._getBarHeight(range.name); |
| 591 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi dth / 2; | 595 var middleBarY = y + Math.floor(this._rowHeight / 2 - height / 2) + lineWi dth / 2; |
| 592 var start = this._timeToPosition(range.start); | 596 var start = this._timeToPosition(range.start); |
| 593 var end = this._timeToPosition(range.end); | 597 var end = this._timeToPosition(range.end); |
| 594 path.rect(start, middleBarY, end - start, height - lineWidth); | 598 path.rect(start, middleBarY, end - start, height - lineWidth); |
| 595 } | 599 } |
| 596 } | 600 } |
| 597 | 601 |
| 598 /** | 602 /** |
| 599 * @param {!CanvasRenderingContext2D} context | 603 * @param {!CanvasRenderingContext2D} context |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 629 return this._initiatedColor; | 633 return this._initiatedColor; |
| 630 if (node.isNavigationRequest()) | 634 if (node.isNavigationRequest()) |
| 631 return this._rowNavigationRequestColor; | 635 return this._rowNavigationRequestColor; |
| 632 if (!isStriped) | 636 if (!isStriped) |
| 633 return 'transparent'; | 637 return 'transparent'; |
| 634 return this._rowStripeColor; | 638 return this._rowStripeColor; |
| 635 } | 639 } |
| 636 } | 640 } |
| 637 }; | 641 }; |
| 638 | 642 |
| 639 /** @enum {string} */ | |
| 640 Network.NetworkWaterfallColumn._colorsForResourceType = { | |
| 641 document: 'hsl(215, 100%, 80%)', | |
| 642 font: 'hsl(8, 100%, 80%)', | |
| 643 media: 'hsl(90, 50%, 80%)', | |
| 644 image: 'hsl(90, 50%, 80%)', | |
| 645 script: 'hsl(31, 100%, 80%)', | |
| 646 stylesheet: 'hsl(272, 64%, 80%)', | |
| 647 texttrack: 'hsl(8, 100%, 80%)', | |
| 648 websocket: 'hsl(0, 0%, 95%)', | |
| 649 xhr: 'hsl(53, 100%, 80%)', | |
| 650 other: 'hsl(0, 0%, 95%)' | |
| 651 }; | |
| 652 | |
| 653 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */ | 643 /** @typedef {!{fillStyle: (string|undefined), lineWidth: (number|undefined), bo rderColor: (string|undefined)}} */ |
| 654 Network.NetworkWaterfallColumn._LayerStyles; | 644 Network.NetworkWaterfallColumn._LayerStyle; |
| 655 | 645 |
| 656 /** @typedef {!{x: number, y: number, text: string}} */ | 646 /** @typedef {!{x: number, y: number, text: string}} */ |
| 657 Network.NetworkWaterfallColumn._TextLayer; | 647 Network.NetworkWaterfallColumn._TextLayer; |
| OLD | NEW |