Title: [128061] trunk
Revision
128061
Author
podivi...@chromium.org
Date
2012-09-10 07:50:39 -0700 (Mon, 10 Sep 2012)

Log Message

Web Inspector: support empty entries in source maps.
https://bugs.webkit.org/show_bug.cgi?id=96088

Reviewed by Vsevolod Vlasov.

Empty entries should be mapped to the compiled script.

Source/WebCore:

* inspector/front-end/CompilerScriptMapping.js:
(WebInspector.CompilerScriptMapping):
(WebInspector.CompilerScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.CompilerScriptMapping.prototype._reset):
(WebInspector.SourceMapParser.prototype._parseMap):

LayoutTests:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128060 => 128061)


--- trunk/LayoutTests/ChangeLog	2012-09-10 14:38:00 UTC (rev 128060)
+++ trunk/LayoutTests/ChangeLog	2012-09-10 14:50:39 UTC (rev 128061)
@@ -1,3 +1,15 @@
+2012-09-10  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: support empty entries in source maps.
+        https://bugs.webkit.org/show_bug.cgi?id=96088
+
+        Reviewed by Vsevolod Vlasov.
+
+        Empty entries should be mapped to the compiled script.
+
+        * http/tests/inspector/compiler-script-mapping.html:
+        * http/tests/inspector/resources/source-map.json:
+
 2012-09-10  Dan Bernstein  <m...@apple.com>
 
         REGRESSION (r128006): Three spatial navigation tests are failing

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


--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2012-09-10 14:38:00 UTC (rev 128060)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2012-09-10 14:50:39 UTC (rev 128061)
@@ -71,6 +71,8 @@
             };
             var mapping = new WebInspector.SourceMapParser("source-map.json", mappingPayload);
             checkMapping(0, 0, "example.js", 0, 0, mapping);
+            var entry = mapping.findEntry(0, 1);
+            InspectorTest.assertEquals(2, entry.length);
             checkMapping(0, 2, "example.js", 0, 2, mapping);
             next();
         },
@@ -131,25 +133,25 @@
             script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
             mapping.addScript(script);
 
-            var uiSourceCodeList = mapping.uiSourceCodes();
-            InspectorTest.assertEquals(2, uiSourceCodeList.length);
-            InspectorTest.assertEquals("http://localhost:8000/inspector/resources/source1.js", uiSourceCodeList[0].url);
-            InspectorTest.assertEquals("http://localhost:8000/inspector/resources/source2.js", uiSourceCodeList[1].url);
+            var uiSourceCode1 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source1.js"];
+            var uiSourceCode2 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source2.js"];
+            var originalUISourceCode = mapping._originalUISourceCodeForScriptId[script.scriptId];
 
-            InspectorTest.checkUILocation(uiSourceCodeList[0], 4, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 81)));
-            InspectorTest.checkUILocation(uiSourceCodeList[0], 5, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 93)));
-            InspectorTest.checkUILocation(uiSourceCodeList[1], 7, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 1, 151)));
+            InspectorTest.checkUILocation(uiSourceCode1, 4, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 81)));
+            InspectorTest.checkUILocation(uiSourceCode1, 5, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 93)));
+            InspectorTest.checkUILocation(uiSourceCode2, 7, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 1, 151)));
+            InspectorTest.checkUILocation(originalUISourceCode, 1, 200, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 1, 200)));
 
-            InspectorTest.checkRawLocation(script, 0, 42, mapping.uiLocationToRawLocation(uiSourceCodeList[0], 3, 10));
-            InspectorTest.checkRawLocation(script, 1, 85, mapping.uiLocationToRawLocation(uiSourceCodeList[1], 0, 0));
-            InspectorTest.checkRawLocation(script, 1, 110, mapping.uiLocationToRawLocation(uiSourceCodeList[1], 5, 2));
+            InspectorTest.checkRawLocation(script, 0, 42, mapping.uiLocationToRawLocation(uiSourceCode1, 3, 10));
+            InspectorTest.checkRawLocation(script, 1, 85, mapping.uiLocationToRawLocation(uiSourceCode2, 0, 0));
+            InspectorTest.checkRawLocation(script, 1, 110, mapping.uiLocationToRawLocation(uiSourceCode2, 5, 2));
 
