Web Inspector: imported recordings are unable to be viewed after navigation
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2018 16:10:59 +0000 (16:10 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2018 16:10:59 +0000 (16:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189208

Reviewed by Joseph Pecoraro.

Move the "Imported Recordings" folder to the top level (instead of under "Overview") so that
it is selectable when there are no canvases but there is an imported recording.

* UserInterface/Controllers/CanvasManager.js:
(WI.CanvasManager.prototype._removeCanvas):
Null out the `source` of each `WI.Recording` for the removed `WI.Canvas`.

* UserInterface/Views/CanvasTabContentView.js:
(WI.CanvasTabContentView):
(WI.CanvasTabContentView.prototype._removeCanvas):
Add each `WI.Recording`for the removed `WI.Canvas` to the "Imported Recordings" folder.

* UserInterface/Views/CanvasContentView.js:
(WI.CanvasContentView.prototype.refresh):
(WI.CanvasContentView.prototype.initialLayout):
(WI.CanvasContentView.prototype._showError):
Drive-by: don't recreate the error preview element if it already exists.
* UserInterface/Views/CanvasSidebarPanel.js:
(WI.CanvasSidebarPanel.prototype.updateRepresentedObjects): Added.
(WI.CanvasSidebarPanel.prototype.shown):
(WI.CanvasSidebarPanel.prototype._currentRepresentedObjectsDidChange): Deleted.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js
Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.js

index beed0a4..4d36386 100644 (file)
@@ -1,3 +1,33 @@
+2018-09-12  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: imported recordings are unable to be viewed after navigation
+        https://bugs.webkit.org/show_bug.cgi?id=189208
+
+        Reviewed by Joseph Pecoraro.
+
+        Move the "Imported Recordings" folder to the top level (instead of under "Overview") so that
+        it is selectable when there are no canvases but there is an imported recording.
+
+        * UserInterface/Controllers/CanvasManager.js:
+        (WI.CanvasManager.prototype._removeCanvas):
+        Null out the `source` of each `WI.Recording` for the removed `WI.Canvas`.
+
+        * UserInterface/Views/CanvasTabContentView.js:
+        (WI.CanvasTabContentView):
+        (WI.CanvasTabContentView.prototype._removeCanvas):
+        Add each `WI.Recording`for the removed `WI.Canvas` to the "Imported Recordings" folder.
+
+        * UserInterface/Views/CanvasContentView.js:
+        (WI.CanvasContentView.prototype.refresh):
+        (WI.CanvasContentView.prototype.initialLayout):
+        (WI.CanvasContentView.prototype._showError):
+        Drive-by: don't recreate the error preview element if it already exists.
+
+        * UserInterface/Views/CanvasSidebarPanel.js:
+        (WI.CanvasSidebarPanel.prototype.updateRepresentedObjects): Added.
+        (WI.CanvasSidebarPanel.prototype.shown):
+        (WI.CanvasSidebarPanel.prototype._currentRepresentedObjectsDidChange): Deleted.
+
 2018-09-11  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Fix typo "vritualized"
index 5b4b4f9..547eb27 100644 (file)
@@ -273,6 +273,11 @@ WI.CanvasManager = class CanvasManager extends WI.Object
             this._dispatchShaderProgramRemoved(program);
         }
 
+        for (let recording of canvas.recordingCollection) {
+            recording.source = null;
+            recording.createDisplayName(recording.displayName);
+        }
+
         this.dispatchEventToListeners(WI.CanvasManager.Event.CanvasRemoved, {canvas});
     }
 
index cee34bb..d9b0134 100644 (file)
@@ -81,14 +81,11 @@ WI.CanvasContentView = class CanvasContentView extends WI.ContentView
         this.representedObject.requestContent().then((content) => {
             this._pendingContent = content;
             if (!this._pendingContent) {
-                console.error("Canvas content not available.", this.representedObject);
+                this._showError();
                 return;
             }
 
             this.needsLayout();
-        })
-        .catch(() => {
-            this._showError();
         });
     }
 
@@ -149,6 +146,9 @@ WI.CanvasContentView = class CanvasContentView extends WI.ContentView
         this._pixelSizeElement.className = "pixel-size";
         this._memoryCostElement = metrics.appendChild(document.createElement("span"));
         this._memoryCostElement.className = "memory-cost";
+
+        if (this._errorElement)
+            this._showError();
     }
 
     layout()
@@ -234,14 +234,16 @@ WI.CanvasContentView = class CanvasContentView extends WI.ContentView
 
     _showError()
     {
-        console.assert(!this._errorElement, "Error element already exists.");
-
         if (this._previewImageElement)
             this._previewImageElement.remove();
 
-        const isError = true;
-        this._errorElement = WI.createMessageTextView(WI.UIString("No Preview Available"), isError);
-        this._previewContainerElement.appendChild(this._errorElement);
+        if (!this._errorElement) {
+            const isError = true;
+            this._errorElement = WI.createMessageTextView(WI.UIString("No Preview Available"), isError);
+        }
+
+        if (this._previewContainerElement)
+            this._previewContainerElement.appendChild(this._errorElement);
     }
 
     _toggleRecording(event)
index ac2b9b1..c924d57 100644 (file)
@@ -159,12 +159,49 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         this._selectedRecordingActionIndex = this._recording.actions.indexOf(action);
     }
 
