Title: [117269] trunk
Revision
117269
Author
[email protected]
Date
2012-05-16 05:41:26 -0700 (Wed, 16 May 2012)

Log Message

Web Inspector: Move edit/save script source logic to _javascript_Source.
https://bugs.webkit.org/show_bug.cgi?id=86604

Reviewed by Pavel Feldman.

Source/WebCore:

Added working copy notion to UISourceCode.
Moved DebuggerResourceBinding content edit calls to _javascript_Source.
Added WorkingCopyChanged event to UISourceCode.

* inspector/front-end/CompilerScriptMapping.js:
* inspector/front-end/DebuggerResourceBinding.js:
(WebInspector.DebuggerResourceBinding.prototype.canSetContent):
* inspector/front-end/_javascript_Source.js:
(WebInspector._javascript_Source):
(WebInspector._javascript_Source.prototype.breakpointStorageId):
(WebInspector._javascript_Source.prototype.isEditable):
(WebInspector._javascript_Source.prototype.commitWorkingCopy):
(WebInspector):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.wasShown):
(WebInspector._javascript_SourceFrame.prototype.canEditSource):
(WebInspector._javascript_SourceFrame.prototype.commitEditing):
(WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
(WebInspector._javascript_SourceFrame.prototype.beforeTextChanged):
(WebInspector._javascript_SourceFrame.prototype._didEditContent):
(WebInspector._javascript_SourceFrame.prototype._onMouseDown):
* inspector/front-end/NavigatorView.js:
(WebInspector.NavigatorView.prototype._uiSourceCodeWorkingCopyChanged):
(WebInspector.NavigatorView.prototype._uiSourceCodeContentChanged):
(WebInspector.NavigatorView.prototype._updateScriptTitle):
(WebInspector.NavigatorView.prototype._removeUISourceCode):
(WebInspector.NavigatorView.prototype._addUISourceCodeListeners):
(WebInspector.NavigatorView.prototype._removeUISourceCodeListeners):
(WebInspector.NavigatorView.prototype.reset):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype._createUISourceCode):
* inspector/front-end/ScriptSnippetModel.js:
(WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
(WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
* inspector/front-end/ScriptsPanel.js:
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer):
(WebInspector.TabbedEditorContainer.prototype._titleForFile):
(WebInspector.TabbedEditorContainer.prototype._appendFileTab):
(WebInspector.TabbedEditorContainer.prototype._tabClosed):
(WebInspector.TabbedEditorContainer.prototype._updateFileTitle.get if):
(WebInspector.TabbedEditorContainer.prototype._updateFileTitle):
(WebInspector.TabbedEditorContainer.prototype._uiSourceCodeWorkingCopyChanged):
(WebInspector.TabbedEditorContainer.prototype._uiSourceCodeContentChanged):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.contentChanged):
(WebInspector.UISourceCode.prototype.isEditable):
(WebInspector.UISourceCode.prototype.workingCopy):
(WebInspector.UISourceCode.prototype.setWorkingCopy):
(WebInspector.UISourceCode.prototype.isDirty):
(WebInspector.UISourceCode.prototype.commitWorkingCopy):

LayoutTests:

* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/scripts-panel.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (117268 => 117269)


--- trunk/LayoutTests/ChangeLog	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/LayoutTests/ChangeLog	2012-05-16 12:41:26 UTC (rev 117269)
@@ -1,3 +1,13 @@
+2012-05-16  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Move edit/save script source logic to _javascript_Source.
+        https://bugs.webkit.org/show_bug.cgi?id=86604
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/debugger/breakpoint-manager.html:
+        * inspector/debugger/scripts-panel.html:
+
 2012-05-16  Christophe Dumez  <[email protected]>
 
         [EFL] A few tests need expected result or rebaselining

Modified: trunk/LayoutTests/inspector/debugger/breakpoint-manager.html (117268 => 117269)


