Title: [92838] trunk
Revision
92838
Author
[email protected]
Date
2011-08-11 05:20:59 -0700 (Thu, 11 Aug 2011)

Log Message

Web Inspector: use source-file-replaced instead of source-file-changed event.
https://bugs.webkit.org/show_bug.cgi?id=65551

Reviewed by Pavel Feldman.

Source/WebCore:

Test: inspector/debugger/source-frame-count.html

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype._addScript):
(WebInspector.DebuggerPresentationModel.prototype._uiSourceCodeReplaced):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._removeSourceFrame):
(WebInspector.ScriptsPanel.prototype._sourceFileReplaced):
* inspector/front-end/SourceFile.js:
(WebInspector.RawSourceCode):
(WebInspector.RawSourceCode.prototype.get uiSourceCode):
(WebInspector.RawSourceCode.prototype.reload):
* inspector/front-end/inspector.js:
(WebInspector._createPanels):

LayoutTests:

* inspector/debugger/scripts-panel-expected.txt:
* inspector/debugger/scripts-panel.html:
* inspector/debugger/source-file-expected.txt:
* inspector/debugger/source-file.html:
* inspector/debugger/source-frame-count-expected.txt: Added.
* inspector/debugger/source-frame-count.html: Added.
* platform/chromium/test_expectations.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (92837 => 92838)


--- trunk/LayoutTests/ChangeLog	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/LayoutTests/ChangeLog	2011-08-11 12:20:59 UTC (rev 92838)
@@ -1,3 +1,18 @@
+2011-08-11  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: use source-file-replaced instead of source-file-changed event.
+        https://bugs.webkit.org/show_bug.cgi?id=65551
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/debugger/scripts-panel-expected.txt:
+        * inspector/debugger/scripts-panel.html:
+        * inspector/debugger/source-file-expected.txt:
+        * inspector/debugger/source-file.html:
+        * inspector/debugger/source-frame-count-expected.txt: Added.
+        * inspector/debugger/source-frame-count.html: Added.
+        * platform/chromium/test_expectations.txt:
+
 2011-08-11  Andrei Popescu  <[email protected]>
 
         Master: Support CSS3 font feature properties

Modified: trunk/LayoutTests/inspector/debugger/scripts-panel-expected.txt (92837 => 92838)


--- trunk/LayoutTests/inspector/debugger/scripts-panel-expected.txt	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel-expected.txt	2011-08-11 12:20:59 UTC (rev 92838)
@@ -1,29 +1,38 @@
 Tests that scripts panel UI elements work as intended.
 
-Debugger was enabled.
 
 Running: testInitialLoad
+Source requested for foo.js
+Dump files select:
+        bar.js
+        baz.js
+        foo.js
+Source requested for baz.js
 
 Running: testHistory
+Source requested for index.html
+Source requested for script1.js
+Source requested for script2.js
+Source requested for script3.js
 
-Running: testSourceFramesCount
-Page reloaded.
-
 Running: testFilesSelect
