Title: [121850] trunk/Source/WebCore
Revision
121850
Author
[email protected]
Date
2012-07-04 07:07:43 -0700 (Wed, 04 Jul 2012)

Log Message

Web Inspector: Get rid of ResourceDomainModelBinding and DebuggerResourceBinding, make Resource.setContent private.
https://bugs.webkit.org/show_bug.cgi?id=90531

Reviewed by Pavel Feldman.

Resource.setContent made private. It is delegating now to UISourceCodes which take care of domain specific actions.
DebuggerResourceBinding was be removed and DebuggerResourceBinding.setScriptSource was moved to _javascript_Source.
ResourceDomainModelBinding was removed as well.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModelResourceBinding):
* inspector/front-end/DebuggerResourceBinding.js: Removed.
* inspector/front-end/_javascript_Source.js:
(WebInspector._javascript_Source.prototype.workingCopyCommitted):
(WebInspector._javascript_Source.prototype._setScriptSource.didEditScriptSource):
(WebInspector._javascript_Source.prototype._setScriptSource):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype._setContent):
(WebInspector.Resource.prototype.revertToOriginal):
(WebInspector.Resource.prototype.revertAndClearHistory):
(WebInspector.ResourceRevision.prototype.revertToThis):
* inspector/front-end/StylesPanel.js:
(WebInspector.StyleSource.prototype.isEditable):
* inspector/front-end/UISourceCode.js:
* inspector/front-end/WebKit.qrc:
* inspector/front-end/Workspace.js:
(WebInspector.Workspace):
* inspector/front-end/inspector.html:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121849 => 121850)


--- trunk/Source/WebCore/ChangeLog	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/ChangeLog	2012-07-04 14:07:43 UTC (rev 121850)
@@ -1,3 +1,37 @@
+2012-07-04  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Get rid of ResourceDomainModelBinding and DebuggerResourceBinding, make Resource.setContent private.
+        https://bugs.webkit.org/show_bug.cgi?id=90531
+
+        Reviewed by Pavel Feldman.
+
+        Resource.setContent made private. It is delegating now to UISourceCodes which take care of domain specific actions.
+        DebuggerResourceBinding was be removed and DebuggerResourceBinding.setScriptSource was moved to _javascript_Source.
+        ResourceDomainModelBinding was removed as well.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/compile-front-end.py:
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModelResourceBinding):
+        * inspector/front-end/DebuggerResourceBinding.js: Removed.
+        * inspector/front-end/_javascript_Source.js:
+        (WebInspector._javascript_Source.prototype.workingCopyCommitted):
+        (WebInspector._javascript_Source.prototype._setScriptSource.didEditScriptSource):
+        (WebInspector._javascript_Source.prototype._setScriptSource):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype._setContent):
+        (WebInspector.Resource.prototype.revertToOriginal):
+        (WebInspector.Resource.prototype.revertAndClearHistory):
+        (WebInspector.ResourceRevision.prototype.revertToThis):
+        * inspector/front-end/StylesPanel.js:
+        (WebInspector.StyleSource.prototype.isEditable):
+        * inspector/front-end/UISourceCode.js:
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/Workspace.js:
+        (WebInspector.Workspace):
+        * inspector/front-end/inspector.html:
+
 2012-07-04  'Pavel Feldman'  <[email protected]>
 
         Not reviewed: follow up to r121843, reduce inspector dock timeout to 200ms.

Modified: trunk/Source/WebCore/WebCore.gypi (121849 => 121850)


--- trunk/Source/WebCore/WebCore.gypi	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/WebCore.gypi	2012-07-04 14:07:43 UTC (rev 121850)
@@ -6256,7 +6256,6 @@
             'inspector/front-end/DatabaseTableView.js',
             'inspector/front-end/DataGrid.js',
             'inspector/front-end/DebuggerModel.js',
-            'inspector/front-end/DebuggerResourceBinding.js',
             'inspector/front-end/DebuggerScriptMapping.js',
             'inspector/front-end/Dialog.js',
             'inspector/front-end/DirectoryContentView.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (121849 => 121850)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-07-04 14:07:43 UTC (rev 121850)
@@ -74834,10 +74834,6 @@
 					>
 				</File>
 				<File
-					RelativePath="..\inspector\front-end\DebuggerResourceBinding.js"
-					>
-				</File>
-				<File
 					RelativePath="..\inspector\front-end\DebuggerScriptMapping.js"
 					>
 				</File>

Modified: trunk/Source/WebCore/inspector/compile-front-end.py (121849 => 121850)


--- trunk/Source/WebCore/inspector/compile-front-end.py	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/compile-front-end.py	2012-07-04 14:07:43 UTC (rev 121850)
@@ -79,7 +79,6 @@
             "DOMAgent.js",
             "DOMStorage.js",
             "DebuggerModel.js",
