Title: [166190] trunk/Source/WebInspectorUI
Revision
166190
Author
[email protected]
Date
2014-03-24 13:57:33 -0700 (Mon, 24 Mar 2014)

Log Message

Lazy load source code referred to from the source map, instead of when
the source code is revealed in the Resources sidebar.

https://bugs.webkit.org/show_bug.cgi?id=130625

Reviewed by Joseph Pecoraro.

* UserInterface/Models/SourceMapResource.js:
(WebInspector.SourceMapResource): Set up the type info here so it can be used to
dispaly the right icon in the sidebar.
(WebInspector.SourceMapResource.prototype.canRequestContentFromBackend): Use _contentRequested.
(WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoaded):
Reset finished and remove the type change dance we had before.
* UserInterface/Views/SourceMapResourceTreeElement.js:
(WebInspector.SourceMapResourceTreeElement.prototype.onattach): Removed. Don't request content here.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (166189 => 166190)


--- trunk/Source/WebInspectorUI/ChangeLog	2014-03-24 20:51:12 UTC (rev 166189)
+++ trunk/Source/WebInspectorUI/ChangeLog	2014-03-24 20:57:33 UTC (rev 166190)
@@ -1,3 +1,21 @@
+2014-03-24  Timothy Hatcher  <[email protected]>
+
+        Lazy load source code referred to from the source map, instead of when
+        the source code is revealed in the Resources sidebar.
+
+        https://bugs.webkit.org/show_bug.cgi?id=130625
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Models/SourceMapResource.js:
+        (WebInspector.SourceMapResource): Set up the type info here so it can be used to
+        dispaly the right icon in the sidebar.
+        (WebInspector.SourceMapResource.prototype.canRequestContentFromBackend): Use _contentRequested.
+        (WebInspector.SourceMapResource.prototype.requestContentFromBackend.sourceMapResourceLoaded):
+        Reset finished and remove the type change dance we had before.
+        * UserInterface/Views/SourceMapResourceTreeElement.js:
+        (WebInspector.SourceMapResourceTreeElement.prototype.onattach): Removed. Don't request content here.
+
 2014-03-23  James Craig  <[email protected]>
 
         Web Inspector: AXI: add other ARIA one-to-many relationships: owns, flowto, controls.

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js (166189 => 166190)


--- trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js	2014-03-24 20:51:12 UTC (rev 166189)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js	2014-03-24 20:57:33 UTC (rev 166190)
@@ -31,6 +31,21 @@
     console.assert(sourceMap);
 
     this._sourceMap = sourceMap;
+    this._contentRequested = false;
+
+    var inheritedMIMEType = this._sourceMap.originalSourceCode instanceof WebInspector.Resource ? this._sourceMap.originalSourceCode.syntheticMIMEType : null;
+
+    var fileExtension = WebInspector.fileExtensionForURL(url);
+    var fileExtensionMIMEType = WebInspector.mimeTypeForFileExtension(fileExtension, true);
+
+    // FIXME: This is a layering violation. It should use a helper function on the
+    // Resource base-class to set _mimeType and _type.
+    this._mimeType = fileExtensionMIMEType || inheritedMIMEType || "text/_javascript_";
+    this._type = WebInspector.Resource.Type.fromMIMEType(this._mimeType);
+
+    // Mark the resource as loaded so it does not show a spinner in the sidebar.
+    // We will really load the resource the first time content is requested.
+    this.markAsFinished();
 };
 
 WebInspector.SourceMapResource.prototype = {
@@ -62,18 +77,22 @@
 
     canRequestContentFromBackend: function()
     {
-        return !this.finished;
+        return !this._contentRequested;
     },
 
     requestContentFromBackend: function(callback)
     {
+        this._contentRequested = true;
+
+        // Revert the markAsFinished that was done in the constructor.
+        this.revertMarkAsFinished();
+
         var inlineContent = this._sourceMap.sourceContent(this.url);
         if (inlineContent) {
             // Force inline content to be asynchronous to match the expected load pattern.
             setTimeout(function() {
                 // FIXME: We don't know the MIME-type for inline content. Guess by analyzing the content?
-                // Guess by using the type of the original resource?
-                sourceMapResourceLoaded.call(this, null, inlineContent, "text/_javascript_", 200);
+                sourceMapResourceLoaded.call(this, null, inlineContent, this.mimeType, 200);
             }.bind(this));
 
             return true;
@@ -89,29 +108,9 @@
                 return;
             }
 
-            var fileExtension = WebInspector.fileExtensionForURL(this.url);
-            var fileExtensionMIMEType = WebInspector.mimeTypeForFileExtension(fileExtension, true) || "text/_javascript_";
-
             // FIXME: Add support for picking the best MIME-type. Right now the file extension is the best bet.
-            mimeType = fileExtensionMIMEType;
+            // The constructor set MIME-type based on the file extension and we ignore mimeType here.
 
-            var oldType = this._type;
-            var oldMIMEType = this._mimeType;
-
-            // FIXME: This is a layering violation. It should use a helper function on the Resource base-class.
-            this._mimeType = mimeType;
-            this._type = WebInspector.Resource.Type.fromMIMEType(this._mimeType);
-
-            if (oldMIMEType !== mimeType) {
-                // Delete the MIME-type components so the MIME-type is re-parsed the next time it is requested.
-                delete this._mimeTypeComponents;
-
-                this.dispatchEventToListeners(WebInspector.Resource.Event.MIMETypeDidChange, {oldMIMEType: oldMIMEType});
-            }
-
-            if (oldType !== this._type)
-                this.dispatchEventToListeners(WebInspector.Resource.Event.TypeDidChange, {oldType: oldType});
-
             this.markAsFinished();
 
             callback(null, body, base64encoded);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceMapResourceTreeElement.js (166189 => 166190)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceMapResourceTreeElement.js	2014-03-24 20:51:12 UTC (rev 166189)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceMapResourceTreeElement.js	2014-03-24 20:57:33 UTC (rev 166190)
@@ -41,16 +41,6 @@
 
     // Protected
 
-    onattach: function()
-    {
-        WebInspector.ResourceTreeElement.prototype.onattach.call(this);
-
-        // SourceMap resources must be loaded by the frontend, and only
-        // then do they get their type information. So force a load as
-        // soon as they are attached to the sidebar.
-        this.resource.requestContent(function() {});
-    },
-
     _updateTitles: function()
     {
         var oldMainTitle = this.mainTitle;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to