-text:         ?a=b, tooltip: ?a=b
-text:         …oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url, tooltip: very_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url
-text: example.com, tooltip: 
-text:         ?a=b, tooltip: http://example.com/?a=b
-text: localhost, tooltip: 
-text: LayoutTests/inspector/debugger/foo/bar, tooltip: 
-text:         script.js, tooltip: <root>/foo/bar/script.js
-text:         script.js?a=1, tooltip: <root>/foo/bar/script.js?a=1
-text:         script.js?a=2, tooltip: <root>/foo/bar/script.js?a=2
-text: LayoutTests/inspector/debugger/foo/baz, tooltip: 
-text:         script.js, tooltip: <root>/foo/baz/script.js
-text: Content scripts, tooltip: 
-text:         contentScript.js?a=1, tooltip: <root>/foo/bar/contentScript.js?a=1
-text:         contentScript.js?a=2, tooltip: <root>/foo/bar/contentScript.js?a=2
-text:         contentScript2.js?a=1, tooltip: <root>/foo/bar/contentScript2.js?a=1
-Debugger was disabled.
+        ?a=b(?a=b)
+        ...oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url(very_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url)
+example.com
+        ?a=b(http://example.com/?a=b)
+localhost
+LayoutTests/inspector/debugger/foo/bar
+        script.js(<root>/foo/bar/script.js)
+        script.js?a=1(<root>/foo/bar/script.js?a=1)
+        script.js?a=2(<root>/foo/bar/script.js?a=2)
+LayoutTests/inspector/debugger/foo/baz
+        script.js(<root>/foo/baz/script.js)
+Content scripts
+        contentScript.js?a=1(<root>/foo/bar/contentScript.js?a=1)
+        contentScript.js?a=2(<root>/foo/bar/contentScript.js?a=2)
+        contentScript2.js?a=1(<root>/foo/bar/contentScript2.js?a=1)
 
+Running: testSourceReplaced
+Source requested for foo.js
+Source requested for bar.js
+

Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (92837 => 92838)


--- trunk/LayoutTests/inspector/debugger/scripts-panel.html	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html	2011-08-11 12:20:59 UTC (rev 92838)
@@ -1,133 +1,123 @@
 <html>
 <head>
 <script src=""
-<script src=""
-<script src=""
-<script src=""
-<script src=""
 
 <script>
 
 function test()
 {
-    var panel = WebInspector.panels.scripts;
-    var select = panel._filesSelectElement;
-    var files = ["debugger-test.js", "inspector-test.js", "script1.js", "script2.js", "script3.js", "scripts-panel.html"];
+    function createMockScript(url, scriptId)
+    {
+        return {
+            sourceURL: url,
+            scriptId: scriptId,
+            requestSource: function(callback)
+            {
+                InspectorTest.addResult("Source requested for " + url);
+                callback("");
+            }
+        };
+    }
 
-    InspectorTest.runDebuggerTestSuite([
+    function showSourceFrame(panel, fileName)
+    {
+        var select = panel._filesSelectElement;
+        for (var i = 0; i < select.length; ++i) {
+            if (select[i].text.indexOf(fileName) === -1)
+                continue;
+            select.selectedIndex = i;
+            panel._filesSelectChanged();
+            break;
+        }
+    }
+
+    InspectorTest.runTestSuite([
         function testInitialLoad(next)
         {
-            function checkFilesList()
-            {
-                for (var i = 0; i < files.length; ++i) {
-                    var found = false;
-                    for (var j = 0; j < select.length; ++j) {
-                        if (select[j].text.indexOf(files[i]) !== -1) {
-                            found = true;
-                            break;
-                        }
-                    }
-                    if (!found) {
-                        InspectorTest.addSniffer(panel, "_addOptionToFilesSelect", checkFilesList);
-                        return;
-                    }
-                }
+            var model = new WebInspector.DebuggerPresentationModel();
+            var panel = new WebInspector.ScriptsPanel(model);
 
-                var sourceFrameCount = 0;
-                for (var sourceFileId in panel._sourceFileIdToSourceFrame)
-                    sourceFrameCount += 1;
-                InspectorTest.assertEquals(1, sourceFrameCount, "wrong number of source frames created during initial load");
+            model._addScript(createMockScript("foo.js", "1"));
+            model._addScript(createMockScript("bar.js", "2"));
+            model._addScript(createMockScript("baz.js", "3"));
 
-                next();
-            }
-            checkFilesList();
+            InspectorTest.addResult("Dump files select:");
+            var select = panel._filesSelectElement;
+            for (var i = 0; i < select.length; ++i)
+                InspectorTest.addResult(select[i].text.replace(/\u00a0/g, " "));
+
+            // Selected file should be "foo.js".
+            InspectorTest.assertEquals(2, select.selectedIndex);
+            InspectorTest.assertEquals("foo.js", select[2].text.replace(/\s/g, ""));
+
+            // Select "baz.js".
+            select.selectedIndex = 1;
+            panel._filesSelectChanged();
+
+            next();
         },
 
         function testHistory(next)
         {
-            function showSourceFrame(fileName)
-            {
-                for (var i = 0; i < select.length; ++i) {
-                    if (select[i].text.indexOf(fileName) === -1)
-                        continue;
-                    select.selectedIndex = i;
-                    panel._filesSelectChanged();
-                    break;
-                }
-            }
+            var model = new WebInspector.DebuggerPresentationModel();
+            var panel = new WebInspector.ScriptsPanel(model);
 
+            var files = ["index.html", "script1.js", "script2.js", "script3.js"];
+            for (var i = 0; i < files.length; ++i)
+                model._addScript(createMockScript(files[i], (i + 1).toString()));
+
             function checkCurrentlySelectedFileName(fileName)
             {
-                InspectorTest.assertTrue(select[select.selectedIndex].text.indexOf(fileName) !== -1, "Option text should contain file name: " + select[select.selectedIndex].text + " vs " + fileName);
+                var index = panel._filesSelectElement.selectedIndex;
+                var text = panel._filesSelectElement[index].text;
+                InspectorTest.assertTrue(text.indexOf(fileName) !== -1,
+                    "Wrong option text. Expected <" + fileName + ">, found <" + text + ">.");
             }
 
             for (var i = 0; i < files.length; ++i)
-                showSourceFrame(files[i]);
-            checkCurrentlySelectedFileName("scripts-panel.html");
-            InspectorTest.assertEquals(true, panel.forwardButton.disabled, "Forward should be disabled at first.");
+                showSourceFrame(panel, files[i]);
+            checkCurrentlySelectedFileName("script3.js");
+            InspectorTest.assertEquals(true, panel.forwardButton.disabled, "Forward should be disabled.");
 
             panel.backButton.click();
-            checkCurrentlySelectedFileName("script3.js");
+            checkCurrentlySelectedFileName("script2.js");
             InspectorTest.assertEquals(false, panel.forwardButton.disabled, "Forward should be enabled after back button click.");
 
             panel.forwardButton.click();
-            checkCurrentlySelectedFileName("scripts-panel.html");
+            checkCurrentlySelectedFileName("script3.js");
             InspectorTest.assertEquals(true, panel.forwardButton.disabled, "Forward should be disabled after forward button click.");
 
-            for (var i = 0; i < files.length - 1; ++i)
-                panel.backButton.click();
+            panel.backButton.click();
+            checkCurrentlySelectedFileName("script2.js");
 
-            checkCurrentlySelectedFileName("debugger-test.js");
+            panel.backButton.click();
+            checkCurrentlySelectedFileName("script1.js");
 
+            panel.backButton.click();
+            checkCurrentlySelectedFileName("index.html");
+
             panel.forwardButton.click();
             panel.forwardButton.click();
-            panel.forwardButton.click();
             checkCurrentlySelectedFileName("script2.js");
 
-            showSourceFrame("inspector-test.js");
-            checkCurrentlySelectedFileName("inspector-test.js");
+            showSourceFrame(panel, "script1.js");
+            checkCurrentlySelectedFileName("script1.js");
             InspectorTest.assertEquals(true, panel.forwardButton.disabled);
 
             panel.backButton.click();
             checkCurrentlySelectedFileName("script2.js");
 
             panel.backButton.click();
-            checkCurrentlySelectedFileName("script1.js");
+            checkCurrentlySelectedFileName("index.html");
 
-            panel.backButton.click();
-            checkCurrentlySelectedFileName("debugger-test.js");
-
             next();
         },
 
-        function testSourceFramesCount(next)
-        {
-            var sourceFrameCount = 0;
-
-            InspectorTest.showScriptSource("scripts-panel.html", didShowScriptSource);
-
-            function didShowScriptSource()
-            {
-                function didCreateSourceFrame()
-                {
-                    sourceFrameCount += 1;
-                }
-                InspectorTest.addSniffer(panel, "_createSourceFrame", didCreateSourceFrame, true);
-                InspectorTest.reloadPage(didReload);
-            }
-
-            function didReload()
-            {
-                InspectorTest.assertTrue(select[select.selectedIndex].text.indexOf("scripts-panel.html") !== -1);
-                // There should be maximum 2 source frames: first one is the first shown, second one is the last viewed ("scripts-panel.html").
-                InspectorTest.assertEquals(true, sourceFrameCount <= 2, "too many source frames created after page reload");
-                next();
-            }
-        },
-
         function testFilesSelect(next)
         {
-            var panel = new WebInspector.ScriptsPanel();
+            var model = new WebInspector.DebuggerPresentationModel();
+            var panel = new WebInspector.ScriptsPanel(model);
+
             var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/";
             var nextId = 0;
             function addOption(url, isContentScript)
@@ -149,37 +139,30 @@
             for (var i = 0; i < select.length; ++i) {
                 var option = select[i];
                 var text = option.text.replace(/.*LayoutTests/, "LayoutTests");
+                text = text.replace(/\u00a0/g, " ").replace(/\u2026/g, "...");
                 var tooltip = option.title.replace(rootURL, "<root>/");
-                InspectorTest.addResult("text: " + text + ", tooltip: " + tooltip);
+                InspectorTest.addResult(text + (tooltip ? "(" + tooltip + ")" : ""));
             }
             next();
+        },
+
+        function testSourceReplaced(next)
+        {
+            var model = new WebInspector.DebuggerPresentationModel();
+            var panel = new WebInspector.ScriptsPanel(model);
+
+            model._addScript(createMockScript("foo.js", "1"));
+            model._addScript(createMockScript("bar.js", "2"));
+            var sourceFile = model._sourceFileForScript("bar.js");
+            panel._sourceFileReplaced({ data: { oldSourceCode: sourceFile, sourceCode: sourceFile }});
+            showSourceFrame(panel, "bar.js");
+            next();
         }
     ]);
 };
 
 </script>
 
-<script>
-function secondInlinedScriptInPage()
-{
-    return 0;
-}
-</script>
-
-<script>
-function thirdInlinedScriptInPage()
-{
-    return 0;
-}
-</script>
-
-<script>
-function fourthInlinedScriptInPage()
-{
-    return 0;
-}
-</script>
-
 </head>
 
 <body _onload_="runTest()">

Modified: trunk/LayoutTests/inspector/debugger/source-file-expected.txt (92837 => 92838)


--- trunk/LayoutTests/inspector/debugger/source-file-expected.txt	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/LayoutTests/inspector/debugger/source-file-expected.txt	2011-08-11 12:20:59 UTC (rev 92838)
@@ -9,3 +9,5 @@
 
 Running: testConcatenatedFormattedConvertLocation
 
+Running: testUISourceCodeAdded
+

Modified: trunk/LayoutTests/inspector/debugger/source-file.html (92837 => 92838)


--- trunk/LayoutTests/inspector/debugger/source-file.html	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/LayoutTests/inspector/debugger/source-file.html	2011-08-11 12:20:59 UTC (rev 92838)
@@ -109,6 +109,19 @@
                 next();
             }
             sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);
+        },
+
+        function testUISourceCodeAdded(next)
+        {
+            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
+            var sourceFile = new WebInspector.RawSourceCode("id", script);
+            function uiSourceCodeAdded(event)
+            {
+                InspectorTest.assertEquals("foo.js", event.data.url);
+            }
+            sourceFile.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeAdded, uiSourceCodeAdded, this);
+
+            next();
         }
     ]);
 };

