Web Inspector: UISourceCode should take care of adding revision after committing...
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2012 15:14:01 +0000 (15:14 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2012 15:14:01 +0000 (15:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90549

Reviewed by Pavel Feldman.

Revision is now added in UISourceCode.commitWorkingCopy synchronously even if saving to JS VM or CSS model failed.

* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModelResourceBinding.prototype.setStyleContent):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._handleOpenURL):
(WebInspector.ExtensionServer.prototype._onGetResourceContent):
(WebInspector.ExtensionServer.prototype._onSetResourceContent):
* inspector/front-end/JavaScriptSource.js:
(WebInspector.JavaScriptSource.prototype.workingCopyCommitted):
* inspector/front-end/StylesPanel.js:
(WebInspector.StyleSource.prototype._callOrSetTimeout):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.commitWorkingCopy):
* inspector/front-end/Workspace.js:
(WebInspector.CompositeUISourceCodeProvider.prototype.uiSourceCodeForURL):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/CSSStyleModel.js
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/JavaScriptSource.js
Source/WebCore/inspector/front-end/StylesPanel.js
Source/WebCore/inspector/front-end/UISourceCode.js
Source/WebCore/inspector/front-end/Workspace.js

index aa60405..e60e848 100644 (file)
@@ -1,3 +1,27 @@
+2012-07-04  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Web Inspector: UISourceCode should take care of adding revision after committing working copy.
+        https://bugs.webkit.org/show_bug.cgi?id=90549
+
+        Reviewed by Pavel Feldman.
+
+        Revision is now added in UISourceCode.commitWorkingCopy synchronously even if saving to JS VM or CSS model failed.
+
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModelResourceBinding.prototype.setStyleContent):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer.prototype._handleOpenURL):
+        (WebInspector.ExtensionServer.prototype._onGetResourceContent):
+        (WebInspector.ExtensionServer.prototype._onSetResourceContent):
+        * inspector/front-end/JavaScriptSource.js:
+        (WebInspector.JavaScriptSource.prototype.workingCopyCommitted):
+        * inspector/front-end/StylesPanel.js:
+        (WebInspector.StyleSource.prototype._callOrSetTimeout):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+        * inspector/front-end/Workspace.js:
+        (WebInspector.CompositeUISourceCodeProvider.prototype.uiSourceCodeForURL):
+
 2012-07-04  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: move settings button back to the right.
