Web Inspector: Timelines: can't reliably stop/start a recording
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / TimelineOverview.js
index a1560e9..3cec4fb 100644 (file)
@@ -116,9 +116,8 @@ WI.TimelineOverview = class TimelineOverview extends WI.View
 
         this._viewModeDidChange();
 
+        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStateChanged, this._handleTimelineCapturingStateChanged, this);
         WI.timelineManager.addEventListener(WI.TimelineManager.Event.RecordingImported, this._recordingImported, this);
-        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStarted, this._capturingStarted, this);
-        WI.timelineManager.addEventListener(WI.TimelineManager.Event.CapturingStopped, this._capturingStopped, this);
     }
 
     // Import / Export
@@ -1032,6 +1031,20 @@ WI.TimelineOverview = class TimelineOverview extends WI.View
         this._editingInstrumentsDidChange();
     }
 
+    _handleTimelineCapturingStateChanged(event)
+    {
+        switch (WI.timelineManager.capturingState) {
+        case WI.TimelineManager.CapturingState.Active:
+            this._editInstrumentsButton.enabled = false;
+            this._stopEditingInstruments();
+            break;
+
+        case WI.TimelineManager.CapturingState.Inactive:
+            this._editInstrumentsButton.enabled = true;
+            break;
+        }
+    }
+
     _recordingImported(event)
     {
         let {overviewData} = event.data;
@@ -1055,17 +1068,6 @@ WI.TimelineOverview = class TimelineOverview extends WI.View
         }
     }
 
-    _capturingStarted(event)
-    {
-        this._editInstrumentsButton.enabled = false;
-        this._stopEditingInstruments();
-    }
-
-    _capturingStopped(event)
-    {
-        this._editInstrumentsButton.enabled = true;
-    }
-
     _compareTimelineTreeElements(a, b)
     {
         let aTimelineType = a.representedObject.type;