Web Inspector: RawSourceCode could be mapped to multiple sources.
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2011 16:09:22 +0000 (16:09 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Oct 2011 16:09:22 +0000 (16:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68526

Source/WebCore:

Replace SourceMapping.uiSourceCode with SourceMapping.uiSourceCodeList as there could be more
then one UISourceCode associated with a RawSourceCode.

Reviewed by Pavel Feldman.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype._sourceMappingUpdated):
(WebInspector.DebuggerPresentationModel.prototype._updateSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
(WebInspector.PresentationCallFrame.prototype.get url):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._uiSourceCodeReplaced):
* inspector/front-end/SourceFile.js:
(WebInspector.RawSourceCode.prototype._saveSourceMapping):
(WebInspector.RawSourceCode.PlainSourceMapping):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiSourceCodeList):
(WebInspector.RawSourceCode.FormattedSourceMapping):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiSourceCodeList):

LayoutTests:

Reviewed by Pavel Feldman.

* inspector/debugger/raw-source-code.html:
* inspector/debugger/scripts-panel.html:

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

LayoutTests/ChangeLog
LayoutTests/inspector/debugger/raw-source-code.html
LayoutTests/inspector/debugger/scripts-panel.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
Source/WebCore/inspector/front-end/RawSourceCode.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/UISourceCode.js

index a9680ff91b8a37d71f4db857312617e396b2650b..d13db1274a12917790fd0eaf261ceddf7ff0611c 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-28  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: RawSourceCode could be mapped to multiple sources.
+        https://bugs.webkit.org/show_bug.cgi?id=68526
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/debugger/raw-source-code.html:
+        * inspector/debugger/scripts-panel.html:
+
 2011-10-10  Zsolt FehĂ©r  <feherzs@inf.u-szeged.hu>
 
         Unreviewed gardening after r96958.
index f29d3da93eb038b5bcbd0c5bb31b5782eabe20af..b1128d3f1525c71652c84dc6729e22df4f7830aa 100644 (file)
@@ -106,7 +106,8 @@ function test()
             var rawSourceCode = createRawSourceCode(script, null);
 
             var sourceMapping = rawSourceCode.sourceMapping;
-            var uiSourceCode = sourceMapping.uiSourceCode;
+            InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+            var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
             InspectorTest.assertEquals("foo.js", uiSourceCode.url);
             InspectorTest.assertEquals(true, uiSourceCode.isContentScript);
             InspectorTest.assertEquals(rawSourceCode, uiSourceCode.rawSourceCode);
