Web Inspector: RawSourceCode does not need uiSourceCode lists because it never has...
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Mar 2012 12:27:39 +0000 (12:27 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Mar 2012 12:27:39 +0000 (12:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81894

Source/WebCore:

RawSourceCode never has more than one uiSourceCode, uiSourceCodeList
are just remains of older implementation. This patch switches RawSourceCode
and SourceMappings from uiSourceCodeList to uiSourceCode.

Reviewed by Pavel Feldman.

* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype.uiSourceCode):
(WebInspector.RawSourceCode.prototype._saveSourceMapping):
(WebInspector.RawSourceCode.SourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.SourceMapping.prototype.uiSourceCode):
(WebInspector.RawSourceCode.PlainSourceMapping):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiSourceCode):
(WebInspector.RawSourceCode.FormattedSourceMapping):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiSourceCode):
* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping.prototype.uiSourceCodeList):
(WebInspector.ResourceScriptMapping.prototype.addScript):
(WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeChanged):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeChanged):
(WebInspector.ResourceScriptMapping.prototype.reset):

LayoutTests:

Reviewed by Pavel Feldman.

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

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

LayoutTests/ChangeLog
LayoutTests/inspector/debugger/raw-source-code.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/RawSourceCode.js
Source/WebCore/inspector/front-end/ResourceScriptMapping.js

index cdfdc6a013c9933f5acf80514150fff3a278e431..2a09764f6b6d5a72d26e3fa04756376d78116743 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-22  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Web Inspector: RawSourceCode does not need uiSourceCode lists because it never has more than one.
+        https://bugs.webkit.org/show_bug.cgi?id=81894
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/debugger/raw-source-code.html:
+
 2012-03-22  Mihai Balan  <mibalan@adobe.com>
 
         [CSSRegions] Add region styling test for region css rules specificity/position
index 602757336d0d9a872d9920d6162fc2fb07a974e1..4f79b76fb48c1ba9c1a7276df542fea705638541 100644 (file)
@@ -37,25 +37,25 @@ function test()
     function createRawSourceCode(script, resource, formatted, compilerSourceMapping)
     {
         var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, createScriptFormatterMock(), !!formatted, compilerSourceMapping);
-        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, defaultUISourceCodeListChangedHandler);
+        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
         return rawSourceCode;
     }
 
-    function waitForUISourceCodeListChangedEvent(rawSourceCode, callback)
+    function waitForUISourceCodeChangedEvent(rawSourceCode, callback)
     {
-        rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, defaultUISourceCodeListChangedHandler);
-        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, uiSourceCodeListChanged);
-        function uiSourceCodeListChanged(event)
+        rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
+        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, uiSourceCodeChanged);
+        function uiSourceCodeChanged(event)
         {
-            rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, uiSourceCodeListChanged);
-            rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, defaultUISourceCodeListChangedHandler);
+            rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, uiSourceCodeChanged);
+            rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
             callback(event);
         }
     }
 
-    function defaultUISourceCodeListChangedHandler()
+    function defaultUISourceCodeChangedHandler()
     {
-        throw "Unexpected UISourceCodeListChanged event.";
+        throw "Unexpected UISourceCodeChanged event.";
     }
 
     function createRawLocation(lineNumber, columnNumber)
@@ -70,8 +70,8 @@ function test()
             var script = InspectorTest.createScriptMock("foo.js", 0, 0, true, "<script source>");
             var rawSourceCode = createRawSourceCode(script, null);
 
-            InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-            var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+            InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+            var uiSourceCode = rawSourceCode.uiSourceCode();
             InspectorTest.assertEquals("foo.js", uiSourceCode.url);
             InspectorTest.assertEquals(true, uiSourceCode.isContentScript);
             InspectorTest.checkUILocation(uiSourceCode, 0, 5, rawSourceCode.rawLocationToUILocation(createRawLocation(0, 5)));
@@ -94,15 +94,15 @@ function test()
             var resource = createPendingResourceMock("document", "<resource content>");
             var rawSourceCode = createRawSourceCode(script1, resource);
 
