Web Inspector: create SourceFrames with content providers.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 16:05:41 +0000 (16:05 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 16:05:41 +0000 (16:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86742

Reviewed by Vsevolod Vlasov.

Simple refactoring.

* inspector/front-end/JavaScriptSourceFrame.js:
(WebInspector.JavaScriptSourceFrame):
(WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
(WebInspector.JavaScriptSourceFrame.prototype.afterTextChanged):
(WebInspector.JavaScriptSourceFrame.prototype._didEditContent):
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceSourceFrame):
(WebInspector.ResourceSourceFrame.prototype.get resource):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._createSourceFrame):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.prototype._ensureContentLoaded):
* inspector/front-end/StylesPanel.js:
(WebInspector.StyleSourceFrame):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.contentURL):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
Source/WebCore/inspector/front-end/ResourceView.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/SourceFrame.js
Source/WebCore/inspector/front-end/StylesPanel.js
Source/WebCore/inspector/front-end/UISourceCode.js

index c2e8152..b4c2a33 100644 (file)
@@ -1,3 +1,30 @@
+2012-05-17  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: create SourceFrames with content providers.
+        https://bugs.webkit.org/show_bug.cgi?id=86742
+
+        Reviewed by Vsevolod Vlasov.
+
+        Simple refactoring.
+
+        * inspector/front-end/JavaScriptSourceFrame.js:
+        (WebInspector.JavaScriptSourceFrame):
+        (WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
+        (WebInspector.JavaScriptSourceFrame.prototype.afterTextChanged):
+        (WebInspector.JavaScriptSourceFrame.prototype._didEditContent):
+        * inspector/front-end/ResourceView.js:
+        (WebInspector.ResourceSourceFrame):
+        (WebInspector.ResourceSourceFrame.prototype.get resource):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._createSourceFrame):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        (WebInspector.SourceFrame.prototype._ensureContentLoaded):
+        * inspector/front-end/StylesPanel.js:
+        (WebInspector.StyleSourceFrame):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype.contentURL):
+
 2012-05-17  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: error when expanding an HTMLAllCollection object in the console
index be1213d..9e561ab 100644 (file)
@@ -44,7 +44,7 @@ WebInspector.JavaScriptSourceFrame = function(scriptsPanel, uiSourceCode)
     for (var i = 0; i < locations.length; ++i)
         this._breakpointAdded({data:locations[i]});
 
-    WebInspector.SourceFrame.call(this, uiSourceCode.url);
+    WebInspector.SourceFrame.call(this, uiSourceCode);
 
     this._popoverHelper = new WebInspector.ObjectPopoverHelper(this.textViewer.element,
             this._getPopoverAnchor.bind(this), this._resolveObjectForPopover.bind(this), this._onHidePopover.bind(this), true);
@@ -80,24 +80,6 @@ WebInspector.JavaScriptSourceFrame.prototype = {
     },
 
     /**
-     * @param {function(?string, boolean, string)} callback
-     */
-    requestContent: function(callback)
-    {
-        /**
-         * @param {?string} content
-         * @param {boolean} contentEncoded
-         * @param {string} mimeType
-         */
-        function mycallback(content, contentEncoded, mimeType)
-        {
-            this._originalContent = content;
-            callback(content, contentEncoded, mimeType);
-        }
-        this._uiSourceCode.requestContent(mycallback.bind(this));
-    },
-
-    /**
      * @return {boolean}
      */
     canEditSource: function()
@@ -113,7 +95,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
         this._editingContent = true;
         if (!this._uiSourceCode.isDirty())
             return;