Added: trunk/LayoutTests/inspector/debugger/source-frame-count-expected.txt (0 => 92838)


--- trunk/LayoutTests/inspector/debugger/source-frame-count-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/source-frame-count-expected.txt	2011-08-11 12:20:59 UTC (rev 92838)
@@ -0,0 +1,8 @@
+Tests that scripts panel does not create too many source frames.
+
+Debugger was enabled.
+
+Running: testSourceFramesCount
+Page reloaded.
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/source-frame-count-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/debugger/source-frame-count.html (0 => 92838)


--- trunk/LayoutTests/inspector/debugger/source-frame-count.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/source-frame-count.html	2011-08-11 12:20:59 UTC (rev 92838)
@@ -0,0 +1,72 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+
+<script>
+
+function test()
+{
+    InspectorTest.runDebuggerTestSuite([
+        function testSourceFramesCount(next)
+        {
+            var panel = WebInspector.panels.scripts;
+            var select = panel._filesSelectElement;
+            var sourceFrameCount = 0;
+
+            InspectorTest.showScriptSource("source-frame-count.html", didShowScriptSource);
+
+            function didShowScriptSource()
+            {
+                function didCreateSourceFrame()
+                {
+                    sourceFrameCount += 1;
+                }
+                InspectorTest.addSniffer(panel, "_createSourceFrame", didCreateSourceFrame, true);
+                InspectorTest.reloadPage(didReload);
+            }
+
+            function didReload()
+            {
+                InspectorTest.assertTrue(select[select.selectedIndex].text.indexOf("source-frame-count.html") !== -1);
+                // There should be maximum 2 source frames: first one is the first shown, second one is the last viewed ("scripts-panel.html").
+                InspectorTest.assertEquals(true, sourceFrameCount <= 2, "too many source frames created after page reload");
+                next();
+            }
+        }
+    ]);
+};
+
+</script>
+
+<script>
+function secondInlinedScriptInPage()
+{
+    return 0;
+}
+</script>
+
+<script>
+function thirdInlinedScriptInPage()
+{
+    return 0;
+}
+</script>
+
+<script>
+function fourthInlinedScriptInPage()
+{
+    return 0;
+}
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests that scripts panel does not create too many source frames.</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/source-frame-count.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (92837 => 92838)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-08-11 12:20:59 UTC (rev 92838)
@@ -3411,7 +3411,6 @@
 // New test added in r87324
 BUGCR83994 WIN : platform/win/plugins/call-_javascript_-that-destroys-plugin.html = CRASH
 