@@ -136,7 +137,9 @@ function test()
             function mappingReady(event)
             {
                 InspectorTest.assertTrue(!event.data.oldSourceCode);
-                var uiSourceCode = rawSourceCode.sourceMapping.uiSourceCode;
+                var sourceMapping = rawSourceCode.sourceMapping;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
                 InspectorTest.assertEquals("index.html", uiSourceCode.url);
                 InspectorTest.assertEquals(false, uiSourceCode.isContentScript);
                 uiSourceCode.requestContent(didRequestContent);
@@ -161,7 +164,8 @@ function test()
             var rawSourceCode = createRawSourceCode(script1, resource);
 
             var sourceMapping = rawSourceCode.sourceMapping;
-            var uiSourceCode = sourceMapping.uiSourceCode;
+            InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+            var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
             InspectorTest.assertEquals("index.html", uiSourceCode.url);
             InspectorTest.assertEquals(false, uiSourceCode.isContentScript);
             uiSourceCode.requestContent(didRequestContent);
@@ -195,7 +199,10 @@ function test()
 
             function requestContent()
             {
-                rawSourceCode.sourceMapping.uiSourceCode.requestContent(didRequestContentOneScript);
+                var sourceMapping = rawSourceCode.sourceMapping;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
+                uiSourceCode.requestContent(didRequestContentOneScript);
             }
 
             function didRequestContentOneScript(mimeType, content)
@@ -211,7 +218,10 @@ function test()
 
             function requestContentTwoScripts()
             {
-                rawSourceCode.sourceMapping.uiSourceCode.requestContent(didRequestContentTwoScripts);
+                var sourceMapping = rawSourceCode.sourceMapping;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
+                uiSourceCode.requestContent(didRequestContentTwoScripts);
             }
 
             function didRequestContentTwoScripts(mimeType, content)
@@ -226,7 +236,10 @@ function test()
 
             function requestContentResource()
             {
-                rawSourceCode.sourceMapping.uiSourceCode.requestContent(didRequestContentResource);
+                var sourceMapping = rawSourceCode.sourceMapping;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
+                uiSourceCode.requestContent(didRequestContentResource);
             }
 
             function didRequestContentResource(mimeType, content)
@@ -248,7 +261,8 @@ function test()
             var rawSourceCode = createRawSourceCode(script, resource, false);
 
             var sourceMapping = rawSourceCode.sourceMapping;
-            var uiSourceCode = sourceMapping.uiSourceCode;
+            InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+            var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
             checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
             checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
             uiSourceCode.requestContent(didRequestContent);
@@ -266,7 +280,8 @@ function test()
             function requestFormattedContent()
             {
                 var sourceMapping = rawSourceCode.sourceMapping;
-                var uiSourceCode = sourceMapping.uiSourceCode;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
                 checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
                 checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
                 uiSourceCode.requestContent(didRequestFormattedContent);
@@ -284,7 +299,8 @@ function test()
             function requestNotFormattedContent()
             {
                 var sourceMapping = rawSourceCode.sourceMapping;
-                var uiSourceCode = sourceMapping.uiSourceCode;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
                 checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
                 checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
                 uiSourceCode.requestContent(didRequestNotFormattedContent);
@@ -313,7 +329,8 @@ function test()
             function checkMapping()
             {
                 var sourceMapping = rawSourceCode.sourceMapping;
-                var uiSourceCode = sourceMapping.uiSourceCode;
+                InspectorTest.assertEquals(1, sourceMapping.uiSourceCodeList().length);
+                var uiSourceCode = sourceMapping.uiSourceCodeList()[0];
                 checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
                 checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2));
                 next();
index 10ca84a6a6e72498b2541c46f4eda7aea1788f0c..ab5dc37f7aaf124974d0dcc910857d1912cd068f 100644 (file)
@@ -167,7 +167,7 @@ function test()
 
             addUISouceCode(model, "foo.js");
             var uiSourceCode = addUISouceCode(model, "bar.js");
-            panel._uiSourceCodeReplaced({ data: { oldUISourceCode: uiSourceCode, uiSourceCode: uiSourceCode }});
+            panel._uiSourceCodeReplaced({ data: { oldUISourceCodeList: [uiSourceCode], uiSourceCodeList: [uiSourceCode] }});
             showSourceFrame(panel, "bar.js");
             next();
         }
index 57fe1e90c825a6f56693cc821a0e264e6e438560..bb1d4fb8a52860b14b9a012423636b739337ab07 100644 (file)
@@ -1,3 +1,31 @@
+2011-09-28  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: RawSourceCode could be mapped to multiple sources.
+        https://bugs.webkit.org/show_bug.cgi?id=68526
+
+        Replace SourceMapping.uiSourceCode with SourceMapping.uiSourceCodeList as there could be more
+        then one UISourceCode associated with a RawSourceCode.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype._sourceMappingUpdated):
+        (WebInspector.DebuggerPresentationModel.prototype._updateSourceMapping):
+        (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
+        (WebInspector.PresentationCallFrame.prototype.get url):
+        (WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent):
+        (WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._uiSourceCodeReplaced):
+        * inspector/front-end/SourceFile.js:
+        (WebInspector.RawSourceCode.prototype._saveSourceMapping):
+        (WebInspector.RawSourceCode.PlainSourceMapping):
+        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.rawLocationToUILocation):
+        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiSourceCodeList):
+        (WebInspector.RawSourceCode.FormattedSourceMapping):
+        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.rawLocationToUILocation):
+        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiSourceCodeList):
+
 2011-10-10  Andreas Kling  <kling@webkit.org>
 
         Shrink RenderLayer and ScrollableArea.
