Web Inspector: Canvas: remove event listeners once a recording is ready
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2019 22:05:15 +0000 (22:05 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2019 22:05:15 +0000 (22:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195324

Reviewed by Matt Baker.

* UserInterface/Models/Recording.js:
(WI.Recording):
(WI.Recording.prototype.async swizzle):
(WI.Recording.prototype.async _process):

* UserInterface/Views/RecordingActionTreeElement.js:
(WI.RecordingActionTreeElement):
(WI.RecordingActionTreeElement.prototype._handleValidityChanged):

* UserInterface/Views/CanvasSidebarPanel.js:
(WI.CanvasSidebarPanel.prototype.set recording):
(WI.CanvasSidebarPanel.prototype._handleRecordingProcessedAction):

* UserInterface/Views/RecordingContentView.js:
(WI.RecordingContentView.prototype.initialLayout):
(WI.RecordingContentView.prototype._handleRecordingProcessedAction):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/Recording.js
Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/RecordingActionTreeElement.js
Source/WebInspectorUI/UserInterface/Views/RecordingContentView.js

index 0e0fa1e..55ef8ac 100644 (file)
@@ -1,3 +1,27 @@
+2019-03-05  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Canvas: remove event listeners once a recording is ready
+        https://bugs.webkit.org/show_bug.cgi?id=195324
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Models/Recording.js:
+        (WI.Recording):
+        (WI.Recording.prototype.async swizzle):
+        (WI.Recording.prototype.async _process):
+
+        * UserInterface/Views/RecordingActionTreeElement.js:
+        (WI.RecordingActionTreeElement):
+        (WI.RecordingActionTreeElement.prototype._handleValidityChanged):
+
+        * UserInterface/Views/CanvasSidebarPanel.js:
+        (WI.CanvasSidebarPanel.prototype.set recording):
+        (WI.CanvasSidebarPanel.prototype._handleRecordingProcessedAction):
+
+        * UserInterface/Views/RecordingContentView.js:
+        (WI.RecordingContentView.prototype.initialLayout):
+        (WI.RecordingContentView.prototype._handleRecordingProcessedAction):
+
 2019-03-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Attempting to select records in the bottom 16px of the timeline overview graph fails
index 4354c2b..1323d32 100644 (file)
@@ -36,7 +36,7 @@ WI.Recording = class Recording extends WI.Object
         this._data = data;
         this._displayName = WI.UIString("Recording");
 
-        this._swizzle = [];
+        this._swizzle = null;
         this._actions = [new WI.RecordingInitialStateAction].concat(...this._frames.map((frame) => frame.actions));
         this._visualActionIndexes = [];
         this._source = null;
@@ -295,6 +295,9 @@ WI.Recording = class Recording extends WI.Object
 
     async swizzle(index, type)
     {
+        if (!this._swizzle)
+            this._swizzle = {};
+
         if (typeof this._swizzle[index] !== "object")
             this._swizzle[index] = {};
 
@@ -530,6 +533,7 @@ WI.Recording = class Recording extends WI.Object
                 return;
         }
 
+        this._swizzle = null;
         this._processContext = null;
         this._processing = false;
     }
index e0e8831..bea5159 100644 (file)
@@ -114,17 +114,15 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         if (recording === this._recording)
             return;
 
-        if (this._recording) {
-            this._recording.removeEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
-            this._recording.removeEventListener(WI.Recording.Event.StartProcessingFrame, this._handleRecordingStartProcessingFrame, this);
-        }
+        if (this._recording)
+            this._recording.removeEventListener(null, null, this);
 
         if (recording)
             this.canvas = recording.source;
 
         this._recording = recording;
 
-        if (this._recording) {
+        if (this._recording && !this._recording.ready) {
             this._recording.addEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
             this._recording.addEventListener(WI.Recording.Event.StartProcessingFrame, this._handleRecordingStartProcessingFrame, this);
         }
@@ -579,12 +577,16 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         console.assert(isInitialStateAction || this._recordingTreeOutline.children.lastValue instanceof WI.FolderTreeElement, "There should be a WI.FolderTreeElement for the frame for this action.");
         this._createRecordingActionTreeElement(action, index, isInitialStateAction ? this._recordingTreeOutline : this._recordingTreeOutline.children.lastValue);
 
-        if (this._recording.ready && !this._recording[WI.CanvasSidebarPanel.SelectedActionSymbol])
-            this.action = this._recording.actions[0];
+        if (this._recording.ready) {
+            this._recording.removeEventListener(null, null, this);
 
-        if (action === this._recording.actions.lastValue && this._recordingProcessingOptionsContainer) {
-            this._recordingProcessingOptionsContainer.remove();
-            this._recordingProcessingOptionsContainer = null;
+            if (!this._recording[WI.CanvasSidebarPanel.SelectedActionSymbol])
+                this.action = this._recording.actions[0];
+
+            if (this._recordingProcessingOptionsContainer) {
+                this._recordingProcessingOptionsContainer.remove();
+                this._recordingProcessingOptionsContainer = null;
+            }
         }
     }
 
index dbadc7d..64b95e7 100644 (file)
@@ -38,7 +38,8 @@ WI.RecordingActionTreeElement = class RecordingActionTreeElement extends WI.Gene
         this._index = index;
         this._copyText = copyText;
 
-        this.representedObject.addEventListener(WI.RecordingAction.Event.ValidityChanged, this._handleValidityChanged, this);
+        if (this.representedObject.valid)
+            this.representedObject.addEventListener(WI.RecordingAction.Event.ValidityChanged, this._handleValidityChanged, this);
     }
 
     // Static
@@ -453,6 +454,8 @@ WI.RecordingActionTreeElement = class RecordingActionTreeElement extends WI.Gene
     _handleValidityChanged(event)
     {
         this.addClassName("invalid");
+
+        this.representedObject.removeEventListener(null, null, this);
     }
 };
 
index 137c957..b8a0225 100644 (file)
@@ -167,7 +167,8 @@ WI.RecordingContentView = class RecordingContentView extends WI.ContentView
         this._sliderElement.min = 0;
         this._sliderElement.max = 0;
 
-        this.representedObject.addEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
+        if (!this.representedObject.ready)
+            this.representedObject.addEventListener(WI.Recording.Event.ProcessedAction, this._handleRecordingProcessedAction, this);
     }
 
     // Private
@@ -486,6 +487,9 @@ WI.RecordingContentView = class RecordingContentView extends WI.ContentView
     {
         this._sliderElement.max = this.representedObject.visualActionIndexes.length;
         this._updateSliderValue();
+
+        if (this.representedObject.ready)
+            this.representedObject.removeEventListener(null, null, this);
     }
 };