OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 this._stopRecording(); | 446 this._stopRecording(); |
447 } | 447 } |
448 | 448 |
449 /** | 449 /** |
450 * @this {!WebInspector.TimelinePanel} | 450 * @this {!WebInspector.TimelinePanel} |
451 */ | 451 */ |
452 function finishLoading() | 452 function finishLoading() |
453 { | 453 { |
454 this._setOperationInProgress(null); | 454 this._setOperationInProgress(null); |
455 this._updateToggleTimelineButton(false); | 455 this._updateToggleTimelineButton(false); |
456 this._hideStatusPane(); | 456 this._hideRecordingHelpMessage(); |
457 } | 457 } |
458 var progressIndicator = new WebInspector.ProgressIndicator(); | 458 var progressIndicator = new WebInspector.ProgressIndicator(); |
459 this._setOperationInProgress(progressIndicator); | 459 this._setOperationInProgress(progressIndicator); |
460 return new WebInspector.ProgressProxy(progressIndicator, finishLoading.b ind(this)); | 460 return new WebInspector.ProgressProxy(progressIndicator, finishLoading.b ind(this)); |
461 }, | 461 }, |
462 | 462 |
463 /** | 463 /** |
464 * @param {?WebInspector.ProgressIndicator} indicator | 464 * @param {?WebInspector.ProgressIndicator} indicator |
465 */ | 465 */ |
466 _setOperationInProgress: function(indicator) | 466 _setOperationInProgress: function(indicator) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 toolbarItem.setEnabled(enabled); | 657 toolbarItem.setEnabled(enabled); |
658 } | 658 } |
659 this._recordingOptionUIControls.forEach(handler); | 659 this._recordingOptionUIControls.forEach(handler); |
660 }, | 660 }, |
661 | 661 |
662 /** | 662 /** |
663 * @param {boolean} userInitiated | 663 * @param {boolean} userInitiated |
664 */ | 664 */ |
665 _startRecording: function(userInitiated) | 665 _startRecording: function(userInitiated) |
666 { | 666 { |
667 console.assert(!this._statusDialog, "Status dialog is already opened."); | |
668 this._statusDialog = new WebInspector.TimelinePanel.StatusDialog(); | |
669 this._statusDialog.addEventListener(WebInspector.TimelinePanel.StatusDia log.Events.Finish, this._stopRecording, this); | |
670 WebInspector.Dialog.show(null, this._statusDialog, true); | |
671 WebInspector.Dialog.currentInstance().focus(); | |
667 this._updateStatus(WebInspector.UIString("Initializing recording\u2026") ); | 672 this._updateStatus(WebInspector.UIString("Initializing recording\u2026") ); |
673 | |
668 this._autoRecordGeneration = userInitiated ? null : {}; | 674 this._autoRecordGeneration = userInitiated ? null : {}; |
669 this._model.startRecording(true, this._enableJSSamplingSettingSetting.ge t(), this._captureMemorySetting.get(), this._captureLayersAndPicturesSetting.get (), this._captureFilmStripSetting && this._captureFilmStripSetting.get()); | 675 this._model.startRecording(true, this._enableJSSamplingSettingSetting.ge t(), this._captureMemorySetting.get(), this._captureLayersAndPicturesSetting.get (), this._captureFilmStripSetting && this._captureFilmStripSetting.get()); |
670 if (this._lazyFrameModel) | 676 if (this._lazyFrameModel) |
671 this._lazyFrameModel.setMergeRecords(false); | 677 this._lazyFrameModel.setMergeRecords(false); |
672 | 678 |
673 for (var i = 0; i < this._overviewControls.length; ++i) | 679 for (var i = 0; i < this._overviewControls.length; ++i) |
674 this._overviewControls[i].timelineStarted(); | 680 this._overviewControls[i].timelineStarted(); |
675 | 681 |
676 if (userInitiated) | 682 if (userInitiated) |
677 WebInspector.userMetrics.TimelineStarted.record(); | 683 WebInspector.userMetrics.TimelineStarted.record(); |
678 this._setUIControlsEnabled(false); | 684 this._setUIControlsEnabled(false); |
685 this._hideRecordingHelpMessage(); | |
679 }, | 686 }, |
680 | 687 |
681 _stopRecording: function() | 688 _stopRecording: function() |
682 { | 689 { |
690 this._statusDialog && this._statusDialog.finish(); | |
691 this._updateStatus(WebInspector.UIString("Retrieving timeline\u2026")); | |
683 this._stopPending = true; | 692 this._stopPending = true; |
684 this._updateToggleTimelineButton(false); | 693 this._updateToggleTimelineButton(false); |
685 this._autoRecordGeneration = null; | 694 this._autoRecordGeneration = null; |
686 this._model.stopRecording(); | 695 this._model.stopRecording(); |
687 if (this._statusElement) | |
688 this._updateStatus(WebInspector.UIString("Retrieving events\u2026")) ; | |
689 this._setUIControlsEnabled(true); | 696 this._setUIControlsEnabled(true); |
690 }, | 697 }, |
691 | 698 |
692 _onSuspendStateChanged: function() | 699 _onSuspendStateChanged: function() |
693 { | 700 { |
694 this._updateToggleTimelineButton(this.toggleTimelineButton.toggled()); | 701 this._updateToggleTimelineButton(this.toggleTimelineButton.toggled()); |
695 }, | 702 }, |
696 | 703 |
697 /** | 704 /** |
698 * @param {boolean} toggled | 705 * @param {boolean} toggled |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 this._updateSelectionDetails(); | 767 this._updateSelectionDetails(); |
761 delete this._filmStripModel; | 768 delete this._filmStripModel; |
762 }, | 769 }, |
763 | 770 |
764 /** | 771 /** |
765 * @param {!WebInspector.Event} event | 772 * @param {!WebInspector.Event} event |
766 */ | 773 */ |
767 _onRecordingStarted: function(event) | 774 _onRecordingStarted: function(event) |
768 { | 775 { |
769 this._updateToggleTimelineButton(true); | 776 this._updateToggleTimelineButton(true); |
770 if (event.data && event.data.fromFile) | 777 var message = event.data && event.data.fromFile ? WebInspector.UIString( "Loading\u2026") : WebInspector.UIString("Recording\u2026"); |
771 this._updateStatus(WebInspector.UIString("Loading\u2026")); | 778 this._updateStatus(message); |
772 else | 779 this._statusDialog && this._statusDialog.startTimer(); |
773 this._updateStatus(WebInspector.UIString("%d events collected", 0)); | |
774 }, | 780 }, |
775 | 781 |
776 _recordingInProgress: function() | 782 _recordingInProgress: function() |
777 { | 783 { |
778 return this.toggleTimelineButton.toggled(); | 784 return this.toggleTimelineButton.toggled(); |
779 }, | 785 }, |
780 | 786 |
781 /** | 787 /** |
782 * @param {!WebInspector.Event} event | 788 * @param {!WebInspector.Event} event |
783 */ | 789 */ |
784 _onTracingBufferUsage: function(event) | 790 _onTracingBufferUsage: function(event) |
785 { | 791 { |
786 var usage = /** @type {number} */ (event.data); | 792 var usage = /** @type {number} */ (event.data); |
787 this._updateStatus(WebInspector.UIString("Buffer usage %d%%", Math.round (usage * 100))); | 793 this._statusDialog && this._statusDialog.updateBufferUsage(usage * 100); |
794 }, | |
795 | |
796 _onRetrieveEventsProgress: function() | |
797 { | |
798 this._updateStatus(WebInspector.UIString("Retrieving timeline\u2026")); | |
788 }, | 799 }, |
789 | 800 |
790 /** | 801 /** |
791 * @param {!WebInspector.Event} event | 802 * @param {string} statusMessage |
792 */ | 803 */ |
793 _onRetrieveEventsProgress: function(event) | 804 _updateStatus: function(statusMessage) |
794 { | 805 { |
795 var progress = /** @type {number} */ (event.data); | 806 this._statusDialog && this._statusDialog.updateStatus(statusMessage); |
796 this._updateStatus(WebInspector.UIString("Retrieving events\u2026 %d%%", Math.round(progress * 100))); | |
797 }, | 807 }, |
798 | 808 |
799 _showRecordingHelpMessage: function() | 809 _showRecordingHelpMessage: function() |
800 { | 810 { |
801 /** | 811 /** |
802 * @param {string} tagName | 812 * @param {string} tagName |
803 * @param {string} contents | 813 * @param {string} contents |
804 * @return {!Element} | 814 * @return {!Element} |
805 */ | 815 */ |
806 function encloseWithTag(tagName, contents) | 816 function encloseWithTag(tagName, contents) |
807 { | 817 { |
808 var e = createElement(tagName); | 818 var e = createElement(tagName); |
809 e.textContent = contents; | 819 e.textContent = contents; |
810 return e; | 820 return e; |
811 } | 821 } |
812 | 822 |
813 var recordNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli nePanelShortcuts.StartStopRecording[0].name); | 823 var recordNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli nePanelShortcuts.StartStopRecording[0].name); |
814 var reloadNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli nePanelShortcuts.RecordPageReload[0].name); | 824 var reloadNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli nePanelShortcuts.RecordPageReload[0].name); |
815 var navigateNode = encloseWithTag("b", WebInspector.UIString("WASD")); | 825 var navigateNode = encloseWithTag("b", WebInspector.UIString("WASD")); |
816 var hintText = createElementWithClass("div", "recording-hint"); | 826 var hintText = createElementWithClass("div", "recording-hint"); |
817 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "To capture a new timeline, click the record toolbar button or hit %s."), [recor dNode], null)); | 827 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "To capture a new timeline, click the record toolbar button or hit %s."), [recor dNode], null)); |
818 hintText.createChild("br"); | 828 hintText.createChild("br"); |
819 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "To evaluate page load performance, hit %s to record the reload."), [reloadNode] , null)); | 829 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "To evaluate page load performance, hit %s to record the reload."), [reloadNode] , null)); |
820 hintText.createChild("p"); | 830 hintText.createChild("p"); |
821 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "After recording, select an area of interest in the overview by dragging."), [], null)); | 831 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "After recording, select an area of interest in the overview by dragging."), [], null)); |
822 hintText.createChild("br"); | 832 hintText.createChild("br"); |
823 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "Then, zoom and pan the timeline with the mousewheel and %s keys."), [navigateNo de], null)); | 833 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString( "Then, zoom and pan the timeline with the mousewheel and %s keys."), [navigateNo de], null)); |
824 this._updateStatus(hintText); | 834 this._hideRecordingHelpMessage(); |
835 this._helpMessageElement = this._searchableView.element.createChild("div ", "timeline-status-pane fill"); | |
836 this._helpMessageElement.removeChildren(); | |
837 this._helpMessageElement.appendChild(hintText); | |
825 }, | 838 }, |
826 | 839 |
827 /** | 840 _hideRecordingHelpMessage: function() |
828 * @param {string|!Element} statusMessage | |
829 */ | |
830 _updateStatus: function(statusMessage) | |
831 { | 841 { |
832 if (!this._statusElement) | 842 if (this._helpMessageElement) |
833 this._showStatusPane(); | 843 this._helpMessageElement.remove(); |
834 this._statusElement.removeChildren(); | 844 delete this._helpMessageElement; |
835 if (typeof statusMessage === "string") | |
836 this._statusElement.textContent = statusMessage; | |
837 else | |
838 this._statusElement.appendChild(statusMessage); | |
839 }, | |
840 | |
841 _showStatusPane: function() | |
842 { | |
843 this._hideStatusPane(); | |
844 this._statusElement = this._searchableView.element.createChild("div", "t imeline-status-pane fill"); | |
845 }, | |
846 | |
847 _hideStatusPane: function() | |
848 { | |
849 if (this._statusElement) | |
850 this._statusElement.remove(); | |
851 delete this._statusElement; | |
852 }, | 845 }, |
853 | 846 |
854 _onRecordingStopped: function() | 847 _onRecordingStopped: function() |
855 { | 848 { |
856 this._stopPending = false; | 849 this._stopPending = false; |
857 this._updateToggleTimelineButton(false); | 850 this._updateToggleTimelineButton(false); |
858 if (this._lazyFrameModel) { | 851 if (this._lazyFrameModel) { |
859 this._lazyFrameModel.reset(); | 852 this._lazyFrameModel.reset(); |
860 this._lazyFrameModel.addTraceEvents(this._model.target(), this._mode l.inspectedTargetEvents(), this._tracingModel.sessionId()); | 853 this._lazyFrameModel.addTraceEvents(this._model.target(), this._mode l.inspectedTargetEvents(), this._tracingModel.sessionId()); |
861 } | 854 } |
862 this._overviewPane.reset(); | 855 this._overviewPane.reset(); |
863 this._overviewPane.setBounds(this._model.minimumRecordTime(), this._mode l.maximumRecordTime()); | 856 this._overviewPane.setBounds(this._model.minimumRecordTime(), this._mode l.maximumRecordTime()); |
864 this.requestWindowTimes(this._model.minimumRecordTime(), this._model.max imumRecordTime()); | 857 this.requestWindowTimes(this._model.minimumRecordTime(), this._model.max imumRecordTime()); |
865 this._refreshViews(); | 858 this._refreshViews(); |
866 this._hideStatusPane(); | |
867 for (var i = 0; i < this._overviewControls.length; ++i) | 859 for (var i = 0; i < this._overviewControls.length; ++i) |
868 this._overviewControls[i].timelineStopped(); | 860 this._overviewControls[i].timelineStopped(); |
869 this._setMarkers(); | 861 this._setMarkers(); |
870 this._overviewPane.scheduleUpdate(); | 862 this._overviewPane.scheduleUpdate(); |
871 this._updateSearchHighlight(false, true); | 863 this._updateSearchHighlight(false, true); |
864 if (this._statusDialog) { | |
865 this._statusDialog.hide(); | |
866 delete this._statusDialog; | |
867 } | |
872 }, | 868 }, |
873 | 869 |
874 _setMarkers: function() | 870 _setMarkers: function() |
875 { | 871 { |
876 var markers = new Map(); | 872 var markers = new Map(); |
877 var recordTypes = WebInspector.TimelineModel.RecordType; | 873 var recordTypes = WebInspector.TimelineModel.RecordType; |
878 for (var record of this._model.eventDividerRecords()) { | 874 for (var record of this._model.eventDividerRecords()) { |
879 if (record.type() === recordTypes.TimeStamp || record.type() === rec ordTypes.ConsoleTime) | 875 if (record.type() === recordTypes.TimeStamp || record.type() === rec ordTypes.ConsoleTime) |
880 continue; | 876 continue; |
881 markers.set(record.startTime(), WebInspector.TimelineUIUtils.createD ividerForRecord(record, 0)); | 877 markers.set(record.startTime(), WebInspector.TimelineUIUtils.createD ividerForRecord(record, 0)); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1739 case WebInspector.TimelineModel.RecordType.JSFrame: | 1735 case WebInspector.TimelineModel.RecordType.JSFrame: |
1740 return false; | 1736 return false; |
1741 default: | 1737 default: |
1742 return true; | 1738 return true; |
1743 } | 1739 } |
1744 }, | 1740 }, |
1745 | 1741 |
1746 __proto__: WebInspector.TimelineModel.Filter.prototype | 1742 __proto__: WebInspector.TimelineModel.Filter.prototype |
1747 } | 1743 } |
1748 | 1744 |
1745 /** | |
1746 * @constructor | |
1747 * @extends {WebInspector.DialogDelegate} | |
1748 */ | |
1749 WebInspector.TimelinePanel.StatusDialog = function() | |
1750 { | |
1751 WebInspector.DialogDelegate.call(this); | |
1752 this.element.classList.add("timeline-status-dialog"); | |
1753 this.element.createChild("div", "title").textContent = WebInspector.UIString ("Recording Timeline"); | |
1754 this._status = this.element.createChild("div", "status"); | |
pfeldman
2015/08/27 22:22:13
Please use timeline prefix everywhere or migrate t
alph
2015/08/28 18:34:42
Done.
| |
1755 this._time = this.element.createChild("div", "time"); | |
1756 this._bufferUsage = this.element.createChild("div", "buffer-usage").createCh ild("div", "indicator-container").createChild("div", "indicator"); | |
1757 this._stopButton = this.element.createChild("div", "stop-button").createChil d("button"); | |
1758 this._stopButton.textContent = WebInspector.UIString("Finish"); | |
1759 this._stopButton.setAttribute("autofocus", "true"); | |
1760 this._stopButton.addEventListener("click", this._onFinish.bind(this)); | |
1761 this._startTime = Date.now(); | |
1762 this._finishKeys = new Set([ | |
1763 WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortc ut.Keys.Space).key, | |
1764 WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortc ut.Keys.Enter).key, | |
1765 WebInspector.ShortcutsScreen.TimelinePanelShortcuts.StartStopRecording[0 ].key | |
1766 ]); | |
1767 } | |
1768 | |
1769 WebInspector.TimelinePanel.StatusDialog.Events = { | |
1770 Finish: "Finish" | |
1771 } | |
1772 | |
1773 WebInspector.TimelinePanel.StatusDialog.prototype = { | |
1774 /** | |
1775 * @override | |
1776 */ | |
1777 willHide: function() | |
1778 { | |
1779 this._stopTimer(); | |
1780 }, | |
1781 | |
1782 finish: function() | |
1783 { | |
1784 this._stopButton.setAttribute("disabled", "true"); | |
1785 this._stopTimer(); | |
1786 }, | |
1787 | |
1788 hide: function() | |
1789 { | |
1790 WebInspector.Dialog.hide(); | |
1791 }, | |
1792 | |
1793 /** | |
1794 * @param {string} text | |
1795 */ | |
1796 updateStatus: function(text) | |
1797 { | |
1798 this._status.textContent = text; | |
1799 }, | |
1800 | |
1801 /** | |
1802 * @param {number} percent | |
1803 */ | |
1804 updateBufferUsage: function(percent) | |
1805 { | |
1806 this._bufferUsage.style.width = percent.toFixed(1) + "%"; | |
1807 this._updateTimer(); | |
1808 }, | |
1809 | |
1810 /** | |
1811 * @override | |
1812 * @param {!KeyboardEvent} event | |
1813 */ | |
1814 onKeyDown: function(event) | |
1815 { | |
1816 var key = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); | |
1817 if (this._finishKeys.has(key)) | |
1818 this._onFinish(); | |
1819 event.consume(); | |
1820 }, | |
1821 | |
1822 _onFinish: function() | |
1823 { | |
1824 this.dispatchEventToListeners(WebInspector.TimelinePanel.StatusDialog.Ev ents.Finish); | |
1825 }, | |
1826 | |
1827 startTimer: function() | |
1828 { | |
1829 this._timeUpdateTimer = setInterval(this._updateTimer.bind(this, false), 1000); | |
1830 }, | |
1831 | |
1832 _stopTimer: function() | |
1833 { | |
1834 if (!this._timeUpdateTimer) | |
1835 return; | |
1836 clearInterval(this._timeUpdateTimer); | |
1837 this._updateTimer(true); | |
1838 delete this._timeUpdateTimer; | |
1839 }, | |
1840 | |
1841 /** | |
1842 * @param {boolean=} precise | |
1843 */ | |
1844 _updateTimer: function(precise) | |
1845 { | |
1846 var elapsed = (Date.now() - this._startTime) / 1000; | |
1847 this._time.textContent = WebInspector.UIString("%s\u2009sec", elapsed.to Fixed(precise ? 1 : 0)); | |
1848 }, | |
1849 | |
1850 __proto__: WebInspector.DialogDelegate.prototype | |
1851 } | |
1852 | |
1749 WebInspector.TimelinePanel.show = function() | 1853 WebInspector.TimelinePanel.show = function() |
1750 { | 1854 { |
1751 WebInspector.inspectorView.setCurrentPanel(WebInspector.TimelinePanel.instan ce()); | 1855 WebInspector.inspectorView.setCurrentPanel(WebInspector.TimelinePanel.instan ce()); |
1752 } | 1856 } |
1753 | 1857 |
1754 /** | 1858 /** |
1755 * @return {!WebInspector.TimelinePanel} | 1859 * @return {!WebInspector.TimelinePanel} |
1756 */ | 1860 */ |
1757 WebInspector.TimelinePanel.instance = function() | 1861 WebInspector.TimelinePanel.instance = function() |
1758 { | 1862 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1792 /** | 1896 /** |
1793 * @override | 1897 * @override |
1794 * @param {string} value | 1898 * @param {string} value |
1795 */ | 1899 */ |
1796 handleQueryParam: function(value) | 1900 handleQueryParam: function(value) |
1797 { | 1901 { |
1798 WebInspector.TimelinePanel.show(); | 1902 WebInspector.TimelinePanel.show(); |
1799 WebInspector.TimelinePanel.instance()._loadFromURL(value); | 1903 WebInspector.TimelinePanel.instance()._loadFromURL(value); |
1800 } | 1904 } |
1801 } | 1905 } |
OLD | NEW |