Title: [132086] trunk
Revision
132086
Author
vse...@chromium.org
Date
2012-10-22 09:56:50 -0700 (Mon, 22 Oct 2012)

Log Message

Web Inspector: Prepare mappings to moving uiSourceCodes creation out of them to workspace.
https://bugs.webkit.org/show_bug.cgi?id=99997

Reviewed by Pavel Feldman.

Source/WebCore:

Source mappings could now store a link to temporary uiSourceCodes only.
Otherwise it should retrieve uiSourceCodes from workspace by URL.
Original uiSourceCodes are now temporary in CompilerScriptMapping.

* inspector/front-end/CompilerScriptMapping.js:
(WebInspector.CompilerScriptMapping):
(WebInspector.CompilerScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.CompilerScriptMapping.prototype.loadSourceMapForScript):
(WebInspector.CompilerScriptMapping.prototype._reset):
* inspector/front-end/NetworkUISourceCodeProvider.js:
(WebInspector.NetworkUISourceCodeProvider):
(WebInspector.NetworkUISourceCodeProvider.prototype._parsedScriptSource):
(WebInspector.NetworkUISourceCodeProvider.prototype._resourceAdded):
(WebInspector.NetworkUISourceCodeProvider.prototype._addUISourceCode):
(WebInspector.NetworkUISourceCodeProvider.prototype._projectWillReset):
* inspector/front-end/SASSSourceMapping.js:
(WebInspector.SASSSourceMapping):
(_bindUISourceCode):
(_reset):

LayoutTests:

* http/tests/inspector/compiler-script-mapping.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (132085 => 132086)


--- trunk/LayoutTests/ChangeLog	2012-10-22 16:55:09 UTC (rev 132085)
+++ trunk/LayoutTests/ChangeLog	2012-10-22 16:56:50 UTC (rev 132086)
@@ -1,3 +1,12 @@
+2012-10-22  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Prepare mappings to moving uiSourceCodes creation out of them to workspace.
+        https://bugs.webkit.org/show_bug.cgi?id=99997
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/compiler-script-mapping.html:
+
 2012-10-22  Zan Dobersek  <zandober...@gmail.com>
 
         Unreviewed GTK gardening.

Modified: trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html (132085 => 132086)


--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2012-10-22 16:55:09 UTC (rev 132085)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2012-10-22 16:56:50 UTC (rev 132086)
@@ -142,11 +142,12 @@
 
             function step1()
             {
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
+                InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(originalUISourceCodeAdded);
                 script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
                 script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
                 script.setSourceMapping(mapping);
                 mapping.addScript(script);
+                afterScriptAdded();
             }
 
             function originalUISourceCodeAdded(uiSourceCode)
@@ -165,10 +166,12 @@
                 InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", WebInspector.resourceTypes.Script, "");
             }
 
-            function originalResourceUISourceCodeAdded(uiSourceCode)
+            function originalResourceUISourceCodeAdded(uiSourceCode) { }
+
+            function afterScriptAdded(uiSourceCode)
             {
-                var uiSourceCode1 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source1.js"];
-                var uiSourceCode2 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source2.js"];
+                var uiSourceCode1 = InspectorTest.testWorkspace.uiSourceCodeForURL("http://localhost:8000/inspector/resources/source1.js");
+                var uiSourceCode2 = InspectorTest.testWorkspace.uiSourceCodeForURL("http://localhost:8000/inspector/resources/source2.js");
                 var originalUISourceCode = mapping._originalUISourceCodeForScriptId[script.scriptId];
 
                 InspectorTest.checkUILocation(uiSourceCode1, 4, 4, script.rawLocationToUILocation(0, 81));
@@ -211,7 +214,7 @@
             script.sourceMapURL = "data:application/json;base64," + btoa(JSON.stringify(sourceMap));
             mapping.addScript(script);
 
-            var uiSourceCode = mapping._uiSourceCodeByURL["source.js"];
+            var uiSourceCode = workspace.uiSourceCodeForURL("source.js");
 
             InspectorTest.checkUILocation(uiSourceCode, 2, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 18)));
             InspectorTest.checkRawLocation(script, 0, 18, mapping.uiLocationToRawLocation(uiSourceCode, 2, 4));