-BUGWK61519 LINUX WIN : inspector/debugger/scripts-panel.html = PASS TIMEOUT TEXT
 BUGCR84031 : storage/domstorage/sessionstorage/delete-removal.html = PASS TIMEOUT
 BUGCR84032 WIN CPU : fast/dom/object-plugin-hides-properties.html = PASS TIMEOUT
 

Modified: trunk/Source/WebCore/ChangeLog (92837 => 92838)


--- trunk/Source/WebCore/ChangeLog	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/Source/WebCore/ChangeLog	2011-08-11 12:20:59 UTC (rev 92838)
@@ -1,3 +1,25 @@
+2011-08-11  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: use source-file-replaced instead of source-file-changed event.
+        https://bugs.webkit.org/show_bug.cgi?id=65551
+
+        Reviewed by Pavel Feldman.
+
+        Test: inspector/debugger/source-frame-count.html
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype._addScript):
+        (WebInspector.DebuggerPresentationModel.prototype._uiSourceCodeReplaced):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._removeSourceFrame):
+        (WebInspector.ScriptsPanel.prototype._sourceFileReplaced):
+        * inspector/front-end/SourceFile.js:
+        (WebInspector.RawSourceCode):
+        (WebInspector.RawSourceCode.prototype.get uiSourceCode):
+        (WebInspector.RawSourceCode.prototype.reload):
+        * inspector/front-end/inspector.js:
+        (WebInspector._createPanels):
+
 2011-08-11  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: [REGRESSION] Resources panel search fails when search result is found in a resource used in several frames.

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (92837 => 92838)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-08-11 12:20:59 UTC (rev 92838)
@@ -58,7 +58,7 @@
 
 WebInspector.DebuggerPresentationModel.Events = {
     SourceFileAdded: "source-file-added",
-    SourceFileChanged: "source-file-changed",
+    SourceFileReplaced: "source-file-replaced",
     ConsoleMessageAdded: "console-message-added",
     ConsoleMessagesCleared: "console-messages-cleared",
     BreakpointAdded: "breakpoint-added",
@@ -177,20 +177,28 @@
             return;
         }
 
