Web Inspector: Timelines: add UI for preventing auto-stop
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Feb 2019 04:17:58 +0000 (04:17 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Feb 2019 04:17:58 +0000 (04:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194956

Reviewed by Joseph Pecoraro.

Add a checkbox to the navigation area of the Timelines tab that controls whether recordings
automatically stop (e.g. after "load" or a period of inactivity).

* UserInterface/Views/TimelineRecordingContentView.js:
(WI.TimelineRecordingContentView):
(WI.TimelineRecordingContentView.prototype.get navigationItems):
(WI.TimelineRecordingContentView.prototype._handleAutoStopCheckboxCheckedDidChange): Added.
(WI.TimelineRecordingContentView.prototype._handleTimelinesAutoStopSettingChanged): Added.

* UserInterface/Controllers/TimelineManager.js:
(WI.TimelineManager):
(WI.TimelineManager.prototype.capturingStopped):
(WI.TimelineManager.prototype._stopAutoRecordingSoon):
(WI.TimelineManager.prototype._resetAutoRecordingMaxTimeTimeout):
(WI.TimelineManager.prototype._resetAutoRecordingDeadTimeTimeout):
(WI.TimelineManager.prototype._handleTimelinesAutoStopSettingChanged):

* UserInterface/Base/Setting.js:
* Localizations/en.lproj/localizedStrings.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241982 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Setting.js
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js

index 3737ba6..f1d3030 100644 (file)
@@ -1,5 +1,32 @@
 2019-02-22  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Timelines: add UI for preventing auto-stop
+        https://bugs.webkit.org/show_bug.cgi?id=194956
+
+        Reviewed by Joseph Pecoraro.
+
+        Add a checkbox to the navigation area of the Timelines tab that controls whether recordings
+        automatically stop (e.g. after "load" or a period of inactivity).
+
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WI.TimelineRecordingContentView):
+        (WI.TimelineRecordingContentView.prototype.get navigationItems):
+        (WI.TimelineRecordingContentView.prototype._handleAutoStopCheckboxCheckedDidChange): Added.
+        (WI.TimelineRecordingContentView.prototype._handleTimelinesAutoStopSettingChanged): Added.
+
+        * UserInterface/Controllers/TimelineManager.js:
+        (WI.TimelineManager):
+        (WI.TimelineManager.prototype.capturingStopped):
+        (WI.TimelineManager.prototype._stopAutoRecordingSoon):
+        (WI.TimelineManager.prototype._resetAutoRecordingMaxTimeTimeout):
+        (WI.TimelineManager.prototype._resetAutoRecordingDeadTimeTimeout):
+        (WI.TimelineManager.prototype._handleTimelinesAutoStopSettingChanged):
+
+        * UserInterface/Base/Setting.js:
+        * Localizations/en.lproj/localizedStrings.js:
+
+2019-02-22  Devin Rousso  <drousso@apple.com>
+
         REGRESSION(r?): Web Inspector: Popovers have inset shadows
         https://bugs.webkit.org/show_bug.cgi?id=192963
         <rdar://problem/46888679>
index e938eba..d59ade4 100644 (file)
@@ -938,6 +938,7 @@ localizedStrings["Stop element selection (%s)"] = "Stop element selection (%s)";
 localizedStrings["Stop recording"] = "Stop recording";
 localizedStrings["Stop recording (%s)"] = "Stop recording (%s)";
 localizedStrings["Stop recording canvas actions"] = "Stop recording canvas actions";
+localizedStrings["Stop recording once page loads"] = "Stop recording once page loads";
 localizedStrings["Stopping the \u201C%s\u201D audit"] = "Stopping the \u201C%s\u201D audit";
 localizedStrings["Storage"] = "Storage";
 localizedStrings["Style Attribute"] = "Style Attribute";
index c5ee292..2b02ae4 100644 (file)
@@ -150,6 +150,7 @@ WI.settings = {
     showShadowDOM: new WI.Setting("show-shadow-dom", false),
     showWhitespaceCharacters: new WI.Setting("show-whitespace-characters", false),
     tabSize: new WI.Setting("tab-size", 4),
+    timelinesAutoStop: new WI.Setting("timelines-auto-stop", true),
     zoomFactor: new WI.Setting("zoom-factor", 1),
 
     // Experimental
index 8ca9d97..90ccfc9 100644 (file)
@@ -39,6 +39,8 @@ WI.TimelineManager = class TimelineManager extends WI.Object
         WI.heapManager.addEventListener(WI.HeapManager.Event.GarbageCollected, this._garbageCollected, this);
         WI.memoryManager.addEventListener(WI.MemoryManager.Event.MemoryPressure, this._memoryPressure, this);
 
+        WI.settings.timelinesAutoStop.addEventListener(WI.Setting.Event.Changed, this._handleTimelinesAutoStopSettingChanged, this);
+
         this._enabledTimelineTypesSetting = new WI.Setting("enabled-instrument-types", WI.TimelineManager.defaultTimelineTypes());
 
         this._isCapturing = false;
@@ -304,15 +306,7 @@ WI.TimelineManager = class TimelineManager extends WI.Object
 
         WI.DOMNode.removeEventListener(null, null, this);
 
-        if (this._stopCapturingTimeout) {
-            clearTimeout(this._stopCapturingTimeout);
-            this._stopCapturingTimeout = undefined;
-        }
-
-        if (this._deadTimeTimeout) {
-            clearTimeout(this._deadTimeTimeout);
-            this._deadTimeTimeout = undefined;
-        }
+        this.relaxAutoStop();
 
         this._isCapturing = false;
         this._isCapturingPageReload = false;
@@ -847,6 +841,9 @@ WI.TimelineManager = class TimelineManager extends WI.Object
 
     _stopAutoRecordingSoon()
     {
+        if (!WI.settings.timelinesAutoStop.value)
+            return;
+
         // Only auto stop when auto capturing.
         if (!this._isCapturing || !this._mainResourceForAutoCapturing)
             return;
@@ -858,6 +855,9 @@ WI.TimelineManager = class TimelineManager extends WI.Object
 
     _resetAutoRecordingMaxTimeTimeout()
     {
+        if (!WI.settings.timelinesAutoStop.value)
+            return;
+
         if (this._stopCapturingTimeout)
             clearTimeout(this._stopCapturingTimeout);
         this._stopCapturingTimeout = setTimeout(this._boundStopCapturing, WI.TimelineManager.MaximumAutoRecordDuration);
@@ -865,6 +865,9 @@ WI.TimelineManager = class TimelineManager extends WI.Object
 
     _resetAutoRecordingDeadTimeTimeout()
     {
+        if (!WI.settings.timelinesAutoStop.value)
+            return;
+
         // Only monitor dead time when auto capturing.
         if (!this._isCapturing || !this._mainResourceForAutoCapturing)
             return;
@@ -948,6 +951,17 @@ WI.TimelineManager = class TimelineManager extends WI.Object
         this.activeRecording.addMemoryPressureEvent(event.data.memoryPressureEvent);
     }
 
+    _handleTimelinesAutoStopSettingChanged(event)
+    {
+        if (!this._isCapturing)
+            return;
+
+        if (WI.settings.timelinesAutoStop.value)
+            this._resetAutoRecordingMaxTimeTimeout();
+        else
+            this.relaxAutoStop();
+    }
+
     _scriptProfilerTypeToScriptTimelineRecordType(type)
     {
         switch (type) {
index a6d1066..80d97d0 100644 (file)
@@ -56,6 +56,12 @@ WI.TimelineRecordingContentView = class TimelineRecordingContentView extends WI.
         this._timelineContentBrowser.navigationBar.addNavigationItem(this._filterBarNavigationItem);
         this.addSubview(this._timelineContentBrowser);
 
+        this._autoStopCheckboxNavigationItem = new WI.CheckboxNavigationItem("auto-stop-recording", WI.UIString("Stop recording once page loads"), WI.settings.timelinesAutoStop.value);
+        this._autoStopCheckboxNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
+        this._autoStopCheckboxNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, this._handleAutoStopCheckboxCheckedDidChange, this);
+
+        WI.settings.timelinesAutoStop.addEventListener(WI.Setting.Event.Changed, this._handleTimelinesAutoStopSettingChanged, this);
+
         this._clearTimelineNavigationItem = new WI.ButtonNavigationItem("clear-timeline", WI.UIString("Clear Timeline (%s)").format(WI.clearKeyboardShortcut.displayName), "Images/NavigationItemTrash.svg", 15, 15);
         this._clearTimelineNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
         this._clearTimelineNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._clearTimeline, this);
@@ -152,7 +158,11 @@ WI.TimelineRecordingContentView = class TimelineRecordingContentView extends WI.
 
     get navigationItems()
     {
-        return [this._clearTimelineNavigationItem];
+        return [
+            this._autoStopCheckboxNavigationItem,
+            new WI.DividerNavigationItem,
+            this._clearTimelineNavigationItem,
+        ];
     }
 
     get handleCopyEvent()
@@ -536,6 +546,16 @@ WI.TimelineRecordingContentView = class TimelineRecordingContentView extends WI.
         this._waitingToResetCurrentTime = false;
     }
 
+    _handleAutoStopCheckboxCheckedDidChange(event)
+    {
+        WI.settings.timelinesAutoStop.value = this._autoStopCheckboxNavigationItem.checked;
+    }
+
+    _handleTimelinesAutoStopSettingChanged(event)
+    {
+        this._autoStopCheckboxNavigationItem.checked = WI.settings.timelinesAutoStop.value;
+    }
+
     _clearTimeline(event)
     {
         if (WI.timelineManager.activeRecording === this._recording && WI.timelineManager.isCapturing())