Title: [106112] trunk/Source/WebCore
Revision
106112
Author
[email protected]
Date
2012-01-27 05:46:09 -0800 (Fri, 27 Jan 2012)

Log Message

Web Inspector: Scripts panel: fix event dispatching between FileSelector and EditorContainer.
https://bugs.webkit.org/show_bug.cgi?id=77126

Reviewed by Pavel Feldman.

* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._uiSourceCodeAdded.get if):
(WebInspector.ScriptsPanel.prototype._reset):
(WebInspector.ScriptsPanel.prototype._showSourceLine):
(WebInspector.ScriptsPanel.prototype._updateExecutionLine):
(WebInspector.ScriptsPanel.prototype._editorClosed):
(WebInspector.ScriptsPanel.prototype._editorSelected):
(WebInspector.ScriptsPanel.FileSelector.prototype.revealUISourceCode):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype.revealUISourceCode):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._innerRevealUISourceCode):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._addOptionToFilesSelect.insertOrdered):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._addOptionToFilesSelect):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._goBack):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._goForward):
(WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._filesSelectChanged):
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer):
(WebInspector.TabbedEditorContainer.prototype._tabClosed):
(WebInspector.TabbedEditorContainer.prototype._tabSelected):
(WebInspector.TabbedEditorContainer.prototype.reset):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106111 => 106112)


--- trunk/Source/WebCore/ChangeLog	2012-01-27 13:26:59 UTC (rev 106111)
+++ trunk/Source/WebCore/ChangeLog	2012-01-27 13:46:09 UTC (rev 106112)
@@ -1,3 +1,31 @@
+2012-01-26  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Scripts panel: fix event dispatching between FileSelector and EditorContainer.
+        https://bugs.webkit.org/show_bug.cgi?id=77126
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._uiSourceCodeAdded.get if):
+        (WebInspector.ScriptsPanel.prototype._reset):
+        (WebInspector.ScriptsPanel.prototype._showSourceLine):
+        (WebInspector.ScriptsPanel.prototype._updateExecutionLine):
+        (WebInspector.ScriptsPanel.prototype._editorClosed):
+        (WebInspector.ScriptsPanel.prototype._editorSelected):
+        (WebInspector.ScriptsPanel.FileSelector.prototype.revealUISourceCode):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype.revealUISourceCode):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._innerRevealUISourceCode):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._addOptionToFilesSelect.insertOrdered):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._addOptionToFilesSelect):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._goBack):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._goForward):
+        (WebInspector.ScriptsPanel.ComboBoxFileSelector.prototype._filesSelectChanged):
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer):
+        (WebInspector.TabbedEditorContainer.prototype._tabClosed):
+        (WebInspector.TabbedEditorContainer.prototype._tabSelected):
+        (WebInspector.TabbedEditorContainer.prototype.reset):
+
 2012-01-27  Nikolas Zimmermann  <[email protected]>
 
         <feImage> DOM mutation problems

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (106111 => 106112)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-01-27 13:26:59 UTC (rev 106111)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-01-27 13:46:09 UTC (rev 106112)
@@ -92,6 +92,7 @@
     this._fileSelector.addEventListener(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, this._fileSelected, this);
     this._fileSelector.addEventListener(WebInspector.ScriptsPanel.FileSelector.Events.ReleasedFocusAfterSelection, this._fileSelectorReleasedFocus, this);
     this._editorContainer.addEventListener(WebInspector.EditorContainer.Events.EditorSelected, this._editorSelected, this);
+    this._editorContainer.addEventListener(WebInspector.EditorContainer.Events.EditorClosed, this._editorClosed, this);
 
     this.splitView.mainElement.appendChild(this.debugSidebarResizeWidgetElement);
 
@@ -254,7 +255,6 @@
             // Anonymous sources are shown only when stepping.
             return;
         }
-        
         this._fileSelector.addUISourceCode(uiSourceCode);
 
         var lastViewedURL = WebInspector.settings.lastViewedScriptFile.get();
@@ -262,12 +262,12 @@
             this._initialViewSelectionProcessed = true;
             // Option we just added is the only option in files select.
             // We have to show corresponding source frame immediately.
