Title: [116791] trunk/Source/WebCore
Revision
116791
Author
[email protected]
Date
2012-05-11 11:50:41 -0700 (Fri, 11 May 2012)

Log Message

Web Inspector: move canEditScriptSource and setScriptSource from DebuggerPresentationModel into ResourceBinding
https://bugs.webkit.org/show_bug.cgi?id=86234

Reviewed by Vsevolod Vlasov.

Simple move refactoring.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerResourceBinding):
(WebInspector.DebuggerResourceBinding.canEditScriptSource):
(WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
(WebInspector.DebuggerResourceBinding.setScriptSource):
(WebInspector.DebuggerResourceBinding.prototype.canSetContent):
(WebInspector.DebuggerResourceBinding.prototype._uiSourceCodeForResource):
(WebInspector.DebuggerResourceBinding.prototype._setContentWithInitialContent):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.canEditSource):
(WebInspector._javascript_SourceFrame.prototype.editContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116790 => 116791)


--- trunk/Source/WebCore/ChangeLog	2012-05-11 18:48:19 UTC (rev 116790)
+++ trunk/Source/WebCore/ChangeLog	2012-05-11 18:50:41 UTC (rev 116791)
@@ -1,3 +1,25 @@
+2012-05-11  Pavel Feldman  <[email protected]>
+
+        Web Inspector: move canEditScriptSource and setScriptSource from DebuggerPresentationModel into ResourceBinding
+        https://bugs.webkit.org/show_bug.cgi?id=86234
+
+        Reviewed by Vsevolod Vlasov.
+
+        Simple move refactoring.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        (WebInspector.DebuggerResourceBinding):
+        (WebInspector.DebuggerResourceBinding.canEditScriptSource):
+        (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
+        (WebInspector.DebuggerResourceBinding.setScriptSource):
+        (WebInspector.DebuggerResourceBinding.prototype.canSetContent):
+        (WebInspector.DebuggerResourceBinding.prototype._uiSourceCodeForResource):
+        (WebInspector.DebuggerResourceBinding.prototype._setContentWithInitialContent):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.canEditSource):
+        (WebInspector._javascript_SourceFrame.prototype.editContent):
+
 2012-05-11  Julien Chaffraix  <[email protected]>
 
         Remove RenderLayer::m_scrollOverflow

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (116790 => 116791)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-05-11 18:48:19 UTC (rev 116790)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-05-11 18:50:41 UTC (rev 116791)
@@ -41,7 +41,7 @@
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
 
-    new WebInspector.DebuggerPresentationModelResourceBinding(this);
+    new WebInspector.DebuggerResourceBinding();
     new WebInspector.PresentationConsoleMessageHelper();
 }
 
@@ -89,44 +89,6 @@
         }
     },
 
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @return {boolean}
-     */
-    canEditScriptSource: function(uiSourceCode)
-    {
-        return WebInspector.debuggerModel.canSetScriptSource() && uiSourceCode.isEditable;
-    },
-
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {string} newSource
-     * @param {function(?Protocol.Error)} callback
-     */
-    setScriptSource: function(uiSourceCode, newSource, callback)
-    {
-        var rawLocation = uiSourceCode.uiLocationToRawLocation(0, 0);
-        var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
-
-        /**
-         * @this {WebInspector.DebuggerPresentationModel}
-         * @param {?Protocol.Error} error
-         */
-        function didEditScriptSource(error)
-        {
-            callback(error);
-            if (error)
-                return;
-
-            var resource = WebInspector.resourceForURL(script.sourceURL);
-            if (resource)
-                resource.addRevision(newSource);
-
-            uiSourceCode.contentChanged(newSource);
-        }
-        WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
-    },
-
     _debuggerReset: function()
     {
         this._scriptMapping.reset();
@@ -269,23 +231,60 @@
 /**
  * @constructor
  * @implements {WebInspector.ResourceDomainModelBinding}
- * @param {WebInspector.DebuggerPresentationModel} model
  */
-WebInspector.DebuggerPresentationModelResourceBinding = function(model)
+WebInspector.DebuggerResourceBinding = function()
 {
-    this._presentationModel = model;
     WebInspector.Resource.registerDomainModelBinding(WebInspector.resourceTypes.Script, this);
 }
 
-WebInspector.DebuggerPresentationModelResourceBinding.prototype = {
+
+/**
+ * @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
+ */
+WebInspector.DebuggerResourceBinding.setScriptSource = function(uiSourceCode, newSource, callback)
+{
+    var rawLocation = uiSourceCode.uiLocationToRawLocation(0, 0);
+    var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
+
     /**
+     * @this {WebInspector.DebuggerPresentationModel}
+     * @param {?Protocol.Error} error
+     */
+    function didEditScriptSource(error)
+    {
+        callback(error);
+        if (error)
+            return;
+
+        var resource = WebInspector.resourceForURL(script.sourceURL);
+        if (resource)
+            resource.addRevision(newSource);
+
+        uiSourceCode.contentChanged(newSource);
+    }
+    WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
+}
+
+WebInspector.DebuggerResourceBinding.prototype = {
+    /**
      * @param {WebInspector.Resource} resource
      * @return {boolean}
      */
     canSetContent: function(resource)
     {
         var uiSourceCode = this._uiSourceCodeForResource(resource);
-        return !!uiSourceCode && this._presentationModel.canEditScriptSource(uiSourceCode);
+        return !!uiSourceCode && WebInspector.DebuggerResourceBinding.canEditScriptSource(uiSourceCode);
     },
 
     /**
@@ -314,7 +313,7 @@
      */
     _uiSourceCodeForResource: function(resource)
     {
-        var uiSourceCodes = this._presentationModel.uiSourceCodes();
+        var uiSourceCodes = WebInspector.debuggerPresentationModel.uiSourceCodes();
         for (var i = 0; i < uiSourceCodes.length; ++i) {
             if (uiSourceCodes[i].url ="" resource.url)
                 return uiSourceCodes[i];
@@ -333,7 +332,7 @@
     _setContentWithInitialContent: function(uiSourceCode, content, userCallback, oldContent, oldContentEncoded, mimeType)
     {
         /**
-         * @this {WebInspector.DebuggerPresentationModelResourceBinding}
+         * @this {WebInspector.DebuggerResourceBinding}
          * @param {?string} error
          */
         function callback(error)
@@ -341,11 +340,11 @@
             if (userCallback)
                 userCallback(error);
         }
-        this._presentationModel.setScriptSource(uiSourceCode, content, callback.bind(this));
+        WebInspector.DebuggerResourceBinding.setScriptSource(uiSourceCode, content, callback.bind(this));
     }
 }
 
-WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;
+WebInspector.DebuggerResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;
 
 /**
  * @type {?WebInspector.DebuggerPresentationModel}

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


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-11 18:48:19 UTC (rev 116790)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-11 18:50:41 UTC (rev 116791)
@@ -100,15 +100,18 @@
         this._uiSourceCode.requestContent(mycallback.bind(this));
     },
 
+    /**
+     * @return {boolean}
+     */
     canEditSource: function()
     {
-        return this._model.canEditScriptSource(this._uiSourceCode);
+        return WebInspector.DebuggerResourceBinding.canEditScriptSource(this._uiSourceCode);
     },
 
     editContent: function(newContent, callback)
     {
         this._editingContent = true;
-        this._model.setScriptSource(this._uiSourceCode, newContent, callback);
+        WebInspector.DebuggerResourceBinding.setScriptSource(this._uiSourceCode, newContent, callback);
     },
 
     /**
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to