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

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

Issue 2418953002: [Devtools] Added simplified/latency view to network timeline experiment (Closed)
Patch Set: Merge branch 'master' of https://chromium.googlesource.com/chromium/src into NETWORK_TIMELINE_8_LAT… Created 4 years, 2 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 | third_party/WebKit/Source/devtools/front_end/network/networkLogView.css » ('j') | 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 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @param {!WebInspector.NetworkLogView} networkLogView 8 * @param {!WebInspector.NetworkLogView} networkLogView
9 * @param {!WebInspector.SortableDataGrid} dataGrid 9 * @param {!WebInspector.SortableDataGrid} dataGrid
10 */ 10 */
11 WebInspector.NetworkTimelineColumn = function(networkLogView, dataGrid) 11 WebInspector.NetworkTimelineColumn = function(networkLogView, dataGrid)
12 { 12 {
13 WebInspector.VBox.call(this, true); 13 WebInspector.VBox.call(this, true);
14 this.registerRequiredCSS("network/networkTimelineColumn.css"); 14 this.registerRequiredCSS("network/networkTimelineColumn.css");
15 15
16 this._canvas = this.contentElement.createChild("canvas"); 16 this._canvas = this.contentElement.createChild("canvas");
17 this._canvas.tabIndex = 1; 17 this._canvas.tabIndex = 1;
18 this.setDefaultFocusedElement(this._canvas); 18 this.setDefaultFocusedElement(this._canvas);
19 19
20 /** @const */ 20 /** @const */
21 this._leftPadding = 5; 21 this._leftPadding = 5;
22 /** @const */ 22 /** @const */
23 this._rightPadding = 5; 23 this._rightPadding = 5;
24 /** @const */
25 this._fontSize = 10;
24 26
25 this._dataGrid = dataGrid; 27 this._dataGrid = dataGrid;
26 this._networkLogView = networkLogView; 28 this._networkLogView = networkLogView;
27 29
28 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this)); 30 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this));
29 this._popoverHelper.setTimeout(300, 300); 31 this._popoverHelper.setTimeout(300, 300);
30 32
31 this._vScrollElement = this.contentElement.createChild("div", "network-timel ine-v-scroll"); 33 this._vScrollElement = this.contentElement.createChild("div", "network-timel ine-v-scroll");
32 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), { passive: true }); 34 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), { passive: true });
33 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind( this), { passive: true }); 35 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind( this), { passive: true });
(...skipping 17 matching lines...) Expand all
51 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChanged, this._updateHeight.bind(this)); 53 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChanged, this._updateHeight.bind(this));
52 54
53 /** @type {!Array<!WebInspector.NetworkRequest>} */ 55 /** @type {!Array<!WebInspector.NetworkRequest>} */
54 this._requestData = []; 56 this._requestData = [];
55 57
56 /** @type {?WebInspector.NetworkRequest} */ 58 /** @type {?WebInspector.NetworkRequest} */
57 this._hoveredRequest = null; 59 this._hoveredRequest = null;
58 60
59 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", WebIn spector.ThemeSupport.ColorUsage.Background); 61 this._rowStripeColor = WebInspector.themeSupport.patchColor("#f5f5f5", WebIn spector.ThemeSupport.ColorUsage.Background);
60 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", WebIns pector.ThemeSupport.ColorUsage.Background); 62 this._rowHoverColor = WebInspector.themeSupport.patchColor("#ebf2fc", WebIns pector.ThemeSupport.ColorUsage.Background);
63
64 /** @type {!Map<!WebInspector.ResourceType, string>} */
65 this._borderColorsForResourceTypeCache = new Map();
66 /** @type {!Map<string, !CanvasGradient>} */
67 this._colorsForResourceTypeCache = new Map();
61 } 68 }
62 69
63 WebInspector.NetworkTimelineColumn.Events = { 70 WebInspector.NetworkTimelineColumn.Events = {
64 RequestHovered: Symbol("RequestHovered") 71 RequestHovered: Symbol("RequestHovered")
65 } 72 }
66 73
74 WebInspector.NetworkTimelineColumn._colorsForResourceType = {
75 document: "hsl(215, 100%, 80%)",
76 font: "hsl(8, 100%, 80%)",
77 media: "hsl(272, 64%, 80%)",
78 image: "hsl(272, 64%, 80%)",
79 script: "hsl(31, 100%, 80%)",
80 stylesheet: "hsl(90, 50%, 80%)",
81 texttrack: "hsl(8, 100%, 80%)",
82 websocket: "hsl(0, 0%, 95%)",
83 xhr: "hsl(53, 100%, 80%)",
84 other: "hsl(0, 0%, 95%)"
85 }
86
67 WebInspector.NetworkTimelineColumn.prototype = { 87 WebInspector.NetworkTimelineColumn.prototype = {
68 /** 88 /**
69 * @override 89 * @override
70 */ 90 */
71 willHide: function() 91 willHide: function()
72 { 92 {
73 this._popoverHelper.hidePopover(); 93 this._popoverHelper.hidePopover();
74 }, 94 },
75 95
76 /** 96 /**
(...skipping 30 matching lines...) Expand all
107 }, 127 },
108 128
109 /** 129 /**
110 * @param {!Element|!AnchorBox} anchor 130 * @param {!Element|!AnchorBox} anchor
111 * @param {!WebInspector.Popover} popover 131 * @param {!WebInspector.Popover} popover
112 */ 132 */
113 _showPopover: function(anchor, popover) 133 _showPopover: function(anchor, popover)
114 { 134 {
115 if (!this._hoveredRequest) 135 if (!this._hoveredRequest)
116 return; 136 return;
117 var content = WebInspector.RequestTimingView.createTimingTable(this._hov eredRequest, this._networkLogView.timeCalculator().minimumBoundary()); 137 var content = WebInspector.RequestTimingView.createTimingTable(this._hov eredRequest, this._networkLogView.calculator().minimumBoundary());
118 popover.showForAnchor(content, anchor); 138 popover.showForAnchor(content, anchor);
119 }, 139 },
120 140
121 wasShown: function() 141 wasShown: function()
122 { 142 {
123 this.scheduleUpdate(); 143 this.scheduleUpdate();
124 }, 144 },
125 145
126 scheduleRefreshData: function() 146 scheduleRefreshData: function()
127 { 147 {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 */ 297 */
278 _timeToPosition: function(time) 298 _timeToPosition: function(time)
279 { 299 {
280 var availableWidth = this._offsetWidth - this._leftPadding - this._right Padding; 300 var availableWidth = this._offsetWidth - this._leftPadding - this._right Padding;
281 var timeToPixel = availableWidth / (this._endTime - this._startTime); 301 var timeToPixel = availableWidth / (this._endTime - this._startTime);
282 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP ixel); 302 return Math.floor(this._leftPadding + (time - this._startTime) * timeToP ixel);
283 }, 303 },
284 304
285 _draw: function() 305 _draw: function()
286 { 306 {
307 var useTimingBars = !WebInspector.moduleSetting("networkColorCodeResourc eTypes").get() && !this._networkLogView.calculator().startAtZero;
287 var requests = this._requestData; 308 var requests = this._requestData;
288 var context = this._canvas.getContext("2d"); 309 var context = this._canvas.getContext("2d");
289 context.save(); 310 context.save();
290 context.scale(window.devicePixelRatio, window.devicePixelRatio); 311 context.scale(window.devicePixelRatio, window.devicePixelRatio);
291 context.translate(0, this._networkLogView.headerHeight()); 312 context.translate(0, this._networkLogView.headerHeight());
292 context.rect(0, 0, this._offsetWidth, this._offsetHeight); 313 context.rect(0, 0, this._offsetWidth, this._offsetHeight);
293 context.clip(); 314 context.clip();
294 var rowHeight = this._networkLogView.rowHeight(); 315 var rowHeight = this._networkLogView.rowHeight();
295 var scrollTop = this._vScrollElement.scrollTop; 316 var scrollTop = this._vScrollElement.scrollTop;
296 var firstRequestIndex = Math.floor(scrollTop / rowHeight); 317 var firstRequestIndex = Math.floor(scrollTop / rowHeight);
297 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat h.ceil(this._offsetHeight / rowHeight)); 318 var lastRequestIndex = Math.min(requests.length, firstRequestIndex + Mat h.ceil(this._offsetHeight / rowHeight));
298 for (var i = firstRequestIndex; i < lastRequestIndex; i++) { 319 for (var i = firstRequestIndex; i < lastRequestIndex; i++) {
299 var rowOffset = rowHeight * i; 320 var rowOffset = rowHeight * i;
300 var request = requests[i]; 321 var request = requests[i];
301 this._decorateRow(context, request, i, rowOffset - scrollTop, rowHei ght); 322 this._decorateRow(context, request, i, rowOffset - scrollTop, rowHei ght);
302 var ranges = WebInspector.RequestTimingView.calculateRequestTimeRang es(request, 0); 323 if (useTimingBars)
303 for (var range of ranges) { 324 this._drawTimingBars(context, request, rowOffset - scrollTop);
304 if (range.name === WebInspector.RequestTimeRangeNames.Total || 325 else
305 range.name === WebInspector.RequestTimeRangeNames.Sending || 326 this._drawSimplifiedBars(context, request, rowOffset - scrollTop );
306 range.end - range.start === 0)
307 continue;
308 this._drawBar(context, range, rowOffset - scrollTop);
309 }
310 } 327 }
311 context.restore(); 328 context.restore();
312 this._drawDividers(context); 329 this._drawDividers(context);
313 }, 330 },
314 331
315 _drawDividers: function(context) 332 _drawDividers: function(context)
316 { 333 {
317 context.save(); 334 context.save();
318 /** @const */ 335 /** @const */
319 var minGridSlicePx = 64; // minimal distance between grid lines. 336 var minGridSlicePx = 64; // minimal distance between grid lines.
320 /** @const */
321 var fontSize = 10;
322 337
323 var drawableWidth = this._offsetWidth - this._leftPadding - this._rightP adding; 338 var drawableWidth = this._offsetWidth - this._leftPadding - this._rightP adding;
324 var timelineDuration = this._timelineDuration(); 339 var timelineDuration = this._timelineDuration();
325 var dividersCount = drawableWidth / minGridSlicePx; 340 var dividersCount = drawableWidth / minGridSlicePx;
326 var gridSliceTime = timelineDuration / dividersCount; 341 var gridSliceTime = timelineDuration / dividersCount;
327 var pixelsPerTime = drawableWidth / timelineDuration; 342 var pixelsPerTime = drawableWidth / timelineDuration;
328 343
329 // Align gridSliceTime to a nearest round value. 344 // Align gridSliceTime to a nearest round value.
330 // We allow spans that fit into the formula: span = (1|2|5)x10^n, 345 // We allow spans that fit into the formula: span = (1|2|5)x10^n,
331 // e.g.: ... .1 .2 .5 1 2 5 10 20 50 ... 346 // e.g.: ... .1 .2 .5 1 2 5 10 20 50 ...
332 // After a span has been chosen make grid lines at multiples of the span . 347 // After a span has been chosen make grid lines at multiples of the span .
333 348
334 var logGridSliceTime = Math.ceil(Math.log(gridSliceTime) / Math.LN10); 349 var logGridSliceTime = Math.ceil(Math.log(gridSliceTime) / Math.LN10);
335 gridSliceTime = Math.pow(10, logGridSliceTime); 350 gridSliceTime = Math.pow(10, logGridSliceTime);
336 if (gridSliceTime * pixelsPerTime >= 5 * minGridSlicePx) 351 if (gridSliceTime * pixelsPerTime >= 5 * minGridSlicePx)
337 gridSliceTime = gridSliceTime / 5; 352 gridSliceTime = gridSliceTime / 5;
338 if (gridSliceTime * pixelsPerTime >= 2 * minGridSlicePx) 353 if (gridSliceTime * pixelsPerTime >= 2 * minGridSlicePx)
339 gridSliceTime = gridSliceTime / 2; 354 gridSliceTime = gridSliceTime / 2;
340 355
341 context.lineWidth = 1; 356 context.lineWidth = 1;
342 context.strokeStyle = "rgba(0, 0, 0, .1)"; 357 context.strokeStyle = "rgba(0, 0, 0, .1)";
343 context.font = fontSize + "px sans-serif"; 358 context.font = this._fontSize + "px sans-serif";
344 context.fillStyle = "#444" 359 context.fillStyle = "#444"
345 gridSliceTime = gridSliceTime; 360 gridSliceTime = gridSliceTime;
346 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi dth; position += gridSliceTime * pixelsPerTime) { 361 for (var position = gridSliceTime * pixelsPerTime; position < drawableWi dth; position += gridSliceTime * pixelsPerTime) {
347 // Added .5 because canvas drawing points are between pixels. 362 // Added .5 because canvas drawing points are between pixels.
348 var drawPosition = Math.floor(position) + this._leftPadding + .5; 363 var drawPosition = Math.floor(position) + this._leftPadding + .5;
349 context.beginPath(); 364 context.beginPath();
350 context.moveTo(drawPosition, 0); 365 context.moveTo(drawPosition, 0);
351 context.lineTo(drawPosition, this._offsetHeight); 366 context.lineTo(drawPosition, this._offsetHeight);
352 context.stroke(); 367 context.stroke();
353 if (position <= gridSliceTime * pixelsPerTime) 368 if (position <= gridSliceTime * pixelsPerTime)
354 continue; 369 continue;
355 var textData = Number.secondsToString(position / pixelsPerTime); 370 var textData = Number.secondsToString(position / pixelsPerTime);
356 context.fillText(textData, drawPosition - context.measureText(textDa ta).width - 2, Math.floor(this._networkLogView.headerHeight() - fontSize / 2)); 371 context.fillText(textData, drawPosition - context.measureText(textDa ta).width - 2, Math.floor(this._networkLogView.headerHeight() - this._fontSize / 2));
357 } 372 }
358 context.restore(); 373 context.restore();
359 }, 374 },
360 375
361 /** 376 /**
362 * @return {number} 377 * @return {number}
363 */ 378 */
364 _timelineDuration: function() 379 _timelineDuration: function()
365 { 380 {
366 return this._networkLogView.calculator().maximumBoundary() - this._netwo rkLogView.calculator().minimumBoundary(); 381 return this._networkLogView.calculator().maximumBoundary() - this._netwo rkLogView.calculator().minimumBoundary();
367 }, 382 },
368 383
369 /** 384 /**
370 * @param {!WebInspector.RequestTimeRangeNames} type 385 * @param {!WebInspector.RequestTimeRangeNames=} type
371 * @return {number} 386 * @return {number}
372 */ 387 */
373 _getBarHeight: function(type) 388 _getBarHeight: function(type)
374 { 389 {
375 var types = WebInspector.RequestTimeRangeNames; 390 var types = WebInspector.RequestTimeRangeNames;
376 switch (type) { 391 switch (type) {
377 case types.Connecting: 392 case types.Connecting:
378 case types.SSL: 393 case types.SSL:
379 case types.DNS: 394 case types.DNS:
380 case types.Proxy: 395 case types.Proxy:
381 case types.Blocking: 396 case types.Blocking:
382 case types.Push: 397 case types.Push:
383 case types.Queueing: 398 case types.Queueing:
384 return 7; 399 return 7;
385 default: 400 default:
386 return 13; 401 return 13;
387 } 402 }
388 }, 403 },
389 404
390 /** 405 /**
406 * @param {!WebInspector.NetworkRequest} request
407 * @return {string}
408 */
409 _borderColorForResourceType: function(request)
410 {
411 var resourceType = request.resourceType();
412 if (this._borderColorsForResourceTypeCache.has(resourceType))
413 return this._borderColorsForResourceTypeCache.get(resourceType);
414 var colorsForResourceType = WebInspector.NetworkTimelineColumn._colorsFo rResourceType;
415 var color = colorsForResourceType[resourceType] || colorsForResourceType .Other;
416 var parsedColor = WebInspector.Color.parse(color);
417 var hsla = parsedColor.hsla();
418 hsla[1] /= 2;
419 hsla[2] -= Math.min(hsla[2], 0.2);
420 var resultColor = /** @type {string} */ (parsedColor.asString(null));
421 this._borderColorsForResourceTypeCache.set(resourceType, resultColor);
422 return resultColor;
423 },
424
425 /**
391 * @param {!CanvasRenderingContext2D} context 426 * @param {!CanvasRenderingContext2D} context
392 * @param {!WebInspector.RequestTimeRange} range 427 * @param {!WebInspector.NetworkRequest} request
428 * @return {string|!CanvasGradient}
429 */
430 _colorForResourceType: function(context, request)
431 {
432 var colorsForResourceType = WebInspector.NetworkTimelineColumn._colorsFo rResourceType;
433 var resourceType = request.resourceType();
434 var color = colorsForResourceType[resourceType] || colorsForResourceType .Other;
435 if (request.cached())
436 return color;
437
438 if (this._colorsForResourceTypeCache.has(color))
439 return this._colorsForResourceTypeCache.get(color);
440 var parsedColor = WebInspector.Color.parse(color);
441 var hsla = parsedColor.hsla();
442 hsla[1] -= Math.min(hsla[1], 0.28);
443 hsla[2] -= Math.min(hsla[2], 0.15);
444 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight( ));
445 gradient.addColorStop(0, color);
446 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(nul l)));
447 this._colorsForResourceTypeCache.set(color, gradient);
448 return gradient;
449 },
450
451 /**
452 * @param {!CanvasRenderingContext2D} context
453 * @param {!WebInspector.NetworkRequest} request
393 * @param {number} y 454 * @param {number} y
394 */ 455 */
395 _drawBar: function(context, range, y) 456 _drawSimplifiedBars: function(context, request, y)
396 { 457 {
458 /** @const */
459 var borderWidth = 1;
460
397 context.save(); 461 context.save();
462 var calculator = this._networkLogView.calculator();
463 var percentages = calculator.computeBarGraphPercentages(request);
464 var drawWidth = this._offsetWidth - this._leftPadding - this._rightPaddi ng;
465 var borderOffset = borderWidth % 2 === 0 ? 0 : .5;
466 var start = this._leftPadding + Math.floor((percentages.start / 100) * d rawWidth) + borderOffset;
467 var mid = this._leftPadding + Math.floor((percentages.middle / 100) * dr awWidth) + borderOffset;
468 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawW idth) + borderOffset;
469 var height = this._getBarHeight();
470 y += Math.floor(this._networkLogView.rowHeight() / 2 - height / 2 + bord erWidth) - borderWidth / 2;
471
472 context.translate(0, y);
473 context.fillStyle = this._colorForResourceType(context, request);
474 context.strokeStyle = this._borderColorForResourceType(request);
475 context.lineWidth = borderWidth;
476
398 context.beginPath(); 477 context.beginPath();
399 var lineWidth = 0; 478 context.globalAlpha = .5;
400 var color = this._colorForType(range.name); 479 context.rect(start, 0, mid - start, height - borderWidth);
401 var borderColor = color; 480 context.fill();
402 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) { 481 context.stroke();
403 borderColor = "lightgrey"; 482
404 lineWidth = 2; 483 var barWidth = Math.max(2, end - mid);
484 context.beginPath();
485 context.globalAlpha = 1;
486 context.rect(mid, 0, barWidth, height - borderWidth);
487 context.fill();
488 context.stroke();
489
490 if (request === this._hoveredRequest) {
491 var labels = calculator.computeBarGraphLabels(request);
492 this._drawSimplifiedBarDetails(context, labels.left, labels.right, s tart, mid, mid + barWidth + borderOffset);
405 } 493 }
406 if (range.name === WebInspector.RequestTimeRangeNames.Receiving) 494
407 lineWidth = 2;
408 context.fillStyle = color;
409 var height = this._getBarHeight(range.name);
410 y += Math.floor(this._networkLogView.rowHeight() / 2 - height / 2) + lin eWidth / 2;
411 var start = this._timeToPosition(range.start);
412 var end = this._timeToPosition(range.end);
413 context.rect(start, y, end - start, height - lineWidth);
414 if (lineWidth) {
415 context.lineWidth = lineWidth;
416 context.strokeStyle = borderColor;
417 context.stroke();
418 }
419 context.fill();
420 context.restore(); 495 context.restore();
421 }, 496 },
422 497
498 /**
499 * @param {!CanvasRenderingContext2D} context
500 * @param {string} leftText
501 * @param {string} rightText
502 * @param {number} startX
503 * @param {number} midX
504 * @param {number} endX
505 */
506 _drawSimplifiedBarDetails: function(context, leftText, rightText, startX, mi dX, endX)
507 {
508 /** @const */
509 var barDotLineLength = 10;
510
511 context.save();
512 var height = this._getBarHeight();
513 var leftLabelWidth = context.measureText(leftText).width;
514 var rightLabelWidth = context.measureText(rightText).width;
515 context.fillStyle = "#444";
516 context.strokeStyle = "#444";
517 if (leftLabelWidth < midX - startX) {
518 var midBarX = startX + (midX - startX) / 2 - leftLabelWidth / 2;
519 context.fillText(leftText, midBarX, this._fontSize);
520 } else if (barDotLineLength + leftLabelWidth + this._leftPadding < start X) {
521 context.beginPath();
522 context.arc(startX, Math.floor(height / 2), 2, 0, 2 * Math.PI);
523 context.fill();
524 context.fillText(leftText, startX - leftLabelWidth - barDotLineLengt h - 1, this._fontSize);
525 context.beginPath();
526 context.lineWidth = 1;
527 context.moveTo(startX - barDotLineLength, Math.floor(height / 2));
528 context.lineTo(startX, Math.floor(height / 2));
529 context.stroke();
530 }
531
532 if (rightLabelWidth < endX - midX) {
533 var midBarX = midX + (endX - midX) / 2 - rightLabelWidth / 2;
534 context.fillText(rightText, midBarX, this._fontSize);
535 } else if (endX + barDotLineLength + rightLabelWidth < this._offsetWidth - this._leftPadding - this._rightPadding) {
536 context.beginPath();
537 context.arc(endX, Math.floor(height / 2), 2, 0, 2 * Math.PI);
538 context.fill();
539 context.fillText(rightText, endX + barDotLineLength + 1, this._fontS ize);
540 context.beginPath();
541 context.lineWidth = 1;
542 context.moveTo(endX, Math.floor(height / 2));
543 context.lineTo(endX + barDotLineLength, Math.floor(height / 2));
544 context.stroke();
545 }
546 context.restore();
547 },
548
549 /**
550 * @param {!CanvasRenderingContext2D} context
551 * @param {!WebInspector.NetworkRequest} request
552 * @param {number} y
553 */
554 _drawTimingBars: function(context, request, y)
555 {
556 context.save();
557 var ranges = WebInspector.RequestTimingView.calculateRequestTimeRanges(r equest, 0);
558 for (var range of ranges) {
559 if (range.name === WebInspector.RequestTimeRangeNames.Total ||
560 range.name === WebInspector.RequestTimeRangeNames.Sending ||
561 range.end - range.start === 0)
562 continue;
563 context.beginPath();
564 var lineWidth = 0;
565 var color = this._colorForType(range.name);
566 var borderColor = color;
567 if (range.name === WebInspector.RequestTimeRangeNames.Queueing) {
568 borderColor = "lightgrey";
569 lineWidth = 2;
570 }
571 if (range.name === WebInspector.RequestTimeRangeNames.Receiving)
572 lineWidth = 2;
573 context.fillStyle = color;
574 var height = this._getBarHeight(range.name);
575 var middleBarY = y + Math.floor(this._networkLogView.rowHeight() / 2 - height / 2) + lineWidth / 2;
576 var start = this._timeToPosition(range.start);
577 var end = this._timeToPosition(range.end);
578 context.rect(start, middleBarY, end - start, height - lineWidth);
579 if (lineWidth) {
580 context.lineWidth = lineWidth;
581 context.strokeStyle = borderColor;
582 context.stroke();
583 }
584 context.fill();
585 }
586 context.restore();
587 },
588
423 /** 589 /**
424 * @param {!CanvasRenderingContext2D} context 590 * @param {!CanvasRenderingContext2D} context
425 * @param {!WebInspector.NetworkRequest} request 591 * @param {!WebInspector.NetworkRequest} request
426 * @param {number} rowNumber 592 * @param {number} rowNumber
427 * @param {number} y 593 * @param {number} y
428 * @param {number} rowHeight 594 * @param {number} rowHeight
429 */ 595 */
430 _decorateRow: function(context, request, rowNumber, y, rowHeight) 596 _decorateRow: function(context, request, rowNumber, y, rowHeight)
431 { 597 {
432 if (rowNumber % 2 === 1 && this._hoveredRequest !== request) 598 if (rowNumber % 2 === 1 && this._hoveredRequest !== request)
433 return; 599 return;
434 context.save(); 600 context.save();
435 context.beginPath(); 601 context.beginPath();
436 var color = this._rowStripeColor; 602 var color = this._rowStripeColor;
437 if (this._hoveredRequest === request) 603 if (this._hoveredRequest === request)
438 color = this._rowHoverColor; 604 color = this._rowHoverColor;
439 605
440 context.fillStyle = color; 606 context.fillStyle = color;
441 context.rect(0, y, this._offsetWidth, rowHeight); 607 context.rect(0, y, this._offsetWidth, rowHeight);
442 context.fill(); 608 context.fill();
443 context.restore(); 609 context.restore();
444 }, 610 },
445 611
446 __proto__: WebInspector.VBox.prototype 612 __proto__: WebInspector.VBox.prototype
447 } 613 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/network/networkLogView.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698