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

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

Issue 2470273002: [Devtools] Fixed new timeline simplified bars popover hover (Closed)
Patch Set: changes Created 4 years, 1 month 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 | no next file » | 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 * @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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 /** 80 /**
81 * @param {!Element} element 81 * @param {!Element} element
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 88 var useTimingBars =
89 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(this._ hoveredRequest, 0) 89 !WebInspector.moduleSetting('networkColorCodeResourceTypes').get() && !t his._calculator.startAtZero;
90 .find(data => data.name === 'total'); 90 if (useTimingBars) {
91 var start = this._timeToPosition(range.start); 91 var range = WebInspector.RequestTimingView.calculateRequestTimeRanges(this ._hoveredRequest, 0)
92 var end = this._timeToPosition(range.end); 92 .find(data => data.name === 'total');
93 var start = this._timeToPosition(range.start);
94 var end = this._timeToPosition(range.end);
95 } else {
96 var range = this._getSimplifiedBarRange(this._hoveredRequest, 0);
97 var start = range.start;
98 var end = range.end;
99 }
93 100
94 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)
95 return; 102 return;
96 103
97 var rowIndex = this._requestData.findIndex(request => this._hoveredRequest = == request); 104 var rowIndex = this._requestData.findIndex(request => this._hoveredRequest = == request);
98 var barHeight = this._getBarHeight(range.name); 105 var barHeight = this._getBarHeight(range.name);
99 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop) + ((this._rowHeight - barHeight) / 2); 106 var y = this._headerHeight + (this._rowHeight * rowIndex - this._scrollTop) + ((this._rowHeight - barHeight) / 2);
100 107
101 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca nvasPosition.top + y + barHeight) 108 if (event.clientY < this._canvasPosition.top + y || event.clientY > this._ca nvasPosition.top + y + barHeight)
102 return; 109 return;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 hsla[1] -= Math.min(hsla[1], 0.28); 386 hsla[1] -= Math.min(hsla[1], 0.28);
380 hsla[2] -= Math.min(hsla[2], 0.15); 387 hsla[2] -= Math.min(hsla[2], 0.15);
381 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight()); 388 var gradient = context.createLinearGradient(0, 0, 0, this._getBarHeight());
382 gradient.addColorStop(0, color); 389 gradient.addColorStop(0, color);
383 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null))) ; 390 gradient.addColorStop(1, /** @type {string} */ (parsedColor.asString(null))) ;
384 this._colorsForResourceTypeCache.set(color, gradient); 391 this._colorsForResourceTypeCache.set(color, gradient);
385 return gradient; 392 return gradient;
386 } 393 }
387 394
388 /** 395 /**
396 * @param {!WebInspector.NetworkRequest} request
397 * @param {number} borderOffset
398 * @return {!{start: number, mid: number, end: number}}
399 */
400 _getSimplifiedBarRange(request, borderOffset) {
401 var drawWidth = this._offsetWidth - this._leftPadding;
402 var percentages = this._calculator.computeBarGraphPercentages(request);
403 return {
404 start: this._leftPadding + Math.floor((percentages.start / 100) * drawWidt h) + borderOffset,
405 mid: this._leftPadding + Math.floor((percentages.middle / 100) * drawWidth ) + borderOffset,
406 end: this._leftPadding + Math.floor((percentages.end / 100) * drawWidth) + borderOffset
407 };
408 }
409
410 /**
389 * @param {!CanvasRenderingContext2D} context 411 * @param {!CanvasRenderingContext2D} context
390 * @param {!WebInspector.NetworkRequest} request 412 * @param {!WebInspector.NetworkRequest} request
391 * @param {number} y 413 * @param {number} y
392 */ 414 */
393 _drawSimplifiedBars(context, request, y) { 415 _drawSimplifiedBars(context, request, y) {
394 /** @const */ 416 const borderWidth = 1;
395 var borderWidth = 1; 417 var borderOffset = borderWidth % 2 === 0 ? 0 : 0.5;
396 418
397 context.save(); 419 context.save();
398 var percentages = this._calculator.computeBarGraphPercentages(request); 420 var ranges = this._getSimplifiedBarRange(request, borderOffset);
399 var drawWidth = this._offsetWidth - this._leftPadding;
400 var borderOffset = borderWidth % 2 === 0 ? 0 : .5;
401 var start = this._leftPadding + Math.floor((percentages.start / 100) * drawW idth) + borderOffset;
402 var mid = this._leftPadding + Math.floor((percentages.middle / 100) * drawWi dth) + borderOffset;
403 var end = this._leftPadding + Math.floor((percentages.end / 100) * drawWidth ) + borderOffset;
404 var height = this._getBarHeight(); 421 var height = this._getBarHeight();
405 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2; 422 y += Math.floor(this._rowHeight / 2 - height / 2 + borderWidth) - borderWidt h / 2;
406 423
407 context.translate(0, y); 424 context.translate(0, y);
408 context.fillStyle = this._colorForResourceType(context, request); 425 context.fillStyle = this._colorForResourceType(context, request);
409 context.strokeStyle = this._borderColorForResourceType(request); 426 context.strokeStyle = this._borderColorForResourceType(request);
410 context.lineWidth = borderWidth; 427 context.lineWidth = borderWidth;
411 428
412 context.beginPath(); 429 context.beginPath();
413 context.globalAlpha = .5; 430 context.globalAlpha = 0.5;
414 context.rect(start, 0, mid - start, height - borderWidth); 431 context.rect(ranges.start, 0, ranges.mid - ranges.start, height - borderWidt h);
415 context.fill(); 432 context.fill();
416 context.stroke(); 433 context.stroke();
417 434
418 var barWidth = Math.max(2, end - mid); 435 var barWidth = Math.max(2, ranges.end - ranges.mid);
419 context.beginPath(); 436 context.beginPath();
420 context.globalAlpha = 1; 437 context.globalAlpha = 1;
421 context.rect(mid, 0, barWidth, height - borderWidth); 438 context.rect(ranges.mid, 0, barWidth, height - borderWidth);
422 context.fill(); 439 context.fill();
423 context.stroke(); 440 context.stroke();
424 441
425 if (request === this._hoveredRequest) { 442 if (request === this._hoveredRequest) {
426 var labels = this._calculator.computeBarGraphLabels(request); 443 var labels = this._calculator.computeBarGraphLabels(request);
427 this._drawSimplifiedBarDetails(context, labels.left, labels.right, start, mid, mid + barWidth + borderOffset); 444 this._drawSimplifiedBarDetails(context, labels.left, labels.right, ranges. start, ranges.mid, ranges.mid + barWidth + borderOffset);
428 } 445 }
429 446
430 context.restore(); 447 context.restore();
431 } 448 }
432 449
433 /** 450 /**
434 * @param {!CanvasRenderingContext2D} context 451 * @param {!CanvasRenderingContext2D} context
435 * @param {string} leftText 452 * @param {string} leftText
436 * @param {string} rightText 453 * @param {string} rightText
437 * @param {number} startX 454 * @param {number} startX
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 font: 'hsl(8, 100%, 80%)', 583 font: 'hsl(8, 100%, 80%)',
567 media: 'hsl(272, 64%, 80%)', 584 media: 'hsl(272, 64%, 80%)',
568 image: 'hsl(272, 64%, 80%)', 585 image: 'hsl(272, 64%, 80%)',
569 script: 'hsl(31, 100%, 80%)', 586 script: 'hsl(31, 100%, 80%)',
570 stylesheet: 'hsl(90, 50%, 80%)', 587 stylesheet: 'hsl(90, 50%, 80%)',
571 texttrack: 'hsl(8, 100%, 80%)', 588 texttrack: 'hsl(8, 100%, 80%)',
572 websocket: 'hsl(0, 0%, 95%)', 589 websocket: 'hsl(0, 0%, 95%)',
573 xhr: 'hsl(53, 100%, 80%)', 590 xhr: 'hsl(53, 100%, 80%)',
574 other: 'hsl(0, 0%, 95%)' 591 other: 'hsl(0, 0%, 95%)'
575 }; 592 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698