-        function contentChanged(sourceFile)
-        {
-            if (this._sourceFiles[sourceFileId] === sourceFile)
-                this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileChanged, this._sourceFiles[sourceFileId]);
-        }
-        sourceFile = new WebInspector.RawSourceCode(sourceFileId, script, this._formatter, contentChanged.bind(this));
+        sourceFile = new WebInspector.RawSourceCode(sourceFileId, script, this._formatter);
         sourceFile.setFormatted(this._formatSourceFiles);
         this._sourceFiles[sourceFileId] = sourceFile;
+        sourceFile.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this);
 
         this._restoreBreakpoints(sourceFile);
 
-        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, sourceFile);
+        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, sourceFile.uiSourceCode);
     },
 
+    _uiSourceCodeReplaced: function(event)
+    {
+        var oldUISourceCode = event.data.oldSourceCode;
+        var newUISourceCode = event.data.sourceCode;
+
+        delete this._sourceFiles[oldUISourceCode.id];
+        this._sourceFiles[newUISourceCode.id] = newUISourceCode;
+
+        // FIXME: restore breakpoints in new source code (currently we just recreate everything when switching to pretty-print mode).
+        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileReplaced, event.data);
+    },
+
     _restoreBreakpoints: function(sourceFile)
     {
         var pendingBreakpoints = this._breakpointsWithoutSourceFile[sourceFile.id];

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (92837 => 92838)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-08-11 12:20:59 UTC (rev 92838)
@@ -24,11 +24,11 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.ScriptsPanel = function()
+WebInspector.ScriptsPanel = function(presentationModel)
 {
     WebInspector.Panel.call(this, "scripts");
 
-    this._presentationModel = WebInspector.debuggerPresentationModel;
+    this._presentationModel = presentationModel;
 
     this.registerShortcuts();
 
@@ -157,7 +157,7 @@
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerWasDisabled, this);
 
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, this._sourceFileAdded, this)
-    this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.SourceFileChanged, this._sourceFileChanged, this);
+    this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.SourceFileReplaced, this._sourceFileReplaced, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, this._consoleMessageAdded, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, this._breakpointAdded, this);
@@ -639,21 +639,30 @@
         return sourceFrame;
     },
 