-            this._showAndRevealInFileSelector(uiSourceCode);
+            this._showFile(uiSourceCode);
             // Restore original value of lastViewedScriptFile because
             // source frame was shown as a result of initial load.
             WebInspector.settings.lastViewedScriptFile.set(lastViewedURL);
         } else if (uiSourceCode.url ="" lastViewedURL)
-            this._showAndRevealInFileSelector(uiSourceCode);
+            this._showFile(uiSourceCode);
     },
 
     _uiSourceCodeRemoved: function(event)
@@ -416,7 +416,8 @@
         this._debuggerResumed();
 
         delete this._initialViewSelectionProcessed;
-
+        delete this._curentUISourceCode;
+        
         this._editorContainer.reset();
         this._updateScriptViewStatusBarItems();
 
@@ -471,7 +472,7 @@
      */
     _showSourceLine: function(uiSourceCode, lineNumber)
     {
-        var sourceFrame = this._showAndRevealInFileSelector(uiSourceCode);
+        var sourceFrame = this._showFile(uiSourceCode);
         if (typeof lineNumber === "number")
             sourceFrame.highlightLine(lineNumber);
         sourceFrame.focus();
@@ -483,8 +484,15 @@
      */
     _showFile: function(uiSourceCode)
     {
+        if (!this._fileSelector.isScriptSourceAdded(uiSourceCode))
+            return null;
+        
         var sourceFrame = this._getOrCreateSourceFrame(uiSourceCode);
+        if (this._curentUISourceCode === uiSourceCode)
+            return sourceFrame;
+        this._curentUISourceCode = uiSourceCode;
 
+        this._fileSelector.revealUISourceCode(uiSourceCode);
         this._editorContainer.showFile(uiSourceCode);
         this._updateScriptViewStatusBarItems();
 
@@ -494,19 +502,6 @@
         return sourceFrame;
     },
 
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @return {WebInspector.SourceFrame}
-     */
-    _showAndRevealInFileSelector: function(uiSourceCode)
-    {
-        if (!this._fileSelector.isScriptSourceAdded(uiSourceCode))
-            return null;
-        
-        this._fileSelector.revealUISourceCode(uiSourceCode);
-        return this._showFile(uiSourceCode);
-    },
-
     requestVisibleScriptOutline: function()
     {
         function contentCallback(mimeType, content)
@@ -536,7 +531,7 @@
         this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame);
         return sourceFrame;
     },
-    
+
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      * @return {WebInspector.SourceFrame}
@@ -545,7 +540,7 @@
     {
         return this._sourceFramesByUISourceCode.get(uiSourceCode) || this._createSourceFrame(uiSourceCode);
     },
-    
+
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      * @return {WebInspector.SourceFrame}
@@ -623,7 +618,7 @@
         // Anonymous scripts are not added to files select by default.
         this._fileSelector.addUISourceCode(uiLocation.uiSourceCode);
         
-        var sourceFrame = this._showAndRevealInFileSelector(uiLocation.uiSourceCode);
+        var sourceFrame = this._showFile(uiLocation.uiSourceCode);
         sourceFrame.setExecutionLine(uiLocation.lineNumber);
         this._executionSourceFrame = sourceFrame;
     },
@@ -646,10 +641,21 @@
         this._updateExecutionLine(this._presentationModel.executionLineLocation);
     },
 
+    _editorClosed: function(event)
+    {
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
+
+        // We don't need to update file selector here regardless of whether useScriptsNavigator is set or not:
+        // SingleFileEditorContainer never dispatches EditorClosed, so no need to update ComboBoxFileSelector; 
+        // ScriptsNavigator does not need to update on EditorClosed.
+
+        this._updateScriptViewStatusBarItems();
+    },
+
     _editorSelected: function(event)
     {
         var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
-        this._fileSelector.revealUISourceCode(uiSourceCode);
+        this._showFile(uiSourceCode);
     },
 
     _fileSelected: function(event)
