Web Inspector: get rid of RawSourceCode.createSourceMappingIfNeeded.
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Sep 2011 16:38:22 +0000 (16:38 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Sep 2011 16:38:22 +0000 (16:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67717

Source/WebCore:

Listen to SourceMappingUpdated event instead of using createSourceMappingIfNeeded.

Reviewed by Yury Semikhatsky.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor):
(WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
(WebInspector.DebuggerPresentationModel.prototype._updateSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
(WebInspector.DebuggerPresentationModel.prototype._restoreConsoleMessages):
(WebInspector.DebuggerPresentationModel.prototype.setFormatSource):
(WebInspector.DebuggerPresentationModel.prototype._consoleMessageAdded):
(WebInspector.DebuggerPresentationModel.prototype._createPresentationMessage):
(WebInspector.DebuggerPresentationModel.prototype._consoleCleared):
(WebInspector.DebuggerPresentationModel.prototype.continueToLine):
(WebInspector.DebuggerPresentationModel.prototype.messagesForUISourceCode):
(WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
(WebInspector.PresentationCallFrame.prototype.sourceLine.sourceMappingUpdated):
(WebInspector.PresentationCallFrame.prototype.sourceLine):
* inspector/front-end/SourceFile.js:

LayoutTests:

Merge source-file.html into raw-source-code.html.

Reviewed by Yury Semikhatsky.

* inspector/debugger/raw-source-code.html:
* inspector/debugger/source-file.html: Removed.

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

LayoutTests/ChangeLog
LayoutTests/inspector/debugger/raw-source-code.html
LayoutTests/inspector/debugger/source-file.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/BreakpointManager.js
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
Source/WebCore/inspector/front-end/SourceFile.js

index 34ccbe2..c29851c 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-07  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: get rid of RawSourceCode.createSourceMappingIfNeeded.
+        https://bugs.webkit.org/show_bug.cgi?id=67717
+
+        Merge source-file.html into raw-source-code.html.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/debugger/raw-source-code.html:
+        * inspector/debugger/source-file.html: Removed.
+
 2011-09-08  Cary Clark  <caryclark@google.com>
 
         Unreviewed; removed one erroneous baseline (Skia on Mac)
index 9e3b3de..410e0d2 100644 (file)
@@ -80,6 +80,25 @@ function test()
         throw "Unexpected SourceMappingUpdated event.";
     }
 
+    function createRawLocation(lineNumber, columnNumber)
+    {
+        return { lineNumber: lineNumber, columnNumber: columnNumber };
+    }
+
+    function checkRawLocation(script, lineNumber, columnNumber, location)
+    {
+        InspectorTest.assertEquals(script.scriptId, location.scriptId);
+        InspectorTest.assertEquals(lineNumber, location.lineNumber);
+        InspectorTest.assertEquals(columnNumber, location.columnNumber);
+    }
+
+    function checkUILocation(uiSourceCode, lineNumber, columnNumber, location)
+    {
+        InspectorTest.assertEquals(uiSourceCode, location.uiSourceCode);
+        InspectorTest.assertEquals(lineNumber, location.lineNumber);
+        InspectorTest.assertEquals(columnNumber, location.columnNumber);
+    }
+
     InspectorTest.runTestSuite([
         function testScriptWithoutResource(next)
         {
@@ -91,6 +110,8 @@ function test()
             InspectorTest.assertEquals("foo.js", uiSourceCode.url);
             InspectorTest.assertEquals(true, uiSourceCode.isContentScript);
             InspectorTest.assertEquals(rawSourceCode, uiSourceCode.rawSourceCode);
+            checkUILocation(uiSourceCode, 0, 5, rawSourceCode.rawLocationToUILocation(createRawLocation(0, 5)));
+            checkRawLocation(script, 0, 10, rawSourceCode.uiLocationToRawLocation(0, 10));
             uiSourceCode.requestContent(didRequestContent);
 
             function didRequestContent(mimeType, content)
@@ -134,8 +155,8 @@ function test()
 
         function testHTMLWithFinishedResource(next)
         {
-            var script1 = createScriptMock("index.html", 0, 10, false, "<script source 1>");
-            var script2 = createScriptMock("index.html", 0, 45, false, "<script source 2>");
+            var script1 = createScriptMock("index.html", 1, 10, false, "<script source 1>");
+            var script2 = createScriptMock("index.html", 5, 45, false, "<script\nsource\n2>");
             var resource = createFinishedResourceMock("document", "<resource content>");
             var rawSourceCode = createRawSourceCode(script1, resource);
 
@@ -152,6 +173,10 @@ function test()
 
                 rawSourceCode.addScript(script2);
                 rawSourceCode.forceUpdateSourceMapping();
+                checkUILocation(uiSourceCode, 1, 20, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 20)));
+                checkRawLocation(script1, 1, 20, rawSourceCode.uiLocationToRawLocation(1, 20));
+                checkRawLocation(script2, 6, 2, rawSourceCode.uiLocationToRawLocation(6, 2));
+
                 next();
             }
         },
@@ -256,10 +281,8 @@ function test()
 
             InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode);
             var uiSourceCode = rawSourceCode.uiSourceCode;
-            var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber : 1, columnNumber: 2 });
-            InspectorTest.assertEquals(uiSourceCode, uiLocation.uiSourceCode);
-            InspectorTest.assertEquals(1, uiLocation.lineNumber);
-            InspectorTest.assertEquals(2, uiLocation.columnNumber);
+            checkUILocation(uiSourceCode, 1, 2, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
+            checkRawLocation(script, 1, 2, rawSourceCode.uiLocationToRawLocation(1, 2));
             uiSourceCode.requestContent(didRequestContent);
 
             function didRequestContent(mimeType, content)
@@ -275,10 +298,8 @@ function test()
             function requestFormattedContent()
             {
                 var uiSourceCode = rawSourceCode.uiSourceCode;
-                var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber : 1, columnNumber: 2 });
-                InspectorTest.assertEquals(uiSourceCode, uiLocation.uiSourceCode);
-                InspectorTest.assertEquals(2, uiLocation.lineNumber);
-                InspectorTest.assertEquals(4, uiLocation.columnNumber);
+                checkUILocation(uiSourceCode, 2, 4, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
+                checkRawLocation(script, 1, 2, rawSourceCode.uiLocationToRawLocation(2, 4));
                 uiSourceCode.requestContent(didRequestFormattedContent);
             }
 