-            "DebuggerResourceBinding.js",
             "DebuggerScriptMapping.js",
             "FileManager.js",
             "FileSystemModel.js",

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -934,7 +934,6 @@
 
 /**
  * @constructor
- * @implements {WebInspector.ResourceDomainModelBinding}
  */
 WebInspector.CSSStyleModelResourceBinding = function(cssModel)
 {
@@ -943,7 +942,6 @@
     this._styleSheetIdToHeader = {};
     this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._styleSheetChanged, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
-    WebInspector.Resource.registerDomainModelBinding(WebInspector.resourceTypes.Stylesheet, this);
 }
 
 WebInspector.CSSStyleModelResourceBinding.prototype = {
@@ -978,30 +976,6 @@
 
     /**
      * @param {WebInspector.Resource} resource
-     * @param {string} content
-     * @param {boolean} majorChange
-     * @param {function(?string)} userCallback
-     */
-    setContent: function(resource, content, majorChange, userCallback)
-    {
-        var styleSource = /** @type {WebInspector.StyleSource} */ resource.uiSourceCode();
-        if (!styleSource) {
-            userCallback("Resource is not editable");
-            return;
-        }
-        this.setStyleContent(styleSource, content, majorChange, userCallback);
-    },
-
-    /**
-     * @return {boolean}
-     */
-    canSetContent: function()
-    {
-        return true;
-    },
-
-    /**
-     * @param {WebInspector.Resource} resource
      * @return {CSSAgent.StyleSheetId}
      */
     _styleSheetIdForResource: function(resource)
@@ -1209,8 +1183,6 @@
     }
 }
 
-WebInspector.CSSStyleModelResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;
-
 /**
  * @constructor
  * @implements {CSSAgent.Dispatcher}

Deleted: trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @constructor
- * @implements {WebInspector.ResourceDomainModelBinding}
- * @param {WebInspector.UISourceCodeProvider} uiSourceCodeProvider
- */
-WebInspector.DebuggerResourceBinding = function(uiSourceCodeProvider)
-{
-    this._uiSourceCodeProvider = uiSourceCodeProvider;
-    WebInspector.Resource.registerDomainModelBinding(WebInspector.resourceTypes.Script, this);
-}
-
-/**
- * @param {WebInspector._javascript_Source} _javascript_Source
- * @param {string} newSource
- * @param {function(?Protocol.Error)} callback
- */
-WebInspector.DebuggerResourceBinding.setScriptSource = function(_javascript_Source, newSource, callback)
-{
-    var rawLocation = _javascript_Source.uiLocationToRawLocation(0, 0);
-    var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
-
-    /**
-     * @this {WebInspector.DebuggerResourceBinding}
-     * @param {?Protocol.Error} error
-     */
-    function didEditScriptSource(error)
-    {
-        if (error) {
-            callback(error);
-            return;
-        }
-
-        var resource = _javascript_Source.resource();
-        if (resource)
-            resource.addRevision(newSource);
-
-        callback(null);
-    }
-    WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
-}
-
-WebInspector.DebuggerResourceBinding.prototype = {
-    /**
-     * @param {WebInspector.Resource} resource
-     * @return {boolean}
-     */
-    canSetContent: function(resource)
-    {
-        var uiSourceCode = resource.uiSourceCode();
-        return !!uiSourceCode && uiSourceCode.isEditable();
-    },
-
-    /**
-     * @param {WebInspector.Resource} resource
-     * @param {string} content
-     * @param {boolean} majorChange
-     * @param {function(?string)} userCallback
-     */
-    setContent: function(resource, content, majorChange, userCallback)
-    {
-        if (!majorChange)
-            return;
-
-        var _javascript_Source = /** @type {WebInspector._javascript_Source} */ resource.uiSourceCode();
-        if (!_javascript_Source) {
-            userCallback("Resource is not editable");
-            return;
-        }
-
-        resource.requestContent(this._setContentWithInitialContent.bind(this, _javascript_Source, content, userCallback));
-    },
-
-    /**
-     * @param {WebInspector._javascript_Source} _javascript_Source
-     * @param {string} content
-     * @param {function(?string)} userCallback
-     * @param {?string} oldContent
-     * @param {boolean} oldContentEncoded
-     * @param {string} mimeType
-     */
-    _setContentWithInitialContent: function(_javascript_Source, content, userCallback, oldContent, oldContentEncoded, mimeType)
-    {
-        /**
-         * @this {WebInspector.DebuggerResourceBinding}
-         * @param {?string} error
-         */
-        function callback(error)
-        {
-            if (userCallback)
-                userCallback(error);
-        }
-        WebInspector.DebuggerResourceBinding.setScriptSource(_javascript_Source, content, callback.bind(this));
-    }
-}
-
-WebInspector.DebuggerResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;

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


--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -207,10 +207,39 @@
             callback(error);
         }
 
