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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/perf_ui/FlameChart.js

Issue 2608043002: DevTools: extract modules (with extensions) (Closed)
Patch Set: fixes Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 Perf_UI.FlameChartDelegate = function() {};
35 35
36 UI.FlameChartDelegate.prototype = { 36 Perf_UI.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 Perf_UI.FlameChart = class extends Perf_UI.ChartViewport {
54 /** 54 /**
55 * @param {!UI.FlameChartDataProvider} dataProvider 55 * @param {!Perf_UI.FlameChartDataProvider} dataProvider
56 * @param {!UI.FlameChartDelegate} flameChartDelegate 56 * @param {!Perf_UI.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 Perf_UI.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
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 {?Perf_UI.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
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 var inDividersBar = this._lastMouseOffsetY < UI.FlameChart.HeaderHeight; 252 var inDividersBar = this._lastMouseOffsetY < Perf_UI.FlameChart.HeaderHeight ;
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 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, this. _lastMouseOffsetY); 256 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, this. _lastMouseOffsetY);
257 if (entryIndex === -1) { 257 if (entryIndex === -1) {
258 this.hideHighlight(); 258 this.hideHighlight();
259 return; 259 return;
260 } 260 }
261 if (this.isDragging()) 261 if (this.isDragging())
262 return; 262 return;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // we skip the click. Otherwise we jump to the sources. 320 // we skip the click. Otherwise we jump to the sources.
321 const clickThreshold = 5; 321 const clickThreshold = 5;
322 if (this.maxDragOffset() > clickThreshold) 322 if (this.maxDragOffset() > clickThreshold)
323 return; 323 return;
324 var groupIndex = this._coordinatesToGroupIndex(event.offsetX, event.offsetY) ; 324 var groupIndex = this._coordinatesToGroupIndex(event.offsetX, event.offsetY) ;
325 if (groupIndex >= 0) { 325 if (groupIndex >= 0) {
326 this._toggleGroupVisibility(groupIndex); 326 this._toggleGroupVisibility(groupIndex);
327 return; 327 return;
328 } 328 }
329 this.hideRangeSelection(); 329 this.hideRangeSelection();
330 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, this._high lightedEntryIndex); 330 this.dispatchEventToListeners(Perf_UI.FlameChart.Events.EntrySelected, this. _highlightedEntryIndex);
331 } 331 }
332 332
333 /** 333 /**
334 * @param {number} groupIndex 334 * @param {number} groupIndex
335 */ 335 */
336 _toggleGroupVisibility(groupIndex) { 336 _toggleGroupVisibility(groupIndex) {
337 if (!this._isGroupCollapsible(groupIndex)) 337 if (!this._isGroupCollapsible(groupIndex))
338 return; 338 return;
339 var groups = this._rawTimelineData.groups; 339 var groups = this._rawTimelineData.groups;
340 var group = groups[groupIndex]; 340 var group = groups[groupIndex];
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 400 }
401 401
402 var keys = UI.KeyboardShortcut.Keys; 402 var keys = UI.KeyboardShortcut.Keys;
403 if (e.keyCode === keys.Left.code || e.keyCode === keys.Right.code) { 403 if (e.keyCode === keys.Left.code || e.keyCode === keys.Right.code) {
404 var level = timelineData.entryLevels[this._selectedEntryIndex]; 404 var level = timelineData.entryLevels[this._selectedEntryIndex];
405 var levelIndexes = this._timelineLevels[level]; 405 var levelIndexes = this._timelineLevels[level];
406 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex); 406 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex);
407 indexOnLevel += e.keyCode === keys.Left.code ? -1 : 1; 407 indexOnLevel += e.keyCode === keys.Left.code ? -1 : 1;
408 e.consume(true); 408 e.consume(true);
409 if (indexOnLevel >= 0 && indexOnLevel < levelIndexes.length) 409 if (indexOnLevel >= 0 && indexOnLevel < levelIndexes.length)
410 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, levelI ndexes[indexOnLevel]); 410 this.dispatchEventToListeners(Perf_UI.FlameChart.Events.EntrySelected, l evelIndexes[indexOnLevel]);
411 return; 411 return;
412 } 412 }
413 if (e.keyCode === keys.Up.code || e.keyCode === keys.Down.code) { 413 if (e.keyCode === keys.Up.code || e.keyCode === keys.Down.code) {
414 e.consume(true); 414 e.consume(true);
415 var level = timelineData.entryLevels[this._selectedEntryIndex]; 415 var level = timelineData.entryLevels[this._selectedEntryIndex];
416 level += e.keyCode === keys.Up.code ? -1 : 1; 416 level += e.keyCode === keys.Up.code ? -1 : 1;
417 if (level < 0 || level >= this._timelineLevels.length) 417 if (level < 0 || level >= this._timelineLevels.length)
418 return; 418 return;
419 var entryTime = timelineData.entryStartTimes[this._selectedEntryIndex] + 419 var entryTime = timelineData.entryStartTimes[this._selectedEntryIndex] +
420 timelineData.entryTotalTimes[this._selectedEntryIndex] / 2; 420 timelineData.entryTotalTimes[this._selectedEntryIndex] / 2;
421 var levelIndexes = this._timelineLevels[level]; 421 var levelIndexes = this._timelineLevels[level];
422 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator) - 1; 422 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator) - 1;
423 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLevel] )) { 423 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLevel] )) {
424 ++indexOnLevel; 424 ++indexOnLevel;
425 if (indexOnLevel >= levelIndexes.length || 425 if (indexOnLevel >= levelIndexes.length ||
426 !entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLeve l])) 426 !entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLeve l]))
427 return; 427 return;
428 } 428 }
429 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, levelInd exes[indexOnLevel]); 429 this.dispatchEventToListeners(Perf_UI.FlameChart.Events.EntrySelected, lev elIndexes[indexOnLevel]);
430 } 430 }
431 } 431 }
432 432
433 /** 433 /**
434 * @param {number} x 434 * @param {number} x
435 * @return {number} 435 * @return {number}
436 */ 436 */
437 _cursorTime(x) { 437 _cursorTime(x) {
438 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime + this._minimumBoundary; 438 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime + this._minimumBoundary;
439 } 439 }
(...skipping 27 matching lines...) Expand all
467 * @param {number} time 467 * @param {number} time
468 * @param {number} entryIndex 468 * @param {number} entryIndex
469 * @return {number} 469 * @return {number}
470 */ 470 */
471 function comparator(time, entryIndex) { 471 function comparator(time, entryIndex) {
472 return time - entryStartTimes[entryIndex]; 472 return time - entryStartTimes[entryIndex];
473 } 473 }
474 var indexOnLevel = Math.max(entryIndexes.upperBound(cursorTime, comparator) - 1, 0); 474 var indexOnLevel = Math.max(entryIndexes.upperBound(cursorTime, comparator) - 1, 0);
475 475
476 /** 476 /**
477 * @this {UI.FlameChart} 477 * @this {Perf_UI.FlameChart}
478 * @param {number} entryIndex 478 * @param {number} entryIndex
479 * @return {boolean} 479 * @return {boolean}
480 */ 480 */
481 function checkEntryHit(entryIndex) { 481 function checkEntryHit(entryIndex) {
482 if (entryIndex === undefined) 482 if (entryIndex === undefined)
483 return false; 483 return false;
484 var startTime = entryStartTimes[entryIndex]; 484 var startTime = entryStartTimes[entryIndex];
485 var duration = entryTotalTimes[entryIndex]; 485 var duration = entryTotalTimes[entryIndex];
486 if (isNaN(duration)) { 486 if (isNaN(duration)) {
487 var dx = (startTime - cursorTime) / this._pixelToTime; 487 var dx = (startTime - cursorTime) / this._pixelToTime;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 if (!text || !text.length) 694 if (!text || !text.length)
695 continue; 695 continue;
696 context.fillStyle = this._dataProvider.textColor(entryIndex); 696 context.fillStyle = this._dataProvider.textColor(entryIndex);
697 context.fillText(text, barX + textPadding, barY + textBaseHeight); 697 context.fillText(text, barX + textPadding, barY + textBaseHeight);
698 } 698 }
699 699
700 context.restore(); 700 context.restore();
701 701
702 this._drawGroupHeaders(width, height); 702 this._drawGroupHeaders(width, height);
703 this._drawMarkers(); 703 this._drawMarkers();
704 const headerHeight = this._rulerEnabled ? UI.FlameChart.HeaderHeight : 0; 704 const headerHeight = this._rulerEnabled ? Perf_UI.FlameChart.HeaderHeight : 0;
705 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3, headerHeight); 705 Perf_UI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3, headerHeig ht);
706 706
707 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn dex); 707 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn dex);
708 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex) ; 708 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex) ;
709 this._updateMarkerHighlight(); 709 this._updateMarkerHighlight();
710 } 710 }
711 711
712 /** 712 /**
713 * @param {number} width 713 * @param {number} width
714 * @param {number} height 714 * @param {number} height
715 */ 715 */
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 */ 807 */
808 function hLine(y) { 808 function hLine(y) {
809 context.moveTo(0, y); 809 context.moveTo(0, y);
810 context.lineTo(width, y); 810 context.lineTo(width, y);
811 } 811 }
812 812
813 /** 813 /**
814 * @param {number} x 814 * @param {number} x
815 * @param {number} y 815 * @param {number} y
816 * @param {boolean} expanded 816 * @param {boolean} expanded
817 * @this {UI.FlameChart} 817 * @this {Perf_UI.FlameChart}
818 */ 818 */
819 function drawExpansionArrow(x, y, expanded) { 819 function drawExpansionArrow(x, y, expanded) {
820 var arrowHeight = this._arrowSide * Math.sqrt(3) / 2; 820 var arrowHeight = this._arrowSide * Math.sqrt(3) / 2;
821 var arrowCenterOffset = Math.round(arrowHeight / 2); 821 var arrowCenterOffset = Math.round(arrowHeight / 2);
822 context.save(); 822 context.save();
823 context.translate(x, y); 823 context.translate(x, y);
824 context.rotate(expanded ? Math.PI / 2 : 0); 824 context.rotate(expanded ? Math.PI / 2 : 0);
825 context.moveTo(-arrowCenterOffset, -this._arrowSide / 2); 825 context.moveTo(-arrowCenterOffset, -this._arrowSide / 2);
826 context.lineTo(-arrowCenterOffset, this._arrowSide / 2); 826 context.lineTo(-arrowCenterOffset, this._arrowSide / 2);
827 context.lineTo(arrowHeight - arrowCenterOffset, 0); 827 context.lineTo(arrowHeight - arrowCenterOffset, 0);
828 context.restore(); 828 context.restore();
829 } 829 }
830 830
831 /** 831 /**
832 * @param {function(number, number, !UI.FlameChart.Group, boolean)} callback 832 * @param {function(number, number, !Perf_UI.FlameChart.Group, boolean)} cal lback
833 * @this {UI.FlameChart} 833 * @this {Perf_UI.FlameChart}
834 */ 834 */
835 function forEachGroup(callback) { 835 function forEachGroup(callback) {
836 /** @type !Array<{nestingLevel: number, visible: boolean}> */ 836 /** @type !Array<{nestingLevel: number, visible: boolean}> */
837 var groupStack = [{nestingLevel: -1, visible: true}]; 837 var groupStack = [{nestingLevel: -1, visible: true}];
838 for (var i = 0; i < groups.length; ++i) { 838 for (var i = 0; i < groups.length; ++i) {
839 var groupTop = groupOffsets[i]; 839 var groupTop = groupOffsets[i];
840 var group = groups[i]; 840 var group = groups[i];
841 if (groupTop - group.style.padding > top + height) 841 if (groupTop - group.style.padding > top + height)
842 break; 842 break;
843 var firstGroup = true; 843 var firstGroup = true;
844 while (groupStack.peekLast().nestingLevel >= group.style.nestingLevel) { 844 while (groupStack.peekLast().nestingLevel >= group.style.nestingLevel) {
845 groupStack.pop(); 845 groupStack.pop();
846 firstGroup = false; 846 firstGroup = false;
847 } 847 }
848 var parentGroupVisible = groupStack.peekLast().visible; 848 var parentGroupVisible = groupStack.peekLast().visible;
849 var thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible( i) || group.expanded); 849 var thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible( i) || group.expanded);
850 groupStack.push({nestingLevel: group.style.nestingLevel, visible: thisGr oupVisible}); 850 groupStack.push({nestingLevel: group.style.nestingLevel, visible: thisGr oupVisible});
851 if (!parentGroupVisible || groupTop + group.style.height < top) 851 if (!parentGroupVisible || groupTop + group.style.height < top)
852 continue; 852 continue;
853 callback(groupTop, i, group, firstGroup); 853 callback(groupTop, i, group, firstGroup);
854 } 854 }
855 } 855 }
856 } 856 }
857 857
858 /** 858 /**
859 * @param {!CanvasRenderingContext2D} context 859 * @param {!CanvasRenderingContext2D} context
860 * @param {!UI.FlameChart.Group} group 860 * @param {!Perf_UI.FlameChart.Group} group
861 * @return {number} 861 * @return {number}
862 */ 862 */
863 _labelWidthForGroup(context, group) { 863 _labelWidthForGroup(context, group) {
864 return UI.measureTextWidth(context, group.name) + this._expansionArrowIndent * (group.style.nestingLevel + 1) + 864 return UI.measureTextWidth(context, group.name) + this._expansionArrowIndent * (group.style.nestingLevel + 1) +
865 2 * this._headerLabelXPadding; 865 2 * this._headerLabelXPadding;
866 } 866 }
867 867
868 /** 868 /**
869 * @param {number} y 869 * @param {number} y
870 * @param {number} startLevel 870 * @param {number} startLevel
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 _drawMarkers() { 928 _drawMarkers() {
929 var markers = this._timelineData().markers; 929 var markers = this._timelineData().markers;
930 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary()); 930 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary());
931 var rightBoundary = this._calculator.maximumBoundary(); 931 var rightBoundary = this._calculator.maximumBoundary();
932 932
933 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d')); 933 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d'));
934 context.save(); 934 context.save();
935 var ratio = window.devicePixelRatio; 935 var ratio = window.devicePixelRatio;
936 context.scale(ratio, ratio); 936 context.scale(ratio, ratio);
937 context.translate(0, 3); 937 context.translate(0, 3);
938 var height = UI.FlameChart.HeaderHeight - 1; 938 var height = Perf_UI.FlameChart.HeaderHeight - 1;
939 for (var i = left; i < markers.length; i++) { 939 for (var i = left; i < markers.length; i++) {
940 var timestamp = markers[i].startTime(); 940 var timestamp = markers[i].startTime();
941 if (timestamp > rightBoundary) 941 if (timestamp > rightBoundary)
942 break; 942 break;
943 markers[i].draw(context, this._calculator.computePosition(timestamp), heig ht, this._timeToPixel); 943 markers[i].draw(context, this._calculator.computePosition(timestamp), heig ht, this._timeToPixel);
944 } 944 }
945 context.restore(); 945 context.restore();
946 } 946 }
947 947
948 _updateMarkerHighlight() { 948 _updateMarkerHighlight() {
949 var element = this._markerHighlighElement; 949 var element = this._markerHighlighElement;
950 if (element.parentElement) 950 if (element.parentElement)
951 element.remove(); 951 element.remove();
952 var markerIndex = this._highlightedMarkerIndex; 952 var markerIndex = this._highlightedMarkerIndex;
953 if (markerIndex === -1) 953 if (markerIndex === -1)
954 return; 954 return;
955 var marker = this._timelineData().markers[markerIndex]; 955 var marker = this._timelineData().markers[markerIndex];
956 var barX = this._timeToPositionClipped(marker.startTime()); 956 var barX = this._timeToPositionClipped(marker.startTime());
957 element.title = marker.title(); 957 element.title = marker.title();
958 var style = element.style; 958 var style = element.style;
959 style.left = barX + 'px'; 959 style.left = barX + 'px';
960 style.backgroundColor = marker.color(); 960 style.backgroundColor = marker.color();
961 this.viewportElement.appendChild(element); 961 this.viewportElement.appendChild(element);
962 } 962 }
963 963
964 /** 964 /**
965 * @param {?UI.FlameChart.TimelineData} timelineData 965 * @param {?Perf_UI.FlameChart.TimelineData} timelineData
966 */ 966 */
967 _processTimelineData(timelineData) { 967 _processTimelineData(timelineData) {
968 if (!timelineData) { 968 if (!timelineData) {
969 this._timelineLevels = null; 969 this._timelineLevels = null;
970 this._visibleLevelOffsets = null; 970 this._visibleLevelOffsets = null;
971 this._visibleLevels = null; 971 this._visibleLevels = null;
972 this._groupOffsets = null; 972 this._groupOffsets = null;
973 this._rawTimelineData = null; 973 this._rawTimelineData = null;
974 this._rawTimelineDataLength = 0; 974 this._rawTimelineDataLength = 0;
975 return; 975 return;
(...skipping 26 matching lines...) Expand all
1002 } 1002 }
1003 1003
1004 _updateLevelPositions() { 1004 _updateLevelPositions() {
1005 var levelCount = this._dataProvider.maxStackDepth(); 1005 var levelCount = this._dataProvider.maxStackDepth();
1006 var groups = this._rawTimelineData.groups || []; 1006 var groups = this._rawTimelineData.groups || [];
1007 this._visibleLevelOffsets = new Uint32Array(levelCount + 1); 1007 this._visibleLevelOffsets = new Uint32Array(levelCount + 1);
1008 this._visibleLevels = new Uint16Array(levelCount); 1008 this._visibleLevels = new Uint16Array(levelCount);
1009 this._groupOffsets = new Uint32Array(groups.length + 1); 1009 this._groupOffsets = new Uint32Array(groups.length + 1);
1010 1010
1011 var groupIndex = -1; 1011 var groupIndex = -1;
1012 var currentOffset = this._rulerEnabled ? UI.FlameChart.HeaderHeight : 2; 1012 var currentOffset = this._rulerEnabled ? Perf_UI.FlameChart.HeaderHeight : 2 ;
1013 var visible = true; 1013 var visible = true;
1014 /** @type !Array<{nestingLevel: number, visible: boolean}> */ 1014 /** @type !Array<{nestingLevel: number, visible: boolean}> */
1015 var groupStack = [{nestingLevel: -1, visible: true}]; 1015 var groupStack = [{nestingLevel: -1, visible: true}];
1016 var lastGroupLevel = Math.max(levelCount, groups.peekLast().startLevel + 1); 1016 var lastGroupLevel = Math.max(levelCount, groups.peekLast().startLevel + 1);
1017 for (var level = 0; level < lastGroupLevel; ++level) { 1017 for (var level = 0; level < lastGroupLevel; ++level) {
1018 while (groupIndex < groups.length - 1 && level === groups[groupIndex + 1]. startLevel) { 1018 while (groupIndex < groups.length - 1 && level === groups[groupIndex + 1]. startLevel) {
1019 ++groupIndex; 1019 ++groupIndex;
1020 var style = groups[groupIndex].style; 1020 var style = groups[groupIndex].style;
1021 var nextLevel = true; 1021 var nextLevel = true;
1022 while (groupStack.peekLast().nestingLevel >= style.nestingLevel) { 1022 while (groupStack.peekLast().nestingLevel >= style.nestingLevel) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 /** @type {!Map<string,!Map<string,number>>} */ 1194 /** @type {!Map<string,!Map<string,number>>} */
1195 this._textWidth = new Map(); 1195 this._textWidth = new Map();
1196 this.update(); 1196 this.update();
1197 } 1197 }
1198 1198
1199 _enabled() { 1199 _enabled() {
1200 return this._rawTimelineDataLength !== 0; 1200 return this._rawTimelineDataLength !== 0;
1201 } 1201 }
1202 }; 1202 };
1203 1203
1204 UI.FlameChart.HeaderHeight = 15; 1204 Perf_UI.FlameChart.HeaderHeight = 15;
1205 1205
1206 UI.FlameChart.MinimalTimeWindowMs = 0.5; 1206 Perf_UI.FlameChart.MinimalTimeWindowMs = 0.5;
1207 1207
1208 /** 1208 /**
1209 * @interface 1209 * @interface
1210 */ 1210 */
1211 UI.FlameChartDataProvider = function() {}; 1211 Perf_UI.FlameChartDataProvider = function() {};
1212 1212
1213 /** 1213 /**
1214 * @typedef {!{name: string, startLevel: number, expanded: (boolean|undefined), style: !UI.FlameChart.GroupStyle}} 1214 * @typedef {!{name: string, startLevel: number, expanded: (boolean|undefined), style: !Perf_UI.FlameChart.GroupStyle}}
1215 */ 1215 */
1216 UI.FlameChart.Group; 1216 Perf_UI.FlameChart.Group;
1217 1217
1218 /** 1218 /**
1219 * @typedef {!{ 1219 * @typedef {!{
1220 * height: number, 1220 * height: number,
1221 * padding: number, 1221 * padding: number,
1222 * collapsible: boolean, 1222 * collapsible: boolean,
1223 * font: string, 1223 * font: string,
1224 * color: string, 1224 * color: string,
1225 * backgroundColor: string, 1225 * backgroundColor: string,
1226 * nestingLevel: number, 1226 * nestingLevel: number,
1227 * shareHeaderLine: (boolean|undefined), 1227 * shareHeaderLine: (boolean|undefined),
1228 * useFirstLineForOverview: (boolean|undefined) 1228 * useFirstLineForOverview: (boolean|undefined)
1229 * }} 1229 * }}
1230 */ 1230 */
1231 UI.FlameChart.GroupStyle; 1231 Perf_UI.FlameChart.GroupStyle;
1232 1232
1233 /** 1233 /**
1234 * @unrestricted 1234 * @unrestricted
1235 */ 1235 */
1236 UI.FlameChart.TimelineData = class { 1236 Perf_UI.FlameChart.TimelineData = class {
1237 /** 1237 /**
1238 * @param {!Array<number>|!Uint16Array} entryLevels 1238 * @param {!Array<number>|!Uint16Array} entryLevels
1239 * @param {!Array<number>|!Float32Array} entryTotalTimes 1239 * @param {!Array<number>|!Float32Array} entryTotalTimes
1240 * @param {!Array<number>|!Float64Array} entryStartTimes 1240 * @param {!Array<number>|!Float64Array} entryStartTimes
1241 * @param {?Array<!UI.FlameChart.Group>} groups 1241 * @param {?Array<!Perf_UI.FlameChart.Group>} groups
1242 */ 1242 */
1243 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) { 1243 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) {
1244 this.entryLevels = entryLevels; 1244 this.entryLevels = entryLevels;
1245 this.entryTotalTimes = entryTotalTimes; 1245 this.entryTotalTimes = entryTotalTimes;
1246 this.entryStartTimes = entryStartTimes; 1246 this.entryStartTimes = entryStartTimes;
1247 this.groups = groups; 1247 this.groups = groups;
1248 /** @type {!Array.<!UI.FlameChartMarker>} */ 1248 /** @type {!Array.<!Perf_UI.FlameChartMarker>} */
1249 this.markers = []; 1249 this.markers = [];
1250 } 1250 }
1251 }; 1251 };
1252 1252
1253 UI.FlameChartDataProvider.prototype = { 1253 Perf_UI.FlameChartDataProvider.prototype = {
1254 /** 1254 /**
1255 * @return {number} 1255 * @return {number}
1256 */ 1256 */
1257 minimumBoundary() {}, 1257 minimumBoundary() {},
1258 1258
1259 /** 1259 /**
1260 * @return {number} 1260 * @return {number}
1261 */ 1261 */
1262 totalTime() {}, 1262 totalTime() {},
1263 1263
1264 /** 1264 /**
1265 * @param {number} value 1265 * @param {number} value
1266 * @param {number=} precision 1266 * @param {number=} precision
1267 * @return {string} 1267 * @return {string}
1268 */ 1268 */
1269 formatValue(value, precision) {}, 1269 formatValue(value, precision) {},
1270 1270
1271 /** 1271 /**
1272 * @return {number} 1272 * @return {number}
1273 */ 1273 */
1274 maxStackDepth() {}, 1274 maxStackDepth() {},
1275 1275
1276 /** 1276 /**
1277 * @return {?UI.FlameChart.TimelineData} 1277 * @return {?Perf_UI.FlameChart.TimelineData}
1278 */ 1278 */
1279 timelineData() {}, 1279 timelineData() {},
1280 1280
1281 /** 1281 /**
1282 * @param {number} entryIndex 1282 * @param {number} entryIndex
1283 * @return {?Element} 1283 * @return {?Element}
1284 */ 1284 */
1285 prepareHighlightedEntryInfo(entryIndex) {}, 1285 prepareHighlightedEntryInfo(entryIndex) {},
1286 1286
1287 /** 1287 /**
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 /** 1331 /**
1332 * @param {number} entryIndex 1332 * @param {number} entryIndex
1333 * @return {string} 1333 * @return {string}
1334 */ 1334 */
1335 textColor(entryIndex) {}, 1335 textColor(entryIndex) {},
1336 }; 1336 };
1337 1337
1338 /** 1338 /**
1339 * @interface 1339 * @interface
1340 */ 1340 */
1341 UI.FlameChartMarker = function() {}; 1341 Perf_UI.FlameChartMarker = function() {};
1342 1342
1343 UI.FlameChartMarker.prototype = { 1343 Perf_UI.FlameChartMarker.prototype = {
1344 /** 1344 /**
1345 * @return {number} 1345 * @return {number}
1346 */ 1346 */
1347 startTime() {}, 1347 startTime() {},
1348 1348
1349 /** 1349 /**
1350 * @return {string} 1350 * @return {string}
1351 */ 1351 */
1352 color() {}, 1352 color() {},
1353 1353
1354 /** 1354 /**
1355 * @return {string} 1355 * @return {string}
1356 */ 1356 */
1357 title() {}, 1357 title() {},
1358 1358
1359 /** 1359 /**
1360 * @param {!CanvasRenderingContext2D} context 1360 * @param {!CanvasRenderingContext2D} context
1361 * @param {number} x 1361 * @param {number} x
1362 * @param {number} height 1362 * @param {number} height
1363 * @param {number} pixelsPerMillisecond 1363 * @param {number} pixelsPerMillisecond
1364 */ 1364 */
1365 draw(context, x, height, pixelsPerMillisecond) {}, 1365 draw(context, x, height, pixelsPerMillisecond) {},
1366 }; 1366 };
1367 1367
1368 /** @enum {symbol} */ 1368 /** @enum {symbol} */
1369 UI.FlameChart.Events = { 1369 Perf_UI.FlameChart.Events = {
1370 EntrySelected: Symbol('EntrySelected') 1370 EntrySelected: Symbol('EntrySelected')
1371 }; 1371 };
1372 1372
1373 /** 1373 /**
1374 * @unrestricted 1374 * @unrestricted
1375 */ 1375 */
1376 UI.FlameChart.ColorGenerator = class { 1376 Perf_UI.FlameChart.ColorGenerator = class {
1377 /** 1377 /**
1378 * @param {!{min: number, max: number}|number=} hueSpace 1378 * @param {!{min: number, max: number}|number=} hueSpace
1379 * @param {!{min: number, max: number, count: (number|undefined)}|number=} sat Space 1379 * @param {!{min: number, max: number, count: (number|undefined)}|number=} sat Space
1380 * @param {!{min: number, max: number, count: (number|undefined)}|number=} lig htnessSpace 1380 * @param {!{min: number, max: number, count: (number|undefined)}|number=} lig htnessSpace
1381 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alp haSpace 1381 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alp haSpace
1382 */ 1382 */
1383 constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) { 1383 constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) {
1384 this._hueSpace = hueSpace || {min: 0, max: 360}; 1384 this._hueSpace = hueSpace || {min: 0, max: 360};
1385 this._satSpace = satSpace || 67; 1385 this._satSpace = satSpace || 67;
1386 this._lightnessSpace = lightnessSpace || 80; 1386 this._lightnessSpace = lightnessSpace || 80;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 _indexToValueInSpace(index, space) { 1431 _indexToValueInSpace(index, space) {
1432 if (typeof space === 'number') 1432 if (typeof space === 'number')
1433 return space; 1433 return space;
1434 var count = space.count || space.max - space.min; 1434 var count = space.count || space.max - space.min;
1435 index %= count; 1435 index %= count;
1436 return space.min + Math.floor(index / (count - 1) * (space.max - space.min)) ; 1436 return space.min + Math.floor(index / (count - 1) * (space.max - space.min)) ;
1437 } 1437 }
1438 }; 1438 };
1439 1439
1440 /** 1440 /**
1441 * @implements {UI.TimelineGrid.Calculator} 1441 * @implements {Perf_UI.TimelineGrid.Calculator}
1442 * @unrestricted 1442 * @unrestricted
1443 */ 1443 */
1444 UI.FlameChart.Calculator = class { 1444 Perf_UI.FlameChart.Calculator = class {
1445 /** 1445 /**
1446 * @param {!UI.FlameChartDataProvider} dataProvider 1446 * @param {!Perf_UI.FlameChartDataProvider} dataProvider
1447 */ 1447 */
1448 constructor(dataProvider) { 1448 constructor(dataProvider) {
1449 this._dataProvider = dataProvider; 1449 this._dataProvider = dataProvider;
1450 this._paddingLeft = 0; 1450 this._paddingLeft = 0;
1451 } 1451 }
1452 1452
1453 /** 1453 /**
1454 * @override 1454 * @override
1455 * @return {number} 1455 * @return {number}
1456 */ 1456 */
1457 paddingLeft() { 1457 paddingLeft() {
1458 return this._paddingLeft; 1458 return this._paddingLeft;
1459 } 1459 }
1460 1460
1461 /** 1461 /**
1462 * @param {!UI.FlameChart} mainPane 1462 * @param {!Perf_UI.FlameChart} mainPane
1463 */ 1463 */
1464 _updateBoundaries(mainPane) { 1464 _updateBoundaries(mainPane) {
1465 this._totalTime = mainPane._dataProvider.totalTime(); 1465 this._totalTime = mainPane._dataProvider.totalTime();
1466 this._zeroTime = mainPane._dataProvider.minimumBoundary(); 1466 this._zeroTime = mainPane._dataProvider.minimumBoundary();
1467 this._minimumBoundaries = this._zeroTime + mainPane._windowLeft * this._tota lTime; 1467 this._minimumBoundaries = this._zeroTime + mainPane._windowLeft * this._tota lTime;
1468 this._maximumBoundaries = this._zeroTime + mainPane._windowRight * this._tot alTime; 1468 this._maximumBoundaries = this._zeroTime + mainPane._windowRight * this._tot alTime;
1469 this._paddingLeft = mainPane._paddingLeft; 1469 this._paddingLeft = mainPane._paddingLeft;
1470 this._width = mainPane._offsetWidth - this._paddingLeft; 1470 this._width = mainPane._offsetWidth - this._paddingLeft;
1471 this._timeToPixel = this._width / this.boundarySpan(); 1471 this._timeToPixel = this._width / this.boundarySpan();
1472 } 1472 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } 1515 }
1516 1516
1517 /** 1517 /**
1518 * @override 1518 * @override
1519 * @return {number} 1519 * @return {number}
1520 */ 1520 */
1521 boundarySpan() { 1521 boundarySpan() {
1522 return this._maximumBoundaries - this._minimumBoundaries; 1522 return this._maximumBoundaries - this._minimumBoundaries;
1523 } 1523 }
1524 }; 1524 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698