Modified: trunk/Source/WebCore/ChangeLog (132085 => 132086)


--- trunk/Source/WebCore/ChangeLog	2012-10-22 16:55:09 UTC (rev 132085)
+++ trunk/Source/WebCore/ChangeLog	2012-10-22 16:56:50 UTC (rev 132086)
@@ -1,3 +1,30 @@
+2012-10-22  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Prepare mappings to moving uiSourceCodes creation out of them to workspace.
+        https://bugs.webkit.org/show_bug.cgi?id=99997
+
+        Reviewed by Pavel Feldman.
+
+        Source mappings could now store a link to temporary uiSourceCodes only.
+        Otherwise it should retrieve uiSourceCodes from workspace by URL.
+        Original uiSourceCodes are now temporary in CompilerScriptMapping.
+
+        * inspector/front-end/CompilerScriptMapping.js:
+        (WebInspector.CompilerScriptMapping):
+        (WebInspector.CompilerScriptMapping.prototype.rawLocationToUILocation):
+        (WebInspector.CompilerScriptMapping.prototype.loadSourceMapForScript):
+        (WebInspector.CompilerScriptMapping.prototype._reset):
+        * inspector/front-end/NetworkUISourceCodeProvider.js:
+        (WebInspector.NetworkUISourceCodeProvider):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._parsedScriptSource):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._resourceAdded):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._addUISourceCode):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._projectWillReset):
+        * inspector/front-end/SASSSourceMapping.js:
+        (WebInspector.SASSSourceMapping):
+        (_bindUISourceCode):
+        (_reset):
+
 2012-10-22  Nicolas Dufresne <nicolas.dufre...@collabora.com>
 
         Gstreamer 1.0 not working

Modified: trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js (132085 => 132086)


--- trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-10-22 16:55:09 UTC (rev 132085)
+++ trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-10-22 16:56:50 UTC (rev 132086)
@@ -36,13 +36,16 @@
 WebInspector.CompilerScriptMapping = function(workspace)
 {
     this._workspace = workspace;
-    this._sourceMapByURL = {};
+    /** @type {Object.<string, WebInspector.SourceMapParser>} */
+    this._sourceMapForSourceMapURL = {};
+    /** @type {Object.<string, WebInspector.SourceMapParser>} */
     this._sourceMapForScriptId = {};
     this._scriptForSourceMap = new Map();
-    this._sourceMapForUISourceCode = new Map();
-    this._uiSourceCodeByURL = {};
+    /** @type {Object.<string, WebInspector.SourceMapParser>} */
+    this._sourceMapForURL = {};
+    /** @type {Object.<string, WebInspector.UISourceCode>} */
     this._originalUISourceCodeForScriptId = {};
-    this._scriptForOriginalUISource = new Map();
+    this._scriptForOriginalUISourceCode = new Map();
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
 }
 
@@ -58,9 +61,12 @@
         var lineNumber = debuggerModelLocation.lineNumber;
         var columnNumber = debuggerModelLocation.columnNumber || 0;
         var entry = sourceMap.findEntry(lineNumber, columnNumber);
-        if (entry.length === 2)
-            return new WebInspector.UILocation(this._originalUISourceCodeForScriptId[debuggerModelLocation.scriptId], lineNumber, columnNumber);
-        return new WebInspector.UILocation(this._uiSourceCodeByURL[entry[2]], entry[3], entry[4]);
+        if (entry.length === 2) {
+            var temporaryUISourceCode = this._originalUISourceCodeForScriptId[debuggerModelLocation.scriptId];
+            return new WebInspector.UILocation(temporaryUISourceCode, lineNumber, columnNumber);
+        }
+        var uiSourceCode = this._workspace.uiSourceCodeForURL(entry[2]);
+        return new WebInspector.UILocation(uiSourceCode, entry[3], entry[4]);
     },
 
     /**
@@ -71,10 +77,10 @@
      */
     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
     {
-        var script = this._scriptForOriginalUISource.get(uiSourceCode);
+        var script = this._scriptForOriginalUISourceCode.get(uiSourceCode);
         if (script)
             return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber);