-            InspectorTest.assertEquals(0, rawSourceCode.uiSourceCodeList().length);
-            waitForUISourceCodeListChangedEvent(rawSourceCode, uiSourceCodeListChanged);
+            InspectorTest.assertTrue(!rawSourceCode.uiSourceCode());
+            waitForUISourceCodeChangedEvent(rawSourceCode, uiSourceCodeChanged);
             resource.finish();
 
-            function uiSourceCodeListChanged(event)
+            function uiSourceCodeChanged(event)
             {
-                InspectorTest.assertEquals(event.data.oldUISourceCodeList.length, 0);
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!event.data.oldUISourceCode);
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 InspectorTest.assertEquals("index.html", uiSourceCode.url);
                 InspectorTest.assertEquals(false, uiSourceCode.isContentScript);
                 uiSourceCode.requestContent(didRequestContent);
@@ -127,8 +127,8 @@ function test()
             var resource = createFinishedResourceMock("document", "<resource content>");
             var rawSourceCode = createRawSourceCode(script1, resource);
 
-            InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-            var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+            InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+            var uiSourceCode = rawSourceCode.uiSourceCode();
             InspectorTest.assertEquals("index.html", uiSourceCode.url);
             InspectorTest.assertEquals(false, uiSourceCode.isContentScript);
             uiSourceCode.requestContent(didRequestContent);
@@ -157,14 +157,14 @@ function test()
             var resource = createPendingResourceMock("document", "<resource content>");
             var rawSourceCode = createRawSourceCode(script1, resource);
 
-            InspectorTest.assertEquals(0, rawSourceCode.uiSourceCodeList().length);
-            waitForUISourceCodeListChangedEvent(rawSourceCode, requestContent);
+            InspectorTest.assertTrue(!rawSourceCode.uiSourceCode());
+            waitForUISourceCodeChangedEvent(rawSourceCode, requestContent);
             rawSourceCode.forceUpdateSourceMapping();
 
             function requestContent()
             {
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 uiSourceCode.requestContent(didRequestContentOneScript);
             }
 
@@ -175,14 +175,14 @@ function test()
 
                 rawSourceCode.forceUpdateSourceMapping();
                 rawSourceCode.addScript(script2);
-                waitForUISourceCodeListChangedEvent(rawSourceCode, requestContentTwoScripts);
+                waitForUISourceCodeChangedEvent(rawSourceCode, requestContentTwoScripts);
                 rawSourceCode.forceUpdateSourceMapping();
             }
 
             function requestContentTwoScripts()
             {
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 uiSourceCode.requestContent(didRequestContentTwoScripts);
             }
 
@@ -192,14 +192,14 @@ function test()
                 InspectorTest.assertEquals("  <script><script source 1></" + "script> <script><script source 2></" + "script>", content);
 
                 rawSourceCode.forceUpdateSourceMapping();
-                waitForUISourceCodeListChangedEvent(rawSourceCode, requestContentResource);
+                waitForUISourceCodeChangedEvent(rawSourceCode, requestContentResource);
                 resource.finish();
             }
 
             function requestContentResource()
             {
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 uiSourceCode.requestContent(didRequestContentResource);
             }
 
@@ -222,8 +222,8 @@ function test()
             var resource = createFinishedResourceMock("script", "<resource content>");
             var rawSourceCode = createRawSourceCode(script, resource, false);
 
-            InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-            var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+            InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+            var uiSourceCode = rawSourceCode.uiSourceCode();
             InspectorTest.checkUILocation(uiSourceCode, 1, 2, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
             InspectorTest.checkRawLocation(script, 2, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 2, 0));
             uiSourceCode.requestContent(didRequestContent);
@@ -234,14 +234,14 @@ function test()
                 InspectorTest.assertEquals("<resource content>", content);
 
                 rawSourceCode.setFormatted(true);
