Title: [101359] trunk
Revision
101359
Author
podivi...@chromium.org
Date
2011-11-29 04:46:34 -0800 (Tue, 29 Nov 2011)

Log Message

Web Inspector: support concatenated source maps.
https://bugs.webkit.org/show_bug.cgi?id=73138

Reviewed by Yury Semikhatsky.

Source/WebCore:

* inspector/front-end/CompilerSourceMapping.js:
(WebInspector.ClosureCompilerSourceMapping):
(WebInspector.ClosureCompilerSourceMapping.prototype.loadSourceCode):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseMappingPayload):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseSections):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseMap):
(WebInspector.ClosureCompilerSourceMapping.prototype._canonicalizeURL):
* inspector/front-end/inspector.js:
(WebInspector.installSourceMappingForTest):

LayoutTests:

* http/tests/inspector/compiler-source-mapping-expected.txt:
* http/tests/inspector/compiler-source-mapping.html:
* http/tests/inspector/resources/source-map.json:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101358 => 101359)


--- trunk/LayoutTests/ChangeLog	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/LayoutTests/ChangeLog	2011-11-29 12:46:34 UTC (rev 101359)
@@ -1,3 +1,14 @@
+2011-11-25  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: support concatenated source maps.
+        https://bugs.webkit.org/show_bug.cgi?id=73138
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/compiler-source-mapping-expected.txt:
+        * http/tests/inspector/compiler-source-mapping.html:
+        * http/tests/inspector/resources/source-map.json:
+
 2011-11-29  Nikolas Zimmermann  <nzimmerm...@rim.com>
 
         Not reviewed. Rebaseline Win SVG results after r101342.

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-expected.txt (101358 => 101359)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-expected.txt	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-expected.txt	2011-11-29 12:46:34 UTC (rev 101359)
@@ -7,5 +7,7 @@
 
 Running: testEmptyLine
 
+Running: testSections
+
 Running: testLoad
 

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html (101358 => 101359)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html	2011-11-29 12:46:34 UTC (rev 101359)
@@ -90,6 +90,32 @@
             next();
         },
 
+        function testSections(next)
+        {
+            var mappingPayload = {
+                "sections": [{
+                    "offset": { "line": 1, "column": 0 },
+                    "map": {
+                        "mappings":"AAAA,CAEC",
+                        "sources":["source1.js"]
+                    }
+                }, {
+                    "offset": { "line": 3, "column": 10 },
+                    "map": {
+                        "mappings":"AAAA,CAEC",
+                        "sources":["source2.js"]
+                    }
+                }
+            ]};
+            var mapping = new WebInspector.ClosureCompilerSourceMapping();
+            mapping._parseMappingPayload(mappingPayload);
+            checkMapping(0, 0, "source1.js", 0, 0, mapping);
+            checkMapping(0, 1, "source1.js", 2, 1, mapping);
+            checkMapping(2, 10, "source2.js", 0, 0, mapping);
+            checkMapping(2, 11, "source2.js", 2, 1, mapping);
+            next();
+        },
+
         function testLoad(next)
         {
             var sourceMapping = new WebInspector.ClosureCompilerSourceMapping("http://localhost:8000/inspector/resources/source-map.json");
@@ -98,8 +124,8 @@
 
             var sources = sourceMapping.sources();
             InspectorTest.assertEquals(2, sources.length);
-            InspectorTest.assertEquals("source1.js", sources[0]);
-            InspectorTest.assertEquals("source2.js", sources[1]);
+            InspectorTest.assertEquals("http://localhost:8000/inspector/resources/source1.js", sources[0]);
+            InspectorTest.assertEquals("http://localhost:8000/inspector/resources/source2.js", sources[1]);
 
             var sourceCode1 = sourceMapping.loadSourceCode(sourceMapping.sources()[0]);
             InspectorTest.assertEquals(0, sourceCode1.indexOf("window.addEventListener"));

Modified: trunk/LayoutTests/http/tests/inspector/resources/source-map.json (101358 => 101359)


--- trunk/LayoutTests/http/tests/inspector/resources/source-map.json	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/LayoutTests/http/tests/inspector/resources/source-map.json	2011-11-29 12:46:34 UTC (rev 101359)
@@ -1,6 +1,7 @@
 {
 "version":3,
 "file":"compiled.js",
+"sourceRoot": "http://localhost:8000/inspector/resources",
 "lineCount":2,
 "mappings":"AACAA,MAAAC,iBAAuB,CAAC,MAAD,CAAS,QAAQ,EACxC,CACI,IAAIC,EAASC,QAAAC,cAAsB,CAAC,QAAD,CACnCF,EAAAG,GAAA,CAAY,MACZH,EAAAD,iBAAuB,CAAC,OAAD,CAAUK,WAAV,CAAuB,CAAA,CAAvB,CACvBH,SAAAI,KAAAC,YAAyB,CAACN,CAAD,CAErBO,EAAAA,CAAMN,QAAAC,cAAsB,CAAC,KAAD,CAChCK,EAAAJ,GAAA,CAAS,ocACTF;QAAAI,KAAAC,YAAyB,CAACC,CAAD,CAR7B,CADuB,CAYvBH,SAASA,YAAW,CAACI,CAAD,CACpB,CAEIC,CAD8BC,IAAZC,YAClBF,QAAc,CAACD,CAAD,CAFlB,C,CCbAG,QAASA,aAAY,EACrB,EAGAA,YAAAC,UAAAH,OAAA,CAAgCI,QAAQ,EACxC,CACIC,OAAAC,IAAW,CAAC,iBAAD,CADf;",
 "sources":["source1.js","source2.js"],

Modified: trunk/Source/WebCore/ChangeLog (101358 => 101359)


--- trunk/Source/WebCore/ChangeLog	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/Source/WebCore/ChangeLog	2011-11-29 12:46:34 UTC (rev 101359)
@@ -1,3 +1,20 @@
+2011-11-25  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: support concatenated source maps.
+        https://bugs.webkit.org/show_bug.cgi?id=73138
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/CompilerSourceMapping.js:
+        (WebInspector.ClosureCompilerSourceMapping):
+        (WebInspector.ClosureCompilerSourceMapping.prototype.loadSourceCode):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parseMappingPayload):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parseSections):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parseMap):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._canonicalizeURL):
+        * inspector/front-end/inspector.js:
+        (WebInspector.installSourceMappingForTest):
+
 2011-11-29  Mario Sanchez Prada  <msanc...@igalia.com>
 
         [Gtk] Regression: text-inserted events lack text inserted and current line