-        this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this, text));
+        this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
     },
 
     /**
@@ -173,7 +155,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
     {
         this._uiSourceCode.setWorkingCopy(this.textModel.text);
         if (!this._uiSourceCode.isDirty())
-            this._didEditContent(this._originalContent, null);
+            this._didEditContent(null);
     },
 
     beforeTextChanged: function()
@@ -193,7 +175,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
         WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
     },
 
-    _didEditContent: function(content, error)
+    _didEditContent: function(error)
     {
         delete this._editingContent;
 
@@ -202,8 +184,6 @@ WebInspector.JavaScriptSourceFrame.prototype = {
             return;
         }
 
-        this._originalContent = content;
-
         // Restore all muted breakpoints.
         for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
             var breakpointDecoration = this.textModel.getAttribute(lineNumber, "breakpoint");
index b6663d6..94a2411 100644 (file)
@@ -83,7 +83,7 @@ WebInspector.ResourceView.nonSourceViewForResource = function(resource)
 WebInspector.ResourceSourceFrame = function(resource)
 {
     this._resource = resource;
-    WebInspector.SourceFrame.call(this, resource.url);
+    WebInspector.SourceFrame.call(this, resource);
     this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
 }
 
@@ -93,23 +93,6 @@ WebInspector.ResourceSourceFrame.prototype = {
         return this._resource;
     },
 
-    /**
-     * @param {function(?string,boolean,string)} callback
-     */
-    requestContent: function(callback)
-    {
-        /**
-         * @param {?string} content
-         * @param {boolean} contentEncoded
-         * @param {string} mimeType
-         */
-        function callbackWrapper(content, contentEncoded, mimeType)
-        {
-            callback(content, contentEncoded, mimeType);
-        }
-        this.resource.requestContent(callbackWrapper.bind(this));
-    },
-
     _contentChanged: function(event)
     {
         this.setContent(this._resource.content, false, this._resource.canonicalMimeType());
index dceb8bd..44d6b3c 100644 (file)
@@ -468,7 +468,7 @@ WebInspector.ScriptsPanel.prototype = {
             sourceFrame = new WebInspector.StyleSourceFrame(uiSourceCode);
         else {
             console.assert(false, "Unknown UISourceCode type");
-            sourceFrame = new WebInspector.SourceFrame(uiSourceCode.url);
+            sourceFrame = new WebInspector.SourceFrame(uiSourceCode);
         }
          
         this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame);
index 3f0b0c8..b6df75f 100644 (file)
 /**
  * @extends {WebInspector.View}
  * @constructor
+ * @param {WebInspector.ContentProvider} contentProvider
  */
-WebInspector.SourceFrame = function(url)
+WebInspector.SourceFrame = function(contentProvider)
 {
     WebInspector.View.call(this);
     this.element.addStyleClass("script-view");
 
-    this._url = url;
+    this._url = contentProvider.contentURL();
+    this._contentProvider = contentProvider;
 
     this._textModel = new WebInspector.TextEditorModel();
 
@@ -114,18 +116,11 @@ WebInspector.SourceFrame.prototype = {
     {
         if (!this._contentRequested) {
             this._contentRequested = true;
-            this.requestContent(this.setContent.bind(this));
+            this._contentProvider.requestContent(this.setContent.bind(this));
         }
     },
 
     /**
-     * @param {function(?string, boolean, string)} callback
-     */
-    requestContent: function(callback)
-    {
-    },
-
-    /**
      * @param {TextDiff} diffData
      */
     markDiff: function(diffData)
index 2c8606d..05d420a 100644 (file)
@@ -113,7 +113,7 @@ WebInspector.StyleSourceFrame = function(styleSource)
 {
     this._resource = styleSource._resource;
     this._styleSource = styleSource;
-    WebInspector.SourceFrame.call(this, this._resource.url);
+    WebInspector.SourceFrame.call(this, this._styleSource);
     this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
 }
 
@@ -127,14 +127,6 @@ WebInspector.StyleSourceFrame.prototype = {
     },
 
     /**
-     * @param {function(?string,boolean,string)} callback
-     */
-    requestContent: function(callback)
-    {
-        this._styleSource.requestContent(callback);
-    },
-
-    /**
      * @param {string} text
      */
     commitEditing: function(text)
index cff3f1b..2ee790d 100644 (file)
@@ -32,6 +32,7 @@
 /**
  * @constructor
  * @extends {WebInspector.Object}
+ * @implements {WebInspector.ContentProvider}
  * @param {string} url
  * @param {WebInspector.ContentProvider} contentProvider
  * @param {WebInspector.SourceMapping=} sourceMapping
@@ -91,6 +92,14 @@ WebInspector.UISourceCode.prototype = {
     },
 
     /**
+     * @return {?string}
+     */
+    contentURL: function()
+    {
+        return this._url;
+    },
+
+    /**
      * @param {function(?string,boolean,string)} callback
      */
     requestContent: function(callback)