-                waitForUISourceCodeListChangedEvent(rawSourceCode, requestFormattedContent);
+                waitForUISourceCodeChangedEvent(rawSourceCode, requestFormattedContent);
                 rawSourceCode._formatter.finish();
             }
 
             function requestFormattedContent()
             {
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 InspectorTest.checkUILocation(uiSourceCode, 2, 4, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
                 InspectorTest.checkRawLocation(script, 1, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 2, 0));
                 uiSourceCode.requestContent(didRequestFormattedContent);
@@ -252,14 +252,14 @@ function test()
                 InspectorTest.assertEquals(mimeType, "text/javascript");
                 InspectorTest.assertEquals("<formatted> <resource content>", content);
 
-                waitForUISourceCodeListChangedEvent(rawSourceCode, requestNotFormattedContent);
+                waitForUISourceCodeChangedEvent(rawSourceCode, requestNotFormattedContent);
                 rawSourceCode.setFormatted(false);
             }
 
             function requestNotFormattedContent()
             {
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 InspectorTest.checkUILocation(uiSourceCode, 1, 2, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
                 InspectorTest.checkRawLocation(script, 2, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 2, 0));
                 uiSourceCode.requestContent(didRequestNotFormattedContent);
@@ -281,15 +281,15 @@ function test()
             var resource = createPendingResourceMock("script", "<resource content>");
             var rawSourceCode = createRawSourceCode(script, resource, true);
 
-            InspectorTest.assertEquals(0, rawSourceCode.uiSourceCodeList().length);
+            InspectorTest.assertTrue(!rawSourceCode.uiSourceCode());
             resource.finish();
-            waitForUISourceCodeListChangedEvent(rawSourceCode, checkMapping);
+            waitForUISourceCodeChangedEvent(rawSourceCode, checkMapping);
             rawSourceCode._formatter.finish();
 
             function checkMapping()
             {
-                InspectorTest.assertEquals(1, rawSourceCode.uiSourceCodeList().length);
-                var uiSourceCode = rawSourceCode.uiSourceCodeList()[0];
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
                 InspectorTest.checkUILocation(uiSourceCode, 2, 4, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 2)));
                 InspectorTest.checkRawLocation(script, 1, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 2, 0));
                 next();
index 0cae38b2cfc6dc32f69ba83b9abca94763e599f9..54f4567814a8f1ff66d568441cc9370bedd4b58b 100644 (file)
@@ -1,3 +1,34 @@
+2012-03-22  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Web Inspector: RawSourceCode does not need uiSourceCode lists because it never has more than one.
+        https://bugs.webkit.org/show_bug.cgi?id=81894
+
+        RawSourceCode never has more than one uiSourceCode, uiSourceCodeList
+        are just remains of older implementation. This patch switches RawSourceCode
+        and SourceMappings from uiSourceCodeList to uiSourceCode.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode.prototype.uiSourceCode):
+        (WebInspector.RawSourceCode.prototype._saveSourceMapping):
+        (WebInspector.RawSourceCode.SourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.SourceMapping.prototype.uiSourceCode):
+        (WebInspector.RawSourceCode.PlainSourceMapping):
+        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.rawLocationToUILocation):
+        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiSourceCode):
+        (WebInspector.RawSourceCode.FormattedSourceMapping):
+        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.rawLocationToUILocation):
+        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiSourceCode):
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping.prototype.uiSourceCodeList):
+        (WebInspector.ResourceScriptMapping.prototype.addScript):
+        (WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeChanged):
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeChanged):
+        (WebInspector.ResourceScriptMapping.prototype.reset):
+
 2012-03-22  Mario Sanchez Prada  <msanchez@igalia.com>
 
         [GTK] Fix the only remaining coding style issue in GTK accessibility code
index e41a9d12ce7413ed76e70a87a4de5379ca5aaeca..55c070d17a482be6fb69c17f5631d548d670565b 100644 (file)
@@ -59,7 +59,7 @@ WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted
 }
 
 WebInspector.RawSourceCode.Events = {
-    UISourceCodeListChanged: "us-source-code-list-changed"
+    UISourceCodeChanged: "us-source-code-changed"
 }
 
 WebInspector.RawSourceCode.prototype = {
@@ -97,13 +97,13 @@ WebInspector.RawSourceCode.prototype = {
     },
 
     /**
-     * @return {Array.<WebInspector.UISourceCode>}
+     * @return {WebInspector.UISourceCode|null}
      */
-    uiSourceCodeList: function()
+    uiSourceCode: function()
     {
         if (this._sourceMapping)
-            return this._sourceMapping.uiSourceCodeList();
-        return [];
+            return this._sourceMapping.uiSourceCode();
+        return null;
     },
 
     /**
@@ -223,11 +223,11 @@ WebInspector.RawSourceCode.prototype = {
      */
     _saveSourceMapping: function(sourceMapping)
     {
-        var oldUISourceCodeList = [];
+        var oldUISourceCode;
         if (this._sourceMapping)
-            oldUISourceCodeList = this._sourceMapping.uiSourceCodeList();
+            oldUISourceCode = this._sourceMapping.uiSourceCode();
         this._sourceMapping = sourceMapping;
-        this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, { oldUISourceCodeList: oldUISourceCodeList });
+        this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { oldUISourceCode: oldUISourceCode });
     }
 }
 