+    updateRepresentedObjects()
+    {
+        let objects = this.contentBrowser.currentRepresentedObjects;
+
+        let canvas = objects.find((object) => object instanceof WI.Canvas);
+        if (canvas) {
+            this.canvas = canvas;
+            return;
+        }
+
+        let shaderProgram = objects.find((object) => object instanceof WI.ShaderProgram);
+        if (shaderProgram) {
+            this.canvas = shaderProgram.canvas;
+            let treeElement = this._canvasTreeOutline.findTreeElement(shaderProgram);
+            const omitFocus = false;
+            const selectedByUser = false;
+            treeElement.revealAndSelect(omitFocus, selectedByUser);
+            return;
+        }
+
+        let recording = objects.find((object) => object instanceof WI.Recording);
+        if (recording) {
+            this.canvas = recording.source;
+
+            this.recording = recording;
+
+            let recordingAction = objects.find((object) => object instanceof WI.RecordingAction);
+            if (recordingAction !== recording[WI.CanvasSidebarPanel.SelectedActionSymbol])
+                this.action = recordingAction;
+
+            return;
+        }
+
+        this.canvas = null;
+        this.recording = null;
+    }
+
     shown()
     {
         super.shown();
 
-        this.contentBrowser.addEventListener(WI.ContentBrowser.Event.CurrentRepresentedObjectsDidChange, this._currentRepresentedObjectsDidChange, this);
-        this._currentRepresentedObjectsDidChange();
+        this.contentBrowser.addEventListener(WI.ContentBrowser.Event.CurrentRepresentedObjectsDidChange, this.updateRepresentedObjects, this);
+        this.updateRepresentedObjects();
     }
 
     hidden()
@@ -254,41 +291,6 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         }
     }
 
-    _currentRepresentedObjectsDidChange(event)
-    {
-        let objects = this.contentBrowser.currentRepresentedObjects;
-
-        let canvas = objects.find((object) => object instanceof WI.Canvas);
-        if (canvas) {
-            this.canvas = canvas;
-            return;
-        }
-
-        let shaderProgram = objects.find((object) => object instanceof WI.ShaderProgram);
-        if (shaderProgram) {
-            this.canvas = shaderProgram.canvas;
-            let treeElement = this._canvasTreeOutline.findTreeElement(shaderProgram);
-            const omitFocus = false;
-            const selectedByUser = false;
-            treeElement.revealAndSelect(omitFocus, selectedByUser);
-            return;
-        }
-
-        let recording = objects.find((object) => object instanceof WI.Recording);
-        if (recording) {
-            this.recording = recording;
-
-            let recordingAction = objects.find((object) => object instanceof WI.RecordingAction);
-            if (recordingAction !== recording[WI.CanvasSidebarPanel.SelectedActionSymbol])
-                this.action = recordingAction;
-
-            return;
-        }
-
-        this.canvas = null;
-        this.recording = null;
-    }
-
     _treeOutlineSelectionDidChange(event)
     {
         let treeElement = event.data.selectedElement;
index cc88b8b..cac2a2e 100644 (file)
@@ -44,9 +44,9 @@ WI.CanvasTabContentView = class CanvasTabContentView extends WI.ContentBrowserTa
         this._overviewTreeElement = new WI.GeneralTreeElement("canvas-overview", WI.UIString("Overview"), null, this._canvasCollection);
         this._canvasTreeOutline.appendChild(this._overviewTreeElement);
 
-        this._importedRecordingsTreeElement = new WI.FolderTreeElement(WI.UIString("Imported Recordings"));
+        this._importedRecordingsTreeElement = new WI.FolderTreeElement(WI.UIString("Imported Recordings"), WI.RecordingCollection);
         this._importedRecordingsTreeElement.hidden = true;
-        this._overviewTreeElement.appendChild(this._importedRecordingsTreeElement);
+        this._canvasTreeOutline.appendChild(this._importedRecordingsTreeElement);
 
         this._recordShortcut = new WI.KeyboardShortcut(null, WI.KeyboardShortcut.Key.Space, this._handleSpace.bind(this));
         this._recordShortcut.implicitlyPreventsDefault = false;
@@ -161,16 +161,25 @@ WI.CanvasTabContentView = class CanvasTabContentView extends WI.ContentBrowserTa
 
     _removeCanvas(canvas)
     {
-        // FIXME: Create tree elements/cards for recordings belonging to the removed canvas.
-
         let treeElement = this._canvasTreeOutline.findTreeElement(canvas);
         console.assert(treeElement, "Missing tree element for canvas.", canvas);
         this._overviewTreeElement.removeChild(treeElement);
         this._canvasCollection.remove(canvas);
 
+        const options = {
+            suppressShowRecording: true,
+        };
+
+        for (let recording of canvas.recordingCollection)
+            this._recordingAdded(recording, options);
+
         let currentContentView = this.contentBrowser.currentContentView;
         if (currentContentView instanceof WI.RecordingContentView && canvas.recordingCollection.has(currentContentView.representedObject))
             this.contentBrowser.updateHierarchicalPathForCurrentContentView();
+
+        let navigationSidebarPanel = this.navigationSidebarPanel;
+        if (navigationSidebarPanel instanceof WI.CanvasSidebarPanel && navigationSidebarPanel.visible)
+            navigationSidebarPanel.updateRepresentedObjects();
     }
 
     _handleCanvasAdded(event)