@@ -294,10 +315,8 @@ function test()
             function requestNotFormattedContent()
             {
                 var uiSourceCode = rawSourceCode.uiSourceCode;
-                var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber : 1, columnNumber: 2 });
-                InspectorTest.assertEquals(uiSourceCode, uiLocation.uiSourceCode);
-                InspectorTest.assertEquals(1, uiLocation.lineNumber);
-                InspectorTest.assertEquals(2, uiLocation.columnNumber);
+                checkUILocation(uiSourceCode, 1, 2, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
+                checkRawLocation(script, 1, 2, rawSourceCode.uiLocationToRawLocation(1, 2));
                 uiSourceCode.requestContent(didRequestNotFormattedContent);
             }
 
@@ -324,11 +343,8 @@ function test()
             function checkMapping()
             {
                 var uiSourceCode = rawSourceCode.uiSourceCode;
-                var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber : 1, columnNumber: 2 });
-                InspectorTest.assertEquals(uiSourceCode, uiLocation.uiSourceCode);
-                InspectorTest.assertEquals(2, uiLocation.lineNumber);
-                InspectorTest.assertEquals(4, uiLocation.columnNumber);
-
+                checkUILocation(uiSourceCode, 2, 4, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
+                checkRawLocation(script, 1, 2, rawSourceCode.uiLocationToRawLocation(2, 4));
                 next();
             }
         }