-        var sourceMap = this._sourceMapForUISourceCode.get(uiSourceCode);
+        var sourceMap = this._sourceMapForURL[uiSourceCode.url];
         var entry = sourceMap.findEntryReversed(uiSourceCode.url, lineNumber);
         return WebInspector.debuggerModel.createRawLocation(this._scriptForSourceMap.get(sourceMap), entry[0], entry[1]);
     },
@@ -84,10 +90,13 @@
      */
     addScript: function(script)
     {
-        var originalUISourceCode = new WebInspector.UISourceCode(script.sourceURL, script, true);
+        // FIXME: We should only create temporary uiSourceCodes on demand and should set this as a mapping to 
+        // relevant uiSourceCodes added by NetworkUISourceCodeProvider.
+        var originalUISourceCode = new WebInspector.UISourceCode(script.sourceURL, script, false);
         this._originalUISourceCodeForScriptId[script.scriptId] = originalUISourceCode;
-        this._scriptForOriginalUISource.put(originalUISourceCode, script);
-        this._workspace.project().addUISourceCode(originalUISourceCode);
+        this._scriptForOriginalUISourceCode.put(originalUISourceCode, script);
+        originalUISourceCode.setSourceMapping(this);
+        this._workspace.project().addTemporaryUISourceCode(originalUISourceCode);
 
         var sourceMap = this.loadSourceMapForScript(script);
 
@@ -97,12 +106,12 @@
             return;
         }
 
-        var uiSourceCodeList = [];
         var sourceURLs = sourceMap.sources();
         for (var i = 0; i < sourceURLs.length; ++i) {
             var sourceURL = sourceURLs[i];
-            if (this._uiSourceCodeByURL[sourceURL])
+            if (this._workspace.uiSourceCodeForURL(sourceURL))
                 continue;
+            this._sourceMapForURL[sourceURL] = sourceMap;
             var sourceContent = sourceMap.sourceContent(sourceURL);
             var contentProvider;
             if (sourceContent)
@@ -110,19 +119,15 @@
             else
                 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
             var uiSourceCode = new WebInspector.UISourceCode(sourceURL, contentProvider, false);
+            this._workspace.project().addUISourceCode(uiSourceCode);
+
             uiSourceCode.setSourceMapping(this);
             uiSourceCode.isContentScript = script.isContentScript;
-            this._uiSourceCodeByURL[sourceURL] = uiSourceCode;
-            this._sourceMapForUISourceCode.put(uiSourceCode, sourceMap);
-            uiSourceCodeList.push(uiSourceCode);
         }
 
         this._sourceMapForScriptId[script.scriptId] = sourceMap;
         this._scriptForSourceMap.put(sourceMap, script);
         script.setSourceMapping(this);
-
-        for (var i = 0; i < uiSourceCodeList.length; ++i)
-            this._workspace.project().addUISourceCode(uiSourceCodeList[i]);
     },
 
     /**
@@ -132,7 +137,7 @@
     loadSourceMapForScript: function(script)
     {
         var sourceMapURL = WebInspector.SourceMapParser.prototype._canonicalizeURL(script.sourceMapURL, script.sourceURL);
-        var sourceMap = this._sourceMapByURL[sourceMapURL];
+        var sourceMap = this._sourceMapForSourceMapURL[sourceMapURL];
         if (sourceMap)
             return sourceMap;
 
@@ -147,19 +152,18 @@
             console.error(e.message);
             return null;
         }
-        this._sourceMapByURL[sourceMapURL] = sourceMap;
+        this._sourceMapForSourceMapURL[sourceMapURL] = sourceMap;
         return sourceMap;
     },
 
     _reset: function()
     {
-        this._sourceMapByURL = {};
+        this._sourceMapForSourceMapURL = {};
         this._sourceMapForScriptId = {};
         this._scriptForSourceMap = new Map();
-        this._sourceMapForUISourceCode = new Map();
-        this._uiSourceCodeByURL = {};
+        this._sourceMapForURL = {};
         this._originalUISourceCodeForScriptId = {};
-        this._scriptForOriginalUISource = new Map();
+        this._scriptForOriginalUISourceCode = new Map();
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js (132085 => 132086)


--- trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js	2012-10-22 16:55:09 UTC (rev 132085)
+++ trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js	2012-10-22 16:56:50 UTC (rev 132086)
@@ -40,7 +40,7 @@
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectDidReset, this._projectDidReset, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
 
-    this._uiSourceCodeForResource = {};
+    this._processedURLs = {};
     this._lastDynamicAnonymousScriptIndexForURL = {};
 }
 
@@ -83,11 +83,7 @@
             if (!parsedURL.host)
                 return;
         }
-        if (this._uiSourceCodeForResource[script.sourceURL])
-            return;
-        var uiSourceCode = new WebInspector.UISourceCode(script.sourceURL, script, true);
-        this._uiSourceCodeForResource[script.sourceURL] = uiSourceCode;
-        this._workspace.project().addUISourceCode(uiSourceCode);
+        this._addUISourceCode(script.sourceURL, script);
     },
 
     /**
@@ -96,29 +92,28 @@
     _resourceAdded: function(event)
     {
         var resource = /** @type {WebInspector.Resource} */ event.data;
