Web Inspector: Canvas tab: don't automatically select a recording when viewing a...
authorwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 May 2018 23:01:25 +0000 (23:01 +0000)
committerwebkit@devinrousso.com <webkit@devinrousso.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 May 2018 23:01:25 +0000 (23:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182950

Reviewed by Matt Baker.

* UserInterface/Views/CanvasSidebarPanel.js:
(WI.CanvasSidebarPanel):
(WI.CanvasSidebarPanel.prototype._currentRepresentedObjectsDidChange):
(WI.CanvasSidebarPanel.prototype._treeOutlineSelectionDidChange):
(WI.CanvasSidebarPanel.prototype._canvasChanged):
(WI.CanvasSidebarPanel.prototype._recordingChanged):
(WI.CanvasSidebarPanel.prototype._updateRecordingScopeBar):
Add a "dummy" ScopeBarItem to the recording ScopeBar that is selected whenever a TreeElement
that doesn't correspond to a Recording is selected. This way, the Recording ScopeBar will
become deselected, and the list of actions will disappear. Clicking on the Recording ScopeBar
will show the previously selected Recording.

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

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

index 6efefec..7d35625 100644 (file)
@@ -1,3 +1,22 @@
+2018-05-14  Devin Rousso  <webkit@devinrousso.com>
+
+        Web Inspector: Canvas tab: don't automatically select a recording when viewing a canvas
+        https://bugs.webkit.org/show_bug.cgi?id=182950
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Views/CanvasSidebarPanel.js:
+        (WI.CanvasSidebarPanel):
+        (WI.CanvasSidebarPanel.prototype._currentRepresentedObjectsDidChange):
+        (WI.CanvasSidebarPanel.prototype._treeOutlineSelectionDidChange):
+        (WI.CanvasSidebarPanel.prototype._canvasChanged):
+        (WI.CanvasSidebarPanel.prototype._recordingChanged):
+        (WI.CanvasSidebarPanel.prototype._updateRecordingScopeBar):
+        Add a "dummy" ScopeBarItem to the recording ScopeBar that is selected whenever a TreeElement
+        that doesn't correspond to a Recording is selected. This way, the Recording ScopeBar will
+        become deselected, and the list of actions will disappear. Clicking on the Recording ScopeBar
+        will show the previously selected Recording.
+
 2018-05-08  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Console drawer resizing is broken when console prompt has >1 line of code
index f239886..75c30b5 100644 (file)
@@ -34,6 +34,7 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
 
         this._navigationBar = new WI.NavigationBar;
         this._scopeBar = null;
+        this._placeholderScopeBarItem = null;
 
         const toolTip = WI.UIString("Start recording canvas actions.\nShift-click to record a single frame.");
         const altToolTip = WI.UIString("Stop recording canvas actions");
@@ -259,9 +260,8 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
 
         let recording = objects.find((object) => object instanceof WI.Recording);
         if (recording) {
-            this.canvas = recording.source;
+            recording[WI.CanvasSidebarPanel.SelectedActionSymbol] = objects.find((object) => object instanceof WI.RecordingAction);
             this.recording = recording;
-            this.action = objects.find((object) => object instanceof WI.RecordingAction);
             return;
         }
 
@@ -276,6 +276,9 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
             return;
 
         if ((treeElement instanceof WI.CanvasTreeElement) || (treeElement instanceof WI.ShaderProgramTreeElement)) {
+            if (this._placeholderScopeBarItem)
+                this._placeholderScopeBarItem.selected = true;
+
             this.showDefaultContentViewForTreeElement(treeElement);
             return;
         }
@@ -316,17 +319,12 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
         if (WI.Canvas.ContextType.Canvas2D || this._canvas.contextType === WI.Canvas.ContextType.WebGL)
             this._recordButtonNavigationItem.enabled = true;
 
-        let defaultSelectedRecording = null;
-        if (this._canvas.recordingCollection.size)
-            defaultSelectedRecording = Array.from(this._canvas.recordingCollection).lastValue;
-
-        this.recording = defaultSelectedRecording;
+        this.recording = null;
     }
 
     _recordingChanged()
     {
         this._recordingTreeOutline.removeChildren();
-        this.element.classList.toggle("has-recordings", !!this._recording);
 
         if (!this._recording)
             return;
@@ -405,12 +403,17 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
     _updateRecordingScopeBar()
     {
         if (this._scopeBar) {
+            this._placeholderScopeBarItem = null;
+
             this._recordingNavigationBar.removeNavigationItem(this._scopeBar);
             this._scopeBar = null;
         }
 
-        this._recordingNavigationBar.element.classList.toggle("hidden", !this._canvas || !this._recording);
-        if (!this._recording || !this._canvas)
+        this._recordingNavigationBar.element.classList.toggle("hidden", !this._canvas);
+
+        let hasRecordings = this._canvas && this._canvas.recordingCollection.size;
+        this.element.classList.toggle("has-recordings", hasRecordings);
+        if (!hasRecordings)
             return;
 
         let scopeBarItems = [];
@@ -419,13 +422,24 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan
             let scopeBarItem = new WI.ScopeBarItem(recording.displayName, recording.displayName);
             if (recording === this._recording)
                 selectedScopeBarItem = scopeBarItem;
+            else
+                scopeBarItem.selected = false;
             scopeBarItem.__recording = recording;
             scopeBarItems.push(scopeBarItem);
         }
 
-        if (!selectedScopeBarItem)
+        if (!selectedScopeBarItem) {
             selectedScopeBarItem = scopeBarItems[0];
 
+            const exclusive = true;
+            const className = null;
+            const hidden = true;
+            this._placeholderScopeBarItem = new WI.ScopeBarItem("canvas-recording-scope-bar-item-placeholder", WI.UIString("Recordings"), exclusive, className, hidden);
+            this._placeholderScopeBarItem.selected = true;
+
+            scopeBarItems.unshift(this._placeholderScopeBarItem);
+        }
+
         this._scopeBar = new WI.ScopeBar("canvas-recordinga-scope-bar", scopeBarItems, selectedScopeBarItem, true);
         this._scopeBar.addEventListener(WI.ScopeBar.Event.SelectionChanged, this._scopeBarSelectionChanged, this);
         this._recordingNavigationBar.insertNavigationItem(this._scopeBar, 0);