diff --git a/LayoutTests/inspector/debugger/source-file.html b/LayoutTests/inspector/debugger/source-file.html
deleted file mode 100644 (file)
index ce2b37c..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<html>
-<head>
-<script src="../../http/tests/inspector/inspector-test.js"></script>
-
-<script>
-
-function test()
-{
-    var mockSourceMapping = {
-        originalToFormatted: function(location)
-        {
-            var formattedLocation = {};
-            formattedLocation.lineNumber = location.lineNumber * 2;
-            formattedLocation.columnNumber = location.columnNumber * 2;
-            return formattedLocation;
-        },
-
-        formattedToOriginal: function(location)
-        {
-            var originalLocation = {};
-            originalLocation.lineNumber = Math.floor(location.lineNumber / 2);
-            originalLocation.columnNumber = Math.floor(location.columnNumber / 2);
-            return originalLocation;
-        }
-    };
-
-    var mockScriptFormatter = {
-        formatContent: function(mimeType, content, callback)
-        {
-            callback(content, mockSourceMapping);
-        }
-    };
-
-    function rl(lineNumber, columnNumber)
-    {
-        return { lineNumber: lineNumber, columnNumber: columnNumber };
-    }
-
-    function checkRawLocation(script, lineNumber, columnNumber, location)
-    {
-        InspectorTest.assertEquals(script.scriptId, location.scriptId);
-        InspectorTest.assertEquals(lineNumber, location.lineNumber);
-        InspectorTest.assertEquals(columnNumber, location.columnNumber);
-    }
-
-    function checkUILocation(rawSourceCode, lineNumber, columnNumber, location)
-    {
-        InspectorTest.assertEquals(rawSourceCode.uiSourceCode, location.uiSourceCode);
-        InspectorTest.assertEquals(lineNumber, location.lineNumber);
-        InspectorTest.assertEquals(columnNumber, location.columnNumber);
-    }
-
-    InspectorTest.runTestSuite([
-        function testPlainConvertLocation(next)
-        {
-            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
-            var rawSourceCode = new WebInspector.RawSourceCode("id", script);
-
-            checkUILocation(rawSourceCode, 10, 20, rawSourceCode.rawLocationToUILocation(rl(10, 20)));
-            checkRawLocation(script, 30, 40, rawSourceCode.uiLocationToRawLocation(30, 40));
-
-            next();
-        },
-
-        function testConcatenatedConvertLocation(next)
-        {
-            var script1 = new WebInspector.Script("1", "foo.js", 10, 20, 30, 40, undefined, undefined, false);
-            var script2 = new WebInspector.Script("2", "foo.js", 50, 60, 70, 80, undefined, undefined, false);
-            var rawSourceCode = new WebInspector.RawSourceCode("id", script1);
-            rawSourceCode.addScript(script2);
-
-            checkUILocation(rawSourceCode, 20, 0, rawSourceCode.rawLocationToUILocation(rl(20, 0)));
-
-            checkRawLocation(script1, 0, 40, rawSourceCode.uiLocationToRawLocation(0, 40));
-            checkRawLocation(script1, 20, 0, rawSourceCode.uiLocationToRawLocation(20, 0));
-            checkRawLocation(script2, 50, 60, rawSourceCode.uiLocationToRawLocation(50, 60));
-
-            next();
-        },
-
-        function testFormattedConvertLocation(next)
-        {
-            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
-            var rawSourceCode = new WebInspector.RawSourceCode("id", script, null, mockScriptFormatter, true);
-
-            function didCreateSourceMapping()
-            {
-                checkUILocation(rawSourceCode, 22, 40, rawSourceCode.rawLocationToUILocation(rl(11, 20)));
-                checkRawLocation(script, 7, 9, rawSourceCode.uiLocationToRawLocation(14, 19));
-                next();
-            }
-            rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
-        },
-
-        function testConcatenatedFormattedConvertLocation(next)
-        {
-            var script1 = new WebInspector.Script("1", "foo.js", 10, 20, 30, 40, undefined, undefined, false);
-            var script2 = new WebInspector.Script("2", "foo.js", 50, 60, 70, 80, undefined, undefined, false);
-            var rawSourceCode = new WebInspector.RawSourceCode("id", script1, null, mockScriptFormatter, true);
-            rawSourceCode.addScript(script2);
-
-            function didCreateSourceMapping()
-            {
-                checkUILocation(rawSourceCode, 22, 60, rawSourceCode.rawLocationToUILocation(rl(11, 30)));
-                checkRawLocation(script1, 12, 10, rawSourceCode.uiLocationToRawLocation(24, 20));
-                checkRawLocation(script2, 60, 19, rawSourceCode.uiLocationToRawLocation(121, 38));
-                next();
-            }
-            rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
-        },
-
-        function testUISourceCodeAdded(next)
-        {
-            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
-            var rawSourceCode = new WebInspector.RawSourceCode("id", script);
-            function uiSourceCodeAdded(event)
-            {
-                InspectorTest.assertEquals("foo.js", event.data.url);
-            }
-            rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeAdded, uiSourceCodeAdded, this);
-
-            next();
-        }
-    ]);
-};
-
-</script>
-
-</head>
-
-<body onload="runTest()">
-<p>Tests mapping between raw locations and ui locations.</p>
-
-</body>
-</html>
index 0ea2950..120f5f0 100644 (file)
@@ -1,3 +1,30 @@
+2011-09-07  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: get rid of RawSourceCode.createSourceMappingIfNeeded.
+        https://bugs.webkit.org/show_bug.cgi?id=67717
+
+        Listen to SourceMappingUpdated event instead of using createSourceMappingIfNeeded.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor):
+        (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
+        (WebInspector.DebuggerPresentationModel.prototype._updateSourceMapping):
+        (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
+        (WebInspector.DebuggerPresentationModel.prototype._restoreConsoleMessages):
+        (WebInspector.DebuggerPresentationModel.prototype.setFormatSource):
+        (WebInspector.DebuggerPresentationModel.prototype._consoleMessageAdded):
+        (WebInspector.DebuggerPresentationModel.prototype._createPresentationMessage):
+        (WebInspector.DebuggerPresentationModel.prototype._consoleCleared):
+        (WebInspector.DebuggerPresentationModel.prototype.continueToLine):
+        (WebInspector.DebuggerPresentationModel.prototype.messagesForUISourceCode):
+        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
+        (WebInspector.PresentationCallFrame.prototype.sourceLine.sourceMappingUpdated):
+        (WebInspector.PresentationCallFrame.prototype.sourceLine):
+        * inspector/front-end/SourceFile.js:
+
 2011-09-06  Pavel Podivilov  <podivilov@chromium.org>
 
         Web Inspector: do not re-create RawSourceCode when toggling pretty-print mode.
index 9289e95..60ec371 100644 (file)
@@ -91,9 +91,10 @@ WebInspector.BreakpointManager.prototype = {
 
     _materializeBreakpoint: function(breakpoint)
     {
-        if (!breakpoint.enabled || breakpoint._debuggerId)
+        if (!breakpoint.enabled || breakpoint._materialized)
             return;
 
+        breakpoint._materialized = true;
         var rawLocation = breakpoint.uiSourceCode.rawSourceCode.uiLocationToRawLocation(breakpoint.lineNumber, 0);
         this._setBreakpointInDebugger(breakpoint, rawLocation);
     },
@@ -215,6 +216,7 @@ WebInspector.BreakpointManager.prototype = {
         function resetBreakpoint(breakpoint)
         {
             this._removeBreakpointFromDebugger(breakpoint);
+            delete breakpoint._materialized;
         }
         this._forEachBreakpoint(resetBreakpoint.bind(this));
     },
index 8a8e1e6..f6edd0c 100644 (file)
@@ -36,8 +36,6 @@ WebInspector.DebuggerPresentationModel = function()
     // FIXME: apply formatter from outside as a generic mapping.
     this._formatter = new WebInspector.ScriptFormatter();
     this._rawSourceCode = {};
-    this._messages = [];
-
     this._presentationCallFrames = [];
     this._selectedCallFrameIndex = 0;
 
@@ -68,34 +66,6 @@ WebInspector.DebuggerPresentationModel.Events = {
 }
 
 WebInspector.DebuggerPresentationModel.prototype = {
-    _scriptLocationToUILocation: function(sourceURL, scriptId, lineNumber, columnNumber, callback)
-    {
-        var rawSourceCode = this._rawSourceCodeForScript(sourceURL, scriptId);
-
-        function didCreateSourceMapping()
-        {
-            var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber });
-            callback(uiLocation.uiSourceCode, uiLocation.lineNumber);
-        }
-        // FIXME: force source formatting if needed. This will go away once formatting
-        // is fully encapsulated in RawSourceCode class.
-        rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
-    },
-
-    _uiLocationToScriptLocation: function(uiSourceCode, lineNumber, callback)
-    {
-        var rawSourceCode = uiSourceCode.rawSourceCode;
-
-        function didCreateSourceMapping()
-        {
-            var rawLocation = rawSourceCode.uiLocationToRawLocation(lineNumber, 0);
-            callback(rawLocation);
-        }
-        // FIXME: force source formatting if needed. This will go away once formatting
-        // is fully encapsulated in RawSourceCode class.
-        rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
-    },
-
     linkifyLocation: function(sourceURL, lineNumber, columnNumber, classes)
     {
         var linkText = WebInspector.formatLinkText(sourceURL, lineNumber);
@@ -110,16 +80,14 @@ WebInspector.DebuggerPresentationModel.prototype = {
 
         function updateAnchor()
         {
-            function didGetLocation(uiSourceCode, lineNumber)
-            {
-                anchor.textContent = WebInspector.formatLinkText(uiSourceCode.url, lineNumber);
-                anchor.setAttribute("preferred_panel", "scripts");
-                anchor.uiSourceCode = uiSourceCode;
-                anchor.lineNumber = lineNumber;
-            }
-            this._scriptLocationToUILocation(sourceURL, null, lineNumber, columnNumber, didGetLocation.bind(this));
+            var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber });
+            anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber);
+            anchor.setAttribute("preferred_panel", "scripts");
+            anchor.uiSourceCode = uiLocation.uiSourceCode;
+            anchor.lineNumber = uiLocation.lineNumber;
         }
-        updateAnchor.call(this);
+        if (rawSourceCode.uiSourceCode)
+            updateAnchor.call(this);
         rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, updateAnchor, this);
         return anchor;
     },