-        if (this._uiSourceCodeForResource[resource.url])
+        this._addUISourceCode(resource.url, resource);
+    },
+
+    /**
+     * @param {WebInspector.ContentProvider} contentProvider
+     */
+    _addUISourceCode: function(url, contentProvider)
+    {
+        var type = contentProvider.contentType();
+        if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspector.resourceTypes.Document && type !== WebInspector.resourceTypes.Script)
             return;
-        var uiSourceCode;
-        switch (resource.type) {
-        case WebInspector.resourceTypes.Stylesheet:
-            uiSourceCode = new WebInspector.UISourceCode(resource.url, resource, true);
-            break;
-        case WebInspector.resourceTypes.Document:
-            uiSourceCode = new WebInspector.UISourceCode(resource.url, resource, false);
-            break;
-        case WebInspector.resourceTypes.Script:
-            uiSourceCode = new WebInspector.UISourceCode(resource.url, resource, true);
-            break;
-        }
-        if (uiSourceCode) {
-            this._uiSourceCodeForResource[resource.url] = uiSourceCode;
-            this._workspace.project().addUISourceCode(uiSourceCode);
-        }
+        if (this._processedURLs[url])
+            return;
+        this._processedURLs[url] = true;
+        var isEditable = type !== WebInspector.resourceTypes.Document;
+        var uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, isEditable);
+        this._workspace.project().addUISourceCode(uiSourceCode);
     },
 
     _projectWillReset: function()
     {
-        this._uiSourceCodeForResource = {};
+        this._processedURLs = {};
         this._lastDynamicAnonymousScriptIndexForURL = {};
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js (132085 => 132086)


--- trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js	2012-10-22 16:55:09 UTC (rev 132085)
+++ trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js	2012-10-22 16:56:50 UTC (rev 132086)
@@ -36,7 +36,6 @@
 WebInspector.SASSSourceMapping = function(workspace)
 {
     this._workspace = workspace;
-    this._uiSourceCodeForURL = {};
     this._uiLocations = {};
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
@@ -112,12 +111,11 @@
      */
     _bindUISourceCode: function(url, line, rawURL, rawLine)
     {
-        var uiSourceCode = this._uiSourceCodeForURL[url];
+        var uiSourceCode = this._workspace.uiSourceCodeForURL(url);
         if (!uiSourceCode) {
             var content = InspectorFrontendHost.loadResourceSynchronously(url);
             var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Stylesheet, content, "text/x-scss");
             uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, true);
-            this._uiSourceCodeForURL[url] = uiSourceCode;
             this._workspace.project().addUISourceCode(uiSourceCode);
             WebInspector.cssModel.setSourceMapping(rawURL, this);
         }
@@ -154,7 +152,6 @@
 
     _reset: function()
     {
-        this._uiSourceCodeForURL = {};
         this._uiLocations = {};
         this._populate();
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to