Web Inspector: Polish TabbedEditorContaner and ScriptsNavigator behavior.
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 15:25:04 +0000 (15:25 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 15:25:04 +0000 (15:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111732

Reviewed by Pavel Feldman.

Resources matching inspectedPageURL are always expanded in NavigatorView now.
Snippets tab in scripts navigator is not automatically opened anymore.
Cleared saved TabbedEditorContainer history because it might have been corrupted due to errors in earlier versions.
Snippets are not revealed in TabbedEditorContainer anymore unless they were actually selected by user or there is no other tabs opened.

* inspector/front-end/NavigatorView.js:
(WebInspector.NavigatorView):
(WebInspector.NavigatorView.prototype.addUISourceCode):
(WebInspector.NavigatorView.prototype._inspectedURLChanged):
(WebInspector.NavigatorView.prototype.revealUISourceCode):
(WebInspector.NavigatorView.prototype.removeUISourceCode):
(WebInspector.NavigatorFolderTreeElement.prototype.onattach):
(WebInspector.NavigatorUISourceCodeTreeNode.prototype.uiSourceCode):
(WebInspector.NavigatorUISourceCodeTreeNode.prototype.reveal):
* inspector/front-end/ScriptsNavigator.js:
(WebInspector.ScriptsNavigator.prototype.revealUISourceCode):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._showFile):
* inspector/front-end/Settings.js:
(WebInspector.VersionController.prototype._updateVersionFrom1To2):
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer.prototype.addUISourceCode.tabId.this._tabIds.get this):
(WebInspector.TabbedEditorContainer.prototype.addUISourceCode):
(WebInspector.TabbedEditorContainer.History.prototype._rebuildItemIndex):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/NavigatorView.js
Source/WebCore/inspector/front-end/ScriptsNavigator.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/Settings.js
Source/WebCore/inspector/front-end/TabbedEditorContainer.js

index 4a0227d..27d753e 100644 (file)
@@ -1,5 +1,37 @@
 2013-03-08  Vsevolod Vlasov  <vsevik@chromium.org>
 
+        Web Inspector: Polish TabbedEditorContaner and ScriptsNavigator behavior.
+        https://bugs.webkit.org/show_bug.cgi?id=111732
+
+        Reviewed by Pavel Feldman.
+
+        Resources matching inspectedPageURL are always expanded in NavigatorView now.
+        Snippets tab in scripts navigator is not automatically opened anymore.
+        Cleared saved TabbedEditorContainer history because it might have been corrupted due to errors in earlier versions.
+        Snippets are not revealed in TabbedEditorContainer anymore unless they were actually selected by user or there is no other tabs opened.
+
+        * inspector/front-end/NavigatorView.js:
+        (WebInspector.NavigatorView):
+        (WebInspector.NavigatorView.prototype.addUISourceCode):
+        (WebInspector.NavigatorView.prototype._inspectedURLChanged):
+        (WebInspector.NavigatorView.prototype.revealUISourceCode):
+        (WebInspector.NavigatorView.prototype.removeUISourceCode):
+        (WebInspector.NavigatorFolderTreeElement.prototype.onattach):
+        (WebInspector.NavigatorUISourceCodeTreeNode.prototype.uiSourceCode):
+        (WebInspector.NavigatorUISourceCodeTreeNode.prototype.reveal):
+        * inspector/front-end/ScriptsNavigator.js:
+        (WebInspector.ScriptsNavigator.prototype.revealUISourceCode):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._showFile):
+        * inspector/front-end/Settings.js:
+        (WebInspector.VersionController.prototype._updateVersionFrom1To2):
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer.prototype.addUISourceCode.tabId.this._tabIds.get this):
+        (WebInspector.TabbedEditorContainer.prototype.addUISourceCode):
+        (WebInspector.TabbedEditorContainer.History.prototype._rebuildItemIndex):
+
+2013-03-08  Vsevolod Vlasov  <vsevik@chromium.org>
+
         Web Inspector: Add shortcut for running a snippet.
         https://bugs.webkit.org/show_bug.cgi?id=111680
 
index 22c96ea..2896445 100644 (file)
@@ -57,6 +57,8 @@ WebInspector.NavigatorView = function()
 
     this._rootNode = new WebInspector.NavigatorRootTreeNode(this);
     this._rootNode.populate();