@@ -164,25 +132,41 @@ WebInspector.DebuggerPresentationModel.prototype = {
     {
         var uiSourceCode = rawSourceCode.uiSourceCode;
 
-        if (!oldUISourceCode)
-            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCode);
-        else {
+        if (oldUISourceCode) {
             var breakpoints = this._breakpointManager.breakpointsForUISourceCode(oldUISourceCode);
             for (var lineNumber in breakpoints) {
                 var breakpoint = breakpoints[lineNumber];
                 this._breakpointRemoved(breakpoint);
                 delete breakpoint.uiSourceCode;
             }
+        }
+
+        this._restoreBreakpoints(uiSourceCode);
+        this._restoreConsoleMessages(uiSourceCode);
+
+        if (!oldUISourceCode)
+            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCode);
+        else {
             var eventData = { uiSourceCode: uiSourceCode, oldUISourceCode: oldUISourceCode };
             this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced, eventData);
         }
+    },
 
+    _restoreBreakpoints: function(uiSourceCode)
+    {
         this._breakpointManager.uiSourceCodeAdded(uiSourceCode);
         var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
         for (var lineNumber in breakpoints)
             this._breakpointAdded(breakpoints[lineNumber]);
     },
 
+    _restoreConsoleMessages: function(uiSourceCode)
+    {
+        var messages = uiSourceCode.rawSourceCode.messages;
+        for (var i = 0; i < messages.length; ++i)
+            messages[i]._presentationMessage = this._createPresentationMessage(messages[i], uiSourceCode);
+    },
+
     canEditScriptSource: function(uiSourceCode)
     {
         if (!Preferences.canEditScriptSource || this._formatSource)
@@ -251,18 +235,9 @@ WebInspector.DebuggerPresentationModel.prototype = {
             return;
 
         this._formatSource = formatSource;
-
         this._breakpointManager.reset();
-
-        for (var id in this._rawSourceCode) {
-            this._rawSourceCode[id].messages = [];
+        for (var id in this._rawSourceCode)
             this._rawSourceCode[id].setFormatted(this._formatSource);
-        }
-
-        var messages = this._messages;
-        this._messages = [];
-        for (var i = 0; i < messages.length; ++i)
-            this._addConsoleMessage(messages[i]);
 
         if (WebInspector.debuggerModel.callFrames)
             this._debuggerPaused();
@@ -271,36 +246,35 @@ WebInspector.DebuggerPresentationModel.prototype = {
     _consoleMessageAdded: function(event)
     {
         var message = event.data;
-        if (message.url && message.isErrorOrWarning() && message.message)
-            this._addConsoleMessage(message);
-    },
-
-    _addConsoleMessage: function(message)
-    {
-        this._messages.push(message);
+        if (!message.url || !message.isErrorOrWarning() || !message.message)
+            return;
 
         var rawSourceCode = this._rawSourceCodeForScript(message.url);
         if (!rawSourceCode)
             return;
 
-        function didGetUILocation(uiSourceCode, lineNumber)
-        {
-            var presentationMessage = {};
-            presentationMessage.uiSourceCode = uiSourceCode;
-            presentationMessage.lineNumber = lineNumber;
-            presentationMessage.originalMessage = message;
-            rawSourceCode.messages.push(presentationMessage);
-            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage);
+        rawSourceCode.messages.push(message);
+        if (rawSourceCode.uiSourceCode) {
+            message._presentationMessage = this._createPresentationMessage(message, rawSourceCode.uiSourceCode);
+            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, message._presentationMessage);
         }
+    },
+
+    _createPresentationMessage: function(message, uiSourceCode)
+    {
         // FIXME(62725): stack trace line/column numbers are one-based.
         var lineNumber = message.stackTrace ? message.stackTrace[0].lineNumber - 1 : message.line - 1;
         var columnNumber = message.stackTrace ? message.stackTrace[0].columnNumber - 1 : 0;
-        this._scriptLocationToUILocation(message.url, null, lineNumber, columnNumber, didGetUILocation.bind(this));
+        var uiLocation = uiSourceCode.rawSourceCode.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber });
+        var presentationMessage = {};
+        presentationMessage.uiSourceCode = uiLocation.uiSourceCode;
+        presentationMessage.lineNumber = uiLocation.lineNumber;
+        presentationMessage.originalMessage = message;
+        return presentationMessage;
     },
 
     _consoleCleared: function()
     {
-        this._messages = [];
         for (var id in this._rawSourceCode)
             this._rawSourceCode[id].messages = [];
         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared);
