Web Inspector: add compiler source mapping support to RawSourceCode.
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 12:32:51 +0000 (12:32 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 12:32:51 +0000 (12:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68891

Reviewed by Pavel Feldman.

Source/WebCore:

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/BreakpointManager.js:
(WebInspector.BreakpointManager.prototype.uiSourceCodeAdded):
(WebInspector.BreakpointManager.prototype.setBreakpoint):
(WebInspector.BreakpointManager.prototype._materializeBreakpoint):
* inspector/front-end/CompilerSourceMappingProvider.js: Added.
(WebInspector.CompilerSourceMappingProvider):
(WebInspector.CompilerSourceMappingProvider.prototype.loadSourceMapping):
(WebInspector.CompilerSourceMappingProvider.prototype.loadSourceCode):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.continueToLine):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype.setCompilerSourceMappingProvider):
(WebInspector.RawSourceCode.prototype._resourceFinished):
(WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping):
(WebInspector.RawSourceCode.prototype._updateSourceMapping):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didLoadSourceMapping):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.CompilerSourceMapping):
(WebInspector.RawSourceCode.CompilerSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.CompilerSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.CompilerSourceMapping.prototype.get uiSourceCodeList):
(WebInspector.CompilerSourceMappingProvider):
(WebInspector.CompilerSourceMappingProvider.prototype.loadSourceMapping):
(WebInspector.CompilerSourceMappingProvider.prototype.loadSourceCode):
* inspector/front-end/UISourceCodeContentProviders.js:
(WebInspector.CompilerSourceMappingContentProvider):
(WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:

LayoutTests:

* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/raw-source-code-expected.txt:
* inspector/debugger/raw-source-code.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96585 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/debugger/breakpoint-manager.html
LayoutTests/inspector/debugger/raw-source-code-expected.txt
LayoutTests/inspector/debugger/raw-source-code.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/inspector/front-end/BreakpointManager.js
Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js [new file with mode: 0644]
Source/WebCore/inspector/front-end/ContentProviders.js
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
Source/WebCore/inspector/front-end/RawSourceCode.js
Source/WebCore/inspector/front-end/WebKit.qrc
Source/WebCore/inspector/front-end/inspector.html

index fcc58b7..7361181 100644 (file)
@@ -1,3 +1,14 @@
+2011-09-29  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: add compiler source mapping support to RawSourceCode.
+        https://bugs.webkit.org/show_bug.cgi?id=68891
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/debugger/breakpoint-manager.html:
+        * inspector/debugger/raw-source-code-expected.txt:
+        * inspector/debugger/raw-source-code.html:
+
 2011-10-04  Hans Wennborg  <hans@chromium.org>
 
         [Chromium] Update expectations for svg/W3C-SVG-1.1/pservers-grad-06-b.svg
index 8255072..8cc864e 100644 (file)
@@ -69,10 +69,10 @@ function test()
 
     var uiSourceCodeA = createUISourceCode("a.js", "a.js",
             function(rawLocation) { return rawLocation; },
-            function(lineNumber, columnNumber) { return { scriptId: "a.js", lineNumber: lineNumber, columnNumber: columnNumber }; });
+            function(uiSourceCode, lineNumber) { return { scriptId: "a.js", lineNumber: lineNumber, columnNumber: 0 }; });
     var uiSourceCodeB = createUISourceCode("b.js", "b.js",
             function(rawLocation) { return rawLocation; },
-            function(lineNumber, columnNumber) { return { scriptId: "b.js", lineNumber: lineNumber, columnNumber: columnNumber }; });
+            function(uiSourceCode, lineNumber) { return { scriptId: "b.js", lineNumber: lineNumber, columnNumber: 0 }; });
 
     function createBreakpointManager(breakpoints)
     {
@@ -205,10 +205,10 @@ function test()
             var breakpointManager = createBreakpointManager([createBreakpoint("c.js", 4, "", true)]);
             var uiSourceCodeC = createUISourceCode("c.js", "c.js",
                     function(rawLocation) { return rawLocation; },
-                    function(lineNumber, columnNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: columnNumber }; });
+                    function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: 0 }; });
             var uiSourceCodeCFormatted = createUISourceCode("deobfuscated:c.js", "c.js",
                     function(rawLocation) { return { lineNumber: rawLocation.lineNumber * 2, columnNumber: rawLocation.columnNumber * 2 }; },
-                    function(lineNumber, columnNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: Math.floor(columnNumber / 2) }; });
+                    function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 }; });
 
             breakpointManager.uiSourceCodeAdded(uiSourceCodeC);
             setTimeout(format, 0);