-    _sourceFileChanged: function(event)
+    _removeSourceFrame: function(sourceFileId)
     {
-        var sourceFileId = event.data.id;
-
-        var oldSourceFrame = this._sourceFileIdToSourceFrame[sourceFileId];
-        if (!oldSourceFrame)
+        var sourceFrame = this._sourceFileIdToSourceFrame[sourceFileId];
+        if (!sourceFrame)
             return;
-        oldSourceFrame.removeEventListener(WebInspector.SourceFrame.Events.Loaded, this._sourceFrameLoaded, this);
         delete this._sourceFileIdToSourceFrame[sourceFileId];
-        if (this.visibleView !== oldSourceFrame)
-            return;
+        sourceFrame.removeEventListener(WebInspector.SourceFrame.Events.Loaded, this._sourceFrameLoaded, this);
+    },
 
-        var newSourceFrame = this._createSourceFrame(sourceFileId)
-        newSourceFrame.inheritScrollPositionsFromView(oldSourceFrame);
-        this.visibleView = newSourceFrame;
+    _sourceFileReplaced: function(event)
+    {
+        var oldSourceFile = event.data.oldSourceCode;
+        var newSourceFile = event.data.sourceCode;
+
+        // Re-bind file select option from old source file to new one.
+        var option = this._sourceFileIdToFilesSelectOption[oldSourceFile.id];
+        delete this._sourceFileIdToFilesSelectOption[oldSourceFile.id];
+        option.sourceFileId = newSourceFile.id;
+        this._sourceFileIdToFilesSelectOption[newSourceFile.id] = option;
+
+        // Remove old source frame and create new one if needed.
+        this._removeSourceFrame(oldSourceFile.id);
+        if (option === this._filesSelectElement[this._filesSelectElement.selectedIndex])
+            this._showSourceFrame(newSourceFile.id);
     },
 
     _sourceFrameLoaded: function(event)