Modified: trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js (101358 => 101359)


--- trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-11-29 12:46:34 UTC (rev 101359)
@@ -82,6 +82,9 @@
     }
 
     this._sourceMappingURL = sourceMappingURL;
+    this._sources = [];
+    this._mappings = [];
+    this._reverseMappingsBySourceURL = {};
 }
 
 WebInspector.ClosureCompilerSourceMapping.prototype = {
@@ -137,11 +140,8 @@
     loadSourceCode: function(sourceURL)
     {
         try {
-            var rootURL = this._sourceMappingURL.substring(0, this._sourceMappingURL.lastIndexOf("/") + 1);
-            if (this._sourceRoot)
-                rootURL += this._sourceRoot + "/";
             // FIXME: make sendRequest async.
-            return InspectorFrontendHost.loadResourceSynchronously(rootURL + sourceURL);
+            return InspectorFrontendHost.loadResourceSynchronously(sourceURL);
         } catch(e) {
             console.error(e.message);
             return "";
@@ -168,24 +168,35 @@
 
     _parseMappingPayload: function(mappingPayload)
     {
-        this._sourceRoot = mappingPayload.sourceRoot;
-        this._sources = mappingPayload.sources;
+        if (mappingPayload.sections)
+            this._parseSections(mappingPayload.sections);
+        else
+            this._parseMap(mappingPayload, 0, 0);
+    },
 
-        this._mappings = [];
-        this._reverseMappingsBySourceURL = {};
-        for (var i = 0; i < this._sources.length; ++i)
-            this._reverseMappingsBySourceURL[this._sources[i]] = [];
+    _parseSections: function(sections)
+    {
+        for (var i = 0; i < sections.length; ++i) {
+            var section = sections[i];
+            this._parseMap(section.map, section.offset.line - 1, section.offset.column)
+        }
+    },
 
-        var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(mappingPayload.mappings);
-
-        var lineNumber = 0;
-        var columnNumber = 0;
-        var sourceIndex = 0;
+    _parseMap: function(map, lineNumber, columnNumber)
+    {
+        var sourceIndex = this._sources.length;
         var sourceLineNumber = 0;
         var sourceColumnNumber = 0;
         var nameIndex = 0;
 
-        var sourceURL = this._sources[0];
+        for (var i = 0; i < map.sources.length; ++i) {
+            var url = "" map.sources[i]);
+            this._sources.push(url);
+            this._reverseMappingsBySourceURL[url] = [];
+        }
+
+        var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(map.mappings);
+        var sourceURL = this._sources[sourceIndex];
         var reverseMappings = this._reverseMappingsBySourceURL[sourceURL];
 
         while (true) {
@@ -243,6 +254,11 @@
         return negative ? -result : result;
     },
 
+    _canonicalizeURL: function(sourceRoot, sourceURL)
+    {
+        return sourceRoot ? sourceRoot + "/" + sourceURL : sourceURL;
+    },
+
     _VLQ_BASE_SHIFT: 5,
     _VLQ_BASE_MASK: (1 << 5) - 1,
     _VLQ_CONTINUATION_MASK: 1 << 5

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (101358 => 101359)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2011-11-29 12:40:45 UTC (rev 101358)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2011-11-29 12:46:34 UTC (rev 101359)
@@ -866,6 +866,6 @@
 {
     // FIXME: remove this method when it's possible to set compiler source mappings via UI.
     var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(url);
-    var uiSourceCode = WebInspector.panels.scripts.visibleView._delegate._uiSourceCode;
+    var uiSourceCode = WebInspector.panels.scripts.visibleView._uiSourceCode;
     uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to