Title: [117455] trunk/Source/WebCore
Revision
117455
Author
pfeld...@chromium.org
Date
2012-05-17 09:05:41 -0700 (Thu, 17 May 2012)

Log Message

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/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame):
(WebInspector._javascript_SourceFrame.prototype.commitEditing):
(WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
(WebInspector._javascript_SourceFrame.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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117454 => 117455)


--- trunk/Source/WebCore/ChangeLog	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/ChangeLog	2012-05-17 16:05:41 UTC (rev 117455)
@@ -1,3 +1,30 @@
+2012-05-17  Pavel Feldman  <pfeld...@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/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame):
+        (WebInspector._javascript_SourceFrame.prototype.commitEditing):
+        (WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
+        (WebInspector._javascript_SourceFrame.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  <yu...@chromium.org>
 
         Web Inspector: error when expanding an HTMLAllCollection object in the console

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


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-05-17 16:05:41 UTC (rev 117455)
@@ -44,7 +44,7 @@
     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 @@
     },
 
     /**
-     * @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 @@
         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 @@
     {
         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.SourceFrame.prototype.beforeTextChanged.call(this);
     },
 
-    _didEditContent: function(content, error)
+    _didEditContent: function(error)
     {
         delete this._editingContent;
 
@@ -202,8 +184,6 @@
             return;
         }
 
-        this._originalContent = content;
-
         // Restore all muted breakpoints.
         for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
             var breakpointDecoration = this.textModel.getAttribute(lineNumber, "breakpoint");

Modified: trunk/Source/WebCore/inspector/front-end/ResourceView.js (117454 => 117455)


--- trunk/Source/WebCore/inspector/front-end/ResourceView.js	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/inspector/front-end/ResourceView.js	2012-05-17 16:05:41 UTC (rev 117455)
@@ -83,7 +83,7 @@
 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 @@
         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());

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


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-05-17 16:05:41 UTC (rev 117455)
@@ -468,7 +468,7 @@
             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);

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (117454 => 117455)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-05-17 16:05:41 UTC (rev 117455)
@@ -31,13 +31,15 @@
 /**
  * @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 @@
     {
         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)

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


--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-05-17 16:05:41 UTC (rev 117455)
@@ -113,7 +113,7 @@
 {
     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 @@
     },
 
     /**
-     * @param {function(?string,boolean,string)} callback
-     */
-    requestContent: function(callback)
-    {
-        this._styleSource.requestContent(callback);
-    },
-
-    /**
      * @param {string} text
      */
     commitEditing: function(text)

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


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-05-17 16:00:36 UTC (rev 117454)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-05-17 16:05:41 UTC (rev 117455)
@@ -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 @@
     },
 
     /**
+     * @return {?string}
+     */
+    contentURL: function()
+    {
+        return this._url;
+    },
+
+    /**
      * @param {function(?string,boolean,string)} callback
      */
     requestContent: function(callback)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to