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

Side by Side Diff: Source/devtools/front_end/timeline/TimelinePanel.js

Issue 1321683003: DevTools: Introduce timeline recording info dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Extract css into a file Created 5 years, 3 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) 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
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
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);
caseq 2015/08/28 23:36:55 Can we make it a callback, not event? There does n
alph 2015/08/29 00:49:38 no way. It is an event!
670 WebInspector.Dialog.show(null, this._statusDialog, true);
671 WebInspector.Dialog.currentInstance().focus();
pfeldman 2015/08/28 23:24:52 Lets move this into show?
alph 2015/08/29 00:49:38 Done.
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
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();
caseq 2015/08/28 23:36:55 convert to if ()?
alph 2015/08/29 00:49:37 Done.
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);
caseq 2015/08/28 23:36:55 ditto.
alph 2015/08/29 00:49:38 Done.
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();
caseq 2015/08/28 23:36:55 drop this
alph 2015/08/29 00:49:37 Done.
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
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 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element);
1753 shadowRoot.appendChild(WebInspector.Widget.createStyleElement("timeline/time lineStatusDialog.css"));
1754 this._contentElement = shadowRoot.createChild("div", "filmstrip-dialog");
1755 this._contentElement.classList.add("timeline-status-dialog");
caseq 2015/08/28 23:36:55 use space-separated class list in the call above?
alph 2015/08/29 00:49:38 Done.
1756 this._contentElement.createChild("div", "title").textContent = WebInspector. UIString("Recording Timeline");
1757 this._status = this._contentElement.createChild("div", "status");
1758 this._time = this._contentElement.createChild("div", "time");
1759 this._bufferUsage = this._contentElement.createChild("div", "buffer-usage"). createChild("div", "indicator-container").createChild("div", "indicator");
1760 this._stopButton = createTextButton(WebInspector.UIString("Finish"), this._o nFinish.bind(this));
1761 this._contentElement.createChild("div", "stop-button").appendChild(this._sto pButton);
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");
caseq 2015/08/28 23:36:55 why not just disabled = true?
alph 2015/08/29 00:49:38 Done.
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._startTime = Date.now();
1830 this._timeUpdateTimer = setInterval(this._updateTimer.bind(this, false), 1000);
1831 },
1832
1833 _stopTimer: function()
1834 {
1835 if (!this._timeUpdateTimer)
1836 return;
1837 clearInterval(this._timeUpdateTimer);
1838 this._updateTimer(true);
caseq 2015/08/28 23:36:55 I'd nuke precise mode for the sake of brevity -- i
alph 2015/08/29 00:49:38 I'd keep it. Otherwise it might show strange value
1839 delete this._timeUpdateTimer;
1840 },
1841
1842 /**
1843 * @param {boolean=} precise
1844 */
1845 _updateTimer: function(precise)
1846 {
1847 var elapsed = (Date.now() - this._startTime) / 1000;
1848 this._time.textContent = WebInspector.UIString("%s\u2009sec", elapsed.to Fixed(precise ? 1 : 0));
1849 },
1850
1851 __proto__: WebInspector.DialogDelegate.prototype
1852 }
1853
1749 WebInspector.TimelinePanel.show = function() 1854 WebInspector.TimelinePanel.show = function()
1750 { 1855 {
1751 WebInspector.inspectorView.setCurrentPanel(WebInspector.TimelinePanel.instan ce()); 1856 WebInspector.inspectorView.setCurrentPanel(WebInspector.TimelinePanel.instan ce());
1752 } 1857 }
1753 1858
1754 /** 1859 /**
1755 * @return {!WebInspector.TimelinePanel} 1860 * @return {!WebInspector.TimelinePanel}
1756 */ 1861 */
1757 WebInspector.TimelinePanel.instance = function() 1862 WebInspector.TimelinePanel.instance = function()
1758 { 1863 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 /** 1897 /**
1793 * @override 1898 * @override
1794 * @param {string} value 1899 * @param {string} value
1795 */ 1900 */
1796 handleQueryParam: function(value) 1901 handleQueryParam: function(value)
1797 { 1902 {
1798 WebInspector.TimelinePanel.show(); 1903 WebInspector.TimelinePanel.show();
1799 WebInspector.TimelinePanel.instance()._loadFromURL(value); 1904 WebInspector.TimelinePanel.instance()._loadFromURL(value);
1800 } 1905 }
1801 } 1906 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/timeline/module.json » ('j') | Source/devtools/front_end/ui/Dialog.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698