Web Inspector: Timelines: can't reliably stop/start a recording
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / SourcesNavigationSidebarPanel.js
index 568a3cd..f0e94fb 100644 (file)
@@ -282,8 +282,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
         WI.consoleManager.addEventListener(WI.ConsoleManager.Event.IssueAdded, this._handleConsoleIssueAdded, this);
         WI.consoleManager.addEventListener(WI.ConsoleManager.Event.Cleared, this._handleConsoleCleared, this);
 
-        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingWillStart, this._handleTimelineCapturingWillStart, this);
-        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._handleTimelineCapturingStopped, this);
+        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
 
         WI.auditManager.addEventListener(WI.AuditManager.Event.TestScheduled, this._handleAuditManagerTestScheduled, this);
         WI.auditManager.addEventListener(WI.AuditManager.Event.TestCompleted, this._handleAuditManagerTestCompleted, this);
@@ -337,8 +336,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             this._handleDebuggerPaused();
 
         if (WI.debuggerManager.breakpointsDisabledTemporarily) {
-            if (WI.timelineManager.isCapturing())
-                this._handleTimelineCapturingWillStart();
+            this._handleTimelineCapturingStateChanged();
 
             if (WI.auditManager.runningState === WI.AuditManager.RunningState.Active || WI.auditManager.runningState === WI.AuditManager.RunningState.Stopping)
                 this._handleAuditManagerTestScheduled();
@@ -1820,34 +1818,33 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
         issueTreeElements.forEach((treeElement) => treeElement.parent.removeChild(treeElement));
     }
 
-    _handleTimelineCapturingWillStart(event)
+    _handleTimelineCapturingStateChanged(event)
     {
         this._updateTemporarilyDisabledBreakpointsButtons();
 
-        if (!this._timelineRecordingWarningElement) {
-            let stopRecordingButton = document.createElement("button");
-            stopRecordingButton.textContent = WI.UIString("Stop recording");
-            stopRecordingButton.addEventListener("click", () => {
-                WI.timelineManager.stopCapturing();
-            });
-
-            this._timelineRecordingWarningElement = document.createElement("div");
-            this._timelineRecordingWarningElement.classList.add("warning-banner");
-            this._timelineRecordingWarningElement.append(WI.UIString("Debugger disabled during Timeline recording"), document.createElement("br"), stopRecordingButton);
-        }
-
-        this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild);
+        switch (WI.timelineManager.capturingState) {
+        case WI.TimelineManager.CapturingState.Starting:
+            if (!this._timelineRecordingWarningElement) {
+                let stopRecordingButton = document.createElement("button");
+                stopRecordingButton.textContent = WI.UIString("Stop recording");
+                stopRecordingButton.addEventListener("click", () => {
+                    WI.timelineManager.stopCapturing();
+                });
 
-        this._updateBreakpointsDisabledBanner();
-    }
+                this._timelineRecordingWarningElement = document.createElement("div");
+                this._timelineRecordingWarningElement.classList.add("warning-banner");
+                this._timelineRecordingWarningElement.append(WI.UIString("Debugger disabled during Timeline recording"), document.createElement("br"), stopRecordingButton);
+            }
 
-    _handleTimelineCapturingStopped(event)
-    {
-        this._updateTemporarilyDisabledBreakpointsButtons();
+            this.contentView.element.insertBefore(this._timelineRecordingWarningElement, this.contentView.element.firstChild);
+            break;
 
-        if (this._timelineRecordingWarningElement) {
-            this._timelineRecordingWarningElement.remove();
-            this._timelineRecordingWarningElement = null;
+        case WI.TimelineManager.CapturingState.Inactive:
+            if (this._timelineRecordingWarningElement) {
+                this._timelineRecordingWarningElement.remove();
+                this._timelineRecordingWarningElement = null;
+            }
+            break;
         }
 
         this._updateBreakpointsDisabledBanner();