index aec3921..bbcd04f 100644 (file)
@@ -15,3 +15,5 @@ Running: testFormattingWithFinishedResource
 
 Running: testFormattingWithPendingResource
 
+Running: testCompilerSourceMapping
+
index 56999de..cfc755a 100644 (file)
@@ -111,7 +111,7 @@ function test()
             InspectorTest.assertEquals(true, uiSourceCode.isContentScript);
             InspectorTest.assertEquals(rawSourceCode, uiSourceCode.rawSourceCode);
             checkUILocation(uiSourceCode, 0, 5, sourceMapping.rawLocationToUILocation(createRawLocation(0, 5)));
-            checkRawLocation(script, 0, 10, sourceMapping.uiLocationToRawLocation(0, 10));
+            checkRawLocation(script, 10, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 10));
             uiSourceCode.requestContent(didRequestContent);
 
             function didRequestContent(mimeType, content)
@@ -174,8 +174,8 @@ function test()
                 rawSourceCode.addScript(script2);
                 rawSourceCode.forceUpdateSourceMapping();
                 checkUILocation(uiSourceCode, 1, 20, sourceMapping.rawLocationToUILocation(createRawLocation(1, 20)));
-                checkRawLocation(script1, 1, 20, sourceMapping.uiLocationToRawLocation(1, 20));
-                checkRawLocation(script2, 6, 2, sourceMapping.uiLocationToRawLocation(6, 2));
+                checkRawLocation(script1, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 1));
+                checkRawLocation(script2, 6, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 6));
 
                 next();
             }
@@ -283,7 +283,7 @@ function test()
             var sourceMapping = rawSourceCode.sourceMapping;
             var uiSourceCode = sourceMapping.uiSourceCode;
             checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
-            checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(1, 2));
+            checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
             uiSourceCode.requestContent(didRequestContent);
 
             function didRequestContent(mimeType, content)
@@ -301,7 +301,7 @@ function test()
                 var sourceMapping = rawSourceCode.sourceMapping;
                 var uiSourceCode = sourceMapping.uiSourceCode;
                 checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
-                checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(2, 4));
+                checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
                 uiSourceCode.requestContent(didRequestFormattedContent);
             }
 
@@ -319,7 +319,7 @@ function test()
                 var sourceMapping = rawSourceCode.sourceMapping;
                 var uiSourceCode = sourceMapping.uiSourceCode;
                 checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
-                checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(1, 2));
+                checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
                 uiSourceCode.requestContent(didRequestNotFormattedContent);
             }
 
@@ -348,7 +348,72 @@ function test()
                 var sourceMapping = rawSourceCode.sourceMapping;
                 var uiSourceCode = sourceMapping.uiSourceCode;
                 checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
-                checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(2, 4));
+                checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
+                next();
+            }
+        },
+
+        function testCompilerSourceMapping(next)
+        {
+            function createCompilerSourceMappingMock()
+            {
+                return {
+                    compiledLocationToSourceLocation: function(lineNumber, columnNumber)
+                    {
+                        if (lineNumber < 10)
+                            return { sourceURL: "source1.js", lineNumber: lineNumber * 2, columnNumber: columnNumber * 2 };
+                        return { sourceURL: "source2.js", lineNumber: (lineNumber - 10) * 2, columnNumber: columnNumber * 2 };
+                    },
+                    sourceLocationToCompiledLocation: function(sourceURL, lineNumber)
+                    {
+                        if (sourceURL === "source1.js")
+                            return { lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 };
+                        return { lineNumber: Math.floor(lineNumber / 2) + 10, columnNumber: 0 };
+                    },
+                    sources: function() { return ["source1.js", "source2.js"]; }
+                };
+            }
+            function createCompilerSourceMappingProviderMock()
+            {
+                return {
+                    loadSourceMapping: function(callback) { callback(createCompilerSourceMappingMock()); },
+                    loadSourceCode: function(url, callback) { callback("<content of " + url + ">"); }
+                }
+            }
+
+            var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
+            var resource = createPendingResourceMock("script", "<resource content>");
+            var rawSourceCode = createRawSourceCode(script, resource);
+            var uiSourceCodeList;
+
+            waitForSourceMappingEvent(rawSourceCode, checkMapping);
+            rawSourceCode.setCompilerSourceMappingProvider(createCompilerSourceMappingProviderMock());
+            function checkMapping()
+            {
+                var sourceMapping = rawSourceCode.sourceMapping;
+                uiSourceCodeList = sourceMapping.uiSourceCodeList;
+                var uiSourceCodeByURL = {};
+                for (var i = 0; i < uiSourceCodeList.length; ++i)
+                    uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
+                checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
+                checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20)));
+                checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2));
+                checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10));
+
+                uiSourceCodeList[0].requestContent(didRequestContent1);
+            }
+
+            function didRequestContent1(mimeType, content)
+            {
+                InspectorTest.assertEquals("text/javascript", mimeType);
+                InspectorTest.assertEquals("<content of source1.js>", content);
+                uiSourceCodeList[1].requestContent(didRequestContent2);
+            }
+
+            function didRequestContent2(mimeType, content)
+            {
+                InspectorTest.assertEquals("text/javascript", mimeType);
+                InspectorTest.assertEquals("<content of source2.js>", content);
                 next();
             }
         }