@@ -1058,7 +1064,7 @@
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      */
-    revealUISourceCode: function(uiSourceCode) { return false; },
+    revealUISourceCode: function(uiSourceCode) { },
 
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
@@ -1079,7 +1085,8 @@
 WebInspector.EditorContainer = function() { }
 
 WebInspector.EditorContainer.Events = {
-    EditorSelected: "EditorSelected"
+    EditorSelected: "EditorSelected",
+    EditorClosed: "EditorClosed"
 }
 
 WebInspector.EditorContainer.prototype = {
@@ -1183,6 +1190,8 @@
      */
     revealUISourceCode: function(uiSourceCode)
     {
+        if (this._filesSelectElement.selectedIndex === uiSourceCode._option.index)
+            return;
         this._innerRevealUISourceCode(uiSourceCode, true);
     },
     
@@ -1200,8 +1209,7 @@
         
         this._updateBackAndForwardButtons();
         this._filesSelectElement.selectedIndex = uiSourceCode._option.index;
-        
-        return;
+        this.dispatchEventToListeners(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, uiSourceCode);
     },
     
     /**
@@ -1390,7 +1398,10 @@
                 return a.nameForSorting.localeCompare(b.nameForSorting);
             }
             var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare);
+            var showsNothing = select.selectedIndex === -1;
             select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
+            if (showsNothing)
+                select.selectedIndex = -1;
         }
 
         insertOrdered(option);
@@ -1449,7 +1460,6 @@
 
         var uiSourceCode = this._backForwardList[--this._currentBackForwardIndex];
         this._innerRevealUISourceCode(uiSourceCode, false);
-        this.dispatchEventToListeners(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, uiSourceCode);
     },
 
     _goForward: function()
@@ -1461,7 +1471,6 @@
 
         var uiSourceCode = this._backForwardList[++this._currentBackForwardIndex];
         this._innerRevealUISourceCode(uiSourceCode, false);
-        this.dispatchEventToListeners(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, uiSourceCode);
     },
 
     /**
@@ -1474,7 +1483,6 @@
 
         var uiSourceCode = this._filesSelectElement[this._filesSelectElement.selectedIndex]._uiSourceCode;
         this._innerRevealUISourceCode(uiSourceCode, true);
-        this.dispatchEventToListeners(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, uiSourceCode);
         if (focusSource)
             this.dispatchEventToListeners(WebInspector.ScriptsPanel.FileSelector.Events.ReleasedFocusAfterSelection, uiSourceCode);
     }

Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (106111 => 106112)


--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-01-27 13:26:59 UTC (rev 106111)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-01-27 13:46:09 UTC (rev 106112)
@@ -44,7 +44,7 @@
     this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
 
     this._tabIds = new Map();  
-    this._files = {};  
+    this._files = {};
 }
 
 WebInspector.TabbedEditorContainer._tabId = 0;
@@ -71,6 +71,10 @@
      */
     showFile: function(uiSourceCode)
     {
+        if (this._currentFile === uiSourceCode)
+            return;
+        
+        this._currentFile = uiSourceCode;
         var tabId = this._tabIds.get(uiSourceCode) || this._appendFileTab(uiSourceCode);
         this._tabbedPane.selectTab(tabId);
     },
@@ -127,8 +131,12 @@
     _tabClosed: function(event)
     {
         var tabId = /** @type {string} */ event.data.tabId;
-        this._tabIds.remove(this._files[tabId]);
+
+        var uiSourceCode = this._files[tabId];
+        this._tabIds.remove(uiSourceCode);
         delete this._files[tabId];
+
+        this.dispatchEventToListeners(WebInspector.ScriptsPanel.EditorContainer.Events.EditorClosed, uiSourceCode);
     },
 
     /**
@@ -137,7 +145,11 @@
     _tabSelected: function(event)
     {
         var tabId = /** @type {string} */ event.data.tabId;
-        this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorSelected, this._files[tabId]);
+        var uiSourceCode = this._files[tabId];
+        
+        if (this._currentFile === uiSourceCode)
+            return;
+        this.dispatchEventToListeners(WebInspector.EditorContainer.Events.EditorSelected, uiSourceCode);
     },
 
     /**
@@ -204,7 +216,7 @@
         this._tabbedPane.closeAllTabs();
         this._tabIds = new Map();
         this._files = {};
-
+        delete this._currentFile;
     },
 
     /**
@@ -216,4 +228,4 @@
     }
 }
 
-WebInspector.TabbedEditorContainer.prototype.__proto__ = WebInspector.Object.prototype;
\ No newline at end of file
+WebInspector.TabbedEditorContainer.prototype.__proto__ = WebInspector.Object.prototype;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to