index 62ddb260ea91a86c2ce4e21d9412a28da13c3af2..c11173b6d43f5c93cff7328c1a7b43355c7839b5 100644 (file)
@@ -123,40 +123,48 @@ WebInspector.DebuggerPresentationModel.prototype = {
     _sourceMappingUpdated: function(event)
     {
         var rawSourceCode = event.target;
-        var oldUISourceCode = event.data.oldUISourceCode;
-        this._updateSourceMapping(rawSourceCode, oldUISourceCode);
+        var oldSourceMapping = event.data.oldSourceMapping;
+        this._updateSourceMapping(rawSourceCode, oldSourceMapping);
     },
 
-    _updateSourceMapping: function(rawSourceCode, oldUISourceCode)
+    _updateSourceMapping: function(rawSourceCode, oldSourceMapping)
     {
-        if (oldUISourceCode) {
-            var breakpoints = this._breakpointManager.breakpointsForUISourceCode(oldUISourceCode);
-            for (var lineNumber in breakpoints) {
-                var breakpoint = breakpoints[lineNumber];
-                this._breakpointRemoved(breakpoint);
-                delete breakpoint.uiSourceCode;
+        if (oldSourceMapping) {
+            var oldUISourceCodeList = oldSourceMapping.uiSourceCodeList();
+            for (var i = 0; i < oldUISourceCodeList.length; ++i) {
+                var breakpoints = this._breakpointManager.breakpointsForUISourceCode(oldUISourceCodeList[i]);
+                for (var lineNumber in breakpoints) {
+                    var breakpoint = breakpoints[lineNumber];
+                    this._breakpointRemoved(breakpoint);
+                    delete breakpoint.uiSourceCode;
+                }
             }
         }
 
         this._restoreBreakpoints(rawSourceCode);
         this._restoreConsoleMessages(rawSourceCode);
 
-        var uiSourceCode = rawSourceCode.sourceMapping.uiSourceCode;
-        if (!oldUISourceCode)
-            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCode);
-        else {
-            var eventData = { uiSourceCode: uiSourceCode, oldUISourceCode: oldUISourceCode };
+        if (!oldSourceMapping) {
+            var uiSourceCodeList = rawSourceCode.sourceMapping.uiSourceCodeList();
+            for (var i = 0; i < uiSourceCodeList.length; ++i)
+                this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCodeList[i]);
+        } else {
+            var eventData = { uiSourceCodeList: rawSourceCode.sourceMapping.uiSourceCodeList(), oldUISourceCodeList: oldSourceMapping.uiSourceCodeList() };
             this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced, eventData);
         }
     },
 
     _restoreBreakpoints: function(rawSourceCode)
     {
-        var uiSourceCode = rawSourceCode.sourceMapping.uiSourceCode;
-        this._breakpointManager.uiSourceCodeAdded(uiSourceCode);
-        var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
-        for (var lineNumber in breakpoints)
-            this._breakpointAdded(breakpoints[lineNumber]);
+        var uiSourceCodeList = rawSourceCode.sourceMapping.uiSourceCodeList();
+        for (var i = 0; i < uiSourceCodeList.length; ++i) {
+            var uiSourceCode = uiSourceCodeList[i];
+            this._breakpointManager.uiSourceCodeAdded(uiSourceCode);
+            var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
+            for (var lineNumber in breakpoints)
+                this._breakpointAdded(breakpoints[lineNumber]);
+        }
+
     },
 
     _restoreConsoleMessages: function(rawSourceCode)
@@ -432,9 +440,13 @@ WebInspector.DebuggerPresentationModel.prototype = {
     _debuggerReset: function()
     {
         for (var id in this._rawSourceCode) {
-            if (this._rawSourceCode[id].sourceMapping && this._rawSourceCode[id].sourceMapping.uiSourceCode)
-                this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeRemoved, this._rawSourceCode[id].sourceMapping.uiSourceCode);
-            this._rawSourceCode[id].removeAllListeners();
+            var rawSourceCode = this._rawSourceCode[id];
+            if (rawSourceCode.sourceMapping) {
+                var uiSourceCodeList = rawSourceCode.sourceMapping.uiSourceCodeList();
+                for (var i = 0; i < uiSourceCodeList.length; ++i)
+                    this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeRemoved, uiSourceCodeList[i]);
+            }
+            rawSourceCode.removeAllListeners();
         }
         this._rawSourceCode = {};
         this._presentationCallFrames = [];
@@ -530,7 +542,7 @@ WebInspector.DebuggerPresentationModelResourceBinding.prototype = {
         var rawSourceCode = this._presentationModel._rawSourceCodeForScriptWithURL(resource.url)
         if (!rawSourceCode)
             return false;
-        return this._presentationModel.canEditScriptSource(rawSourceCode.sourceMapping.uiSourceCode);
+        return this._presentationModel.canEditScriptSource(rawSourceCode.sourceMapping.uiSourceCodeList()[0]);
     },
 
     setContent: function(resource, content, majorChange, userCallback)
@@ -544,7 +556,7 @@ WebInspector.DebuggerPresentationModelResourceBinding.prototype = {
             return;
         }
 
-        resource.requestContent(this._setContentWithInitialContent.bind(this, rawSourceCode.sourceMapping.uiSourceCode, content, userCallback));
+        resource.requestContent(this._setContentWithInitialContent.bind(this, rawSourceCode.sourceMapping.uiSourceCodeList()[0], content, userCallback));
     },
 
     _setContentWithInitialContent: function(uiSourceCode, content, userCallback, oldContent)