@@ -308,11 +282,8 @@ WebInspector.DebuggerPresentationModel.prototype = {
 
     continueToLine: function(uiSourceCode, lineNumber)
     {
-        function didGetScriptLocation(location)
-        {
-            WebInspector.debuggerModel.continueToLocation(location);
-        }
-        this._uiLocationToScriptLocation(uiSourceCode, lineNumber, didGetScriptLocation);
+        var rawLocation = uiSourceCode.rawSourceCode.uiLocationToRawLocation(lineNumber, 0);
+        WebInspector.debuggerModel.continueToLocation(rawLocation);
     },
 
     breakpointsForUISourceCode: function(uiSourceCode)
@@ -327,7 +298,10 @@ WebInspector.DebuggerPresentationModel.prototype = {
     messagesForUISourceCode: function(uiSourceCode)
     {
         var rawSourceCode = uiSourceCode.rawSourceCode;
-        return rawSourceCode.messages;
+        var messages = [];
+        for (var i = 0; i < rawSourceCode.messages.length; ++i)
+            messages.push(rawSourceCode.messages[i]._presentationMessage);
+        return messages;
     },
 
     setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled)
@@ -437,7 +411,6 @@ WebInspector.DebuggerPresentationModel.prototype = {
     _debuggerReset: function()
     {
         this._rawSourceCode = {};
-        this._messages = [];
         this._presentationCallFrames = [];
         this._selectedCallFrameIndex = 0;
         this._breakpointManager.debuggerReset();
@@ -521,11 +494,25 @@ WebInspector.PresentationCallFrame.prototype = {
 
     sourceLine: function(callback)
     {
-        var location = this._callFrame.location;
-        if (!this.isInternalScript)
-            this._model._scriptLocationToUILocation(null, location.scriptId, location.lineNumber, location.columnNumber, callback);
-        else
-            callback(undefined, location.lineNumber);
+        var rawLocation = this._callFrame.location;
+        if (!this._rawSourceCode) {
+            callback(undefined, rawLocation.lineNumber);
+            return;
+        }
+
+        if (this._rawSourceCode.uiSourceCode) {
+            var uiLocation = this._rawSourceCode.rawLocationToUILocation(rawLocation);
+            callback(uiLocation.uiSourceCode, uiLocation.lineNumber);
+            return;
+        }
+
+        function sourceMappingUpdated()
+        {
+            this._rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this);
+            var uiLocation = this._rawSourceCode.rawLocationToUILocation(rawLocation);
+            callback(uiLocation.uiSourceCode, uiLocation.lineNumber);
+        }
+        this._rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this);
     }
 }
 
index 85064f1..c8120f6 100644 (file)
@@ -118,22 +118,6 @@ WebInspector.RawSourceCode.prototype = {
         return closestScript;
     },
 
-    createSourceMappingIfNeeded: function(callback)
-    {
-        // FIXME: remove createSourceMappingIfNeeded, client should listen to SourceMappingUpdated event instead.
-        if (this._uiSourceCode && !this._updatingSourceMapping) {
-            callback();
-            return;
-        }
-
-        function sourceMappingUpdated()
-        {
-            this.removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this);
-            callback();
-        }
-        this.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this);
-    },
-
     forceUpdateSourceMapping: function(script)
     {
         if (!this._useTemporaryContent || !this._hasNewScripts)