OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @interface | 32 * @interface |
33 */ | 33 */ |
34 WebInspector.TimeRangeController = function() { } | 34 WebInspector.FlameChartDelegate = function() { } |
35 | 35 |
36 WebInspector.TimeRangeController.prototype = { | 36 WebInspector.FlameChartDelegate.prototype = { |
37 /** | 37 /** |
38 * @param {number} startTime | 38 * @param {number} startTime |
39 * @param {number} endTime | 39 * @param {number} endTime |
40 */ | 40 */ |
41 requestWindowTimes: function(startTime, endTime) { } | 41 requestWindowTimes: function(startTime, endTime) { }, |
| 42 |
| 43 /** |
| 44 * @param {number} entryIndex |
| 45 * @param {number} x |
| 46 * @param {number} y |
| 47 * @param {number} width |
| 48 * @param {number} height |
| 49 */ |
| 50 drawSelectedElement: function(entryIndex, x, y, width, height) { } |
42 } | 51 } |
43 | 52 |
44 /** | 53 /** |
45 * @constructor | 54 * @constructor |
46 * @extends {WebInspector.View} | 55 * @extends {WebInspector.View} |
47 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 56 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
48 */ | 57 */ |
49 WebInspector.FlameChart = function(dataProvider) | 58 WebInspector.FlameChart = function(dataProvider) |
50 { | 59 { |
51 WebInspector.View.call(this); | 60 WebInspector.View.call(this); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 * @param {number} entryIndex | 183 * @param {number} entryIndex |
175 * @return {?string} | 184 * @return {?string} |
176 */ | 185 */ |
177 entryFont: function(entryIndex) { }, | 186 entryFont: function(entryIndex) { }, |
178 | 187 |
179 /** | 188 /** |
180 * @param {number} entryIndex | 189 * @param {number} entryIndex |
181 * @return {!string} | 190 * @return {!string} |
182 */ | 191 */ |
183 entryColor: function(entryIndex) { }, | 192 entryColor: function(entryIndex) { }, |
| 193 |
| 194 /** |
| 195 * @param {number} entryIndex |
| 196 * @return {!{startTimeOffset: number, endTimeOffset: number}} |
| 197 */ |
| 198 highlightTimeRange: function(entryIndex) { }, |
184 } | 199 } |
185 | 200 |
186 /** | 201 /** |
187 * @constructor | 202 * @constructor |
188 * @implements {WebInspector.TimelineGrid.Calculator} | 203 * @implements {WebInspector.TimelineGrid.Calculator} |
189 */ | 204 */ |
190 WebInspector.FlameChart.Calculator = function() | 205 WebInspector.FlameChart.Calculator = function() |
191 { | 206 { |
192 this._paddingLeft = 0; | 207 this._paddingLeft = 0; |
193 } | 208 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 _createColor: function(index, sat) | 415 _createColor: function(index, sat) |
401 { | 416 { |
402 var hue = (index * 7 + 12 * (index % 2)) % 360; | 417 var hue = (index * 7 + 12 * (index % 2)) % 360; |
403 return "hsla(" + hue + ", " + sat + "%, 66%, 0.7)"; | 418 return "hsla(" + hue + ", " + sat + "%, 66%, 0.7)"; |
404 } | 419 } |
405 } | 420 } |
406 | 421 |
407 /** | 422 /** |
408 * @constructor | 423 * @constructor |
409 * @extends {WebInspector.View} | 424 * @extends {WebInspector.View} |
410 * @implements {WebInspector.TimeRangeController} | 425 * @implements {WebInspector.FlameChartDelegate} |
411 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 426 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
412 */ | 427 */ |
413 WebInspector.FlameChart.OverviewPane = function(dataProvider) | 428 WebInspector.FlameChart.OverviewPane = function(dataProvider) |
414 { | 429 { |
415 WebInspector.View.call(this); | 430 WebInspector.View.call(this); |
416 this.element.classList.add("flame-chart-overview-pane"); | 431 this.element.classList.add("flame-chart-overview-pane"); |
417 this._overviewContainer = this.element.createChild("div", "overview-containe
r"); | 432 this._overviewContainer = this.element.createChild("div", "overview-containe
r"); |
418 this._overviewGrid = new WebInspector.OverviewGrid("flame-chart"); | 433 this._overviewGrid = new WebInspector.OverviewGrid("flame-chart"); |
419 this._overviewGrid.element.classList.add("fill"); | 434 this._overviewGrid.element.classList.add("fill"); |
420 this._overviewCanvas = this._overviewContainer.createChild("canvas", "flame-
chart-overview-canvas"); | 435 this._overviewCanvas = this._overviewContainer.createChild("canvas", "flame-
chart-overview-canvas"); |
421 this._overviewContainer.appendChild(this._overviewGrid.element); | 436 this._overviewContainer.appendChild(this._overviewGrid.element); |
422 this._overviewCalculator = new WebInspector.FlameChart.OverviewCalculator(); | 437 this._overviewCalculator = new WebInspector.FlameChart.OverviewCalculator(); |
423 this._dataProvider = dataProvider; | 438 this._dataProvider = dataProvider; |
424 } | 439 } |
425 | 440 |
426 WebInspector.FlameChart.OverviewPane.prototype = { | 441 WebInspector.FlameChart.OverviewPane.prototype = { |
427 /** | 442 /** |
428 * @param {number} windowStartTime | 443 * @param {number} windowStartTime |
429 * @param {number} windowEndTime | 444 * @param {number} windowEndTime |
430 */ | 445 */ |
431 requestWindowTimes: function(windowStartTime, windowEndTime) | 446 requestWindowTimes: function(windowStartTime, windowEndTime) |
432 { | 447 { |
433 this._overviewGrid.setWindow(windowStartTime / this._dataProvider.totalT
ime(), windowEndTime / this._dataProvider.totalTime()); | 448 this._overviewGrid.setWindow(windowStartTime / this._dataProvider.totalT
ime(), windowEndTime / this._dataProvider.totalTime()); |
434 }, | 449 }, |
435 | 450 |
436 /** | 451 /** |
| 452 * @param {number} entryIndex |
| 453 * @param {number} x |
| 454 * @param {number} y |
| 455 * @param {number} width |
| 456 * @param {number} height |
| 457 */ |
| 458 drawSelectedElement: function(entryIndex, x, y, width, height) |
| 459 { |
| 460 }, |
| 461 |
| 462 /** |
437 * @param {!number} timeLeft | 463 * @param {!number} timeLeft |
438 * @param {!number} timeRight | 464 * @param {!number} timeRight |
439 */ | 465 */ |
440 _selectRange: function(timeLeft, timeRight) | 466 _selectRange: function(timeLeft, timeRight) |
441 { | 467 { |
442 this._overviewGrid.setWindow(timeLeft / this._dataProvider.totalTime(),
timeRight / this._dataProvider.totalTime()); | 468 this._overviewGrid.setWindow(timeLeft / this._dataProvider.totalTime(),
timeRight / this._dataProvider.totalTime()); |
443 }, | 469 }, |
444 | 470 |
445 /** | 471 /** |
446 * @return {?WebInspector.FlameChart.TimelineData} | 472 * @return {?WebInspector.FlameChart.TimelineData} |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 context.lineTo(canvasWidth + 1, canvasHeight - 1); | 578 context.lineTo(canvasWidth + 1, canvasHeight - 1); |
553 context.fill(); | 579 context.fill(); |
554 context.stroke(); | 580 context.stroke(); |
555 context.closePath(); | 581 context.closePath(); |
556 } | 582 } |
557 | 583 |
558 /** | 584 /** |
559 * @constructor | 585 * @constructor |
560 * @extends {WebInspector.View} | 586 * @extends {WebInspector.View} |
561 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 587 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
562 * @param {!WebInspector.TimeRangeController} timeRangeController | 588 * @param {!WebInspector.FlameChartDelegate} flameChartDelegate |
563 * @param {boolean} isTopDown | 589 * @param {boolean} isTopDown |
564 * @param {boolean} timeBasedWindow | 590 * @param {boolean} timeBasedWindow |
565 */ | 591 */ |
566 WebInspector.FlameChart.MainPane = function(dataProvider, timeRangeController, i
sTopDown, timeBasedWindow) | 592 WebInspector.FlameChart.MainPane = function(dataProvider, flameChartDelegate, is
TopDown, timeBasedWindow) |
567 { | 593 { |
568 WebInspector.View.call(this); | 594 WebInspector.View.call(this); |
569 this.element.classList.add("flame-chart-main-pane"); | 595 this.element.classList.add("flame-chart-main-pane"); |
570 this._timeRangeController = timeRangeController; | 596 this._flameChartDelegate = flameChartDelegate; |
571 this._isTopDown = isTopDown; | 597 this._isTopDown = isTopDown; |
572 this._timeBasedWindow = timeBasedWindow; | 598 this._timeBasedWindow = timeBasedWindow; |
573 | 599 |
574 this._timelineGrid = new WebInspector.TimelineGrid(); | 600 this._timelineGrid = new WebInspector.TimelineGrid(); |
575 this.element.appendChild(this._timelineGrid.element); | 601 this.element.appendChild(this._timelineGrid.element); |
576 this._calculator = new WebInspector.FlameChart.Calculator(); | 602 this._calculator = new WebInspector.FlameChart.Calculator(); |
577 | 603 |
578 this._canvas = this.element.createChild("canvas"); | 604 this._canvas = this.element.createChild("canvas"); |
579 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this)); | 605 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this)); |
580 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f
alse); | 606 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f
alse); |
581 this._canvas.addEventListener("click", this._onClick.bind(this), false); | 607 this._canvas.addEventListener("click", this._onClick.bind(this), false); |
582 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(
this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "mov
e", null); | 608 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(
this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "mov
e", null); |
583 | 609 |
584 this._entryInfo = this.element.createChild("div", "profile-entry-info"); | 610 this._entryInfo = this.element.createChild("div", "profile-entry-info"); |
585 this._highlightElement = this.element.createChild("div", "flame-chart-highli
ght-element"); | 611 this._highlightElement = this.element.createChild("div", "flame-chart-highli
ght-element"); |
586 | 612 |
587 this._dataProvider = dataProvider; | 613 this._dataProvider = dataProvider; |
588 | 614 |
589 this._windowLeft = 0.0; | 615 this._windowLeft = 0.0; |
590 this._windowRight = 1.0; | 616 this._windowRight = 1.0; |
591 this._windowWidth = 1.0; | 617 this._windowWidth = 1.0; |
592 this._timeWindowLeft = 0; | 618 this._timeWindowLeft = 0; |
593 this._timeWindowRight = Infinity; | 619 this._timeWindowRight = Infinity; |
594 this._barHeight = dataProvider.barHeight(); | 620 this._barHeight = dataProvider.barHeight(); |
595 this._barHeightDelta = this._isTopDown ? -this._barHeight : this._barHeight; | 621 this._barHeightDelta = this._isTopDown ? -this._barHeight : this._barHeight; |
596 this._minWidth = 1; | 622 this._minWidth = 1; |
597 this._paddingLeft = 15; | 623 this._paddingLeft = 15; |
598 this._highlightedEntryIndex = -1; | 624 this._highlightedEntryIndex = -1; |
| 625 this._selectedEntryIndex = -1; |
599 } | 626 } |
600 | 627 |
601 WebInspector.FlameChart.MainPane.prototype = { | 628 WebInspector.FlameChart.MainPane.prototype = { |
602 /** | 629 /** |
603 * @return {?WebInspector.FlameChart.TimelineData} | 630 * @return {?WebInspector.FlameChart.TimelineData} |
604 */ | 631 */ |
605 _timelineData: function() | 632 _timelineData: function() |
606 { | 633 { |
607 return this._dataProvider.timelineData(); | 634 return this._dataProvider.timelineData(); |
608 }, | 635 }, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 var windowShift = pixelShift / this._totalPixels; | 686 var windowShift = pixelShift / this._totalPixels; |
660 var windowTime = this._windowWidth * this._totalTime; | 687 var windowTime = this._windowWidth * this._totalTime; |
661 var timeShift = windowTime * pixelShift / this._pixelWindowWidth; | 688 var timeShift = windowTime * pixelShift / this._pixelWindowWidth; |
662 timeShift = Number.constrain( | 689 timeShift = Number.constrain( |
663 timeShift, | 690 timeShift, |
664 this._zeroTime - this._dragStartWindowLeft, | 691 this._zeroTime - this._dragStartWindowLeft, |
665 this._zeroTime + this._totalTime - this._dragStartWindowRight | 692 this._zeroTime + this._totalTime - this._dragStartWindowRight |
666 ); | 693 ); |
667 var windowLeft = this._dragStartWindowLeft + timeShift; | 694 var windowLeft = this._dragStartWindowLeft + timeShift; |
668 var windowRight = this._dragStartWindowRight + timeShift; | 695 var windowRight = this._dragStartWindowRight + timeShift; |
669 this._timeRangeController.requestWindowTimes(windowLeft, windowRight); | 696 this._flameChartDelegate.requestWindowTimes(windowLeft, windowRight); |
670 this._wasDragged = true; | 697 this._wasDragged = true; |
671 }, | 698 }, |
672 | 699 |
673 _endCanvasDragging: function() | 700 _endCanvasDragging: function() |
674 { | 701 { |
675 this._isDragging = false; | 702 this._isDragging = false; |
676 }, | 703 }, |
677 | 704 |
678 /** | 705 /** |
679 * @param {?MouseEvent} event | 706 * @param {?MouseEvent} event |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 windowLeft += (windowLeft - cursorTime) * zoom; | 764 windowLeft += (windowLeft - cursorTime) * zoom; |
738 windowRight += (windowRight - cursorTime) * zoom; | 765 windowRight += (windowRight - cursorTime) * zoom; |
739 } else { | 766 } else { |
740 var shift = e.wheelDeltaX * this._pixelToTime; | 767 var shift = e.wheelDeltaX * this._pixelToTime; |
741 shift = Number.constrain(shift, this._zeroTime - windowLeft, this._t
otalTime + this._zeroTime - windowRight); | 768 shift = Number.constrain(shift, this._zeroTime - windowLeft, this._t
otalTime + this._zeroTime - windowRight); |
742 windowLeft += shift; | 769 windowLeft += shift; |
743 windowRight += shift; | 770 windowRight += shift; |
744 } | 771 } |
745 windowLeft = Number.constrain(windowLeft, this._zeroTime, this._totalTim
e + this._zeroTime); | 772 windowLeft = Number.constrain(windowLeft, this._zeroTime, this._totalTim
e + this._zeroTime); |
746 windowRight = Number.constrain(windowRight, this._zeroTime, this._totalT
ime + this._zeroTime); | 773 windowRight = Number.constrain(windowRight, this._zeroTime, this._totalT
ime + this._zeroTime); |
747 this._timeRangeController.requestWindowTimes(windowLeft, windowRight); | 774 this._flameChartDelegate.requestWindowTimes(windowLeft, windowRight); |
748 }, | 775 }, |
749 | 776 |
750 /** | 777 /** |
751 * @param {number} x | 778 * @param {number} x |
752 * @return {number} | 779 * @return {number} |
753 */ | 780 */ |
754 _cursorTime: function(x) | 781 _cursorTime: function(x) |
755 { | 782 { |
756 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTi
me + this._zeroTime; | 783 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTi
me + this._zeroTime; |
757 }, | 784 }, |
758 | 785 |
759 /** | 786 /** |
760 * @param {!number} x | 787 * @param {!number} x |
761 * @param {!number} y | 788 * @param {!number} y |
762 */ | 789 */ |
763 _coordinatesToEntryIndex: function(x, y) | 790 _coordinatesToEntryIndex: function(x, y) |
764 { | 791 { |
765 var timelineData = this._timelineData(); | 792 var timelineData = this._timelineData(); |
766 if (!timelineData) | 793 if (!timelineData) |
767 return -1; | 794 return -1; |
768 var cursorTime = this._cursorTime(x); | 795 var cursorTimeOffset = this._cursorTime(x) - this._zeroTime; |
769 var cursorLevel = this._isTopDown ? Math.floor(y / this._barHeight - 1)
: Math.floor((this._canvas.height / window.devicePixelRatio - y) / this._barHeig
ht); | 796 var cursorLevel = this._isTopDown ? Math.floor(y / this._barHeight - 1)
: Math.floor((this._canvas.height / window.devicePixelRatio - y) / this._barHeig
ht); |
770 var entryOffsets = timelineData.entryOffsets; | 797 var entryOffsets = timelineData.entryOffsets; |
771 var entryTotalTimes = timelineData.entryTotalTimes; | 798 var entryTotalTimes = timelineData.entryTotalTimes; |
772 var entryLevels = timelineData.entryLevels; | 799 var entryLevels = timelineData.entryLevels; |
773 var length = entryOffsets.length; | 800 var length = entryOffsets.length; |
774 for (var i = 0; i < length; ++i) { | 801 for (var i = 0; i < length; ++i) { |
775 if (cursorTime < entryOffsets[i]) | 802 if (cursorTimeOffset < entryOffsets[i]) |
776 return -1; | 803 return -1; |
777 if (cursorTime < (entryOffsets[i] + entryTotalTimes[i]) | 804 if (cursorTimeOffset < (entryOffsets[i] + entryTotalTimes[i]) |
778 && cursorLevel === entryLevels[i]) | 805 && cursorLevel === entryLevels[i]) |
779 return i; | 806 return i; |
780 } | 807 } |
781 return -1; | 808 return -1; |
782 }, | 809 }, |
783 | 810 |
784 /** | 811 /** |
785 * @param {!number} height | 812 * @param {!number} height |
786 * @param {!number} width | 813 * @param {!number} width |
787 */ | 814 */ |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[
entryIndex]); | 921 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[
entryIndex]); |
895 barWidth = Math.max(barRight - barX, minWidth); | 922 barWidth = Math.max(barRight - barX, minWidth); |
896 barLevel = entryLevels[entryIndex]; | 923 barLevel = entryLevels[entryIndex]; |
897 barY = this._levelToHeight(barLevel); | 924 barY = this._levelToHeight(barLevel); |
898 context.rect(barX, barY, barWidth, this._barHeight); | 925 context.rect(barX, barY, barWidth, this._barHeight); |
899 if (barWidth > minTextWidth) | 926 if (barWidth > minTextWidth) |
900 titleIndexes[lastTitleIndex++] = entryIndex; | 927 titleIndexes[lastTitleIndex++] = entryIndex; |
901 } | 928 } |
902 context.fill(); | 929 context.fill(); |
903 } | 930 } |
| 931 |
904 context.textBaseline = "alphabetic"; | 932 context.textBaseline = "alphabetic"; |
905 context.fillStyle = "#333"; | 933 context.fillStyle = "#333"; |
906 this._dotsWidth = context.measureText("\u2026").width; | 934 this._dotsWidth = context.measureText("\u2026").width; |
907 | 935 |
908 for (i = 0; i < lastTitleIndex; ++i) { | 936 for (i = 0; i < lastTitleIndex; ++i) { |
909 entryIndex = titleIndexes[i]; | 937 entryIndex = titleIndexes[i]; |
910 text = this._dataProvider.entryTitle(entryIndex); | 938 text = this._dataProvider.entryTitle(entryIndex); |
911 if (!text || !text.length) | 939 if (!text || !text.length) |
912 continue; | 940 continue; |
913 font = this._dataProvider.entryFont(entryIndex); | 941 font = this._dataProvider.entryFont(entryIndex); |
914 if (font !== lastUsedFont) | 942 if (font !== lastUsedFont) |
915 context.font = font; | 943 context.font = font; |
916 | 944 |
917 entryOffset = entryOffsets[entryIndex]; | 945 entryOffset = entryOffsets[entryIndex]; |
918 barX = this._offsetToPosition(entryOffset); | 946 barX = this._offsetToPosition(entryOffset); |
919 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[entr
yIndex]); | 947 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[entr
yIndex]); |
920 barWidth = Math.max(barRight - barX, minWidth); | 948 barWidth = Math.max(barRight - barX, minWidth); |
921 xText = Math.max(0, barX); | 949 xText = Math.max(0, barX); |
922 textWidth = barWidth - textPaddingLeft + barX - xText; | 950 textWidth = barWidth - textPaddingLeft + barX - xText; |
923 title = this._prepareText(context, text, textWidth); | 951 title = this._prepareText(context, text, textWidth); |
924 if (title) | 952 if (title) |
925 context.fillText(title, xText + textPaddingLeft, textBaseHeight
- entryLevels[entryIndex] * this._barHeightDelta); | 953 context.fillText(title, xText + textPaddingLeft, textBaseHeight
- entryLevels[entryIndex] * this._barHeightDelta); |
926 } | 954 } |
927 this._updateHighlightElement(); | 955 this._updateHighlightElement(); |
| 956 this._updateSelectedElement(); |
928 }, | 957 }, |
929 | 958 |
930 _updateHighlightElement: function() | 959 _updateHighlightElement: function() |
931 { | 960 { |
932 if (this._highlightElement.parentElement) | 961 if (this._highlightElement.parentElement) |
933 this._highlightElement.remove(); | 962 this._highlightElement.remove(); |
934 var entryIndex = this._highlightedEntryIndex; | 963 var entryIndex = this._highlightedEntryIndex; |
935 if (entryIndex === -1) | 964 if (entryIndex === -1) |
936 return; | 965 return; |
937 var timelineData = this._timelineData(); | 966 var timelineData = this._timelineData(); |
938 var entryOffset = timelineData.entryOffsets[entryIndex]; | 967 var timeRange = this._dataProvider.highlightTimeRange(entryIndex); |
939 var barX = this._offsetToPosition(entryOffset); | 968 var barX = this._offsetToPosition(timeRange.startTimeOffset); |
940 var barRight = this._offsetToPosition(entryOffset + timelineData.entryTo
talTimes[entryIndex]); | 969 var barRight = this._offsetToPosition(timeRange.endTimeOffset); |
941 var barWidth = Math.max(barRight - barX, this._minWidth); | 970 var barWidth = Math.max(barRight - barX, this._minWidth); |
942 | 971 |
943 var style = this._highlightElement.style; | 972 var style = this._highlightElement.style; |
944 style.left = barX + "px"; | 973 style.left = barX + "px"; |
945 style.width = barWidth + "px"; | 974 style.width = barWidth + "px"; |
946 style.top = this._levelToHeight(timelineData.entryLevels[entryIndex]) +
"px"; | 975 style.top = this._levelToHeight(timelineData.entryLevels[entryIndex]) +
"px"; |
947 style.height = this._barHeight + "px"; | 976 style.height = this._barHeight + "px"; |
948 this.element.appendChild(this._highlightElement); | 977 this.element.appendChild(this._highlightElement); |
949 }, | 978 }, |
950 | 979 |
| 980 setSelectedEntry: function(entryIndex) |
| 981 { |
| 982 this._selectedEntryIndex = entryIndex; |
| 983 this._updateSelectedElement(); |
| 984 }, |
| 985 |
| 986 _updateSelectedElement: function() |
| 987 { |
| 988 var entryIndex = this._selectedEntryIndex; |
| 989 if (entryIndex === -1) |
| 990 return; |
| 991 var timelineData = this._timelineData(); |
| 992 var timeRange = this._dataProvider.highlightTimeRange(entryIndex); |
| 993 var barX = this._offsetToPosition(timeRange.startTimeOffset); |
| 994 var barRight = this._offsetToPosition(timeRange.endTimeOffset); |
| 995 var barWidth = Math.max(barRight - barX, this._minWidth); |
| 996 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]); |
| 997 this._flameChartDelegate.drawSelectedElement(entryIndex, barX, barY, bar
Width, this._barHeight); |
| 998 }, |
| 999 |
951 _offsetToPosition: function(offset) | 1000 _offsetToPosition: function(offset) |
952 { | 1001 { |
953 return Math.floor(offset * this._timeToPixel) - this._pixelWindowLeft +
this._paddingLeft; | 1002 return Math.floor(offset * this._timeToPixel) - this._pixelWindowLeft +
this._paddingLeft; |
954 }, | 1003 }, |
955 | 1004 |
956 _levelToHeight: function(level) | 1005 _levelToHeight: function(level) |
957 { | 1006 { |
958 return this._baseHeight - level * this._barHeightDelta; | 1007 return this._baseHeight - level * this._barHeightDelta; |
959 }, | 1008 }, |
960 | 1009 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 this._timelineGrid.hideDividers(); | 1114 this._timelineGrid.hideDividers(); |
1066 this.draw(this.element.clientWidth, this.element.clientHeight); | 1115 this.draw(this.element.clientWidth, this.element.clientHeight); |
1067 this._calculator._updateBoundaries(this); | 1116 this._calculator._updateBoundaries(this); |
1068 this._timelineGrid.element.style.width = this.element.clientWidth; | 1117 this._timelineGrid.element.style.width = this.element.clientWidth; |
1069 var offsets = this._dataProvider.dividerOffsets(this._calculator.minimum
Boundary(), this._calculator.maximumBoundary()); | 1118 var offsets = this._dataProvider.dividerOffsets(this._calculator.minimum
Boundary(), this._calculator.maximumBoundary()); |
1070 this._timelineGrid.updateDividers(this._calculator, offsets, true); | 1119 this._timelineGrid.updateDividers(this._calculator, offsets, true); |
1071 }, | 1120 }, |
1072 | 1121 |
1073 __proto__: WebInspector.View.prototype | 1122 __proto__: WebInspector.View.prototype |
1074 } | 1123 } |
OLD | NEW |