--- trunk/LayoutTests/inspector/debugger/breakpoint-manager.html	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager.html	2012-05-16 12:41:26 UTC (rev 117269)
@@ -136,7 +136,7 @@
     {
         breakpointManager._debuggerModel._addScript(url, url);
         InspectorTest.addResult("  Adding UISourceCode: " + url + ")");
-        var uiSourceCode = new WebInspector._javascript_Source(url, null, defaultMapping);
+        var uiSourceCode = new WebInspector._javascript_Source(url, null, defaultMapping, false);
         uiSourceCodes[url] = uiSourceCode;
         breakpointManager.restoreBreakpoints(uiSourceCode);
         return uiSourceCode;

Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (117268 => 117269)


--- trunk/LayoutTests/inspector/debugger/scripts-panel.html	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html	2012-05-16 12:41:26 UTC (rev 117269)
@@ -47,7 +47,7 @@
     }
     function createUISouceCode(url)
     {
-        var uiSourceCode = new WebInspector._javascript_Source(url, null, null);
+        var uiSourceCode = new WebInspector._javascript_Source(url, null, null, false);
         uiSourceCode.requestContent = function(callback)
         {
             InspectorTest.addResult("Source requested for " + url);

Modified: trunk/Source/WebCore/ChangeLog (117268 => 117269)


--- trunk/Source/WebCore/ChangeLog	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/ChangeLog	2012-05-16 12:41:26 UTC (rev 117269)
@@ -1,3 +1,63 @@
+2012-05-16  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Move edit/save script source logic to _javascript_Source.
+        https://bugs.webkit.org/show_bug.cgi?id=86604
+
+        Reviewed by Pavel Feldman.
+
+        Added working copy notion to UISourceCode.
+        Moved DebuggerResourceBinding content edit calls to _javascript_Source.
+        Added WorkingCopyChanged event to UISourceCode.
+
+        * inspector/front-end/CompilerScriptMapping.js:
+        * inspector/front-end/DebuggerResourceBinding.js:
+        (WebInspector.DebuggerResourceBinding.prototype.canSetContent):
+        * inspector/front-end/_javascript_Source.js:
+        (WebInspector._javascript_Source):
+        (WebInspector._javascript_Source.prototype.breakpointStorageId):
+        (WebInspector._javascript_Source.prototype.isEditable):
+        (WebInspector._javascript_Source.prototype.commitWorkingCopy):
+        (WebInspector):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.wasShown):
+        (WebInspector._javascript_SourceFrame.prototype.canEditSource):
+        (WebInspector._javascript_SourceFrame.prototype.commitEditing):
+        (WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
+        (WebInspector._javascript_SourceFrame.prototype.beforeTextChanged):
+        (WebInspector._javascript_SourceFrame.prototype._didEditContent):
+        (WebInspector._javascript_SourceFrame.prototype._onMouseDown):
+        * inspector/front-end/NavigatorView.js:
+        (WebInspector.NavigatorView.prototype._uiSourceCodeWorkingCopyChanged):
+        (WebInspector.NavigatorView.prototype._uiSourceCodeContentChanged):
+        (WebInspector.NavigatorView.prototype._updateScriptTitle):
+        (WebInspector.NavigatorView.prototype._removeUISourceCode):
+        (WebInspector.NavigatorView.prototype._addUISourceCodeListeners):
+        (WebInspector.NavigatorView.prototype._removeUISourceCodeListeners):
+        (WebInspector.NavigatorView.prototype.reset):
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode.prototype._createUISourceCode):
+        * inspector/front-end/ScriptSnippetModel.js:
+        (WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
+        (WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
+        * inspector/front-end/ScriptsPanel.js:
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer):
+        (WebInspector.TabbedEditorContainer.prototype._titleForFile):
+        (WebInspector.TabbedEditorContainer.prototype._appendFileTab):
+        (WebInspector.TabbedEditorContainer.prototype._tabClosed):
+        (WebInspector.TabbedEditorContainer.prototype._updateFileTitle.get if):
+        (WebInspector.TabbedEditorContainer.prototype._updateFileTitle):
+        (WebInspector.TabbedEditorContainer.prototype._uiSourceCodeWorkingCopyChanged):
+        (WebInspector.TabbedEditorContainer.prototype._uiSourceCodeContentChanged):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode):
+        (WebInspector.UISourceCode.prototype.contentChanged):
+        (WebInspector.UISourceCode.prototype.isEditable):
+        (WebInspector.UISourceCode.prototype.workingCopy):
+        (WebInspector.UISourceCode.prototype.setWorkingCopy):
+        (WebInspector.UISourceCode.prototype.isDirty):
+        (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+
 2012-05-16  Pavel Feldman  <[email protected]>
 
         Web Inspector: get rid of UISourceCodeListChanged event.

Modified: trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -116,9 +116,8 @@
                 contentProvider = new WebInspector.StaticContentProvider("text/_javascript_", sourceContent);
             else
                 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
-            var uiSourceCode = new WebInspector._javascript_Source(sourceURL, contentProvider, this);
+            var uiSourceCode = new WebInspector._javascript_Source(sourceURL, contentProvider, this, false);
             uiSourceCode.isContentScript = script.isContentScript;
-            uiSourceCode.isEditable = false;
             this._uiSourceCodeByURL[sourceURL] = uiSourceCode;
             this._sourceMapForUISourceCode.put(uiSourceCode, sourceMap);
             uiSourceCodeList.push(uiSourceCode);

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -39,18 +39,8 @@
     WebInspector.Resource.registerDomainModelBinding(WebInspector.resourceTypes.Script, this);
 }
 
-
 /**
  * @param {WebInspector.UISourceCode} uiSourceCode
- * @return {boolean}
- */
-WebInspector.DebuggerResourceBinding.canEditScriptSource = function(uiSourceCode)
-{
-    return WebInspector.debuggerModel.canSetScriptSource() && uiSourceCode.isEditable;
-}
-
-/**
- * @param {WebInspector.UISourceCode} uiSourceCode
  * @param {string} newSource
  * @param {function(?Protocol.Error)} callback
  */
@@ -86,7 +76,7 @@
     canSetContent: function(resource)
     {
         var uiSourceCode = this._uiSourceCodeForResource(resource);
-        return !!uiSourceCode && WebInspector.DebuggerResourceBinding.canEditScriptSource(uiSourceCode);
+        return !!uiSourceCode && uiSourceCode.isEditable();
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -35,9 +35,10 @@
  * @param {WebInspector.ContentProvider} contentProvider
  * @param {WebInspector.SourceMapping} sourceMapping
  */
-WebInspector._javascript_Source = function(url, contentProvider, sourceMapping)
+WebInspector._javascript_Source = function(url, contentProvider, sourceMapping, isEditable)
 {
     WebInspector.UISourceCode.call(this, url, contentProvider, sourceMapping);
+    this._isEditable = isEditable;
 
     this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping();
     // FIXME: postpone breakpoints restore to after the mapping has been established.
@@ -161,6 +162,20 @@
     breakpointStorageId: function()
     {
         return this._formatted ? "deobfuscated:" + this.url : this.url;
+    },
+
+    /**
+     * @return {boolean}
+     */
+    isEditable: function()
+    {
+        return this._isEditable && WebInspector.debuggerModel.canSetScriptSource();
+    },
+
+    commitWorkingCopy: function(callback)
+    {  
+        if (this.isDirty())
+            WebInspector.DebuggerResourceBinding.setScriptSource(this, this.workingCopy(), callback);
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -71,7 +71,6 @@
     wasShown: function()
     {
         WebInspector.SourceFrame.prototype.wasShown.call(this);
-        this._setScriptSourceIsDirty(this._isDirty);
     },
 
     willHide: function()
@@ -103,7 +102,7 @@
      */
     canEditSource: function()
     {
-        return WebInspector.DebuggerResourceBinding.canEditScriptSource(this._uiSourceCode);
+        return this._uiSourceCode.isEditable();
     },
 
     /**
@@ -112,7 +111,7 @@
     commitEditing: function(text)
     {
         this._editingContent = true;
-        WebInspector.DebuggerResourceBinding.setScriptSource(this._uiSourceCode, text, this._didEditContent.bind(this, text));
+        this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this, text));
     },
 
     /**
@@ -170,22 +169,14 @@
 
     afterTextChanged: function(oldRange, newRange)
     {
-        var isDirty = this.textModel.text !== this._originalContent;
-        if (isDirty)
-            this._setScriptSourceIsDirty(true);
-        else
+        this._uiSourceCode.setWorkingCopy(this.textModel.text);
+        if (!this._uiSourceCode.isDirty())
             this._didEditContent(this._originalContent, null);
     },
 
-    _setScriptSourceIsDirty: function(isDirty)
-    {
-        this._scriptsPanel.setScriptSourceIsDirty(this._uiSourceCode, isDirty);
-        this._isDirty = isDirty;
-    },
-
     beforeTextChanged: function()
     {
-        if (!this._isDirty) {
+        if (!this._uiSourceCode.isDirty()) {
             // Disable all breakpoints in the model, store them as muted breakpoints.
             var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);
             var lineNumbers = {};
@@ -197,7 +188,6 @@
             }
         }
 
-        this._isDirty = true;
         WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
     },
 
@@ -211,7 +201,6 @@
         }
 
         this._originalContent = content;
-        this._isDirty = false;
 
         // Restore all muted breakpoints.
         for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
@@ -223,7 +212,6 @@
                 this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled);
             }
         }
-        this._setScriptSourceIsDirty(false);
     },
 
     _getPopoverAnchor: function(element, event)
@@ -382,7 +370,7 @@
 
     _onMouseDown: function(event)
     {
-        if (this._isDirty)
+        if (this._uiSourceCode.isDirty())
             return;
 
         if (event.button != 0 || event.altKey || event.ctrlKey || event.metaKey)

Modified: trunk/Source/WebCore/inspector/front-end/NavigatorView.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/NavigatorView.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/NavigatorView.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -75,11 +75,24 @@
         var scriptTreeElement = new WebInspector.NavigatorScriptTreeElement(this, uiSourceCode, "");
         this._scriptTreeElementsByUISourceCode.put(uiSourceCode, scriptTreeElement);
         this._updateScriptTitle(uiSourceCode);
+        this._addUISourceCodeListeners(uiSourceCode);
 
         var folderTreeElement = this.getOrCreateFolderTreeElement(uiSourceCode);
         folderTreeElement.appendChild(scriptTreeElement);
     },
 
+    _uiSourceCodeWorkingCopyChanged: function(event)
+    {
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+        this._updateScriptTitle(uiSourceCode)
+    },
+    
+    _uiSourceCodeContentChanged: function(event)
+    {
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+        this._updateScriptTitle(uiSourceCode);
+    },
+
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      */
@@ -98,6 +111,8 @@
             titleText = uiSourceCode.parsedURL.url;
         if (!titleText)
             titleText = WebInspector.UIString("(program)");
+        if (uiSourceCode.isDirty())
+            titleText = "*" + titleText;
         scriptTreeElement.titleText = titleText;
     },
 
@@ -177,8 +192,27 @@
             treeElement = parent;
         }
         this._scriptTreeElementsByUISourceCode.remove(uiSourceCode);
+        this._removeUISourceCodeListeners(uiSourceCode);
     },
 
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     */
+    _addUISourceCodeListeners: function(uiSourceCode)
+    {
+        uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
+        uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
+    },
+
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     */
+    _removeUISourceCodeListeners: function(uiSourceCode)
+    {
+        uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
+        uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
+    },
+
     _showScriptFoldersSettingChanged: function()
     {
         var uiSourceCodes = this._scriptsTree.scriptTreeElements();
@@ -231,12 +265,17 @@
         }
 
         var editingConfig = new WebInspector.EditingConfig(commitHandler.bind(this), cancelHandler.bind(this));
+        this._updateScriptTitle(uiSourceCode, true);
         WebInspector.startEditing(scriptTreeElement.titleElement, editingConfig);
         window.getSelection().setBaseAndExtent(scriptTreeElement.titleElement, 0, scriptTreeElement.titleElement, 1);
     },
 
     reset: function()
     {
+        var uiSourceCodes = this._scriptsTree.scriptTreeElements;
+        for (var i = 0; i < uiSourceCodes.length; ++i)
+            this._removeUISourceCodeListeners(uiSourceCodes[i]);
+
         this._scriptsTree.stopSearch();
         this._scriptsTree.removeChildren();
         this._folderTreeElements = {};

Modified: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -100,9 +100,8 @@
         else
             contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
 
-        var uiSourceCode = new WebInspector._javascript_Source(this.url, contentProvider, this._sourceMapping);
+        var uiSourceCode = new WebInspector._javascript_Source(this.url, contentProvider, this._sourceMapping, isStandaloneScript);
         uiSourceCode.isContentScript = this.isContentScript;
-        uiSourceCode.isEditable = isStandaloneScript;
         return uiSourceCode;
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -76,9 +76,8 @@
     _addScriptSnippet: function(snippet)
     {
         var uiSourceCodeURL = ""; // FIXME: to be implemented.
-        var uiSourceCode = new WebInspector._javascript_Source(uiSourceCodeURL, new WebInspector.SnippetContentProvider(snippet), this._snippetScriptMapping);
+        var uiSourceCode = new WebInspector._javascript_Source(uiSourceCodeURL, new WebInspector.SnippetContentProvider(snippet), this._snippetScriptMapping, true);
         uiSourceCode.isSnippet = true;
-        uiSourceCode.isEditable = true;
         this._uiSourceCodeForSnippet.put(snippet, uiSourceCode);
         this._snippetForUISourceCode.put(uiSourceCode, snippet);
         this._snippetScriptMapping._fireUISourceCodeAdded(uiSourceCode);
@@ -215,7 +214,7 @@
      */
     _createUISourceCodeForScript: function(script)
     {
-        var uiSourceCode = new WebInspector._javascript_Source(script.sourceURL, script, this._snippetScriptMapping);
+        var uiSourceCode = new WebInspector._javascript_Source(script.sourceURL, script, this._snippetScriptMapping, false);
         uiSourceCode.isSnippetEvaluation = true;
         this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
         this._scriptForUISourceCode.put(uiSourceCode, script);

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


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -264,16 +264,6 @@
         this._removeSourceFrame(uiSourceCode);
     },
 
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {boolean} isDirty
-     */
-    setScriptSourceIsDirty: function(uiSourceCode, isDirty)
-    {
-        this._navigator.setScriptSourceIsDirty(uiSourceCode, isDirty);
-        this._editorContainer.setFileIsDirty(uiSourceCode, isDirty);
-    },
-
     _consoleCommandEvaluatedInSelectedCallFrame: function(event)
     {
         this.sidebarPanes.scopechain.update(WebInspector.debuggerModel.selectedCallFrame());

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


--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -47,6 +47,7 @@
  */
 WebInspector.TabbedEditorContainer = function(delegate, settingName)
 {
+    WebInspector.Object.call(this);
     this._delegate = delegate;
 
     this._tabbedPane = new WebInspector.TabbedPane();
@@ -135,15 +136,21 @@
         const maxDisplayNameLength = 30;
         const minDisplayQueryParamLength = 5;
 
+        var title;
         var parsedURL = uiSourceCode.parsedURL;
         if (!parsedURL.isValid)
-            return parsedURL.url ? parsedURL.url.trimMiddle(maxDisplayNameLength) : WebInspector.UIString("(program)");
-
-        var maxDisplayQueryParamLength = Math.max(minDisplayQueryParamLength, maxDisplayNameLength - parsedURL.lastPathComponent.length);
-        var displayQueryParams = parsedURL.queryParams ? "?" + parsedURL.queryParams.trimEnd(maxDisplayQueryParamLength - 1) : "";
-        var displayLastPathComponent = parsedURL.lastPathComponent.trimMiddle(maxDisplayNameLength - displayQueryParams.length);
-        var displayName = displayLastPathComponent + displayQueryParams;
-        return displayName || WebInspector.UIString("(program)");
+            title = parsedURL.url ? parsedURL.url.trimMiddle(maxDisplayNameLength) : WebInspector.UIString("(program)");
+        else {
+            var maxDisplayQueryParamLength = Math.max(minDisplayQueryParamLength, maxDisplayNameLength - parsedURL.lastPathComponent.length);
+            var displayQueryParams = parsedURL.queryParams ? "?" + parsedURL.queryParams.trimEnd(maxDisplayQueryParamLength - 1) : "";
+            var displayLastPathComponent = parsedURL.lastPathComponent.trimMiddle(maxDisplayNameLength - displayQueryParams.length);
+            var displayName = displayLastPathComponent + displayQueryParams;
+            title = displayName || WebInspector.UIString("(program)");
+        }
+        
+        if (uiSourceCode.isDirty())
+            title += "*";
+        return title;
     },
 
     /**
@@ -219,6 +226,9 @@
         this._files[tabId] = uiSourceCode;
         
         this._tabbedPane.appendTab(tabId, title, view, tooltip, userGesture);
+
+        uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
+        uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
         return tabId;
     },
 
@@ -245,6 +255,8 @@
         this._tabIds.remove(uiSourceCode);
         delete this._files[tabId];
         delete this._currentFile;
+        uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
+        uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
 
         this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.EditorClosed, uiSourceCode);
 
@@ -287,19 +299,28 @@
 
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {boolean} isDirty
      */
-    setFileIsDirty: function(uiSourceCode, isDirty)
+    _updateFileTitle: function(uiSourceCode)
     {
         var tabId = this._tabIds.get(uiSourceCode);
         if (tabId) {
             var title = this._titleForFile(uiSourceCode);
-            if (isDirty)
-                title += "*";
             this._tabbedPane.changeTabTitle(tabId, title);
         }
     },
+    
+    _uiSourceCodeWorkingCopyChanged: function(event)
+    {
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+        this._updateFileTitle(uiSourceCode);
+    },
 
+    _uiSourceCodeContentChanged: function(event)
+    {
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+        this._updateFileTitle(uiSourceCode);
+    },
+
     reset: function()
     {
         this._tabbedPane.closeAllTabs();

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (117268 => 117269)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-05-16 12:36:22 UTC (rev 117268)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-05-16 12:41:26 UTC (rev 117269)
@@ -43,7 +43,6 @@
     this._contentProvider = contentProvider;
     this._sourceMapping = sourceMapping;
     this.isContentScript = false;
-    this.isEditable = false;
     /**
      * @type Array.<function(?string,boolean,string)>
      */
@@ -57,6 +56,7 @@
 
 WebInspector.UISourceCode.Events = {
     ContentChanged: "ContentChanged",
+    WorkingCopyChanged: "WorkingCopyChanged",
     ConsoleMessageAdded: "ConsoleMessageAdded",
     ConsoleMessageRemoved: "ConsoleMessageRemoved",
     ConsoleMessagesCleared: "ConsoleMessagesCleared"
@@ -101,12 +101,57 @@
         console.assert(this._contentLoaded);
         var oldContent = this._content;
         this._content = newContent;
+        delete this._workingCopy;
         this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {oldContent: oldContent, content: newContent});
     },
 
     /**
+     * @return {boolean}
+     */
+    isEditable: function()
+    {
+        return false;
+    },
+
+    /**
      * @return {string}
      */
+    workingCopy: function()
+    {
+        console.assert(this._contentLoaded);
+        return this._workingCopy;
+    },
+
+    /**
+     * @param {string} newWorkingCopy
+     */
+    setWorkingCopy: function(newWorkingCopy)
+    {
+        console.assert(this._contentLoaded);
+        var oldWorkingCopy = this._workingCopy;
+        if (this._content === newWorkingCopy)
+            delete this._workingCopy;
+        else
+            this._workingCopy = newWorkingCopy;
+        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy});
+    },
+
+    /**
+     * @return {boolean}
+     */
+    isDirty: function()
+    {
+        return this._contentLoaded && typeof this._workingCopy !== "undefined" && this._workingCopy !== this._content;
+    },
+
+    commitWorkingCopy: function(callback)
+    {
+        // Overriden.
+    },
+
+    /**
+     * @return {string}
+     */
     mimeType: function()
     {
         return this._mimeType;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to