index 284e94e..1bccada 100644 (file)
@@ -955,23 +955,10 @@ WebInspector.CSSStyleModelResourceBinding.prototype = {
     {
         var resource = styleSource.resource();
         if (this._styleSheetIdForResource(resource)) {
-            this._innerSetContent(resource, content, majorChange, innerCallback, null);
+            this._innerSetContent(resource, content, majorChange, userCallback, null);
             return;
         }
-        this._loadStyleSheetHeaders(this._innerSetContent.bind(this, resource, content, majorChange, innerCallback));
-        
-        function innerCallback(error)
-        {
-            if (error) {
-                userCallback(error);
-                return;
-            }
-
-            if (majorChange)
-                resource.addRevision(content);
-
-            userCallback(null);
-        }
+        this._loadStyleSheetHeaders(this._innerSetContent.bind(this, resource, content, majorChange, userCallback));
     },
 
     /**
index c16ae48..b835fb9 100644 (file)
@@ -290,7 +290,7 @@ WebInspector.ExtensionServer.prototype = {
 
     _handleOpenURL: function(port, details)
     {
-        var url = /** @type {String} */ details.url;
+        var url = /** @type {string} */ details.url;
         var contentProvider = WebInspector.workspace.uiSourceCodeForURL(url) || WebInspector.resourceForURL(url);
         if (!contentProvider)
             return false;
@@ -482,7 +482,7 @@ WebInspector.ExtensionServer.prototype = {
 
     _onGetResourceContent: function(message, port)
     {
-        var url = /** @type {String} */ message.url;
+        var url = /** @type {string} */ message.url;
         var contentProvider = WebInspector.workspace.uiSourceCodeForURL(url) || WebInspector.resourceForURL(url);
         if (!contentProvider)
             return this._status.E_NOTFOUND(url);
@@ -500,7 +500,7 @@ WebInspector.ExtensionServer.prototype = {
             this._dispatchCallback(message.requestId, port, response);
         }
 
-        var url = /** @type {String} */ message.url;
+        var url = /** @type {string} */ message.url;
         var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url);
         if (!uiSourceCode) {
             var resource = WebInspector.resourceTreeModel.resourceForURL(url);
@@ -512,7 +512,7 @@ WebInspector.ExtensionServer.prototype = {
         if (message.commit)
             uiSourceCode.commitWorkingCopy(callbackWrapper.bind(this));
         else
-            callbackWrapper.call(this);
+            callbackWrapper.call(this, null);
     },
 
     _requestId: function(request)
index c29f02f..53afc90 100644 (file)
@@ -207,36 +207,9 @@ WebInspector.JavaScriptSource.prototype = {
             callback(error);
         }
 
-        this._setScriptSource(this.workingCopy(), innerCallback.bind(this));
-    },
-
-    /**
-     * @param {string} newSource
-     * @param {function(?Protocol.Error)} callback
-     */
-    _setScriptSource: function(newSource, callback)
-    {
         var rawLocation = this.uiLocationToRawLocation(0, 0);
         var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
-
-        /**
-         * @this {WebInspector.JavaScriptSource}
-         * @param {?Protocol.Error} error
-         */
-        function didEditScriptSource(error)
-        {
-            if (error) {
-                callback(error);
-                return;
-            }
-
-            var resource = this.resource();
-            if (resource)
-                resource.addRevision(newSource);
-
-            callback(null);
-        }
-        WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
+        WebInspector.debuggerModel.setScriptSource(script.scriptId, this.workingCopy(), innerCallback.bind(this));
     },
 
     /**
index 9120b19..1cb4020 100644 (file)
@@ -130,7 +130,7 @@ WebInspector.StyleSource.prototype = {
         if (WebInspector.StyleSource.updateTimeout >= 0)
             this._incrementalUpdateTimer = setTimeout(callback, WebInspector.StyleSource.updateTimeout);
         else
-            callback();
+            callback(null);
     },
 
     /**
index ae8c50a..8b9ff64 100644 (file)
@@ -201,23 +201,18 @@ WebInspector.UISourceCode.prototype = {
     commitWorkingCopy: function(callback)
     {
         if (!this.isDirty()) {
-            callback()
+            callback(null);
             return;
         }
 
-        /**
-         * @param {?string} error
-         */
-        function innerCallback(error)
-        {
-            delete this._committingWorkingCopy;
-            this.contentChanged(newContent, this._mimeType);
-            callback(error);
-        }
-
         var newContent = this._workingCopy;
         this._committingWorkingCopy = true;
-        this.workingCopyCommitted(innerCallback.bind(this));
+        this.workingCopyCommitted(callback);
+        if (this.resource())
+            this.resource().addRevision(newContent);
+        delete this._committingWorkingCopy;
+        this.contentChanged(newContent, this._mimeType);
+
     },
 
     /**
index de943e1..972cd6a 100644 (file)
@@ -76,8 +76,8 @@ WebInspector.CompositeUISourceCodeProvider.prototype = {
     },
 
     /**
-     * @param {String} url
-     * @return {WebInspector.UISourceCode}
+     * @param {string} url
+     * @return {?WebInspector.UISourceCode}
      */
     uiSourceCodeForURL: function(url)
     {
@@ -88,6 +88,7 @@ WebInspector.CompositeUISourceCodeProvider.prototype = {
                     return uiSourceCodes[j];
             }
         }
+        return null;
     },
 
     /**