index 889c95c..c00f371 100644 (file)
@@ -1,3 +1,43 @@
+2011-09-29  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: add compiler source mapping support to RawSourceCode.
+        https://bugs.webkit.org/show_bug.cgi?id=68891
+
+        Reviewed by Pavel Feldman.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/BreakpointManager.js:
+        (WebInspector.BreakpointManager.prototype.uiSourceCodeAdded):
+        (WebInspector.BreakpointManager.prototype.setBreakpoint):
+        (WebInspector.BreakpointManager.prototype._materializeBreakpoint):
+        * inspector/front-end/CompilerSourceMappingProvider.js: Added.
+        (WebInspector.CompilerSourceMappingProvider):
+        (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceMapping):
+        (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceCode):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype.continueToLine):
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode.prototype.setCompilerSourceMappingProvider):
+        (WebInspector.RawSourceCode.prototype._resourceFinished):
+        (WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping):
+        (WebInspector.RawSourceCode.prototype._updateSourceMapping):
+        (WebInspector.RawSourceCode.prototype._createSourceMapping.didLoadSourceMapping):
+        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.CompilerSourceMapping):
+        (WebInspector.RawSourceCode.CompilerSourceMapping.prototype.rawLocationToUILocation):
+        (WebInspector.RawSourceCode.CompilerSourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.CompilerSourceMapping.prototype.get uiSourceCodeList):
+        (WebInspector.CompilerSourceMappingProvider):
+        (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceMapping):
+        (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceCode):
+        * inspector/front-end/UISourceCodeContentProviders.js:
+        (WebInspector.CompilerSourceMappingContentProvider):
+        (WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2011-10-04  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: start adding UI components to the compilation process.
index 79d9b1e..b7f1a60 100644 (file)
             'inspector/front-end/Checkbox.js',
             'inspector/front-end/Color.js',
             'inspector/front-end/CompilerSourceMapping.js',
+            'inspector/front-end/CompilerSourceMappingProvider.js',
             'inspector/front-end/ConsoleMessage.js',
             'inspector/front-end/ConsoleModel.js',
             'inspector/front-end/ConsolePanel.js',
index 0327d00..fb2b73c 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\CompilerSourceMappingProvider.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\ConsoleMessage.js"
                                        >
                                </File>
index 7cb1171..c8498fe 100644 (file)
@@ -57,7 +57,7 @@ WebInspector.BreakpointManager.prototype = {
         for (var lineNumber in breakpoints) {
             var breakpoint = breakpoints[lineNumber];
             breakpoint.uiSourceCode = uiSourceCode;
-            this._materializeBreakpoint(breakpoint);
+            this._materializeBreakpoint(breakpoint, uiSourceCode.rawSourceCode.sourceMapping, uiSourceCode);
             if (breakpoint._debuggerLocation)
                 this._breakpointDebuggerLocationChanged(breakpoint);
         }
@@ -77,7 +77,7 @@ WebInspector.BreakpointManager.prototype = {
         var breakpoint = new WebInspector.Breakpoint(uiSourceCode.id, lineNumber, condition, enabled, persistent);
         breakpoint.uiSourceCode = uiSourceCode;
         this._addBreakpointToUI(breakpoint);
-        this._materializeBreakpoint(breakpoint);
+        this._materializeBreakpoint(breakpoint, uiSourceCode.rawSourceCode.sourceMapping, uiSourceCode);
     },
 
     removeBreakpoint: function(uiSourceCode, lineNumber)
@@ -89,13 +89,13 @@ WebInspector.BreakpointManager.prototype = {
         this._removeBreakpointFromDebugger(breakpoint);
     },
 
-    _materializeBreakpoint: function(breakpoint)
+    _materializeBreakpoint: function(breakpoint, sourceMapping, uiSourceCode)
     {
         if (!breakpoint.enabled || breakpoint._materialized)
             return;
 
         breakpoint._materialized = true;
-        var rawLocation = breakpoint.uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(breakpoint.lineNumber, 0);
+        var rawLocation = sourceMapping.uiLocationToRawLocation(uiSourceCode, breakpoint.lineNumber);
         this._setBreakpointInDebugger(breakpoint, rawLocation);
     },
 
diff --git a/Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js b/Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js
new file mode 100644 (file)
index 0000000..ba74c33
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ */
+WebInspector.CompilerSourceMappingProvider = function()
+{
+}
+
+WebInspector.CompilerSourceMappingProvider.prototype = {
+    loadSourceMapping: function(callback)
+    {
+        // FIXME: load the map from source map server.
+    },
+
+    loadSourceCode: function(sourceURL, callback)
+    {
+        // FIXME: load source code from source map server.
+    }
+}
index d8048fe..317b069 100644 (file)
@@ -162,6 +162,30 @@ WebInspector.ResourceContentProvider.prototype.__proto__ = WebInspector.ContentP
  * @constructor
  * @implements {WebInspector.ContentProvider}
  */
+WebInspector.CompilerSourceMappingContentProvider = function(sourceURL, compilerSourceMappingProvider)
+{
+    this._mimeType = "text/javascript";
+    this._sourceURL = sourceURL;
+    this._compilerSourceMappingProvider = compilerSourceMappingProvider;
+};
+
+WebInspector.CompilerSourceMappingContentProvider.prototype = {
+    requestContent: function(callback)
+    {
+        function didLoadSourceCode(sourceCode)
+        {
+            callback(this._mimeType, sourceCode);
+        }
+        this._compilerSourceMappingProvider.loadSourceCode(this._sourceURL, didLoadSourceCode.bind(this));
+    }
+}
+
+WebInspector.CompilerSourceMappingContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
+
+/**
+ * @constructor
+ * @implements {WebInspector.ContentProvider}
+ */
 WebInspector.StaticContentProvider = function(mimeType, content)
 {
     this._mimeType = mimeType;
index 5530883..b87a90d 100644 (file)
@@ -283,7 +283,8 @@ WebInspector.DebuggerPresentationModel.prototype = {
 
     continueToLine: function(uiSourceCode, lineNumber)
     {
-        var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(lineNumber, 0);
+        // FIXME: use RawSourceCode.uiLocationToRawLocation.
+        var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber);
         WebInspector.debuggerModel.continueToLocation(rawLocation);
     },
 
index cb4e513..41a90d0 100644 (file)
@@ -78,6 +78,14 @@ WebInspector.RawSourceCode.prototype = {
         this._updateSourceMapping();
     },
 
+    setCompilerSourceMappingProvider: function(provider)
+    {
+        if (provider)
+            this._useTemporaryContent = false;
+        this._compilerSourceMappingProvider = provider;
+        this._updateSourceMapping();
+    },
+
     contentEdited: function()
     {
         this._updateSourceMapping();
@@ -85,6 +93,8 @@ WebInspector.RawSourceCode.prototype = {
 
     _resourceFinished: function()
     {
+        if (this._compilerSourceMappingProvider)
+            return;
         this._useTemporaryContent = false;
         this._updateSourceMapping();
     },
@@ -120,14 +130,13 @@ WebInspector.RawSourceCode.prototype = {
         this._updatingSourceMapping = true;
         this._updateNeeded = false;
 
-        var originalContentProvider = this._createContentProvider();
-        this._createSourceMapping(originalContentProvider, didCreateSourceMapping.bind(this));
+        this._createSourceMapping(didCreateSourceMapping.bind(this));
 
-        function didCreateSourceMapping(contentProvider, mapping)
+        function didCreateSourceMapping(sourceMapping)
         {
             this._updatingSourceMapping = false;
             if (!this._updateNeeded)
-                this._saveSourceMapping(contentProvider, mapping);
+                this._saveSourceMapping(sourceMapping);
             else
                 this._updateSourceMapping();
         }
@@ -142,8 +151,27 @@ WebInspector.RawSourceCode.prototype = {
         return new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
     },
 
-    _createSourceMapping: function(originalContentProvider, callback)
+    _createSourceMapping: function(callback)
     {
+        if (this._compilerSourceMappingProvider) {
+            function didLoadSourceMapping(compilerSourceMapping)
+            {
+                var uiSourceCodeList = [];
+                var sourceURLs = compilerSourceMapping.sources();
+                for (var i = 0; i < sourceURLs.length; ++i) {
+                    var sourceURL = sourceURLs[i];
+                    var contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL, this._compilerSourceMappingProvider);
+                    var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, this.isContentScript, this, contentProvider);
+                    uiSourceCodeList.push(uiSourceCode);
+                }
+                var sourceMapping = new WebInspector.RawSourceCode.CompilerSourceMapping(this, uiSourceCodeList, compilerSourceMapping);
+                callback(sourceMapping);
+            }
+            this._compilerSourceMappingProvider.loadSourceMapping(didLoadSourceMapping.bind(this));
+            return;
+        }
+
+        var originalContentProvider = this._createContentProvider();
         if (!this._formatted) {
             var uiSourceCode = new WebInspector.UISourceCode(this.id, this.url, this.isContentScript, this, originalContentProvider);
             var sourceMapping = new WebInspector.RawSourceCode.PlainSourceMapping(this, uiSourceCode);
@@ -193,9 +221,10 @@ WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
         return new WebInspector.UILocation(this._uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
     },
 
-    uiLocationToRawLocation: function(lineNumber, columnNumber)
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber)
     {
-        var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
+        console.assert(uiSourceCode === this._uiSourceCode);
+        var rawLocation = { lineNumber: lineNumber, columnNumber: 0 };
         rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
         return rawLocation;
     },
@@ -223,9 +252,10 @@ WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
         return new WebInspector.UILocation(this._uiSourceCode, location.lineNumber, location.columnNumber);
     },
 
-    uiLocationToRawLocation: function(lineNumber, columnNumber)
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber)
     {
-        var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: columnNumber });
+        console.assert(uiSourceCode === this._uiSourceCode);
+        var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: 0 });
         rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
         return rawLocation;
     },
