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 Network.NetworkWaterfallColumn = class extends UI.VBox { | 7 Network.NetworkWaterfallColumn = class extends UI.VBox { |
8 /** | 8 /** |
9 * @param {number} rowHeight | 9 * @param {number} rowHeight |
10 * @param {!Network.NetworkTimeCalculator} calculator | 10 * @param {!Network.NetworkTimeCalculator} calculator |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 context.scale(window.devicePixelRatio, window.devicePixelRatio); | 301 context.scale(window.devicePixelRatio, window.devicePixelRatio); |
302 context.translate(0, this._headerHeight); | 302 context.translate(0, this._headerHeight); |
303 context.rect(0, 0, this._offsetWidth, this._offsetHeight); | 303 context.rect(0, 0, this._offsetWidth, this._offsetHeight); |
304 context.clip(); | 304 context.clip(); |
305 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); | 305 var firstRequestIndex = Math.floor(this._scrollTop / this._rowHeight); |
306 var lastRequestIndex = Math.min(nodes.length, firstRequestIndex + Math.ceil(
this._offsetHeight / this._rowHeight)); | 306 var lastRequestIndex = Math.min(nodes.length, firstRequestIndex + Math.ceil(
this._offsetHeight / this._rowHeight)); |
307 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { | 307 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { |
308 var rowOffset = this._rowHeight * i; | 308 var rowOffset = this._rowHeight * i; |
309 var node = nodes[i]; | 309 var node = nodes[i]; |
310 this._decorateRow(context, node, i, rowOffset - this._scrollTop); | 310 this._decorateRow(context, node, i, rowOffset - this._scrollTop); |
311 if (useTimingBars) | 311 var drawNodes = []; |
312 this._drawTimingBars(context, node, rowOffset - this._scrollTop); | 312 if (node.hasChildren() && !node.expanded) |
313 else | 313 drawNodes = /** @type {!Array<!Network.NetworkNode>} */ (node.flatChildr
en()); |
314 this._drawSimplifiedBars(context, node, rowOffset - this._scrollTop); | 314 drawNodes.push(node); |
| 315 for (var drawNode of drawNodes) { |
| 316 if (useTimingBars) |
| 317 this._drawTimingBars(context, drawNode, rowOffset - this._scrollTop); |
| 318 else |
| 319 this._drawSimplifiedBars(context, drawNode, rowOffset - this._scrollTo
p); |
| 320 } |
315 } | 321 } |
316 this._drawEventDividers(context); | 322 this._drawEventDividers(context); |
317 context.restore(); | 323 context.restore(); |
318 | 324 |
319 const freeZoneAtLeft = 75; | 325 const freeZoneAtLeft = 75; |
320 const freeZoneAtRight = 18; | 326 const freeZoneAtRight = 18; |
321 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize, th
is._headerHeight, freeZoneAtLeft); | 327 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, this._fontSize, th
is._headerHeight, freeZoneAtLeft); |
322 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t
his._headerHeight); | 328 context.clearRect(this._offsetWidth - freeZoneAtRight, 0, freeZoneAtRight, t
his._headerHeight); |
323 this._didDrawForTest(); | 329 this._didDrawForTest(); |
324 } | 330 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset | 433 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) +
borderOffset |
428 }; | 434 }; |
429 } | 435 } |
430 | 436 |
431 /** | 437 /** |
432 * @param {!CanvasRenderingContext2D} context | 438 * @param {!CanvasRenderingContext2D} context |
433 * @param {!Network.NetworkNode} node | 439 * @param {!Network.NetworkNode} node |
434 * @param {number} y | 440 * @param {number} y |
435 */ | 441 */ |
436 _drawSimplifiedBars(context, node, y) { | 442 _drawSimplifiedBars(context, node, y) { |
437 // TODO(allada) This should draw bars for groupped requests. | |
438 var request = node.request(); | 443 var request = node.request(); |
439 if (!request) | 444 if (!request) |
440 return; | 445 return; |
441 const borderWidth = 1; | 446 const borderWidth = 1; |
442 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; | 447 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5; |
443 | 448 |
444 context.save(); | 449 context.save(); |
445 var ranges = this._getSimplifiedBarRange(request, borderOffset); | 450 var ranges = this._getSimplifiedBarRange(request, borderOffset); |
446 var height = this._getBarHeight(); | 451 var height = this._getBarHeight(); |
447 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; | 452 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt
h / 2; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 } | 551 } |
547 context.restore(); | 552 context.restore(); |
548 } | 553 } |
549 | 554 |
550 /** | 555 /** |
551 * @param {!CanvasRenderingContext2D} context | 556 * @param {!CanvasRenderingContext2D} context |
552 * @param {!Network.NetworkNode} node | 557 * @param {!Network.NetworkNode} node |
553 * @param {number} y | 558 * @param {number} y |
554 */ | 559 */ |
555 _drawTimingBars(context, node, y) { | 560 _drawTimingBars(context, node, y) { |
556 // TODO(allada) This should draw bars for groupped requests. | |
557 var request = node.request(); | 561 var request = node.request(); |
558 if (!request) | 562 if (!request) |
559 return; | 563 return; |
560 context.save(); | 564 context.save(); |
561 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0
); | 565 var ranges = Network.RequestTimingView.calculateRequestTimeRanges(request, 0
); |
562 for (var range of ranges) { | 566 for (var range of ranges) { |
563 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N
etwork.RequestTimeRangeNames.Sending || | 567 if (range.name === Network.RequestTimeRangeNames.Total || range.name === N
etwork.RequestTimeRangeNames.Sending || |
564 range.end - range.start === 0) | 568 range.end - range.start === 0) |
565 continue; | 569 continue; |
566 context.beginPath(); | 570 context.beginPath(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 font: 'hsl(8, 100%, 80%)', | 640 font: 'hsl(8, 100%, 80%)', |
637 media: 'hsl(90, 50%, 80%)', | 641 media: 'hsl(90, 50%, 80%)', |
638 image: 'hsl(90, 50%, 80%)', | 642 image: 'hsl(90, 50%, 80%)', |
639 script: 'hsl(31, 100%, 80%)', | 643 script: 'hsl(31, 100%, 80%)', |
640 stylesheet: 'hsl(272, 64%, 80%)', | 644 stylesheet: 'hsl(272, 64%, 80%)', |
641 texttrack: 'hsl(8, 100%, 80%)', | 645 texttrack: 'hsl(8, 100%, 80%)', |
642 websocket: 'hsl(0, 0%, 95%)', | 646 websocket: 'hsl(0, 0%, 95%)', |
643 xhr: 'hsl(53, 100%, 80%)', | 647 xhr: 'hsl(53, 100%, 80%)', |
644 other: 'hsl(0, 0%, 95%)' | 648 other: 'hsl(0, 0%, 95%)' |
645 }; | 649 }; |
OLD | NEW |