| 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 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.NetworkTimelineColumn = class extends WebInspector.VBox { | 7 WebInspector.NetworkTimelineColumn = class extends WebInspector.VBox { |
| 8 /** | 8 /** |
| 9 * @param {number} rowHeight | 9 * @param {number} rowHeight |
| 10 * @param {!WebInspector.NetworkTimeCalculator} calculator | 10 * @param {!WebInspector.NetworkTimeCalculator} calculator |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 * @param {!Event} event | 82 * @param {!Event} event |
| 83 * @return {!AnchorBox|undefined} | 83 * @return {!AnchorBox|undefined} |
| 84 */ | 84 */ |
| 85 _getPopoverAnchor(element, event) { | 85 _getPopoverAnchor(element, event) { |
| 86 if (!this._hoveredRequest) | 86 if (!this._hoveredRequest) |
| 87 return; | 87 return; |
| 88 var useTimingBars = | 88 var useTimingBars = |
| 89 !WebInspector.moduleSetting('networkColorCodeResourceTypes').get() && !t
his._calculator.startAtZero; | 89 !WebInspector.moduleSetting('networkColorCodeResourceTypes').get() && !t
his._calculator.startAtZero; |
| 90 if (useTimingBars) { | 90 if (useTimingBars) { |
| 91 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(this
._hoveredRequest, 0) | 91 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(this
._hoveredRequest, 0) |
| 92 .find(data => data.name === 'total'); | 92 .find(data => data.name === WebInspector.RequestTimeRangeNames.Total); |
| 93 var start = this._timeToPosition(range.start); | 93 var start = this._timeToPosition(range.start); |
| 94 var end = this._timeToPosition(range.end); | 94 var end = this._timeToPosition(range.end); |
| 95 } else { | 95 } else { |
| 96 var range = this._getSimplifiedBarRange(this._hoveredRequest, 0); | 96 var range = this._getSimplifiedBarRange(this._hoveredRequest, 0); |
| 97 var start = range.start; | 97 var start = range.start; |
| 98 var end = range.end; | 98 var end = range.end; |
| 99 } | 99 } |
| 100 | 100 |
| 101 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi
s._canvasPosition.left + end) | 101 if (event.clientX < this._canvasPosition.left + start || event.clientX > thi
s._canvasPosition.left + end) |
| 102 return; | 102 return; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 scheduleDraw() { | 179 scheduleDraw() { |
| 180 if (this._updateRequestID) | 180 if (this._updateRequestID) |
| 181 return; | 181 return; |
| 182 this._updateRequestID = this.element.window().requestAnimationFrame(() => th
is.update()); | 182 this._updateRequestID = this.element.window().requestAnimationFrame(() => th
is.update()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 /** | 185 /** |
| 186 * @param {number=} scrollTop | 186 * @param {number=} scrollTop |
| 187 * @param {!Map<string, !Array<number>>=} eventDividers | 187 * @param {!Map<string, !Array<number>>=} eventDividers |
| 188 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationRequest
: ?WebInspector.NetworkRequest}=} requestData | 188 * @param {!WebInspector.NetworkTimelineColumn.RequestData=} requestData |
| 189 */ | 189 */ |
| 190 update(scrollTop, eventDividers, requestData) { | 190 update(scrollTop, eventDividers, requestData) { |
| 191 if (scrollTop !== undefined) | 191 if (scrollTop !== undefined) |
| 192 this._scrollTop = scrollTop; | 192 this._scrollTop = scrollTop; |
| 193 if (requestData) { | 193 if (requestData) { |
| 194 this._requestData = requestData.requests; | 194 this._requestData = requestData.requests; |
| 195 this._navigationRequest = requestData.navigationRequest; | 195 this._navigationRequest = requestData.navigationRequest; |
| 196 this._calculateCanvasSize(); | 196 this._calculateCanvasSize(); |
| 197 } | 197 } |
| 198 if (eventDividers !== undefined) | 198 if (eventDividers !== undefined) |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 context.fill(); | 432 context.fill(); |
| 433 context.stroke(); | 433 context.stroke(); |
| 434 | 434 |
| 435 var barWidth = Math.max(2, ranges.end - ranges.mid); | 435 var barWidth = Math.max(2, ranges.end - ranges.mid); |
| 436 context.beginPath(); | 436 context.beginPath(); |
| 437 context.globalAlpha = 1; | 437 context.globalAlpha = 1; |
| 438 context.rect(ranges.mid, 0, barWidth, height - borderWidth); | 438 context.rect(ranges.mid, 0, barWidth, height - borderWidth); |
| 439 context.fill(); | 439 context.fill(); |
| 440 context.stroke(); | 440 context.stroke(); |
| 441 | 441 |
| 442 /** @type {?{left: string, right: string, tooltip: (string|undefined)}} */ |
| 443 var labels = null; |
| 442 if (request === this._hoveredRequest) { | 444 if (request === this._hoveredRequest) { |
| 443 var labels = this._calculator.computeBarGraphLabels(request); | 445 labels = this._calculator.computeBarGraphLabels(request); |
| 444 this._drawSimplifiedBarDetails(context, labels.left, labels.right, ranges.
start, ranges.mid, ranges.mid + barWidth + borderOffset); | 446 this._drawSimplifiedBarDetails( |
| 447 context, labels.left, labels.right, ranges.start, ranges.mid, ranges.m
id + barWidth + borderOffset); |
| 448 } |
| 449 |
| 450 if (!this._calculator.startAtZero) { |
| 451 var queueingRange = WebInspector.RequestTimingView.calculateRequestTimeRan
ges(request, 0) |
| 452 .find(data => data.name === WebInspector.RequestTimeRangeNames.Total); |
| 453 var leftLabelWidth = labels ? context.measureText(labels.left).width : 0; |
| 454 var leftTextPlacedInBar = leftLabelWidth < ranges.mid - ranges.start; |
| 455 const wiskerTextPadding = 13; |
| 456 var textOffset = (labels && !leftTextPlacedInBar) ? leftLabelWidth + wiske
rTextPadding : 0; |
| 457 var queueingStart = this._timeToPosition(queueingRange.start); |
| 458 if (ranges.start - textOffset > queueingStart) { |
| 459 context.beginPath(); |
| 460 context.globalAlpha = 1; |
| 461 context.strokeStyle = WebInspector.themeSupport.patchColor( |
| 462 '#a5a5a5', WebInspector.ThemeSupport.ColorUsage.Foreground); |
| 463 context.moveTo(queueingStart, Math.floor(height / 2)); |
| 464 context.lineTo(ranges.start - textOffset, Math.floor(height / 2)); |
| 465 |
| 466 const wiskerHeight = height / 2; |
| 467 context.moveTo(queueingStart + borderOffset, wiskerHeight / 2); |
| 468 context.lineTo(queueingStart + borderOffset, height - wiskerHeight / 2 -
1); |
| 469 context.stroke(); |
| 470 } |
| 445 } | 471 } |
| 446 | 472 |
| 447 context.restore(); | 473 context.restore(); |
| 448 } | 474 } |
| 449 | 475 |
| 450 /** | 476 /** |
| 451 * @param {!CanvasRenderingContext2D} context | 477 * @param {!CanvasRenderingContext2D} context |
| 452 * @param {string} leftText | 478 * @param {string} leftText |
| 453 * @param {string} rightText | 479 * @param {string} rightText |
| 454 * @param {number} startX | 480 * @param {number} startX |
| 455 * @param {number} midX | 481 * @param {number} midX |
| 456 * @param {number} endX | 482 * @param {number} endX |
| 457 */ | 483 */ |
| 458 _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX) { | 484 _drawSimplifiedBarDetails(context, leftText, rightText, startX, midX, endX) { |
| 459 /** @const */ | 485 /** @const */ |
| 460 var barDotLineLength = 10; | 486 var barDotLineLength = 10; |
| 461 | 487 |
| 462 context.save(); | 488 context.save(); |
| 463 var height = this._getBarHeight(); | 489 var height = this._getBarHeight(); |
| 464 var leftLabelWidth = context.measureText(leftText).width; | 490 var leftLabelWidth = context.measureText(leftText).width; |
| 465 var rightLabelWidth = context.measureText(rightText).width; | 491 var rightLabelWidth = context.measureText(rightText).width; |
| 466 context.fillStyle = '#444'; | 492 context.fillStyle = WebInspector.themeSupport.patchColor('#444', WebInspecto
r.ThemeSupport.ColorUsage.Foreground); |
| 467 context.strokeStyle = '#444'; | 493 context.strokeStyle = WebInspector.themeSupport.patchColor('#444', WebInspec
tor.ThemeSupport.ColorUsage.Foreground); |
| 468 if (leftLabelWidth < midX - startX) { | 494 if (leftLabelWidth < midX - startX) { |
| 469 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; | 495 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2; |
| 470 context.fillText(leftText, midBarX, this._fontSize); | 496 context.fillText(leftText, midBarX, this._fontSize); |
| 471 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { | 497 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < startX) { |
| 472 context.beginPath(); | 498 context.beginPath(); |
| 473 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); | 499 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI); |
| 474 context.fill(); | 500 context.fill(); |
| 475 context.fillText(leftText, startX - leftLabelWidth - barDotLineLength - 1,
this._fontSize); | 501 context.fillText(leftText, startX - leftLabelWidth - barDotLineLength - 1,
this._fontSize); |
| 476 context.beginPath(); | 502 context.beginPath(); |
| 477 context.lineWidth = 1; | 503 context.lineWidth = 1; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 597 } |
| 572 if (this._navigationRequest === request) | 598 if (this._navigationRequest === request) |
| 573 return this._rowNavigationRequestColor; | 599 return this._rowNavigationRequestColor; |
| 574 if (rowNumber % 2 === 1) | 600 if (rowNumber % 2 === 1) |
| 575 return 'transparent'; | 601 return 'transparent'; |
| 576 return this._rowStripeColor; | 602 return this._rowStripeColor; |
| 577 } | 603 } |
| 578 } | 604 } |
| 579 }; | 605 }; |
| 580 | 606 |
| 607 /** |
| 608 * @typedef {{requests: !Array<!WebInspector.NetworkRequest>, navigationRequest:
?WebInspector.NetworkRequest}} |
| 609 */ |
| 610 WebInspector.NetworkTimelineColumn.RequestData; |
| 611 |
| 581 WebInspector.NetworkTimelineColumn._colorsForResourceType = { | 612 WebInspector.NetworkTimelineColumn._colorsForResourceType = { |
| 582 document: 'hsl(215, 100%, 80%)', | 613 document: 'hsl(215, 100%, 80%)', |
| 583 font: 'hsl(8, 100%, 80%)', | 614 font: 'hsl(8, 100%, 80%)', |
| 584 media: 'hsl(272, 64%, 80%)', | 615 media: 'hsl(272, 64%, 80%)', |
| 585 image: 'hsl(272, 64%, 80%)', | 616 image: 'hsl(272, 64%, 80%)', |
| 586 script: 'hsl(31, 100%, 80%)', | 617 script: 'hsl(31, 100%, 80%)', |
| 587 stylesheet: 'hsl(90, 50%, 80%)', | 618 stylesheet: 'hsl(90, 50%, 80%)', |
| 588 texttrack: 'hsl(8, 100%, 80%)', | 619 texttrack: 'hsl(8, 100%, 80%)', |
| 589 websocket: 'hsl(0, 0%, 95%)', | 620 websocket: 'hsl(0, 0%, 95%)', |
| 590 xhr: 'hsl(53, 100%, 80%)', | 621 xhr: 'hsl(53, 100%, 80%)', |
| 591 other: 'hsl(0, 0%, 95%)' | 622 other: 'hsl(0, 0%, 95%)' |
| 592 }; | 623 }; |
| OLD | NEW |