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); |
667 this._updateStatus(WebInspector.UIString("Initializing recording\u2026")
); | 671 this._updateStatus(WebInspector.UIString("Initializing recording\u2026")
); |
| 672 |
668 this._autoRecordGeneration = userInitiated ? null : {}; | 673 this._autoRecordGeneration = userInitiated ? null : {}; |
669 this._model.startRecording(true, this._enableJSSamplingSettingSetting.ge
t(), this._captureMemorySetting.get(), this._captureLayersAndPicturesSetting.get
(), this._captureFilmStripSetting && this._captureFilmStripSetting.get()); | 674 this._model.startRecording(true, this._enableJSSamplingSettingSetting.ge
t(), this._captureMemorySetting.get(), this._captureLayersAndPicturesSetting.get
(), this._captureFilmStripSetting && this._captureFilmStripSetting.get()); |
670 if (this._lazyFrameModel) | 675 if (this._lazyFrameModel) |
671 this._lazyFrameModel.setMergeRecords(false); | 676 this._lazyFrameModel.setMergeRecords(false); |
672 | 677 |
673 for (var i = 0; i < this._overviewControls.length; ++i) | 678 for (var i = 0; i < this._overviewControls.length; ++i) |
674 this._overviewControls[i].timelineStarted(); | 679 this._overviewControls[i].timelineStarted(); |
675 | 680 |
676 if (userInitiated) | 681 if (userInitiated) |
677 WebInspector.userMetrics.TimelineStarted.record(); | 682 WebInspector.userMetrics.TimelineStarted.record(); |
678 this._setUIControlsEnabled(false); | 683 this._setUIControlsEnabled(false); |
| 684 this._hideRecordingHelpMessage(); |
679 }, | 685 }, |
680 | 686 |
681 _stopRecording: function() | 687 _stopRecording: function() |
682 { | 688 { |
| 689 if (this._statusDialog) |
| 690 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 if (this._statusDialog) |
773 this._updateStatus(WebInspector.UIString("%d events collected", 0)); | 780 this._statusDialog.startTimer(); |
774 }, | 781 }, |
775 | 782 |
776 _recordingInProgress: function() | 783 _recordingInProgress: function() |
777 { | 784 { |
778 return this.toggleTimelineButton.toggled(); | 785 return this.toggleTimelineButton.toggled(); |
779 }, | 786 }, |
780 | 787 |
781 /** | 788 /** |
782 * @param {!WebInspector.Event} event | 789 * @param {!WebInspector.Event} event |
783 */ | 790 */ |
784 _onTracingBufferUsage: function(event) | 791 _onTracingBufferUsage: function(event) |
785 { | 792 { |
786 var usage = /** @type {number} */ (event.data); | 793 var usage = /** @type {number} */ (event.data); |
787 this._updateStatus(WebInspector.UIString("Buffer usage %d%%", Math.round
(usage * 100))); | 794 if (this._statusDialog) |
| 795 this._statusDialog.updateBufferUsage(usage * 100); |
| 796 }, |
| 797 |
| 798 _onRetrieveEventsProgress: function() |
| 799 { |
| 800 this._updateStatus(WebInspector.UIString("Retrieving timeline\u2026")); |
788 }, | 801 }, |
789 | 802 |
790 /** | 803 /** |
791 * @param {!WebInspector.Event} event | 804 * @param {string} statusMessage |
792 */ | 805 */ |
793 _onRetrieveEventsProgress: function(event) | 806 _updateStatus: function(statusMessage) |
794 { | 807 { |
795 var progress = /** @type {number} */ (event.data); | 808 if (this._statusDialog) |
796 this._updateStatus(WebInspector.UIString("Retrieving events\u2026 %d%%",
Math.round(progress * 100))); | 809 this._statusDialog.updateStatus(statusMessage); |
797 }, | 810 }, |
798 | 811 |
799 _showRecordingHelpMessage: function() | 812 _showRecordingHelpMessage: function() |
800 { | 813 { |
801 /** | 814 /** |
802 * @param {string} tagName | 815 * @param {string} tagName |
803 * @param {string} contents | 816 * @param {string} contents |
804 * @return {!Element} | 817 * @return {!Element} |
805 */ | 818 */ |
806 function encloseWithTag(tagName, contents) | 819 function encloseWithTag(tagName, contents) |
807 { | 820 { |
808 var e = createElement(tagName); | 821 var e = createElement(tagName); |
809 e.textContent = contents; | 822 e.textContent = contents; |
810 return e; | 823 return e; |
811 } | 824 } |
812 | 825 |
813 var recordNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli
nePanelShortcuts.StartStopRecording[0].name); | 826 var recordNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli
nePanelShortcuts.StartStopRecording[0].name); |
814 var reloadNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli
nePanelShortcuts.RecordPageReload[0].name); | 827 var reloadNode = encloseWithTag("b", WebInspector.ShortcutsScreen.Timeli
nePanelShortcuts.RecordPageReload[0].name); |
815 var navigateNode = encloseWithTag("b", WebInspector.UIString("WASD")); | 828 var navigateNode = encloseWithTag("b", WebInspector.UIString("WASD")); |
816 var hintText = createElementWithClass("div", "recording-hint"); | 829 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)); | 830 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"); | 831 hintText.createChild("br"); |
819 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString(
"To evaluate page load performance, hit %s to record the reload."), [reloadNode]
, null)); | 832 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString(
"To evaluate page load performance, hit %s to record the reload."), [reloadNode]
, null)); |
820 hintText.createChild("p"); | 833 hintText.createChild("p"); |
821 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString(
"After recording, select an area of interest in the overview by dragging."), [],
null)); | 834 hintText.appendChild(WebInspector.formatLocalized(WebInspector.UIString(
"After recording, select an area of interest in the overview by dragging."), [],
null)); |
822 hintText.createChild("br"); | 835 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)); | 836 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); | 837 this._hideRecordingHelpMessage(); |
| 838 this._helpMessageElement = this._searchableView.element.createChild("div
", "timeline-status-pane fill"); |
| 839 this._helpMessageElement.appendChild(hintText); |
825 }, | 840 }, |
826 | 841 |
827 /** | 842 _hideRecordingHelpMessage: function() |
828 * @param {string|!Element} statusMessage | |
829 */ | |
830 _updateStatus: function(statusMessage) | |
831 { | 843 { |
832 if (!this._statusElement) | 844 if (this._helpMessageElement) |
833 this._showStatusPane(); | 845 this._helpMessageElement.remove(); |
834 this._statusElement.removeChildren(); | 846 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 }, | 847 }, |
853 | 848 |
854 _onRecordingStopped: function() | 849 _onRecordingStopped: function() |
855 { | 850 { |
856 this._stopPending = false; | 851 this._stopPending = false; |
857 this._updateToggleTimelineButton(false); | 852 this._updateToggleTimelineButton(false); |
858 if (this._lazyFrameModel) { | 853 if (this._lazyFrameModel) { |
859 this._lazyFrameModel.reset(); | 854 this._lazyFrameModel.reset(); |
860 this._lazyFrameModel.addTraceEvents(this._model.target(), this._mode
l.inspectedTargetEvents(), this._tracingModel.sessionId()); | 855 this._lazyFrameModel.addTraceEvents(this._model.target(), this._mode
l.inspectedTargetEvents(), this._tracingModel.sessionId()); |
861 } | 856 } |
862 this._overviewPane.reset(); | 857 this._overviewPane.reset(); |
863 this._overviewPane.setBounds(this._model.minimumRecordTime(), this._mode
l.maximumRecordTime()); | 858 this._overviewPane.setBounds(this._model.minimumRecordTime(), this._mode
l.maximumRecordTime()); |
864 this.requestWindowTimes(this._model.minimumRecordTime(), this._model.max
imumRecordTime()); | 859 this.requestWindowTimes(this._model.minimumRecordTime(), this._model.max
imumRecordTime()); |
865 this._refreshViews(); | 860 this._refreshViews(); |
866 this._hideStatusPane(); | |
867 for (var i = 0; i < this._overviewControls.length; ++i) | 861 for (var i = 0; i < this._overviewControls.length; ++i) |
868 this._overviewControls[i].timelineStopped(); | 862 this._overviewControls[i].timelineStopped(); |
869 this._setMarkers(); | 863 this._setMarkers(); |
870 this._overviewPane.scheduleUpdate(); | 864 this._overviewPane.scheduleUpdate(); |
871 this._updateSearchHighlight(false, true); | 865 this._updateSearchHighlight(false, true); |
| 866 if (this._statusDialog) { |
| 867 this._statusDialog.hide(); |
| 868 delete this._statusDialog; |
| 869 } |
872 }, | 870 }, |
873 | 871 |
874 _setMarkers: function() | 872 _setMarkers: function() |
875 { | 873 { |
876 var markers = new Map(); | 874 var markers = new Map(); |
877 var recordTypes = WebInspector.TimelineModel.RecordType; | 875 var recordTypes = WebInspector.TimelineModel.RecordType; |
878 for (var record of this._model.eventDividerRecords()) { | 876 for (var record of this._model.eventDividerRecords()) { |
879 if (record.type() === recordTypes.TimeStamp || record.type() === rec
ordTypes.ConsoleTime) | 877 if (record.type() === recordTypes.TimeStamp || record.type() === rec
ordTypes.ConsoleTime) |
880 continue; | 878 continue; |
881 markers.set(record.startTime(), WebInspector.TimelineUIUtils.createD
ividerForRecord(record, 0)); | 879 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: | 1737 case WebInspector.TimelineModel.RecordType.JSFrame: |
1740 return false; | 1738 return false; |
1741 default: | 1739 default: |
1742 return true; | 1740 return true; |
1743 } | 1741 } |
1744 }, | 1742 }, |
1745 | 1743 |
1746 __proto__: WebInspector.TimelineModel.Filter.prototype | 1744 __proto__: WebInspector.TimelineModel.Filter.prototype |
1747 } | 1745 } |
1748 | 1746 |
| 1747 /** |
| 1748 * @constructor |
| 1749 * @extends {WebInspector.DialogDelegate} |
| 1750 */ |
| 1751 WebInspector.TimelinePanel.StatusDialog = function() |
| 1752 { |
| 1753 WebInspector.DialogDelegate.call(this); |
| 1754 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element); |
| 1755 shadowRoot.appendChild(WebInspector.Widget.createStyleElement("timeline/time
lineStatusDialog.css")); |
| 1756 this._contentElement = shadowRoot.createChild("div", "timeline-status-dialog
"); |
| 1757 this._contentElement.createChild("div", "title").textContent = WebInspector.
UIString("Recording Timeline"); |
| 1758 this._status = this._contentElement.createChild("div", "status"); |
| 1759 this._time = this._contentElement.createChild("div", "time"); |
| 1760 this._bufferUsage = this._contentElement.createChild("div", "buffer-usage").
createChild("div", "indicator-container").createChild("div", "indicator"); |
| 1761 this._stopButton = createTextButton(WebInspector.UIString("Finish"), this._o
nFinish.bind(this)); |
| 1762 this._contentElement.createChild("div", "stop-button").appendChild(this._sto
pButton); |
| 1763 this._finishKeys = new Set([ |
| 1764 WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortc
ut.Keys.Space).key, |
| 1765 WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortc
ut.Keys.Enter).key, |
| 1766 WebInspector.ShortcutsScreen.TimelinePanelShortcuts.StartStopRecording[0
].key |
| 1767 ]); |
| 1768 } |
| 1769 |
| 1770 WebInspector.TimelinePanel.StatusDialog.Events = { |
| 1771 Finish: "Finish" |
| 1772 } |
| 1773 |
| 1774 WebInspector.TimelinePanel.StatusDialog.prototype = { |
| 1775 /** |
| 1776 * @override |
| 1777 */ |
| 1778 willHide: function() |
| 1779 { |
| 1780 this._stopTimer(); |
| 1781 }, |
| 1782 |
| 1783 finish: function() |
| 1784 { |
| 1785 this._stopButton.disabled = true; |
| 1786 this._stopTimer(); |
| 1787 }, |
| 1788 |
| 1789 hide: function() |
| 1790 { |
| 1791 WebInspector.Dialog.hide(); |
| 1792 }, |
| 1793 |
| 1794 /** |
| 1795 * @param {string} text |
| 1796 */ |
| 1797 updateStatus: function(text) |
| 1798 { |
| 1799 this._status.textContent = text; |
| 1800 }, |
| 1801 |
| 1802 /** |
| 1803 * @param {number} percent |
| 1804 */ |
| 1805 updateBufferUsage: function(percent) |
| 1806 { |
| 1807 this._bufferUsage.style.width = percent.toFixed(1) + "%"; |
| 1808 this._updateTimer(); |
| 1809 }, |
| 1810 |
| 1811 /** |
| 1812 * @override |
| 1813 * @param {!KeyboardEvent} event |
| 1814 */ |
| 1815 onKeyDown: function(event) |
| 1816 { |
| 1817 var key = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); |
| 1818 if (this._finishKeys.has(key)) |
| 1819 this._onFinish(); |
| 1820 event.consume(); |
| 1821 }, |
| 1822 |
| 1823 _onFinish: function() |
| 1824 { |
| 1825 this.dispatchEventToListeners(WebInspector.TimelinePanel.StatusDialog.Ev
ents.Finish); |
| 1826 }, |
| 1827 |
| 1828 startTimer: function() |
| 1829 { |
| 1830 this._startTime = Date.now(); |
| 1831 this._timeUpdateTimer = setInterval(this._updateTimer.bind(this, false),
1000); |
| 1832 }, |
| 1833 |
| 1834 _stopTimer: function() |
| 1835 { |
| 1836 if (!this._timeUpdateTimer) |
| 1837 return; |
| 1838 clearInterval(this._timeUpdateTimer); |
| 1839 this._updateTimer(true); |
| 1840 delete this._timeUpdateTimer; |
| 1841 }, |
| 1842 |
| 1843 /** |
| 1844 * @param {boolean=} precise |
| 1845 */ |
| 1846 _updateTimer: function(precise) |
| 1847 { |
| 1848 var elapsed = (Date.now() - this._startTime) / 1000; |
| 1849 this._time.textContent = WebInspector.UIString("%s\u2009sec", elapsed.to
Fixed(precise ? 1 : 0)); |
| 1850 }, |
| 1851 |
| 1852 __proto__: WebInspector.DialogDelegate.prototype |
| 1853 } |
| 1854 |
1749 WebInspector.TimelinePanel.show = function() | 1855 WebInspector.TimelinePanel.show = function() |
1750 { | 1856 { |
1751 WebInspector.inspectorView.setCurrentPanel(WebInspector.TimelinePanel.instan
ce()); | 1857 WebInspector.inspectorView.setCurrentPanel(WebInspector.TimelinePanel.instan
ce()); |
1752 } | 1858 } |
1753 | 1859 |
1754 /** | 1860 /** |
1755 * @return {!WebInspector.TimelinePanel} | 1861 * @return {!WebInspector.TimelinePanel} |
1756 */ | 1862 */ |
1757 WebInspector.TimelinePanel.instance = function() | 1863 WebInspector.TimelinePanel.instance = function() |
1758 { | 1864 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 /** | 1898 /** |
1793 * @override | 1899 * @override |
1794 * @param {string} value | 1900 * @param {string} value |
1795 */ | 1901 */ |
1796 handleQueryParam: function(value) | 1902 handleQueryParam: function(value) |
1797 { | 1903 { |
1798 WebInspector.TimelinePanel.show(); | 1904 WebInspector.TimelinePanel.show(); |
1799 WebInspector.TimelinePanel.instance()._loadFromURL(value); | 1905 WebInspector.TimelinePanel.instance()._loadFromURL(value); |
1800 } | 1906 } |
1801 } | 1907 } |
OLD | NEW |