@@ -253,7 +253,12 @@ WebInspector.RawSourceCode.SourceMapping.prototype = {
      * @param {number} columnNumber
      * @return {DebuggerAgent.Location}
      */
-    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) { }
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) { },
+
+    /**
+     * @return {WebInspector.UISourceCode}
+     */
+    uiSourceCode: function() { }
 }
 
 /**
@@ -265,7 +270,7 @@ WebInspector.RawSourceCode.SourceMapping.prototype = {
 WebInspector.RawSourceCode.PlainSourceMapping = function(rawSourceCode, uiSourceCode)
 {
     this._rawSourceCode = rawSourceCode;
-    this._uiSourceCodeList = [uiSourceCode];
+    this._uiSourceCode = uiSourceCode;
 }
 
 WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
@@ -275,7 +280,7 @@ WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
      */
     rawLocationToUILocation: function(rawLocation)
     {
-        return new WebInspector.UILocation(this._uiSourceCodeList[0], rawLocation.lineNumber, rawLocation.columnNumber || 0);
+        return new WebInspector.UILocation(this._uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber || 0);
     },
 
     /**
@@ -286,16 +291,16 @@ WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
      */
     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
     {
-        console.assert(uiSourceCode === this._uiSourceCodeList[0]);
+        console.assert(uiSourceCode === this._uiSourceCode);
         return WebInspector.debuggerModel.createRawLocation(this._rawSourceCode._scripts[0], lineNumber, columnNumber);
     },
 
     /**
-     * @return {Array.<WebInspector.UISourceCode>}
+     * @return {WebInspector.UISourceCode}
      */
-    uiSourceCodeList: function()
+    uiSourceCode: function()
     {
-        return this._uiSourceCodeList;
+        return this._uiSourceCode;
     }
 }
 
@@ -309,7 +314,7 @@ WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
 WebInspector.RawSourceCode.FormattedSourceMapping = function(rawSourceCode, uiSourceCode, mapping)
 {
     this._rawSourceCode = rawSourceCode;
-    this._uiSourceCodeList = [uiSourceCode];
+    this._uiSourceCode = uiSourceCode;
     this._mapping = mapping;
 }
 
@@ -320,7 +325,7 @@ WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
     rawLocationToUILocation: function(rawLocation)
     {
         var location = this._mapping.originalToFormatted(rawLocation.lineNumber, rawLocation.columnNumber || 0);
-        return new WebInspector.UILocation(this._uiSourceCodeList[0], location[0], location[1]);
+        return new WebInspector.UILocation(this._uiSourceCode, location[0], location[1]);
     },
 
     /**
@@ -331,17 +336,17 @@ WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
      */
     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
     {
-        console.assert(uiSourceCode === this._uiSourceCodeList[0]);
+        console.assert(uiSourceCode === this._uiSourceCode);
         var location = this._mapping.formattedToOriginal(lineNumber, columnNumber);
         return WebInspector.debuggerModel.createRawLocation(this._rawSourceCode._scripts[0], location[0], location[1]);
     },
 
     /**
-     * @return {Array.<WebInspector.UISourceCode>}
+     * @return {WebInspector.UISourceCode}
      */
-    uiSourceCodeList: function()
+    uiSourceCode: function()
     {
-        return this._uiSourceCodeList;
+        return this._uiSourceCode;
     }
 }
 