Modified: trunk/Source/WebCore/inspector/front-end/SourceFile.js (92837 => 92838)


--- trunk/Source/WebCore/inspector/front-end/SourceFile.js	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/Source/WebCore/inspector/front-end/SourceFile.js	2011-08-11 12:20:59 UTC (rev 92838)
@@ -30,12 +30,12 @@
 
 // RawSourceCode represents _javascript_ resource or HTML resource with inlined scripts
 // as it came from network.
-WebInspector.RawSourceCode = function(id, script, formatter, contentChangedDelegate)
+WebInspector.RawSourceCode = function(id, script, formatter)
 {
     this._scripts = [script];
     this._formatter = formatter;
     this._formatted = false;
-    this._contentChangedDelegate = contentChangedDelegate;
+
     if (script.sourceURL)
         this._resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
     this._requestContentCallbacks = [];
@@ -50,12 +50,22 @@
         this._resource.addEventListener("finished", this.reload.bind(this));
 }
 
+WebInspector.RawSourceCode.Events = {
+    UISourceCodeReplaced: "ui-source-code-replaced"
+}
+
 WebInspector.RawSourceCode.prototype = {
     addScript: function(script)
     {
         this._scripts.push(script);
     },
 
+    get uiSourceCode()
+    {
+        // FIXME: extract UISourceCode from RawSourceCode (currently RawSourceCode implements methods from both interfaces).
+        return this;
+    },
+
     rawLocationToUILocation: function(rawLocation)
     {
         var uiLocation = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation;
@@ -153,7 +163,8 @@
     {
         if (this._contentLoaded) {
             this._contentLoaded = false;
-            this._contentChangedDelegate(this);
+            // FIXME: create another UISourceCode instance here, UISourceCode should be immutable.
+            this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, { oldSourceCode: this, sourceCode: this });
         } else if (this._contentRequested)
             this._reloadContent = true;
         else if (this._requestContentCallbacks.length)
@@ -291,3 +302,5 @@
         return this._resource && !this._resource.finished;
     }
 }
+
+WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (92837 => 92838)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2011-08-11 11:30:31 UTC (rev 92837)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2011-08-11 12:20:59 UTC (rev 92838)
@@ -155,7 +155,7 @@
     _createPanels: function()
     {
         if (WebInspector.WorkerManager.isWorkerFrontend()) {
-            this.panels.scripts = new WebInspector.ScriptsPanel();
+            this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
             this.panels.console = new WebInspector.ConsolePanel();
             return;
         }
@@ -167,7 +167,7 @@
         if (hiddenPanels.indexOf("network") === -1)
             this.panels.network = new WebInspector.NetworkPanel();
         if (hiddenPanels.indexOf("scripts") === -1)
-            this.panels.scripts = new WebInspector.ScriptsPanel();
+            this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
         if (hiddenPanels.indexOf("timeline") === -1)
             this.panels.timeline = new WebInspector.TimelinePanel();
         if (hiddenPanels.indexOf("profiles") === -1)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to