-        WebInspector.DebuggerResourceBinding.setScriptSource(this, this.workingCopy(), innerCallback.bind(this));
+        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._javascript_Source}
+         * @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));
+    },
+
+    /**
      * @param {string} query
      * @param {boolean} caseSensitive
      * @param {boolean} isRegex

Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/Resource.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -58,17 +58,6 @@
         this._request.addEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, this._requestFinished, this);
 }
 
-WebInspector.Resource._domainModelBindings = [];
-
-/**
- * @param {WebInspector.ResourceType} type
- * @param {WebInspector.ResourceDomainModelBinding} binding
- */
-WebInspector.Resource.registerDomainModelBinding = function(type, binding)
-{
-    WebInspector.Resource._domainModelBindings[type.name()] = binding;
-}
-
 WebInspector.Resource._resourceRevisionRegistry = function()
 {
     if (!WebInspector.Resource._resourceRevisionRegistryObject) {
@@ -326,30 +315,16 @@
     },
 
     /**
-     * @return {boolean}
-     */
-    isEditable: function()
-    {
-        if (this._actualResource)
-            return false;
-        var binding = WebInspector.Resource._domainModelBindings[this.type.name()];
-        return binding && binding.canSetContent(this);
-    },
-
-    /**
      * @param {string} newContent
-     * @param {boolean} majorChange
-     * @param {function(?string)} callback
+     * @param {function(String)=} callback
      */
-    setContent: function(newContent, majorChange, callback)
+    _setContent: function(newContent, callback)
     {
-        if (!this.isEditable()) {
-            if (callback)
-                callback("Resource is not editable");
+        var uiSourceCode = this._uiSourceCode;
+        if (!this._uiSourceCode || !this._uiSourceCode.isEditable())
             return;
-        }
-        var binding = WebInspector.Resource._domainModelBindings[this.type.name()];
-        binding.setContent(this, newContent, majorChange, callback);
+        this._uiSourceCode.setWorkingCopy(newContent);
+        this._uiSourceCode.commitWorkingCopy(callback);
     },
 
     /**
@@ -495,7 +470,7 @@
     {
         function revert(content)
         {
-            this.setContent(content, true, function() {});
+            this._setContent(content, function() {});
         }
         this.requestContent(revert.bind(this));
     },
@@ -504,7 +479,7 @@
     {
         function revert(content)
         {
-            this.setContent(content, true, clearHistory.bind(this));
+            this._setContent(content, clearHistory.bind(this));
         }
 
         function clearHistory()
@@ -588,7 +563,7 @@
         function revert(content)
         {
             if (this._resource._content !== content)
-                this._resource.setContent(content, true, function() {});
+                this._resource._setContent(content, function() {});
         }
         this.requestContent(revert.bind(this));
     },
@@ -633,24 +608,3 @@
         WebInspector.Resource.persistRevision(this);
     }
 }
-
-/**
- * @interface
- */
-WebInspector.ResourceDomainModelBinding = function() { }
-
-WebInspector.ResourceDomainModelBinding.prototype = {
-    /**
-     * @param {WebInspector.Resource} resource
-     * @return {boolean}
-     */
-    canSetContent: function(resource) { return true; },
-
-    /**
-     * @param {WebInspector.Resource} resource
-     * @param {string} content
-     * @param {boolean} majorChange
-     * @param {function(?string)} callback
-     */
-    setContent: function(resource, content, majorChange, callback) { }
-}

Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -101,6 +101,14 @@
 
 WebInspector.StyleSource.prototype = {
     /**
+     * @return {boolean}
+     */
+    isEditable: function()
+    {
+        return true;
+    },
+
+    /**
      * @param {function(?string)} callback
      */
     workingCopyCommitted: function(callback)

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


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -200,6 +200,11 @@
      */
     commitWorkingCopy: function(callback)
     {
+        if (!this.isDirty()) {
+            callback()
+            return;
+        }
+
         /**
          * @param {?string} error
          */

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-07-04 14:07:43 UTC (rev 121850)
@@ -37,7 +37,6 @@
     <file>DatabaseTableView.js</file>
     <file>DataGrid.js</file>
     <file>DebuggerModel.js</file>
-    <file>DebuggerResourceBinding.js</file>
     <file>DebuggerScriptMapping.js</file>
     <file>Dialog.js</file>
     <file>DirectoryContentView.js</file>

Modified: trunk/Source/WebCore/inspector/front-end/Workspace.js (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/Workspace.js	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/Workspace.js	2012-07-04 14:07:43 UTC (rev 121850)
@@ -119,7 +119,6 @@
     WebInspector.CompositeUISourceCodeProvider.call(this, providers);
     
     new WebInspector.PresentationConsoleMessageHelper(this);
-    new WebInspector.DebuggerResourceBinding(this);
 }
 
 WebInspector.Workspace.prototype = {

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (121849 => 121850)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2012-07-04 13:55:10 UTC (rev 121849)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2012-07-04 14:07:43 UTC (rev 121850)
@@ -188,7 +188,6 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
-    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to