Web Inspector: REGRESSION: CanvasSidebarPanel is empty for imported recordings
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2018 00:06:40 +0000 (00:06 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2018 00:06:40 +0000 (00:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189061

Reviewed by Brian Burg.

When recordings are imported, they don't have an associated `WI.Canvas`, meaning that the
`WI.Recording` is never added to the canvas' `WI.RecordingCollection`. Previously, the
canvas sidebar relied upon the `ItemAdded` event to update the recording `WI.ScopeBar`.
Since the imported recording isn't ever added to the collection, this is never fired.

This patch moves the function call that updates the `WI.ScopeBar` to a more universal path,
ensuring that no matter how a `WI.Recording` is set for the sidebar, it will be shown.

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

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js

index ae521df..7da94e8 100644 (file)
@@ -1,5 +1,25 @@
 2018-08-28  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: REGRESSION: CanvasSidebarPanel is empty for imported recordings
+        https://bugs.webkit.org/show_bug.cgi?id=189061
+
+        Reviewed by Brian Burg.
+
+        When recordings are imported, they don't have an associated `WI.Canvas`, meaning that the
+        `WI.Recording` is never added to the canvas' `WI.RecordingCollection`. Previously, the
+        canvas sidebar relied upon the `ItemAdded` event to update the recording `WI.ScopeBar`.
+        Since the imported recording isn't ever added to the collection, this is never fired.
+
+        This patch moves the function call that updates the `WI.ScopeBar` to a more universal path,
+        ensuring that no matter how a `WI.Recording` is set for the sidebar, it will be shown.
+
+        * UserInterface/Views/CanvasSidebarPanel.js:
+        (WI.CanvasSidebarPanel.prototype.set recording):
+        (WI.CanvasSidebarPanel.prototype._recordingAdded):
+        (WI.CanvasSidebarPanel.prototype._updateRecordingScopeBar):
+
+2018-08-28  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Search bar is too narrow in some localizations
         https://bugs.webkit.org/show_bug.cgi?id=189060
         <rdar://problem/43006369>
index 34653da..ac2b9b1 100644 (file)
@@ -119,6 +119,8 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
             this._recording.addEventListener(WI.Recording.Event.StartProcessingFrame, this._handleRecordingStartProcessingFrame, this);
         }
 
+        this._updateRecordNavigationItem();
+        this._updateRecordingScopeBar();
         this._recordingChanged();
     }
 
@@ -221,9 +223,6 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
 
     _recordingAdded(event)
     {
-        this._updateRecordNavigationItem();
-        this._updateRecordingScopeBar();
-
         this.recording = event.data.item;
     }
 
@@ -458,14 +457,15 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
 
         this._recordingNavigationBar.element.classList.toggle("hidden", !this._canvas);
 
-        let hasRecordings = this._canvas && this._canvas.recordingCollection.size;
+        let hasRecordings = this._recording || (this._canvas && this._canvas.recordingCollection.size);
         this.element.classList.toggle("has-recordings", hasRecordings);
         if (!hasRecordings)
             return;
 
         let scopeBarItems = [];
         let selectedScopeBarItem = null;
-        for (let recording of this._canvas.recordingCollection) {
+
+        let createScopeBarItem = (recording) => {
             let scopeBarItem = new WI.ScopeBarItem(recording.displayName, recording.displayName);
             if (recording === this._recording)
                 selectedScopeBarItem = scopeBarItem;
@@ -473,8 +473,16 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
                 scopeBarItem.selected = false;
             scopeBarItem.__recording = recording;
             scopeBarItems.push(scopeBarItem);
+        };
+
+        if (this._canvas && this._canvas.recordingCollection) {
+            for (let recording of this._canvas.recordingCollection)
+                createScopeBarItem(recording);
         }
 
+        if (this._recording && (!this._canvas || !this._canvas.recordingCollection.has(this._recording)))
+            createScopeBarItem(this._recording);
+
         if (!selectedScopeBarItem) {
             selectedScopeBarItem = scopeBarItems[0];