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 UI.FlameChartDelegate = function() {}; | 34 PerfUI.FlameChartDelegate = function() {}; |
35 | 35 |
36 UI.FlameChartDelegate.prototype = { | 36 PerfUI.FlameChartDelegate.prototype = { |
37 /** | 37 /** |
38 * @param {number} startTime | 38 * @param {number} startTime |
39 * @param {number} endTime | 39 * @param {number} endTime |
40 */ | 40 */ |
41 requestWindowTimes(startTime, endTime) {}, | 41 requestWindowTimes(startTime, endTime) {}, |
42 | 42 |
43 /** | 43 /** |
44 * @param {number} startTime | 44 * @param {number} startTime |
45 * @param {number} endTime | 45 * @param {number} endTime |
46 */ | 46 */ |
47 updateRangeSelection(startTime, endTime) {}, | 47 updateRangeSelection(startTime, endTime) {}, |
48 }; | 48 }; |
49 | 49 |
50 /** | 50 /** |
51 * @unrestricted | 51 * @unrestricted |
52 */ | 52 */ |
53 UI.FlameChart = class extends UI.ChartViewport { | 53 PerfUI.FlameChart = class extends PerfUI.ChartViewport { |
54 /** | 54 /** |
55 * @param {!UI.FlameChartDataProvider} dataProvider | 55 * @param {!PerfUI.FlameChartDataProvider} dataProvider |
56 * @param {!UI.FlameChartDelegate} flameChartDelegate | 56 * @param {!PerfUI.FlameChartDelegate} flameChartDelegate |
57 * @param {!Common.Setting=} groupExpansionSetting | 57 * @param {!Common.Setting=} groupExpansionSetting |
58 */ | 58 */ |
59 constructor(dataProvider, flameChartDelegate, groupExpansionSetting) { | 59 constructor(dataProvider, flameChartDelegate, groupExpansionSetting) { |
60 super(); | 60 super(); |
61 this.registerRequiredCSS('ui_lazy/flameChart.css'); | 61 this.registerRequiredCSS('perf_ui/flameChart.css'); |
62 this.contentElement.classList.add('flame-chart-main-pane'); | 62 this.contentElement.classList.add('flame-chart-main-pane'); |
63 this._flameChartDelegate = flameChartDelegate; | 63 this._flameChartDelegate = flameChartDelegate; |
64 this._groupExpansionSetting = groupExpansionSetting; | 64 this._groupExpansionSetting = groupExpansionSetting; |
65 this._groupExpansionState = groupExpansionSetting && groupExpansionSetting.g
et() || {}; | 65 this._groupExpansionState = groupExpansionSetting && groupExpansionSetting.g
et() || {}; |
66 | 66 |
67 this._dataProvider = dataProvider; | 67 this._dataProvider = dataProvider; |
68 this._calculator = new UI.FlameChart.Calculator(dataProvider); | 68 this._calculator = new PerfUI.FlameChart.Calculator(dataProvider); |
69 | 69 |
70 this._canvas = /** @type {!HTMLCanvasElement} */ (this.viewportElement.creat
eChild('canvas')); | 70 this._canvas = /** @type {!HTMLCanvasElement} */ (this.viewportElement.creat
eChild('canvas')); |
71 this._canvas.tabIndex = 1; | 71 this._canvas.tabIndex = 1; |
72 this.setDefaultFocusedElement(this._canvas); | 72 this.setDefaultFocusedElement(this._canvas); |
73 this._canvas.addEventListener('mousemove', this._onMouseMove.bind(this), fal
se); | 73 this._canvas.addEventListener('mousemove', this._onMouseMove.bind(this), fal
se); |
74 this._canvas.addEventListener('mouseout', this._onMouseOut.bind(this), false
); | 74 this._canvas.addEventListener('mouseout', this._onMouseOut.bind(this), false
); |
75 this._canvas.addEventListener('click', this._onClick.bind(this), false); | 75 this._canvas.addEventListener('click', this._onClick.bind(this), false); |
76 this._canvas.addEventListener('keydown', this._onKeyDown.bind(this), false); | 76 this._canvas.addEventListener('keydown', this._onKeyDown.bind(this), false); |
77 | 77 |
78 this._entryInfo = this.viewportElement.createChild('div', 'flame-chart-entry
-info'); | 78 this._entryInfo = this.viewportElement.createChild('div', 'flame-chart-entry
-info'); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 _resetCanvas() { | 176 _resetCanvas() { |
177 var ratio = window.devicePixelRatio; | 177 var ratio = window.devicePixelRatio; |
178 this._canvas.width = this._offsetWidth * ratio; | 178 this._canvas.width = this._offsetWidth * ratio; |
179 this._canvas.height = this._offsetHeight * ratio; | 179 this._canvas.height = this._offsetHeight * ratio; |
180 this._canvas.style.width = this._offsetWidth + 'px'; | 180 this._canvas.style.width = this._offsetWidth + 'px'; |
181 this._canvas.style.height = this._offsetHeight + 'px'; | 181 this._canvas.style.height = this._offsetHeight + 'px'; |
182 } | 182 } |
183 | 183 |
184 /** | 184 /** |
185 * @return {?UI.FlameChart.TimelineData} | 185 * @return {?PerfUI.FlameChart.TimelineData} |
186 */ | 186 */ |
187 _timelineData() { | 187 _timelineData() { |
188 if (!this._dataProvider) | 188 if (!this._dataProvider) |
189 return null; | 189 return null; |
190 var timelineData = this._dataProvider.timelineData(); | 190 var timelineData = this._dataProvider.timelineData(); |
191 if (timelineData !== this._rawTimelineData || timelineData.entryStartTimes.l
ength !== this._rawTimelineDataLength) | 191 if (timelineData !== this._rawTimelineData || timelineData.entryStartTimes.l
ength !== this._rawTimelineDataLength) |
192 this._processTimelineData(timelineData); | 192 this._processTimelineData(timelineData); |
193 return this._rawTimelineData; | 193 return this._rawTimelineData; |
194 } | 194 } |
195 | 195 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return; | 242 return; |
243 if (this._coordinatesToGroupIndex(event.offsetX, event.offsetY) >= 0) { | 243 if (this._coordinatesToGroupIndex(event.offsetX, event.offsetY) >= 0) { |
244 this.hideHighlight(); | 244 this.hideHighlight(); |
245 this.viewportElement.style.cursor = 'pointer'; | 245 this.viewportElement.style.cursor = 'pointer'; |
246 return; | 246 return; |
247 } | 247 } |
248 this._updateHighlight(); | 248 this._updateHighlight(); |
249 } | 249 } |
250 | 250 |
251 _updateHighlight() { | 251 _updateHighlight() { |
252 const inDividersBar = this._lastMouseOffsetY < UI.FlameChart.HeaderHeight; | 252 const inDividersBar = this._lastMouseOffsetY < PerfUI.FlameChart.HeaderHeigh
t; |
253 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPosition(t
his._lastMouseOffsetX) : -1; | 253 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPosition(t
his._lastMouseOffsetX) : -1; |
254 this._updateMarkerHighlight(); | 254 this._updateMarkerHighlight(); |
255 | 255 |
256 const entryIndex = this._highlightedMarkerIndex === -1 ? | 256 const entryIndex = this._highlightedMarkerIndex === -1 ? |
257 this._coordinatesToEntryIndex(this._lastMouseOffsetX, this._lastMouseOff
setY) : -1; | 257 this._coordinatesToEntryIndex(this._lastMouseOffsetX, this._lastMouseOff
setY) : |
| 258 -1; |
258 if (entryIndex === -1) { | 259 if (entryIndex === -1) { |
259 this.hideHighlight(); | 260 this.hideHighlight(); |
260 return; | 261 return; |
261 } | 262 } |
262 if (this.isDragging()) | 263 if (this.isDragging()) |
263 return; | 264 return; |
264 this._updatePopover(entryIndex); | 265 this._updatePopover(entryIndex); |
265 this.viewportElement.style.cursor = this._dataProvider.canJumpToEntry(entryI
ndex) ? 'pointer' : 'default'; | 266 this.viewportElement.style.cursor = this._dataProvider.canJumpToEntry(entryI
ndex) ? 'pointer' : 'default'; |
266 this.highlightEntry(entryIndex); | 267 this.highlightEntry(entryIndex); |
267 } | 268 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 // we skip the click. Otherwise we jump to the sources. | 322 // we skip the click. Otherwise we jump to the sources. |
322 const clickThreshold = 5; | 323 const clickThreshold = 5; |
323 if (this.maxDragOffset() > clickThreshold) | 324 if (this.maxDragOffset() > clickThreshold) |
324 return; | 325 return; |
325 var groupIndex = this._coordinatesToGroupIndex(event.offsetX, event.offsetY)
; | 326 var groupIndex = this._coordinatesToGroupIndex(event.offsetX, event.offsetY)
; |
326 if (groupIndex >= 0) { | 327 if (groupIndex >= 0) { |
327 this._toggleGroupVisibility(groupIndex); | 328 this._toggleGroupVisibility(groupIndex); |
328 return; | 329 return; |
329 } | 330 } |
330 this.hideRangeSelection(); | 331 this.hideRangeSelection(); |
331 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, this._high
lightedEntryIndex); | 332 this.dispatchEventToListeners(PerfUI.FlameChart.Events.EntrySelected, this._
highlightedEntryIndex); |
332 } | 333 } |
333 | 334 |
334 /** | 335 /** |
335 * @param {number} groupIndex | 336 * @param {number} groupIndex |
336 */ | 337 */ |
337 _toggleGroupVisibility(groupIndex) { | 338 _toggleGroupVisibility(groupIndex) { |
338 if (!this._isGroupCollapsible(groupIndex)) | 339 if (!this._isGroupCollapsible(groupIndex)) |
339 return; | 340 return; |
340 var groups = this._rawTimelineData.groups; | 341 var groups = this._rawTimelineData.groups; |
341 var group = groups[groupIndex]; | 342 var group = groups[groupIndex]; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 402 } |
402 | 403 |
403 var keys = UI.KeyboardShortcut.Keys; | 404 var keys = UI.KeyboardShortcut.Keys; |
404 if (e.keyCode === keys.Left.code || e.keyCode === keys.Right.code) { | 405 if (e.keyCode === keys.Left.code || e.keyCode === keys.Right.code) { |
405 var level = timelineData.entryLevels[this._selectedEntryIndex]; | 406 var level = timelineData.entryLevels[this._selectedEntryIndex]; |
406 var levelIndexes = this._timelineLevels[level]; | 407 var levelIndexes = this._timelineLevels[level]; |
407 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex); | 408 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex); |
408 indexOnLevel += e.keyCode === keys.Left.code ? -1 : 1; | 409 indexOnLevel += e.keyCode === keys.Left.code ? -1 : 1; |
409 e.consume(true); | 410 e.consume(true); |
410 if (indexOnLevel >= 0 && indexOnLevel < levelIndexes.length) | 411 if (indexOnLevel >= 0 && indexOnLevel < levelIndexes.length) |
411 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, levelI
ndexes[indexOnLevel]); | 412 this.dispatchEventToListeners(PerfUI.FlameChart.Events.EntrySelected, le
velIndexes[indexOnLevel]); |
412 return; | 413 return; |
413 } | 414 } |
414 if (e.keyCode === keys.Up.code || e.keyCode === keys.Down.code) { | 415 if (e.keyCode === keys.Up.code || e.keyCode === keys.Down.code) { |
415 e.consume(true); | 416 e.consume(true); |
416 var level = timelineData.entryLevels[this._selectedEntryIndex]; | 417 var level = timelineData.entryLevels[this._selectedEntryIndex]; |
417 level += e.keyCode === keys.Up.code ? -1 : 1; | 418 level += e.keyCode === keys.Up.code ? -1 : 1; |
418 if (level < 0 || level >= this._timelineLevels.length) | 419 if (level < 0 || level >= this._timelineLevels.length) |
419 return; | 420 return; |
420 var entryTime = timelineData.entryStartTimes[this._selectedEntryIndex] + | 421 var entryTime = timelineData.entryStartTimes[this._selectedEntryIndex] + |
421 timelineData.entryTotalTimes[this._selectedEntryIndex] / 2; | 422 timelineData.entryTotalTimes[this._selectedEntryIndex] / 2; |
422 var levelIndexes = this._timelineLevels[level]; | 423 var levelIndexes = this._timelineLevels[level]; |
423 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator) - 1; | 424 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator) - 1; |
424 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLevel]
)) { | 425 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLevel]
)) { |
425 ++indexOnLevel; | 426 ++indexOnLevel; |
426 if (indexOnLevel >= levelIndexes.length || | 427 if (indexOnLevel >= levelIndexes.length || |
427 !entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLeve
l])) | 428 !entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLeve
l])) |
428 return; | 429 return; |
429 } | 430 } |
430 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, levelInd
exes[indexOnLevel]); | 431 this.dispatchEventToListeners(PerfUI.FlameChart.Events.EntrySelected, leve
lIndexes[indexOnLevel]); |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
434 /** | 435 /** |
435 * @param {number} x | 436 * @param {number} x |
436 * @return {number} | 437 * @return {number} |
437 */ | 438 */ |
438 _cursorTime(x) { | 439 _cursorTime(x) { |
439 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime +
this._minimumBoundary; | 440 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime +
this._minimumBoundary; |
440 } | 441 } |
(...skipping 27 matching lines...) Expand all Loading... |
468 * @param {number} time | 469 * @param {number} time |
469 * @param {number} entryIndex | 470 * @param {number} entryIndex |
470 * @return {number} | 471 * @return {number} |
471 */ | 472 */ |
472 function comparator(time, entryIndex) { | 473 function comparator(time, entryIndex) { |
473 return time - entryStartTimes[entryIndex]; | 474 return time - entryStartTimes[entryIndex]; |
474 } | 475 } |
475 var indexOnLevel = Math.max(entryIndexes.upperBound(cursorTime, comparator)
- 1, 0); | 476 var indexOnLevel = Math.max(entryIndexes.upperBound(cursorTime, comparator)
- 1, 0); |
476 | 477 |
477 /** | 478 /** |
478 * @this {UI.FlameChart} | 479 * @this {PerfUI.FlameChart} |
479 * @param {number} entryIndex | 480 * @param {number} entryIndex |
480 * @return {boolean} | 481 * @return {boolean} |
481 */ | 482 */ |
482 function checkEntryHit(entryIndex) { | 483 function checkEntryHit(entryIndex) { |
483 if (entryIndex === undefined) | 484 if (entryIndex === undefined) |
484 return false; | 485 return false; |
485 var startTime = entryStartTimes[entryIndex]; | 486 var startTime = entryStartTimes[entryIndex]; |
486 var duration = entryTotalTimes[entryIndex]; | 487 var duration = entryTotalTimes[entryIndex]; |
487 if (isNaN(duration)) { | 488 if (isNaN(duration)) { |
488 var dx = (startTime - cursorTime) / this._pixelToTime; | 489 var dx = (startTime - cursorTime) / this._pixelToTime; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 if (!text || !text.length) | 695 if (!text || !text.length) |
695 continue; | 696 continue; |
696 context.fillStyle = this._dataProvider.textColor(entryIndex); | 697 context.fillStyle = this._dataProvider.textColor(entryIndex); |
697 context.fillText(text, barX + textPadding, barY + textBaseHeight); | 698 context.fillText(text, barX + textPadding, barY + textBaseHeight); |
698 } | 699 } |
699 | 700 |
700 context.restore(); | 701 context.restore(); |
701 | 702 |
702 this._drawGroupHeaders(width, height); | 703 this._drawGroupHeaders(width, height); |
703 this._drawMarkers(); | 704 this._drawMarkers(); |
704 const headerHeight = this._rulerEnabled ? UI.FlameChart.HeaderHeight : 0; | 705 const headerHeight = this._rulerEnabled ? PerfUI.FlameChart.HeaderHeight : 0
; |
705 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3, headerHeight); | 706 PerfUI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3, headerHeigh
t); |
706 | 707 |
707 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn
dex); | 708 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn
dex); |
708 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex)
; | 709 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex)
; |
709 this._updateMarkerHighlight(); | 710 this._updateMarkerHighlight(); |
710 } | 711 } |
711 | 712 |
712 /** | 713 /** |
713 * @param {number} width | 714 * @param {number} width |
714 * @param {number} height | 715 * @param {number} height |
715 */ | 716 */ |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 */ | 808 */ |
808 function hLine(y) { | 809 function hLine(y) { |
809 context.moveTo(0, y); | 810 context.moveTo(0, y); |
810 context.lineTo(width, y); | 811 context.lineTo(width, y); |
811 } | 812 } |
812 | 813 |
813 /** | 814 /** |
814 * @param {number} x | 815 * @param {number} x |
815 * @param {number} y | 816 * @param {number} y |
816 * @param {boolean} expanded | 817 * @param {boolean} expanded |
817 * @this {UI.FlameChart} | 818 * @this {PerfUI.FlameChart} |
818 */ | 819 */ |
819 function drawExpansionArrow(x, y, expanded) { | 820 function drawExpansionArrow(x, y, expanded) { |
820 var arrowHeight = this._arrowSide * Math.sqrt(3) / 2; | 821 var arrowHeight = this._arrowSide * Math.sqrt(3) / 2; |
821 var arrowCenterOffset = Math.round(arrowHeight / 2); | 822 var arrowCenterOffset = Math.round(arrowHeight / 2); |
822 context.save(); | 823 context.save(); |
823 context.translate(x, y); | 824 context.translate(x, y); |
824 context.rotate(expanded ? Math.PI / 2 : 0); | 825 context.rotate(expanded ? Math.PI / 2 : 0); |
825 context.moveTo(-arrowCenterOffset, -this._arrowSide / 2); | 826 context.moveTo(-arrowCenterOffset, -this._arrowSide / 2); |
826 context.lineTo(-arrowCenterOffset, this._arrowSide / 2); | 827 context.lineTo(-arrowCenterOffset, this._arrowSide / 2); |
827 context.lineTo(arrowHeight - arrowCenterOffset, 0); | 828 context.lineTo(arrowHeight - arrowCenterOffset, 0); |
828 context.restore(); | 829 context.restore(); |
829 } | 830 } |
830 | 831 |
831 /** | 832 /** |
832 * @param {function(number, number, !UI.FlameChart.Group, boolean)} callback | 833 * @param {function(number, number, !PerfUI.FlameChart.Group, boolean)} call
back |
833 * @this {UI.FlameChart} | 834 * @this {PerfUI.FlameChart} |
834 */ | 835 */ |
835 function forEachGroup(callback) { | 836 function forEachGroup(callback) { |
836 /** @type !Array<{nestingLevel: number, visible: boolean}> */ | 837 /** @type !Array<{nestingLevel: number, visible: boolean}> */ |
837 var groupStack = [{nestingLevel: -1, visible: true}]; | 838 var groupStack = [{nestingLevel: -1, visible: true}]; |
838 for (var i = 0; i < groups.length; ++i) { | 839 for (var i = 0; i < groups.length; ++i) { |
839 var groupTop = groupOffsets[i]; | 840 var groupTop = groupOffsets[i]; |
840 var group = groups[i]; | 841 var group = groups[i]; |
841 if (groupTop - group.style.padding > top + height) | 842 if (groupTop - group.style.padding > top + height) |
842 break; | 843 break; |
843 var firstGroup = true; | 844 var firstGroup = true; |
844 while (groupStack.peekLast().nestingLevel >= group.style.nestingLevel) { | 845 while (groupStack.peekLast().nestingLevel >= group.style.nestingLevel) { |
845 groupStack.pop(); | 846 groupStack.pop(); |
846 firstGroup = false; | 847 firstGroup = false; |
847 } | 848 } |
848 var parentGroupVisible = groupStack.peekLast().visible; | 849 var parentGroupVisible = groupStack.peekLast().visible; |
849 var thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible(
i) || group.expanded); | 850 var thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible(
i) || group.expanded); |
850 groupStack.push({nestingLevel: group.style.nestingLevel, visible: thisGr
oupVisible}); | 851 groupStack.push({nestingLevel: group.style.nestingLevel, visible: thisGr
oupVisible}); |
851 if (!parentGroupVisible || groupTop + group.style.height < top) | 852 if (!parentGroupVisible || groupTop + group.style.height < top) |
852 continue; | 853 continue; |
853 callback(groupTop, i, group, firstGroup); | 854 callback(groupTop, i, group, firstGroup); |
854 } | 855 } |
855 } | 856 } |
856 } | 857 } |
857 | 858 |
858 /** | 859 /** |
859 * @param {!CanvasRenderingContext2D} context | 860 * @param {!CanvasRenderingContext2D} context |
860 * @param {!UI.FlameChart.Group} group | 861 * @param {!PerfUI.FlameChart.Group} group |
861 * @return {number} | 862 * @return {number} |
862 */ | 863 */ |
863 _labelWidthForGroup(context, group) { | 864 _labelWidthForGroup(context, group) { |
864 return UI.measureTextWidth(context, group.name) + this._expansionArrowIndent
* (group.style.nestingLevel + 1) + | 865 return UI.measureTextWidth(context, group.name) + this._expansionArrowIndent
* (group.style.nestingLevel + 1) + |
865 2 * this._headerLabelXPadding; | 866 2 * this._headerLabelXPadding; |
866 } | 867 } |
867 | 868 |
868 /** | 869 /** |
869 * @param {number} y | 870 * @param {number} y |
870 * @param {number} startLevel | 871 * @param {number} startLevel |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 _drawMarkers() { | 929 _drawMarkers() { |
929 var markers = this._timelineData().markers; | 930 var markers = this._timelineData().markers; |
930 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary()); | 931 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary()); |
931 var rightBoundary = this._calculator.maximumBoundary(); | 932 var rightBoundary = this._calculator.maximumBoundary(); |
932 | 933 |
933 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont
ext('2d')); | 934 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont
ext('2d')); |
934 context.save(); | 935 context.save(); |
935 var ratio = window.devicePixelRatio; | 936 var ratio = window.devicePixelRatio; |
936 context.scale(ratio, ratio); | 937 context.scale(ratio, ratio); |
937 context.translate(0, 3); | 938 context.translate(0, 3); |
938 var height = UI.FlameChart.HeaderHeight - 1; | 939 var height = PerfUI.FlameChart.HeaderHeight - 1; |
939 for (var i = left; i < markers.length; i++) { | 940 for (var i = left; i < markers.length; i++) { |
940 var timestamp = markers[i].startTime(); | 941 var timestamp = markers[i].startTime(); |
941 if (timestamp > rightBoundary) | 942 if (timestamp > rightBoundary) |
942 break; | 943 break; |
943 markers[i].draw(context, this._calculator.computePosition(timestamp), heig
ht, this._timeToPixel); | 944 markers[i].draw(context, this._calculator.computePosition(timestamp), heig
ht, this._timeToPixel); |
944 } | 945 } |
945 context.restore(); | 946 context.restore(); |
946 } | 947 } |
947 | 948 |
948 _updateMarkerHighlight() { | 949 _updateMarkerHighlight() { |
949 var element = this._markerHighlighElement; | 950 var element = this._markerHighlighElement; |
950 if (element.parentElement) | 951 if (element.parentElement) |
951 element.remove(); | 952 element.remove(); |
952 var markerIndex = this._highlightedMarkerIndex; | 953 var markerIndex = this._highlightedMarkerIndex; |
953 if (markerIndex === -1) | 954 if (markerIndex === -1) |
954 return; | 955 return; |
955 var marker = this._timelineData().markers[markerIndex]; | 956 var marker = this._timelineData().markers[markerIndex]; |
956 var barX = this._timeToPositionClipped(marker.startTime()); | 957 var barX = this._timeToPositionClipped(marker.startTime()); |
957 element.title = marker.title(); | 958 element.title = marker.title(); |
958 var style = element.style; | 959 var style = element.style; |
959 style.left = barX + 'px'; | 960 style.left = barX + 'px'; |
960 style.backgroundColor = marker.color(); | 961 style.backgroundColor = marker.color(); |
961 this.viewportElement.appendChild(element); | 962 this.viewportElement.appendChild(element); |
962 } | 963 } |
963 | 964 |
964 /** | 965 /** |
965 * @param {?UI.FlameChart.TimelineData} timelineData | 966 * @param {?PerfUI.FlameChart.TimelineData} timelineData |
966 */ | 967 */ |
967 _processTimelineData(timelineData) { | 968 _processTimelineData(timelineData) { |
968 if (!timelineData) { | 969 if (!timelineData) { |
969 this._timelineLevels = null; | 970 this._timelineLevels = null; |
970 this._visibleLevelOffsets = null; | 971 this._visibleLevelOffsets = null; |
971 this._visibleLevels = null; | 972 this._visibleLevels = null; |
972 this._groupOffsets = null; | 973 this._groupOffsets = null; |
973 this._rawTimelineData = null; | 974 this._rawTimelineData = null; |
974 this._rawTimelineDataLength = 0; | 975 this._rawTimelineDataLength = 0; |
975 return; | 976 return; |
(...skipping 26 matching lines...) Expand all Loading... |
1002 } | 1003 } |
1003 | 1004 |
1004 _updateLevelPositions() { | 1005 _updateLevelPositions() { |
1005 var levelCount = this._dataProvider.maxStackDepth(); | 1006 var levelCount = this._dataProvider.maxStackDepth(); |
1006 var groups = this._rawTimelineData.groups || []; | 1007 var groups = this._rawTimelineData.groups || []; |
1007 this._visibleLevelOffsets = new Uint32Array(levelCount + 1); | 1008 this._visibleLevelOffsets = new Uint32Array(levelCount + 1); |
1008 this._visibleLevels = new Uint16Array(levelCount); | 1009 this._visibleLevels = new Uint16Array(levelCount); |
1009 this._groupOffsets = new Uint32Array(groups.length + 1); | 1010 this._groupOffsets = new Uint32Array(groups.length + 1); |
1010 | 1011 |
1011 var groupIndex = -1; | 1012 var groupIndex = -1; |
1012 var currentOffset = this._rulerEnabled ? UI.FlameChart.HeaderHeight : 2; | 1013 var currentOffset = this._rulerEnabled ? PerfUI.FlameChart.HeaderHeight : 2; |
1013 var visible = true; | 1014 var visible = true; |
1014 /** @type !Array<{nestingLevel: number, visible: boolean}> */ | 1015 /** @type !Array<{nestingLevel: number, visible: boolean}> */ |
1015 var groupStack = [{nestingLevel: -1, visible: true}]; | 1016 var groupStack = [{nestingLevel: -1, visible: true}]; |
1016 var lastGroupLevel = Math.max(levelCount, groups.peekLast().startLevel + 1); | 1017 var lastGroupLevel = Math.max(levelCount, groups.peekLast().startLevel + 1); |
1017 for (var level = 0; level < lastGroupLevel; ++level) { | 1018 for (var level = 0; level < lastGroupLevel; ++level) { |
1018 while (groupIndex < groups.length - 1 && level === groups[groupIndex + 1].
startLevel) { | 1019 while (groupIndex < groups.length - 1 && level === groups[groupIndex + 1].
startLevel) { |
1019 ++groupIndex; | 1020 ++groupIndex; |
1020 var style = groups[groupIndex].style; | 1021 var style = groups[groupIndex].style; |
1021 var nextLevel = true; | 1022 var nextLevel = true; |
1022 while (groupStack.peekLast().nestingLevel >= style.nestingLevel) { | 1023 while (groupStack.peekLast().nestingLevel >= style.nestingLevel) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 /** @type {!Map<string,!Map<string,number>>} */ | 1195 /** @type {!Map<string,!Map<string,number>>} */ |
1195 this._textWidth = new Map(); | 1196 this._textWidth = new Map(); |
1196 this.update(); | 1197 this.update(); |
1197 } | 1198 } |
1198 | 1199 |
1199 _enabled() { | 1200 _enabled() { |
1200 return this._rawTimelineDataLength !== 0; | 1201 return this._rawTimelineDataLength !== 0; |
1201 } | 1202 } |
1202 }; | 1203 }; |
1203 | 1204 |
1204 UI.FlameChart.HeaderHeight = 15; | 1205 PerfUI.FlameChart.HeaderHeight = 15; |
1205 | 1206 |
1206 UI.FlameChart.MinimalTimeWindowMs = 0.5; | 1207 PerfUI.FlameChart.MinimalTimeWindowMs = 0.5; |
1207 | 1208 |
1208 /** | 1209 /** |
1209 * @interface | 1210 * @interface |
1210 */ | 1211 */ |
1211 UI.FlameChartDataProvider = function() {}; | 1212 PerfUI.FlameChartDataProvider = function() {}; |
1212 | 1213 |
1213 /** | 1214 /** |
1214 * @typedef {!{name: string, startLevel: number, expanded: (boolean|undefined),
style: !UI.FlameChart.GroupStyle}} | 1215 * @typedef {!{name: string, startLevel: number, expanded: (boolean|undefined),
style: !PerfUI.FlameChart.GroupStyle}} |
1215 */ | 1216 */ |
1216 UI.FlameChart.Group; | 1217 PerfUI.FlameChart.Group; |
1217 | 1218 |
1218 /** | 1219 /** |
1219 * @typedef {!{ | 1220 * @typedef {!{ |
1220 * height: number, | 1221 * height: number, |
1221 * padding: number, | 1222 * padding: number, |
1222 * collapsible: boolean, | 1223 * collapsible: boolean, |
1223 * font: string, | 1224 * font: string, |
1224 * color: string, | 1225 * color: string, |
1225 * backgroundColor: string, | 1226 * backgroundColor: string, |
1226 * nestingLevel: number, | 1227 * nestingLevel: number, |
1227 * shareHeaderLine: (boolean|undefined), | 1228 * shareHeaderLine: (boolean|undefined), |
1228 * useFirstLineForOverview: (boolean|undefined) | 1229 * useFirstLineForOverview: (boolean|undefined) |
1229 * }} | 1230 * }} |
1230 */ | 1231 */ |
1231 UI.FlameChart.GroupStyle; | 1232 PerfUI.FlameChart.GroupStyle; |
1232 | 1233 |
1233 /** | 1234 /** |
1234 * @unrestricted | 1235 * @unrestricted |
1235 */ | 1236 */ |
1236 UI.FlameChart.TimelineData = class { | 1237 PerfUI.FlameChart.TimelineData = class { |
1237 /** | 1238 /** |
1238 * @param {!Array<number>|!Uint16Array} entryLevels | 1239 * @param {!Array<number>|!Uint16Array} entryLevels |
1239 * @param {!Array<number>|!Float32Array} entryTotalTimes | 1240 * @param {!Array<number>|!Float32Array} entryTotalTimes |
1240 * @param {!Array<number>|!Float64Array} entryStartTimes | 1241 * @param {!Array<number>|!Float64Array} entryStartTimes |
1241 * @param {?Array<!UI.FlameChart.Group>} groups | 1242 * @param {?Array<!PerfUI.FlameChart.Group>} groups |
1242 */ | 1243 */ |
1243 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) { | 1244 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) { |
1244 this.entryLevels = entryLevels; | 1245 this.entryLevels = entryLevels; |
1245 this.entryTotalTimes = entryTotalTimes; | 1246 this.entryTotalTimes = entryTotalTimes; |
1246 this.entryStartTimes = entryStartTimes; | 1247 this.entryStartTimes = entryStartTimes; |
1247 this.groups = groups; | 1248 this.groups = groups; |
1248 /** @type {!Array.<!UI.FlameChartMarker>} */ | 1249 /** @type {!Array.<!PerfUI.FlameChartMarker>} */ |
1249 this.markers = []; | 1250 this.markers = []; |
1250 } | 1251 } |
1251 }; | 1252 }; |
1252 | 1253 |
1253 UI.FlameChartDataProvider.prototype = { | 1254 PerfUI.FlameChartDataProvider.prototype = { |
1254 /** | 1255 /** |
1255 * @return {number} | 1256 * @return {number} |
1256 */ | 1257 */ |
1257 minimumBoundary() {}, | 1258 minimumBoundary() {}, |
1258 | 1259 |
1259 /** | 1260 /** |
1260 * @return {number} | 1261 * @return {number} |
1261 */ | 1262 */ |
1262 totalTime() {}, | 1263 totalTime() {}, |
1263 | 1264 |
1264 /** | 1265 /** |
1265 * @param {number} value | 1266 * @param {number} value |
1266 * @param {number=} precision | 1267 * @param {number=} precision |
1267 * @return {string} | 1268 * @return {string} |
1268 */ | 1269 */ |
1269 formatValue(value, precision) {}, | 1270 formatValue(value, precision) {}, |
1270 | 1271 |
1271 /** | 1272 /** |
1272 * @return {number} | 1273 * @return {number} |
1273 */ | 1274 */ |
1274 maxStackDepth() {}, | 1275 maxStackDepth() {}, |
1275 | 1276 |
1276 /** | 1277 /** |
1277 * @return {?UI.FlameChart.TimelineData} | 1278 * @return {?PerfUI.FlameChart.TimelineData} |
1278 */ | 1279 */ |
1279 timelineData() {}, | 1280 timelineData() {}, |
1280 | 1281 |
1281 /** | 1282 /** |
1282 * @param {number} entryIndex | 1283 * @param {number} entryIndex |
1283 * @return {?Element} | 1284 * @return {?Element} |
1284 */ | 1285 */ |
1285 prepareHighlightedEntryInfo(entryIndex) {}, | 1286 prepareHighlightedEntryInfo(entryIndex) {}, |
1286 | 1287 |
1287 /** | 1288 /** |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 /** | 1332 /** |
1332 * @param {number} entryIndex | 1333 * @param {number} entryIndex |
1333 * @return {string} | 1334 * @return {string} |
1334 */ | 1335 */ |
1335 textColor(entryIndex) {}, | 1336 textColor(entryIndex) {}, |
1336 }; | 1337 }; |
1337 | 1338 |
1338 /** | 1339 /** |
1339 * @interface | 1340 * @interface |
1340 */ | 1341 */ |
1341 UI.FlameChartMarker = function() {}; | 1342 PerfUI.FlameChartMarker = function() {}; |
1342 | 1343 |
1343 UI.FlameChartMarker.prototype = { | 1344 PerfUI.FlameChartMarker.prototype = { |
1344 /** | 1345 /** |
1345 * @return {number} | 1346 * @return {number} |
1346 */ | 1347 */ |
1347 startTime() {}, | 1348 startTime() {}, |
1348 | 1349 |
1349 /** | 1350 /** |
1350 * @return {string} | 1351 * @return {string} |
1351 */ | 1352 */ |
1352 color() {}, | 1353 color() {}, |
1353 | 1354 |
1354 /** | 1355 /** |
1355 * @return {string} | 1356 * @return {string} |
1356 */ | 1357 */ |
1357 title() {}, | 1358 title() {}, |
1358 | 1359 |
1359 /** | 1360 /** |
1360 * @param {!CanvasRenderingContext2D} context | 1361 * @param {!CanvasRenderingContext2D} context |
1361 * @param {number} x | 1362 * @param {number} x |
1362 * @param {number} height | 1363 * @param {number} height |
1363 * @param {number} pixelsPerMillisecond | 1364 * @param {number} pixelsPerMillisecond |
1364 */ | 1365 */ |
1365 draw(context, x, height, pixelsPerMillisecond) {}, | 1366 draw(context, x, height, pixelsPerMillisecond) {}, |
1366 }; | 1367 }; |
1367 | 1368 |
1368 /** @enum {symbol} */ | 1369 /** @enum {symbol} */ |
1369 UI.FlameChart.Events = { | 1370 PerfUI.FlameChart.Events = { |
1370 EntrySelected: Symbol('EntrySelected') | 1371 EntrySelected: Symbol('EntrySelected') |
1371 }; | 1372 }; |
1372 | 1373 |
1373 /** | 1374 /** |
1374 * @unrestricted | 1375 * @unrestricted |
1375 */ | 1376 */ |
1376 UI.FlameChart.ColorGenerator = class { | 1377 PerfUI.FlameChart.ColorGenerator = class { |
1377 /** | 1378 /** |
1378 * @param {!{min: number, max: number}|number=} hueSpace | 1379 * @param {!{min: number, max: number}|number=} hueSpace |
1379 * @param {!{min: number, max: number, count: (number|undefined)}|number=} sat
Space | 1380 * @param {!{min: number, max: number, count: (number|undefined)}|number=} sat
Space |
1380 * @param {!{min: number, max: number, count: (number|undefined)}|number=} lig
htnessSpace | 1381 * @param {!{min: number, max: number, count: (number|undefined)}|number=} lig
htnessSpace |
1381 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alp
haSpace | 1382 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alp
haSpace |
1382 */ | 1383 */ |
1383 constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) { | 1384 constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) { |
1384 this._hueSpace = hueSpace || {min: 0, max: 360}; | 1385 this._hueSpace = hueSpace || {min: 0, max: 360}; |
1385 this._satSpace = satSpace || 67; | 1386 this._satSpace = satSpace || 67; |
1386 this._lightnessSpace = lightnessSpace || 80; | 1387 this._lightnessSpace = lightnessSpace || 80; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 _indexToValueInSpace(index, space) { | 1432 _indexToValueInSpace(index, space) { |
1432 if (typeof space === 'number') | 1433 if (typeof space === 'number') |
1433 return space; | 1434 return space; |
1434 var count = space.count || space.max - space.min; | 1435 var count = space.count || space.max - space.min; |
1435 index %= count; | 1436 index %= count; |
1436 return space.min + Math.floor(index / (count - 1) * (space.max - space.min))
; | 1437 return space.min + Math.floor(index / (count - 1) * (space.max - space.min))
; |
1437 } | 1438 } |
1438 }; | 1439 }; |
1439 | 1440 |
1440 /** | 1441 /** |
1441 * @implements {UI.TimelineGrid.Calculator} | 1442 * @implements {PerfUI.TimelineGrid.Calculator} |
1442 * @unrestricted | 1443 * @unrestricted |
1443 */ | 1444 */ |
1444 UI.FlameChart.Calculator = class { | 1445 PerfUI.FlameChart.Calculator = class { |
1445 /** | 1446 /** |
1446 * @param {!UI.FlameChartDataProvider} dataProvider | 1447 * @param {!PerfUI.FlameChartDataProvider} dataProvider |
1447 */ | 1448 */ |
1448 constructor(dataProvider) { | 1449 constructor(dataProvider) { |
1449 this._dataProvider = dataProvider; | 1450 this._dataProvider = dataProvider; |
1450 this._paddingLeft = 0; | 1451 this._paddingLeft = 0; |
1451 } | 1452 } |
1452 | 1453 |
1453 /** | 1454 /** |
1454 * @override | 1455 * @override |
1455 * @return {number} | 1456 * @return {number} |
1456 */ | 1457 */ |
1457 paddingLeft() { | 1458 paddingLeft() { |
1458 return this._paddingLeft; | 1459 return this._paddingLeft; |
1459 } | 1460 } |
1460 | 1461 |
1461 /** | 1462 /** |
1462 * @param {!UI.FlameChart} mainPane | 1463 * @param {!PerfUI.FlameChart} mainPane |
1463 */ | 1464 */ |
1464 _updateBoundaries(mainPane) { | 1465 _updateBoundaries(mainPane) { |
1465 this._totalTime = mainPane._dataProvider.totalTime(); | 1466 this._totalTime = mainPane._dataProvider.totalTime(); |
1466 this._zeroTime = mainPane._dataProvider.minimumBoundary(); | 1467 this._zeroTime = mainPane._dataProvider.minimumBoundary(); |
1467 this._minimumBoundaries = this._zeroTime + mainPane._windowLeft * this._tota
lTime; | 1468 this._minimumBoundaries = this._zeroTime + mainPane._windowLeft * this._tota
lTime; |
1468 this._maximumBoundaries = this._zeroTime + mainPane._windowRight * this._tot
alTime; | 1469 this._maximumBoundaries = this._zeroTime + mainPane._windowRight * this._tot
alTime; |
1469 this._paddingLeft = mainPane._paddingLeft; | 1470 this._paddingLeft = mainPane._paddingLeft; |
1470 this._width = mainPane._offsetWidth - this._paddingLeft; | 1471 this._width = mainPane._offsetWidth - this._paddingLeft; |
1471 this._timeToPixel = this._width / this.boundarySpan(); | 1472 this._timeToPixel = this._width / this.boundarySpan(); |
1472 } | 1473 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 } | 1516 } |
1516 | 1517 |
1517 /** | 1518 /** |
1518 * @override | 1519 * @override |
1519 * @return {number} | 1520 * @return {number} |
1520 */ | 1521 */ |
1521 boundarySpan() { | 1522 boundarySpan() { |
1522 return this._maximumBoundaries - this._minimumBoundaries; | 1523 return this._maximumBoundaries - this._minimumBoundaries; |
1523 } | 1524 } |
1524 }; | 1525 }; |
OLD | NEW |