index 8f03bb7a4fcf275d74085c35fe9cdd54350058b3..1f3756ecea62a9ed25f04d08c9c06783ee8b8c91 100644 (file)
@@ -190,11 +190,11 @@ WebInspector.RawSourceCode.prototype = {
 
     _saveSourceMapping: function(sourceMapping)
     {
-        var oldUISourceCode;
+        var oldSourceMapping;
         if (this._sourceMapping)
-            oldUISourceCode = this._sourceMapping.uiSourceCode;
+            oldSourceMapping = this._sourceMapping;
         this._sourceMapping = sourceMapping;
-        this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.SourceMappingUpdated, { oldUISourceCode: oldUISourceCode });
+        this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.SourceMappingUpdated, { oldSourceMapping: oldSourceMapping });
     }
 }
 
@@ -207,26 +207,26 @@ WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;
 WebInspector.RawSourceCode.PlainSourceMapping = function(rawSourceCode, uiSourceCode)
 {
     this._rawSourceCode = rawSourceCode;
-    this._uiSourceCode = uiSourceCode;
+    this._uiSourceCodeList = [uiSourceCode];
 }
 
 WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
     rawLocationToUILocation: function(rawLocation)
     {
-        return new WebInspector.UILocation(this._uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
+        return new WebInspector.UILocation(this._uiSourceCodeList[0], rawLocation.lineNumber, rawLocation.columnNumber);
     },
 
     uiLocationToRawLocation: function(uiSourceCode, lineNumber)
     {
-        console.assert(uiSourceCode === this._uiSourceCode);
+        console.assert(uiSourceCode === this._uiSourceCodeList[0]);
         var rawLocation = { lineNumber: lineNumber, columnNumber: 0 };
         rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
         return rawLocation;
     },
 
-    get uiSourceCode()
+    uiSourceCodeList: function()
     {
-        return this._uiSourceCode;
+        return this._uiSourceCodeList;
     }
 }
 
@@ -236,7 +236,7 @@ WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
 WebInspector.RawSourceCode.FormattedSourceMapping = function(rawSourceCode, uiSourceCode, mapping)
 {
     this._rawSourceCode = rawSourceCode;
-    this._uiSourceCode = uiSourceCode;
+    this._uiSourceCodeList = [uiSourceCode];
     this._mapping = mapping;
 }
 
@@ -244,20 +244,20 @@ WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
     rawLocationToUILocation: function(rawLocation)
     {
         var location = this._mapping.originalToFormatted(rawLocation);
-        return new WebInspector.UILocation(this._uiSourceCode, location.lineNumber, location.columnNumber);
+        return new WebInspector.UILocation(this._uiSourceCodeList[0], location.lineNumber, location.columnNumber);
     },
 
     uiLocationToRawLocation: function(uiSourceCode, lineNumber)
     {
-        console.assert(uiSourceCode === this._uiSourceCode);
+        console.assert(uiSourceCode === this._uiSourceCodeList[0]);
         var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: 0 });
         rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
         return rawLocation;
     },
 
-    get uiSourceCode()
+    uiSourceCodeList: function()
     {
-        return this._uiSourceCode;
+        return this._uiSourceCodeList;
     }
 }
 
index 8a0a0fec793fd9387231149236eb3ffbc879ba0d..55cdbb604ef4d81626fc1b65163af7b7d0d5834e 100644 (file)
@@ -696,8 +696,9 @@ WebInspector.ScriptsPanel.prototype = {
 
     _uiSourceCodeReplaced: function(event)
     {
-        var oldUISourceCode = event.data.oldUISourceCode;
-        var uiSourceCode = event.data.uiSourceCode;
+        // FIXME: support multiple entries.
+        var oldUISourceCode = event.data.oldUISourceCodeList[0];
+        var uiSourceCode = event.data.uiSourceCodeList[0];
 
         // Re-bind file select option from old source file to new one.
         var option = oldUISourceCode._option;
index 964e789f41291297194466445873a59bc66f5f21..d2f14d4d18cbd551627f76ec283d42c3fb31e208 100644 (file)
@@ -30,6 +30,7 @@
 
 /**
  * @constructor
+ * @extends {WebInspector.Object}
  */
 WebInspector.UISourceCode = function(id, url, isContentScript, rawSourceCode, contentProvider)
 {