| 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 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @constructor | 45 * @constructor |
| 46 * @extends {WebInspector.View} | 46 * @extends {WebInspector.View} |
| 47 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 47 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
| 48 */ | 48 */ |
| 49 WebInspector.FlameChart = function(dataProvider) | 49 WebInspector.FlameChart = function(dataProvider) |
| 50 { | 50 { |
| 51 WebInspector.View.call(this); | 51 WebInspector.View.call(this); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 prepareHighlightedEntryInfo: function(entryIndex) { }, | 153 prepareHighlightedEntryInfo: function(entryIndex) { }, |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * @param {number} entryIndex | 156 * @param {number} entryIndex |
| 157 * @return {boolean} | 157 * @return {boolean} |
| 158 */ | 158 */ |
| 159 canJumpToEntry: function(entryIndex) { }, | 159 canJumpToEntry: function(entryIndex) { }, |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * @param {number} entryIndex | 162 * @param {number} entryIndex |
| 163 * @return {?Object} | |
| 164 */ | |
| 165 entryData: function(entryIndex) { }, | |
| 166 | |
| 167 /** | |
| 168 * @param {number} entryIndex | |
| 169 * @return {?string} | 163 * @return {?string} |
| 170 */ | 164 */ |
| 171 entryTitle: function(entryIndex) { }, | 165 entryTitle: function(entryIndex) { }, |
| 172 | 166 |
| 173 /** | 167 /** |
| 174 * @param {number} entryIndex | 168 * @param {number} entryIndex |
| 175 * @return {?string} | 169 * @return {?string} |
| 176 */ | 170 */ |
| 177 entryFont: function(entryIndex) { }, | 171 entryFont: function(entryIndex) { }, |
| 178 | 172 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 189 textColor: function(entryIndex) { }, | 183 textColor: function(entryIndex) { }, |
| 190 | 184 |
| 191 /** | 185 /** |
| 192 * @return {number} | 186 * @return {number} |
| 193 */ | 187 */ |
| 194 textBaseline: function() { }, | 188 textBaseline: function() { }, |
| 195 | 189 |
| 196 /** | 190 /** |
| 197 * @return {number} | 191 * @return {number} |
| 198 */ | 192 */ |
| 199 textPadding: function() { } | 193 textPadding: function() { }, |
| 194 |
| 195 /** |
| 196 * @return {!{startTimeOffset: number, endTimeOffset: number}} |
| 197 */ |
| 198 highlightTimeRange: function(entryIndex) { } |
| 200 } | 199 } |
| 201 | 200 |
| 202 /** | 201 /** |
| 203 * @constructor | 202 * @constructor |
| 204 * @implements {WebInspector.TimelineGrid.Calculator} | 203 * @implements {WebInspector.TimelineGrid.Calculator} |
| 205 */ | 204 */ |
| 206 WebInspector.FlameChart.Calculator = function() | 205 WebInspector.FlameChart.Calculator = function() |
| 207 { | 206 { |
| 208 this._paddingLeft = 0; | 207 this._paddingLeft = 0; |
| 209 } | 208 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 _createColor: function(index, sat) | 415 _createColor: function(index, sat) |
| 417 { | 416 { |
| 418 var hue = (index * 7 + 12 * (index % 2)) % 360; | 417 var hue = (index * 7 + 12 * (index % 2)) % 360; |
| 419 return "hsla(" + hue + ", " + sat + "%, 66%, 0.7)"; | 418 return "hsla(" + hue + ", " + sat + "%, 66%, 0.7)"; |
| 420 } | 419 } |
| 421 } | 420 } |
| 422 | 421 |
| 423 /** | 422 /** |
| 424 * @constructor | 423 * @constructor |
| 425 * @extends {WebInspector.View} | 424 * @extends {WebInspector.View} |
| 426 * @implements {WebInspector.TimeRangeController} | 425 * @implements {WebInspector.FlameChartDelegate} |
| 427 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 426 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
| 428 */ | 427 */ |
| 429 WebInspector.FlameChart.OverviewPane = function(dataProvider) | 428 WebInspector.FlameChart.OverviewPane = function(dataProvider) |
| 430 { | 429 { |
| 431 WebInspector.View.call(this); | 430 WebInspector.View.call(this); |
| 432 this.element.classList.add("flame-chart-overview-pane"); | 431 this.element.classList.add("flame-chart-overview-pane"); |
| 433 this._overviewContainer = this.element.createChild("div", "overview-containe
r"); | 432 this._overviewContainer = this.element.createChild("div", "overview-containe
r"); |
| 434 this._overviewGrid = new WebInspector.OverviewGrid("flame-chart"); | 433 this._overviewGrid = new WebInspector.OverviewGrid("flame-chart"); |
| 435 this._overviewGrid.element.classList.add("fill"); | 434 this._overviewGrid.element.classList.add("fill"); |
| 436 this._overviewCanvas = this._overviewContainer.createChild("canvas", "flame-
chart-overview-canvas"); | 435 this._overviewCanvas = this._overviewContainer.createChild("canvas", "flame-
chart-overview-canvas"); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 context.lineTo(canvasWidth + 1, canvasHeight - 1); | 567 context.lineTo(canvasWidth + 1, canvasHeight - 1); |
| 569 context.fill(); | 568 context.fill(); |
| 570 context.stroke(); | 569 context.stroke(); |
| 571 context.closePath(); | 570 context.closePath(); |
| 572 } | 571 } |
| 573 | 572 |
| 574 /** | 573 /** |
| 575 * @constructor | 574 * @constructor |
| 576 * @extends {WebInspector.View} | 575 * @extends {WebInspector.View} |
| 577 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 576 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
| 578 * @param {!WebInspector.TimeRangeController} timeRangeController | 577 * @param {!WebInspector.FlameChartDelegate} flameChartDelegate |
| 579 * @param {boolean} isTopDown | 578 * @param {boolean} isTopDown |
| 580 * @param {boolean} timeBasedWindow | 579 * @param {boolean} timeBasedWindow |
| 581 */ | 580 */ |
| 582 WebInspector.FlameChart.MainPane = function(dataProvider, timeRangeController, i
sTopDown, timeBasedWindow) | 581 WebInspector.FlameChart.MainPane = function(dataProvider, flameChartDelegate, is
TopDown, timeBasedWindow) |
| 583 { | 582 { |
| 584 WebInspector.View.call(this); | 583 WebInspector.View.call(this); |
| 585 this.element.classList.add("flame-chart-main-pane"); | 584 this.element.classList.add("flame-chart-main-pane"); |
| 586 this._timeRangeController = timeRangeController; | 585 this._flameChartDelegate = flameChartDelegate; |
| 587 this._isTopDown = isTopDown; | 586 this._isTopDown = isTopDown; |
| 588 this._timeBasedWindow = timeBasedWindow; | 587 this._timeBasedWindow = timeBasedWindow; |
| 589 | 588 |
| 590 this._timelineGrid = new WebInspector.TimelineGrid(); | 589 this._timelineGrid = new WebInspector.TimelineGrid(); |
| 591 this.element.appendChild(this._timelineGrid.element); | 590 this.element.appendChild(this._timelineGrid.element); |
| 592 this._calculator = new WebInspector.FlameChart.Calculator(); | 591 this._calculator = new WebInspector.FlameChart.Calculator(); |
| 593 | 592 |
| 594 this._canvas = this.element.createChild("canvas"); | 593 this._canvas = this.element.createChild("canvas"); |
| 595 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this)); | 594 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this)); |
| 596 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f
alse); | 595 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f
alse); |
| 597 this._canvas.addEventListener("click", this._onClick.bind(this), false); | 596 this._canvas.addEventListener("click", this._onClick.bind(this), false); |
| 598 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(
this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "mov
e", null); | 597 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(
this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "mov
e", null); |
| 599 | 598 |
| 600 this._entryInfo = this.element.createChild("div", "profile-entry-info"); | 599 this._entryInfo = this.element.createChild("div", "profile-entry-info"); |
| 601 this._highlightElement = this.element.createChild("div", "flame-chart-highli
ght-element"); | 600 this._highlightElement = this.element.createChild("div", "flame-chart-highli
ght-element"); |
| 601 this._selectedElement = this.element.createChild("div", "flame-chart-selecte
d-element"); |
| 602 | 602 |
| 603 this._dataProvider = dataProvider; | 603 this._dataProvider = dataProvider; |
| 604 | 604 |
| 605 this._windowLeft = 0.0; | 605 this._windowLeft = 0.0; |
| 606 this._windowRight = 1.0; | 606 this._windowRight = 1.0; |
| 607 this._windowWidth = 1.0; | 607 this._windowWidth = 1.0; |
| 608 this._timeWindowLeft = 0; | 608 this._timeWindowLeft = 0; |
| 609 this._timeWindowRight = Infinity; | 609 this._timeWindowRight = Infinity; |
| 610 this._barHeight = dataProvider.barHeight(); | 610 this._barHeight = dataProvider.barHeight(); |
| 611 this._barHeightDelta = this._isTopDown ? -this._barHeight : this._barHeight; | 611 this._barHeightDelta = this._isTopDown ? -this._barHeight : this._barHeight; |
| 612 this._minWidth = 1; | 612 this._minWidth = 1; |
| 613 this._paddingLeft = 15; | 613 this._paddingLeft = 15; |
| 614 this._highlightedEntryIndex = -1; | 614 this._highlightedEntryIndex = -1; |
| 615 this._selectedEntryIndex = -1; |
| 615 } | 616 } |
| 616 | 617 |
| 617 WebInspector.FlameChart.MainPane.prototype = { | 618 WebInspector.FlameChart.MainPane.prototype = { |
| 618 /** | 619 /** |
| 619 * @return {?WebInspector.FlameChart.TimelineData} | 620 * @return {?WebInspector.FlameChart.TimelineData} |
| 620 */ | 621 */ |
| 621 _timelineData: function() | 622 _timelineData: function() |
| 622 { | 623 { |
| 623 return this._dataProvider.timelineData(); | 624 return this._dataProvider.timelineData(); |
| 624 }, | 625 }, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 var windowShift = pixelShift / this._totalPixels; | 676 var windowShift = pixelShift / this._totalPixels; |
| 676 var windowTime = this._windowWidth * this._totalTime; | 677 var windowTime = this._windowWidth * this._totalTime; |
| 677 var timeShift = windowTime * pixelShift / this._pixelWindowWidth; | 678 var timeShift = windowTime * pixelShift / this._pixelWindowWidth; |
| 678 timeShift = Number.constrain( | 679 timeShift = Number.constrain( |
| 679 timeShift, | 680 timeShift, |
| 680 this._zeroTime - this._dragStartWindowLeft, | 681 this._zeroTime - this._dragStartWindowLeft, |
| 681 this._zeroTime + this._totalTime - this._dragStartWindowRight | 682 this._zeroTime + this._totalTime - this._dragStartWindowRight |
| 682 ); | 683 ); |
| 683 var windowLeft = this._dragStartWindowLeft + timeShift; | 684 var windowLeft = this._dragStartWindowLeft + timeShift; |
| 684 var windowRight = this._dragStartWindowRight + timeShift; | 685 var windowRight = this._dragStartWindowRight + timeShift; |
| 685 this._timeRangeController.requestWindowTimes(windowLeft, windowRight); | 686 this._flameChartDelegate.requestWindowTimes(windowLeft, windowRight); |
| 686 this._wasDragged = true; | 687 this._wasDragged = true; |
| 687 }, | 688 }, |
| 688 | 689 |
| 689 _endCanvasDragging: function() | 690 _endCanvasDragging: function() |
| 690 { | 691 { |
| 691 this._isDragging = false; | 692 this._isDragging = false; |
| 692 }, | 693 }, |
| 693 | 694 |
| 694 /** | 695 /** |
| 695 * @param {?MouseEvent} event | 696 * @param {?MouseEvent} event |
| 696 */ | 697 */ |
| 697 _onMouseMove: function(event) | 698 _onMouseMove: function(event) |
| 698 { | 699 { |
| 699 if (this._isDragging) | 700 if (this._isDragging) |
| 700 return; | 701 return; |
| 701 | |
| 702 var entryIndex = this._coordinatesToEntryIndex(event.offsetX, event.offs
etY); | 702 var entryIndex = this._coordinatesToEntryIndex(event.offsetX, event.offs
etY); |
| 703 | 703 |
| 704 if (this._highlightedEntryIndex === entryIndex) | 704 if (this._highlightedEntryIndex === entryIndex) |
| 705 return; | 705 return; |
| 706 | 706 |
| 707 if (entryIndex === -1 || !this._dataProvider.canJumpToEntry(entryIndex)) | 707 if (entryIndex === -1 || !this._dataProvider.canJumpToEntry(entryIndex)) |
| 708 this._canvas.style.cursor = "default"; | 708 this._canvas.style.cursor = "default"; |
| 709 else | 709 else |
| 710 this._canvas.style.cursor = "pointer"; | 710 this._canvas.style.cursor = "pointer"; |
| 711 | 711 |
| 712 this._highlightedEntryIndex = entryIndex; | 712 this._highlightedEntryIndex = entryIndex; |
| 713 | 713 |
| 714 this._updateHighlightElement(); | 714 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 715 this._entryInfo.removeChildren(); | 715 this._entryInfo.removeChildren(); |
| 716 | 716 |
| 717 if (this._highlightedEntryIndex === -1) | 717 if (this._highlightedEntryIndex === -1) |
| 718 return; | 718 return; |
| 719 | 719 |
| 720 if (!this._isDragging) { | 720 if (!this._isDragging) { |
| 721 var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(this.
_highlightedEntryIndex); | 721 var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(this.
_highlightedEntryIndex); |
| 722 if (entryInfo) | 722 if (entryInfo) |
| 723 this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); | 723 this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); |
| 724 } | 724 } |
| 725 }, | 725 }, |
| 726 | 726 |
| 727 _onClick: function() | 727 _onClick: function() |
| 728 { | 728 { |
| 729 // onClick comes after dragStart and dragEnd events. | 729 // onClick comes after dragStart and dragEnd events. |
| 730 // So if there was drag (mouse move) in the middle of that events | 730 // So if there was drag (mouse move) in the middle of that events |
| 731 // we skip the click. Otherwise we jump to the sources. | 731 // we skip the click. Otherwise we jump to the sources. |
| 732 if (this._wasDragged) | 732 if (this._wasDragged) |
| 733 return; | 733 return; |
| 734 if (this._highlightedEntryIndex === -1) | 734 if (this._highlightedEntryIndex === -1) |
| 735 return; | 735 return; |
| 736 var data = this._dataProvider.entryData(this._highlightedEntryIndex); | 736 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelect
ed, this._highlightedEntryIndex); |
| 737 if (data) | |
| 738 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySe
lected, data); | |
| 739 }, | 737 }, |
| 740 | 738 |
| 741 /** | 739 /** |
| 742 * @param {?MouseEvent} e | 740 * @param {?MouseEvent} e |
| 743 */ | 741 */ |
| 744 _onMouseWheel: function(e) | 742 _onMouseWheel: function(e) |
| 745 { | 743 { |
| 746 var windowLeft = this._timeWindowLeft ? this._timeWindowLeft : this._dat
aProvider.zeroTime(); | 744 var windowLeft = this._timeWindowLeft ? this._timeWindowLeft : this._dat
aProvider.zeroTime(); |
| 747 var windowRight = this._timeWindowRight !== Infinity ? this._timeWindowR
ight : this._dataProvider.zeroTime() + this._dataProvider.totalTime(); | 745 var windowRight = this._timeWindowRight !== Infinity ? this._timeWindowR
ight : this._dataProvider.zeroTime() + this._dataProvider.totalTime(); |
| 748 | 746 |
| 749 if (e.wheelDeltaY) { | 747 if (e.wheelDeltaY) { |
| 750 const mouseWheelZoomSpeed = 1 / 120; | 748 const mouseWheelZoomSpeed = 1 / 120; |
| 751 var zoom = Math.pow(1.2, -e.wheelDeltaY * mouseWheelZoomSpeed) - 1; | 749 var zoom = Math.pow(1.2, -e.wheelDeltaY * mouseWheelZoomSpeed) - 1; |
| 752 var cursorTime = this._cursorTime(e.offsetX); | 750 var cursorTime = this._cursorTime(e.offsetX); |
| 753 windowLeft += (windowLeft - cursorTime) * zoom; | 751 windowLeft += (windowLeft - cursorTime) * zoom; |
| 754 windowRight += (windowRight - cursorTime) * zoom; | 752 windowRight += (windowRight - cursorTime) * zoom; |
| 755 } else { | 753 } else { |
| 756 var shift = e.wheelDeltaX * this._pixelToTime; | 754 var shift = e.wheelDeltaX * this._pixelToTime; |
| 757 shift = Number.constrain(shift, this._zeroTime - windowLeft, this._t
otalTime + this._zeroTime - windowRight); | 755 shift = Number.constrain(shift, this._zeroTime - windowLeft, this._t
otalTime + this._zeroTime - windowRight); |
| 758 windowLeft += shift; | 756 windowLeft += shift; |
| 759 windowRight += shift; | 757 windowRight += shift; |
| 760 } | 758 } |
| 761 windowLeft = Number.constrain(windowLeft, this._zeroTime, this._totalTim
e + this._zeroTime); | 759 windowLeft = Number.constrain(windowLeft, this._zeroTime, this._totalTim
e + this._zeroTime); |
| 762 windowRight = Number.constrain(windowRight, this._zeroTime, this._totalT
ime + this._zeroTime); | 760 windowRight = Number.constrain(windowRight, this._zeroTime, this._totalT
ime + this._zeroTime); |
| 763 this._timeRangeController.requestWindowTimes(windowLeft, windowRight); | 761 this._flameChartDelegate.requestWindowTimes(windowLeft, windowRight); |
| 764 }, | 762 }, |
| 765 | 763 |
| 766 /** | 764 /** |
| 767 * @param {number} x | 765 * @param {number} x |
| 768 * @return {number} | 766 * @return {number} |
| 769 */ | 767 */ |
| 770 _cursorTime: function(x) | 768 _cursorTime: function(x) |
| 771 { | 769 { |
| 772 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTi
me + this._zeroTime; | 770 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTi
me + this._zeroTime; |
| 773 }, | 771 }, |
| 774 | 772 |
| 775 /** | 773 /** |
| 776 * @param {!number} x | 774 * @param {!number} x |
| 777 * @param {!number} y | 775 * @param {!number} y |
| 778 */ | 776 */ |
| 779 _coordinatesToEntryIndex: function(x, y) | 777 _coordinatesToEntryIndex: function(x, y) |
| 780 { | 778 { |
| 781 var timelineData = this._timelineData(); | 779 var timelineData = this._timelineData(); |
| 782 if (!timelineData) | 780 if (!timelineData) |
| 783 return -1; | 781 return -1; |
| 784 var cursorTime = this._cursorTime(x); | 782 var cursorTimeOffset = this._cursorTime(x) - this._zeroTime; |
| 785 var cursorLevel = this._isTopDown ? Math.floor(y / this._barHeight - 1)
: Math.floor((this._canvas.height / window.devicePixelRatio - y) / this._barHeig
ht); | 783 var cursorLevel = this._isTopDown ? Math.floor((y - WebInspector.FlameCh
art.DividersBarHeight) / this._barHeight) : Math.floor((this._canvas.height / wi
ndow.devicePixelRatio - y) / this._barHeight); |
| 786 var entryOffsets = timelineData.entryOffsets; | 784 var entryOffsets = timelineData.entryOffsets; |
| 787 var entryTotalTimes = timelineData.entryTotalTimes; | 785 var entryTotalTimes = timelineData.entryTotalTimes; |
| 788 var entryLevels = timelineData.entryLevels; | 786 var entryLevels = timelineData.entryLevels; |
| 789 var length = entryOffsets.length; | 787 var length = entryOffsets.length; |
| 790 for (var i = 0; i < length; ++i) { | 788 for (var i = 0; i < length; ++i) { |
| 791 if (cursorTime < entryOffsets[i]) | 789 if (cursorTimeOffset < entryOffsets[i]) |
| 792 return -1; | 790 return -1; |
| 793 if (cursorTime < (entryOffsets[i] + entryTotalTimes[i]) | 791 if (cursorTimeOffset < (entryOffsets[i] + entryTotalTimes[i]) |
| 794 && cursorLevel === entryLevels[i]) | 792 && cursorLevel === entryLevels[i]) |
| 795 return i; | 793 return i; |
| 796 } | 794 } |
| 797 return -1; | 795 return -1; |
| 798 }, | 796 }, |
| 799 | 797 |
| 800 /** | 798 /** |
| 801 * @param {!number} height | 799 * @param {!number} height |
| 802 * @param {!number} width | 800 * @param {!number} width |
| 803 */ | 801 */ |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[
entryIndex]); | 910 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[
entryIndex]); |
| 913 barWidth = Math.max(barRight - barX, minWidth); | 911 barWidth = Math.max(barRight - barX, minWidth); |
| 914 barLevel = entryLevels[entryIndex]; | 912 barLevel = entryLevels[entryIndex]; |
| 915 barY = this._levelToHeight(barLevel); | 913 barY = this._levelToHeight(barLevel); |
| 916 context.rect(barX, barY, barWidth, this._barHeight); | 914 context.rect(barX, barY, barWidth, this._barHeight); |
| 917 if (barWidth > minTextWidth) | 915 if (barWidth > minTextWidth) |
| 918 titleIndexes[lastTitleIndex++] = entryIndex; | 916 titleIndexes[lastTitleIndex++] = entryIndex; |
| 919 } | 917 } |
| 920 context.fill(); | 918 context.fill(); |
| 921 } | 919 } |
| 920 |
| 922 context.textBaseline = "alphabetic"; | 921 context.textBaseline = "alphabetic"; |
| 923 context.fillStyle = "#333"; | 922 context.fillStyle = "#333"; |
| 924 this._dotsWidth = context.measureText("\u2026").width; | 923 this._dotsWidth = context.measureText("\u2026").width; |
| 925 | 924 |
| 926 for (i = 0; i < lastTitleIndex; ++i) { | 925 for (i = 0; i < lastTitleIndex; ++i) { |
| 927 entryIndex = titleIndexes[i]; | 926 entryIndex = titleIndexes[i]; |
| 928 text = this._dataProvider.entryTitle(entryIndex); | 927 text = this._dataProvider.entryTitle(entryIndex); |
| 929 if (!text || !text.length) | 928 if (!text || !text.length) |
| 930 continue; | 929 continue; |
| 931 font = this._dataProvider.entryFont(entryIndex); | 930 font = this._dataProvider.entryFont(entryIndex); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 942 context.font = font; | 941 context.font = font; |
| 943 lastUsedFont = font; | 942 lastUsedFont = font; |
| 944 } | 943 } |
| 945 textColor = this._dataProvider.textColor(entryIndex); | 944 textColor = this._dataProvider.textColor(entryIndex); |
| 946 if (textColor !== lastTextColor) { | 945 if (textColor !== lastTextColor) { |
| 947 context.fillStyle = textColor; | 946 context.fillStyle = textColor; |
| 948 lastTextColor = textColor; | 947 lastTextColor = textColor; |
| 949 } | 948 } |
| 950 context.fillText(title, xText + textPadding, textBaseHeight - entryL
evels[entryIndex] * this._barHeightDelta); | 949 context.fillText(title, xText + textPadding, textBaseHeight - entryL
evels[entryIndex] * this._barHeightDelta); |
| 951 } | 950 } |
| 952 this._updateHighlightElement(); | 951 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 952 this._updateElementPosition(this._selectedElement, this._selectedEntryIn
dex); |
| 953 }, | 953 }, |
| 954 | 954 |
| 955 _updateHighlightElement: function() | 955 setSelectedEntry: function(entryIndex) |
| 956 { | 956 { |
| 957 if (this._highlightElement.parentElement) | 957 this._selectedEntryIndex = entryIndex; |
| 958 this._highlightElement.remove(); | 958 this._updateElementPosition(this._selectedElement, this._selectedEntryIn
dex); |
| 959 var entryIndex = this._highlightedEntryIndex; | 959 }, |
| 960 |
| 961 _updateElementPosition: function(element, entryIndex) |
| 962 { |
| 963 if (element.parentElement) |
| 964 element.remove(); |
| 960 if (entryIndex === -1) | 965 if (entryIndex === -1) |
| 961 return; | 966 return; |
| 962 var timelineData = this._timelineData(); | 967 var timelineData = this._timelineData(); |
| 963 var entryOffset = timelineData.entryOffsets[entryIndex]; | 968 var timeRange = this._dataProvider.highlightTimeRange(entryIndex); |
| 964 var barX = this._offsetToPosition(entryOffset); | 969 var barX = this._offsetToPosition(timeRange.startTimeOffset); |
| 965 var barRight = this._offsetToPosition(entryOffset + timelineData.entryTo
talTimes[entryIndex]); | 970 var barRight = this._offsetToPosition(timeRange.endTimeOffset); |
| 966 var barWidth = Math.max(barRight - barX, this._minWidth); | 971 var barWidth = Math.max(barRight - barX, this._minWidth); |
| 967 | 972 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]); |
| 968 var style = this._highlightElement.style; | 973 var style = element.style; |
| 969 style.left = barX + "px"; | 974 style.left = barX + "px"; |
| 975 style.top = barY + "px"; |
| 970 style.width = barWidth + "px"; | 976 style.width = barWidth + "px"; |
| 971 style.top = this._levelToHeight(timelineData.entryLevels[entryIndex]) +
"px"; | |
| 972 style.height = this._barHeight + "px"; | 977 style.height = this._barHeight + "px"; |
| 973 this.element.appendChild(this._highlightElement); | 978 this.element.appendChild(element); |
| 974 }, | 979 }, |
| 975 | 980 |
| 976 _offsetToPosition: function(offset) | 981 _offsetToPosition: function(offset) |
| 977 { | 982 { |
| 978 return Math.floor(offset * this._timeToPixel) - this._pixelWindowLeft +
this._paddingLeft; | 983 return Math.floor(offset * this._timeToPixel) - this._pixelWindowLeft +
this._paddingLeft; |
| 979 }, | 984 }, |
| 980 | 985 |
| 981 _levelToHeight: function(level) | 986 _levelToHeight: function(level) |
| 982 { | 987 { |
| 983 return this._baseHeight - level * this._barHeightDelta; | 988 return this._baseHeight - level * this._barHeightDelta; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 this._timelineGrid.showDividers(); | 1093 this._timelineGrid.showDividers(); |
| 1089 else | 1094 else |
| 1090 this._timelineGrid.hideDividers(); | 1095 this._timelineGrid.hideDividers(); |
| 1091 this.draw(this.element.clientWidth, this.element.clientHeight); | 1096 this.draw(this.element.clientWidth, this.element.clientHeight); |
| 1092 this._calculator._updateBoundaries(this); | 1097 this._calculator._updateBoundaries(this); |
| 1093 this._timelineGrid.element.style.width = this.element.clientWidth; | 1098 this._timelineGrid.element.style.width = this.element.clientWidth; |
| 1094 var offsets = this._dataProvider.dividerOffsets(this._calculator.minimum
Boundary(), this._calculator.maximumBoundary()); | 1099 var offsets = this._dataProvider.dividerOffsets(this._calculator.minimum
Boundary(), this._calculator.maximumBoundary()); |
| 1095 this._timelineGrid.updateDividers(this._calculator, offsets, true); | 1100 this._timelineGrid.updateDividers(this._calculator, offsets, true); |
| 1096 }, | 1101 }, |
| 1097 | 1102 |
| 1103 reset: function() |
| 1104 { |
| 1105 this._highlightedEntryIndex = -1; |
| 1106 this._selectedEntryIndex = -1; |
| 1107 this.update(); |
| 1108 }, |
| 1109 |
| 1098 __proto__: WebInspector.View.prototype | 1110 __proto__: WebInspector.View.prototype |
| 1099 } | 1111 } |
| OLD | NEW |