@@ -239,6 +269,40 @@ WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
 /**
  * @constructor
  */
+WebInspector.RawSourceCode.CompilerSourceMapping = function(rawSourceCode, uiSourceCodeList, mapping)
+{
+    this._rawSourceCode = rawSourceCode;
+    this._uiSourceCodeList = uiSourceCodeList;
+    this._mapping = mapping;
+    this._uiSourceCodeByURL = {};
+    for (var i = 0; i < uiSourceCodeList.length; ++i)
+        this._uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
+}
+
+WebInspector.RawSourceCode.CompilerSourceMapping.prototype = {
+    rawLocationToUILocation: function(rawLocation)
+    {
+        var location = this._mapping.compiledLocationToSourceLocation(rawLocation.lineNumber, rawLocation.columnNumber);
+        var uiSourceCode = this._uiSourceCodeByURL[location.sourceURL];
+        return new WebInspector.UILocation(uiSourceCode, location.lineNumber, location.columnNumber);
+    },
+
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber)
+    {
+        var rawLocation = this._mapping.sourceLocationToCompiledLocation(uiSourceCode.url, lineNumber);
+        rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
+        return rawLocation;
+    },
+
+    get uiSourceCodeList()
+    {
+        return this._uiSourceCodeList;
+    }
+}
+
+/**
+ * @constructor
+ */
 WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber)
 {
     this.uiSourceCode = uiSourceCode;
index d5bf9eb..8c634f5 100644 (file)
@@ -16,6 +16,7 @@
     <file>Checkbox.js</file>
     <file>Color.js</file>
     <file>CompilerSourceMapping.js</file>
+    <file>CompilerSourceMappingProvider.js</file>
     <file>ConsoleMessage.js</file>
     <file>ConsoleModel.js</file>
     <file>ConsolePanel.js</file>
index b50a1b3..399be99 100644 (file)
@@ -164,6 +164,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="ContentProviders.js"></script>
     <script type="text/javascript" src="RawSourceCode.js"></script>
     <script type="text/javascript" src="CompilerSourceMapping.js"></script>
+    <script type="text/javascript" src="CompilerSourceMappingProvider.js"></script>
     <script type="text/javascript" src="DOMAgent.js"></script>
     <script type="text/javascript" src="TimelineAgent.js"></script>
     <script type="text/javascript" src="TimelinePanel.js"></script>