Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 WebInspector.FlameChartDelegate = function() { } | 34 WebInspector.FlameChartDelegate = function() { } |
| 35 | 35 |
| 36 WebInspector.FlameChartDelegate.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 * @param {number} entryIndex | |
| 45 */ | |
| 46 requestSelectionChange: function(entryIndex) { }, | |
|
caseq
2015/05/22 00:09:19
How is that different from FlameChart.Events.Entry
alph
2015/05/22 00:51:53
Ahh, thanks. Missed that.
| |
| 47 | |
| 48 /** | |
| 44 * @param {number} startTime | 49 * @param {number} startTime |
| 45 * @param {number} endTime | 50 * @param {number} endTime |
| 46 */ | 51 */ |
| 47 updateRangeSelection: function(startTime, endTime) { } | 52 updateRangeSelection: function(startTime, endTime) { } |
| 48 } | 53 } |
| 49 | 54 |
| 50 /** | 55 /** |
| 51 * @constructor | 56 * @constructor |
| 52 * @extends {WebInspector.HBox} | 57 * @extends {WebInspector.HBox} |
| 53 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 58 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 | 765 |
| 761 // Block swipe gesture. | 766 // Block swipe gesture. |
| 762 e.consume(true); | 767 e.consume(true); |
| 763 }, | 768 }, |
| 764 | 769 |
| 765 /** | 770 /** |
| 766 * @param {!Event} e | 771 * @param {!Event} e |
| 767 */ | 772 */ |
| 768 _onKeyDown: function(e) | 773 _onKeyDown: function(e) |
| 769 { | 774 { |
| 775 this._handleZoomPanKeys(e); | |
| 776 this._handleSelectionNav(e); | |
| 777 }, | |
| 778 | |
| 779 /** | |
| 780 * @param {!Event} e | |
| 781 */ | |
| 782 _handleSelectionNav: function(e) | |
|
caseq
2015/05/22 00:09:18
no abbreviations pls.
alph
2015/05/22 00:51:54
Done.
| |
| 783 { | |
| 784 if (e.altKey || e.ctrlKey || e.metaKey) | |
| 785 return; | |
| 786 if (this._selectedEntryIndex === -1) | |
| 787 return; | |
| 788 var timelineData = this._timelineData(); | |
| 789 if (!timelineData) | |
| 790 return; | |
| 791 | |
| 792 /** | |
| 793 * @param {number} time | |
| 794 * @param {number} entryIndex | |
| 795 * @return {number} | |
| 796 */ | |
| 797 function timeComparator(time, entryIndex) | |
| 798 { | |
| 799 return time - timelineData.entryStartTimes[entryIndex]; | |
| 800 } | |
| 801 | |
| 802 /** | |
| 803 * @param {number} entry1 | |
| 804 * @param {number} entry2 | |
| 805 * @return {boolean} | |
| 806 */ | |
| 807 function entriesIntersect(entry1, entry2) | |
| 808 { | |
| 809 var start1 = timelineData.entryStartTimes[entry1]; | |
| 810 var start2 = timelineData.entryStartTimes[entry2]; | |
| 811 var end1 = start1 + timelineData.entryTotalTimes[entry1]; | |
| 812 var end2 = start2 + timelineData.entryTotalTimes[entry2]; | |
| 813 return start1 < end2 && start2 < end1; | |
| 814 } | |
| 815 | |
| 816 if (e.keyIdentifier === "Left" || e.keyIdentifier === "Right") { | |
|
caseq
2015/05/22 00:09:18
Let's use constants from WebInspector.KeyboardShor
alph
2015/05/22 00:51:53
Done.
| |
| 817 var level = timelineData.entryLevels[this._selectedEntryIndex]; | |
| 818 var levelIndexes = this._timelineLevels[level]; | |
| 819 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex) ; | |
| 820 indexOnLevel += e.keyIdentifier === "Left" ? -1 : 1; | |
| 821 e.consume(true); | |
| 822 if (indexOnLevel < 0 || indexOnLevel >= levelIndexes.length) | |
| 823 return; | |
| 824 this._flameChartDelegate.requestSelectionChange(levelIndexes[indexOn Level]); | |
| 825 } else if (e.keyIdentifier === "Up" || e.keyIdentifier === "Down") { | |
| 826 var level = timelineData.entryLevels[this._selectedEntryIndex]; | |
| 827 var delta = e.keyIdentifier === "Up" ? 1 : -1; | |
| 828 e.consume(true); | |
| 829 if (this._isTopDown) | |
| 830 delta *= -1; | |
|
caseq
2015/05/22 00:09:18
delta = -delta perhaps?
alph
2015/05/22 00:51:53
Done.
| |
| 831 level += delta; | |
| 832 if (level < 0 || level >= this._timelineLevels.length) | |
| 833 return; | |
| 834 var entryTime = timelineData.entryStartTimes[this._selectedEntryInde x]; | |
| 835 var levelIndexes = this._timelineLevels[level]; | |
| 836 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator ) - 1; | |
| 837 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOn Level])) { | |
| 838 ++indexOnLevel; | |
| 839 if (indexOnLevel >= levelIndexes.length || !entriesIntersect(thi s._selectedEntryIndex, levelIndexes[indexOnLevel])) | |
| 840 return; | |
| 841 } | |
| 842 this._flameChartDelegate.requestSelectionChange(levelIndexes[indexOn Level]); | |
| 843 } | |
| 844 }, | |
| 845 | |
| 846 /** | |
| 847 * @param {!Event} e | |
| 848 */ | |
| 849 _handleZoomPanKeys: function(e) | |
| 850 { | |
| 770 if (e.altKey || e.ctrlKey || e.metaKey) | 851 if (e.altKey || e.ctrlKey || e.metaKey) |
| 771 return; | 852 return; |
| 772 var zoomMultiplier = e.shiftKey ? 0.8 : 0.3; | 853 var zoomMultiplier = e.shiftKey ? 0.8 : 0.3; |
| 773 var panMultiplier = e.shiftKey ? 320 : 80; | 854 var panMultiplier = e.shiftKey ? 320 : 80; |
| 774 if (e.keyCode === "A".charCodeAt(0)) { | 855 if (e.keyCode === "A".charCodeAt(0)) { |
| 775 this._handlePanGesture(-panMultiplier * this._pixelToTime); | 856 this._handlePanGesture(-panMultiplier * this._pixelToTime); |
| 776 e.consume(true); | 857 e.consume(true); |
| 777 } else if (e.keyCode === "D".charCodeAt(0)) { | 858 } else if (e.keyCode === "D".charCodeAt(0)) { |
| 778 this._handlePanGesture(panMultiplier * this._pixelToTime); | 859 this._handlePanGesture(panMultiplier * this._pixelToTime); |
| 779 e.consume(true); | 860 e.consume(true); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1452 this.update(); | 1533 this.update(); |
| 1453 }, | 1534 }, |
| 1454 | 1535 |
| 1455 _enabled: function() | 1536 _enabled: function() |
| 1456 { | 1537 { |
| 1457 return this._rawTimelineDataLength !== 0; | 1538 return this._rawTimelineDataLength !== 0; |
| 1458 }, | 1539 }, |
| 1459 | 1540 |
| 1460 __proto__: WebInspector.HBox.prototype | 1541 __proto__: WebInspector.HBox.prototype |
| 1461 } | 1542 } |
| OLD | NEW |