index 5405057ee523455c9b3874c6ffc47081264e70c9..62d4cdef6b1ba6aa572292d20b49fc9c56f8b045 100644 (file)
@@ -73,9 +73,9 @@ WebInspector.ResourceScriptMapping.prototype = {
     {
         var result = [];
         for (var i = 0; i < this._rawSourceCodes.length; ++i) {
-            var uiSourceCodeList = this._rawSourceCodes[i].uiSourceCodeList();
-            for (var j = 0; j < uiSourceCodeList.length; ++j)
-                result.push(uiSourceCodeList[j]);
+            var uiSourceCode = this._rawSourceCodes[i].uiSourceCode();
+            if (uiSourceCode)
+                result.push(uiSourceCode);
         }
         return result;
     },
@@ -107,36 +107,38 @@ WebInspector.ResourceScriptMapping.prototype = {
         if (isInlineScript)
             this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode;
 
-        if (rawSourceCode.uiSourceCodeList().length)
-            this._uiSourceCodeListChanged(rawSourceCode, [], rawSourceCode.uiSourceCodeList());
-        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
+        if (rawSourceCode.uiSourceCode())
+            this._uiSourceCodeChanged(rawSourceCode, null, rawSourceCode.uiSourceCode());
+        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, this._handleUISourceCodeChanged, this);
     },
 
     /**
      * @param {WebInspector.Event} event
      */
-    _handleUISourceCodeListChanged: function(event)
+    _handleUISourceCodeChanged: function(event)
     {
         var rawSourceCode = /** @type {WebInspector.RawSourceCode} */ event.target;
-        var oldUISourceCodeList = /** @type {Array.<WebInspector.UISourceCode>} */ event.data["oldUISourceCodeList"];
-        this._uiSourceCodeListChanged(rawSourceCode, oldUISourceCodeList, rawSourceCode.uiSourceCodeList());
+        var oldUISourceCode = /** @type {WebInspector.UISourceCode} */ event.data.oldUISourceCode;
+        this._uiSourceCodeChanged(rawSourceCode, oldUISourceCode, rawSourceCode.uiSourceCode());
     },
 
     /**
      * @param {WebInspector.RawSourceCode} rawSourceCode
-     * @param {Array.<WebInspector.UISourceCode>} removedItems
-     * @param {Array.<WebInspector.UISourceCode>} addedItems
+     * @param {WebInspector.UISourceCode} removedItem
+     * @param {WebInspector.UISourceCode} addedItem
      */
-    _uiSourceCodeListChanged: function(rawSourceCode, removedItems, addedItems)
+    _uiSourceCodeChanged: function(rawSourceCode, removedItem, addedItem)
     {
-        for (var i = 0; i < removedItems.length; ++i)
-            this._rawSourceCodeForUISourceCode.remove(removedItems[i]);
-        for (var i = 0; i < addedItems.length; ++i)
-            this._rawSourceCodeForUISourceCode.put(addedItems[i], rawSourceCode);
+        if (removedItem)
+            this._rawSourceCodeForUISourceCode.remove(removedItem);
+        if (addedItem)
+            this._rawSourceCodeForUISourceCode.put(addedItem, rawSourceCode);
 
         var scriptIds = [];
         for (var i = 0; i < rawSourceCode._scripts.length; ++i)
             scriptIds.push(rawSourceCode._scripts[i].scriptId);
+        var removedItems = removedItem ? [removedItem] : [];
+        var addedItems = addedItem ? [addedItem] : [];
         var data = { removedItems: removedItems, addedItems: addedItems, scriptIds: scriptIds };
         this.dispatchEventToListeners(WebInspector.ScriptMapping.Events.UISourceCodeListChanged, data);
     },
@@ -177,7 +179,7 @@ WebInspector.ResourceScriptMapping.prototype = {
     {
         for (var i = 0; i < this._rawSourceCodes.length; ++i) {
             var rawSourceCode = this._rawSourceCodes[i];
-            this._uiSourceCodeListChanged(rawSourceCode, rawSourceCode.uiSourceCodeList(), []);
+            this._uiSourceCodeChanged(rawSourceCode, rawSourceCode.uiSourceCode(), null);
             rawSourceCode.removeAllListeners();
         }
         this._rawSourceCodes = [];