-            uiSourceCodeList[0].requestContent(didRequestContent1);
+            uiSourceCode1.requestContent(didRequestContent1);
 
             function didRequestContent1(content, contentEncoded, mimeType)
             {
                 InspectorTest.assertEquals(0, content.indexOf("window.addEventListener"));
-                uiSourceCodeList[1].requestContent(didRequestContent2);
+                uiSourceCode2.requestContent(didRequestContent2);
             }
 
             function didRequestContent2(content, contentEncoded, mimeType)
@@ -174,14 +176,12 @@
             script.sourceMapURL = "data:application/json;base64," + btoa(JSON.stringify(sourceMap));
             mapping.addScript(script);
 
-            var uiSourceCodeList = mapping.uiSourceCodes();
-            InspectorTest.assertEquals(1, uiSourceCodeList.length);
-            InspectorTest.assertEquals("source.js", uiSourceCodeList[0].url);
+            var uiSourceCode = mapping._uiSourceCodeByURL["source.js"];
 
-            InspectorTest.checkUILocation(uiSourceCodeList[0], 2, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 18)));
-            InspectorTest.checkRawLocation(script, 0, 18, mapping.uiLocationToRawLocation(uiSourceCodeList[0], 2, 4));
+            InspectorTest.checkUILocation(uiSourceCode, 2, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 18)));
+            InspectorTest.checkRawLocation(script, 0, 18, mapping.uiLocationToRawLocation(uiSourceCode, 2, 4));
 
-            uiSourceCodeList[0].requestContent(didRequestContent);
+            uiSourceCode.requestContent(didRequestContent);
 
             function didRequestContent(content, contentEncoded, mimeType)
             {

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


--- trunk/LayoutTests/http/tests/inspector/resources/source-map.json	2012-09-10 14:38:00 UTC (rev 128060)
+++ trunk/LayoutTests/http/tests/inspector/resources/source-map.json	2012-09-10 14:50:39 UTC (rev 128061)
@@ -3,7 +3,7 @@
 "file":"compiled.js",
 "sourceRoot": "",
 "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;",
+"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,C;",
 "sources":["source1.js","source2.js"],
 "names":["window","addEventListener","button","document","createElement","id","handleClick","body","appendChild","bar","event","handle","handler","ClickHandler","prototype","ClickHandler.prototype.handle","console","log"]
 }

Modified: trunk/Source/WebCore/ChangeLog (128060 => 128061)


--- trunk/Source/WebCore/ChangeLog	2012-09-10 14:38:00 UTC (rev 128060)
+++ trunk/Source/WebCore/ChangeLog	2012-09-10 14:50:39 UTC (rev 128061)
@@ -1,3 +1,18 @@
+2012-09-10  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: support empty entries in source maps.
+        https://bugs.webkit.org/show_bug.cgi?id=96088
+
+        Reviewed by Vsevolod Vlasov.
+
+        Empty entries should be mapped to the compiled script.
+
+        * inspector/front-end/CompilerScriptMapping.js:
+        (WebInspector.CompilerScriptMapping):
+        (WebInspector.CompilerScriptMapping.prototype.rawLocationToUILocation):
+        (WebInspector.CompilerScriptMapping.prototype._reset):
+        (WebInspector.SourceMapParser.prototype._parseMap):
+
 2012-09-07  Andrey Kosyakov  <ca...@chromium.org>
 
         Web Inspector: only display heap size statistics for timeline records when it makes sense

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


--- trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-09-10 14:38:00 UTC (rev 128060)
+++ trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2012-09-10 14:50:39 UTC (rev 128061)
@@ -41,6 +41,8 @@
     this._scriptForSourceMap = new Map();
     this._sourceMapForUISourceCode = new Map();
     this._uiSourceCodeByURL = {};
+    this._originalUISourceCodeForScriptId = {};
+    this._scriptForOriginalUISource = new Map();
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
 }
 
@@ -53,7 +55,11 @@
     {
         var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ rawLocation;
         var sourceMap = this._sourceMapForScriptId[debuggerModelLocation.scriptId];
-        var entry = sourceMap.findEntry(debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0);
+        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]);
     },
 