+
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
 }
 
 WebInspector.NavigatorView.Events = {
@@ -83,6 +85,22 @@ WebInspector.NavigatorView.prototype = {
         var uiSourceCodeNode = new WebInspector.NavigatorUISourceCodeTreeNode(this, uiSourceCode);
         this._uiSourceCodeNodes[uiSourceCode.uri()] = uiSourceCodeNode;
         node.appendChild(uiSourceCodeNode);
+        if (uiSourceCode.url === WebInspector.inspectedPageURL)
+            this.revealUISourceCode(uiSourceCode);
+    },
+
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _inspectedURLChanged: function(event)
+    {
+        var nodes = Object.values(this._uiSourceCodeNodes);
+        for (var i = 0; i < nodes.length; ++i) {
+            var uiSourceCode = nodes[i].uiSourceCode();
+            if (uiSourceCode.url === WebInspector.inspectedPageURL)
+                this.revealUISourceCode(uiSourceCode);
+        }
+
     },
 
     /**
@@ -189,8 +207,9 @@ WebInspector.NavigatorView.prototype = {
 
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {boolean=} select
      */
-    revealUISourceCode: function(uiSourceCode)
+    revealUISourceCode: function(uiSourceCode, select)
     {
         var node = this._uiSourceCodeNodes[uiSourceCode.uri()];
         if (!node)
@@ -198,7 +217,7 @@ WebInspector.NavigatorView.prototype = {
         if (this._scriptsTree.selectedTreeElement)
             this._scriptsTree.selectedTreeElement.deselect();
         this._lastSelectedUISourceCode = uiSourceCode;
-        node.reveal();
+        node.reveal(select);
     },
 
     /**
@@ -223,6 +242,7 @@ WebInspector.NavigatorView.prototype = {
         var node = this._uiSourceCodeNodes[uiSourceCode.uri()];
         if (!node)
             return;
+        delete this._uiSourceCodeNodes[uiSourceCode.uri()]
         parentNode.removeChild(node);
         node = parentNode;
         while (node) {
@@ -473,10 +493,7 @@ WebInspector.NavigatorFolderTreeElement.prototype = {
     onattach: function()
     {
         WebInspector.BaseNavigatorTreeElement.prototype.onattach.call(this);
-        if (this.type() === WebInspector.NavigatorTreeOutline.Types.Domain && this.titleText === WebInspector.inspectedPageDomain)
-            this.expand();
-        else
-            this.collapse();
+        this.collapse();
     },
 
     __proto__: WebInspector.BaseNavigatorTreeElement.prototype
@@ -745,6 +762,14 @@ WebInspector.NavigatorUISourceCodeTreeNode = function(navigatorView, uiSourceCod
 
 WebInspector.NavigatorUISourceCodeTreeNode.prototype = {
     /**
+     * @return {WebInspector.UISourceCode}
+     */
+    uiSourceCode: function()
+    {
+        return this._uiSourceCode;
+    },
+
+    /**
      * @return {TreeElement}
      */
     treeElement: function()
@@ -817,11 +842,16 @@ WebInspector.NavigatorUISourceCodeTreeNode.prototype = {
         this.updateTitle();
     },
 
-    reveal: function()
+    /**
+     * @param {boolean=} select
+     */
+    reveal: function(select)
     {
         this.parent.populate();
         this.parent.treeElement().expand();
-        this._treeElement.revealAndSelect();
+        this._treeElement.reveal();
+        if (select)
+            this._treeElement.select();
     },
 
     /**
index 62866cd..0ceca06 100644 (file)
@@ -108,15 +108,14 @@ WebInspector.ScriptsNavigator.prototype = {
 
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {boolean=} select
      */
-    revealUISourceCode: function(uiSourceCode)
+    revealUISourceCode: function(uiSourceCode, select)
     {
-        this._navigatorViewForUISourceCode(uiSourceCode).revealUISourceCode(uiSourceCode);
+        this._navigatorViewForUISourceCode(uiSourceCode).revealUISourceCode(uiSourceCode, select);
         if (uiSourceCode.isContentScript)
             this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ContentScriptsTab);
-        else if (uiSourceCode.project().type() === WebInspector.projectTypes.Snippets)
-            this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.SnippetsTab);
-        else
+        else if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets)
             this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab);
     },
 
index 747775e..471f4a0 100755 (executable)
@@ -433,7 +433,7 @@ WebInspector.ScriptsPanel.prototype = {
             return sourceFrame;
         this._currentUISourceCode = uiSourceCode;
         if (!uiSourceCode.project().isServiceProject())
-            this._navigator.revealUISourceCode(uiSourceCode);
+            this._navigator.revealUISourceCode(uiSourceCode, true);
         this._editorContainer.showFile(uiSourceCode);
         this._updateScriptViewStatusBarItems();
 
index fac8682..a36c8e3 100644 (file)
@@ -357,7 +357,7 @@ WebInspector.VersionController = function()
 {
 }
 
-WebInspector.VersionController.currentVersion = 1;
+WebInspector.VersionController.currentVersion = 2;
 
 WebInspector.VersionController.prototype = {
     updateVersion: function()
@@ -388,6 +388,12 @@ WebInspector.VersionController.prototype = {
         this._clearBreakpointsWhenTooMany(WebInspector.settings.breakpoints, 500000);
     },
 
+    _updateVersionFrom1To2: function()
+    {
+        var versionSetting = WebInspector.settings.createSetting("previouslyViewedFiles", []);
+        versionSetting.set([]);
+    },
+
     /**
      * @param {WebInspector.Setting} breakpointsSetting
      * @param {number} maxBreakpointsCount
index 6b084ab..ee84203 100644 (file)
@@ -192,8 +192,19 @@ WebInspector.TabbedEditorContainer.prototype = {
 
         var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCode, false);
 
+        if (!this._currentFile)
+            return;
+
         // Select tab if this file was the last to be shown.
-        if (!index)
+        if (!index) {
+            this._innerShowFile(uiSourceCode, true);
+            return;
+        }
+
+        var currentProjectType = this._currentFile.project().type();
+        var addedProjectType = uiSourceCode.project().type();
+        var snippetsProjectType = WebInspector.projectTypes.Snippets;
+        if (this._history.index(this._currentFile.uri()) && currentProjectType === snippetsProjectType && addedProjectType !== snippetsProjectType)
             this._innerShowFile(uiSourceCode, true);
     },
 
@@ -481,8 +492,10 @@ WebInspector.TabbedEditorContainer.History.prototype = {
     _rebuildItemIndex: function()
     {
         this._itemsIndex = {};
-        for (var i = 0; i < this._items.length; ++i)
+        for (var i = 0; i < this._items.length; ++i) {
+            console.assert(!this._itemsIndex.hasOwnProperty(this._items[i].url));
             this._itemsIndex[this._items[i].url] = i;
+        }
     },
 
     /**