@@ -65,45 +71,28 @@
      */
     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
     {
+        var script = this._scriptForOriginalUISource.get(uiSourceCode);
+        if (script)
+            return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber);
         var sourceMap = this._sourceMapForUISourceCode.get(uiSourceCode);
         var entry = sourceMap.findEntryReversed(uiSourceCode.url, lineNumber);
         return WebInspector.debuggerModel.createRawLocation(this._scriptForSourceMap.get(sourceMap), entry[0], entry[1]);
     },
 
     /**
-     * @return {Array.<WebInspector.UISourceCode>}
-     */
-    uiSourceCodes: function()
-    {
-        var result = [];
-        for (var url in this._uiSourceCodeByURL)
-            result.push(this._uiSourceCodeByURL[url]);
-        return result;
-    },
-    
-    /**
-     * @param {WebInspector.SourceMapParser} sourceMap
-     * @return {Array.<WebInspector.UISourceCode>}
-     */
-    _uiSourceCodesForSourceMap: function(sourceMap)
-    {
-        var result = []
-        var sourceURLs = sourceMap.sources();
-        for (var i = 0; i < sourceURLs.length; ++i)
-            result.push(this._uiSourceCodeByURL[sourceURLs[i]]);
-        return result;
-    },
-
-    /**
      * @param {WebInspector.Script} script
      */
     addScript: function(script)
     {
+        var originalUISourceCode = new WebInspector._javascript_Source(script.sourceURL, null, script, this, true);
+        this._originalUISourceCodeForScriptId[script.scriptId] = originalUISourceCode;
+        this._scriptForOriginalUISource.put(originalUISourceCode, script);
+        this._workspace.project().addUISourceCode(originalUISourceCode);
+
         var sourceMap = this.loadSourceMapForScript(script);
 
         if (this._scriptForSourceMap.get(sourceMap)) {
             this._sourceMapForScriptId[script.scriptId] = sourceMap;
-            var uiSourceCodes = this._uiSourceCodesForSourceMap(sourceMap);
             script.setSourceMapping(this);
             return;
         }
@@ -169,6 +158,8 @@
         this._scriptForSourceMap = new Map();
         this._sourceMapForUISourceCode = new Map();
         this._uiSourceCodeByURL = {};
+        this._originalUISourceCodeForScriptId = {};
+        this._scriptForOriginalUISource = new Map();
     }
 }
 
@@ -314,22 +305,25 @@
             }
 
             columnNumber += this._decodeVLQ(stringCharIterator);
-            if (!this._isSeparator(stringCharIterator.peek())) {
-                var sourceIndexDelta = this._decodeVLQ(stringCharIterator);
-                if (sourceIndexDelta) {
-                    sourceIndex += sourceIndexDelta;
-                    sourceURL = sources[sourceIndex];
-                    reverseMappings = this._reverseMappingsBySourceURL[sourceURL];
-                }
-                sourceLineNumber += this._decodeVLQ(stringCharIterator);
-                sourceColumnNumber += this._decodeVLQ(stringCharIterator);
-                if (!this._isSeparator(stringCharIterator.peek()))
-                    nameIndex += this._decodeVLQ(stringCharIterator);
+            if (this._isSeparator(stringCharIterator.peek())) {
+                this._mappings.push([lineNumber, columnNumber]);
+                continue;
+            }
 
-                this._mappings.push([lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber]);
-                if (!reverseMappings[sourceLineNumber])
-                    reverseMappings[sourceLineNumber] = [lineNumber, columnNumber];
+            var sourceIndexDelta = this._decodeVLQ(stringCharIterator);
+            if (sourceIndexDelta) {
+                sourceIndex += sourceIndexDelta;
+                sourceURL = sources[sourceIndex];
+                reverseMappings = this._reverseMappingsBySourceURL[sourceURL];
             }
+            sourceLineNumber += this._decodeVLQ(stringCharIterator);
+            sourceColumnNumber += this._decodeVLQ(stringCharIterator);
+            if (!this._isSeparator(stringCharIterator.peek()))
+                nameIndex += this._decodeVLQ(stringCharIterator);
+
+            this._mappings.push([lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber]);
+            if (!reverseMappings[sourceLineNumber])
+                reverseMappings[sourceLineNumber] = [lineNumber, columnNumber];
         }
     },
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to