Web Inspector: Workspace should support several projects and should not have temporar...
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2013 17:31:04 +0000 (17:31 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2013 17:31:04 +0000 (17:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105856

Reviewed by Pavel Feldman.

Source/WebCore:

Workspace now supports several projects with the networkProject being a main one.
Replaced temporary UISourceCodes with specific projects (debugger and liveedit).
The concept of workspace reset on navigation is now replaced with project reset concept instead.
Introduced snippets project (that is not reset on navigation).
Script mappings are now reset on GlobalObjectCleared event.

* inspector/front-end/BreakpointManager.js:
(WebInspector.BreakpointManager):
(WebInspector.BreakpointManager.prototype._innerSetBreakpoint):
(WebInspector.BreakpointManager.prototype._filteredBreakpointLocations):
(WebInspector.BreakpointManager.prototype.toggleAllBreakpoints):
(WebInspector.BreakpointManager.prototype.removeAllBreakpoints):
(WebInspector.BreakpointManager.prototype._projectWillReset.get for):
(WebInspector.BreakpointManager.prototype._projectWillReset):
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel):
(WebInspector.CSSStyleModel.prototype._inspectedURLChanged):
(WebInspector.CSSStyleModel.prototype._resetSourceMappings):
(WebInspector.CSSStyleModelResourceBinding):
(WebInspector.CSSStyleModelResourceBinding.prototype._viaInspectorResourceURL):
(WebInspector.CSSStyleModelResourceBinding.prototype._reset):
* inspector/front-end/CompilerScriptMapping.js:
(WebInspector.CompilerScriptMapping):
(WebInspector.CompilerScriptMapping.prototype._debuggerReset):
* inspector/front-end/DebuggerScriptMapping.js:
* inspector/front-end/DefaultScriptMapping.js:
(WebInspector.DefaultScriptMapping):
(WebInspector.DefaultScriptMapping.prototype.addScript):
(WebInspector.DefaultScriptMapping.prototype._debuggerReset):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._onGetPageResources):
* inspector/front-end/FilteredItemSelectionDialog.js:
(WebInspector.OpenResourceDialog.show):
* inspector/front-end/LiveEditSupport.js:
(WebInspector.LiveEditSupport):
(WebInspector.LiveEditSupport.prototype.uiSourceCodeForLiveEdit):
(WebInspector.LiveEditSupport.prototype._debuggerReset):
* inspector/front-end/NetworkUISourceCodeProvider.js:
(WebInspector.NetworkUISourceCodeProvider):
(WebInspector.NetworkUISourceCodeProvider.prototype._mainFrameNavigated):
(WebInspector.NetworkUISourceCodeProvider.prototype._addFile):
(WebInspector.NetworkUISourceCodeProvider.prototype._reset):
* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAddedToWorkspace):
(WebInspector.ResourceScriptMapping.prototype._debuggerReset):
* inspector/front-end/RevisionHistoryView.js:
(WebInspector.RevisionHistoryView):
(WebInspector.RevisionHistoryView.prototype._projectWillReset):
* inspector/front-end/SASSSourceMapping.js:
(_bindUISourceCode):
* inspector/front-end/ScriptSnippetModel.js:
(WebInspector.ScriptSnippetModel):
(WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
(WebInspector.ScriptSnippetModel.prototype.reset):
* inspector/front-end/ScriptsNavigator.js:
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
(WebInspector.ScriptsPanel.prototype._addUISourceCode):
(WebInspector.ScriptsPanel.prototype._uiSourceCodeRemoved):
(WebInspector.ScriptsPanel.prototype._removeUISourceCodes):
(WebInspector.ScriptsPanel.prototype._debuggerWasDisabled):
(WebInspector.ScriptsPanel.prototype._debuggerReset):
(WebInspector.ScriptsPanel.prototype._projectWillReset):
(WebInspector.ScriptsPanel.prototype.canShowAnchorLocation):
(WebInspector.ScriptsPanel.prototype._revealExecutionLine):
(WebInspector.ScriptsPanel.prototype.showGoToSourceDialog):
* inspector/front-end/SimpleWorkspaceProvider.js:
(WebInspector.SimpleWorkspaceProvider):
(WebInspector.SimpleWorkspaceProvider.prototype.addFile):
(WebInspector.SimpleWorkspaceProvider.prototype.addFileForURL):
(WebInspector.SimpleWorkspaceProvider.prototype.reset):
* inspector/front-end/StylesSourceMapping.js:
(WebInspector.StylesSourceMapping):
(WebInspector.StylesSourceMapping.prototype._projectWillReset):
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer.prototype.reset):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.project):
* inspector/front-end/Workspace.js:
(WebInspector.WorkspaceController):
(WebInspector.WorkspaceController.prototype._inspectedURLChanged):
(WebInspector.Project):
(WebInspector.Project.prototype.name):
(WebInspector.Project.prototype.isServiceProject):
(WebInspector.Project.prototype._reset):
(WebInspector.Workspace):
(WebInspector.Workspace.prototype.uiSourceCodeForURL):
(WebInspector.Workspace.prototype.uiSourceCodeForURI):
(WebInspector.Workspace.prototype.addProject):
(WebInspector.Workspace.prototype.project):
(WebInspector.Workspace.prototype.projects):
(WebInspector.Workspace.prototype.uiSourceCodes):
(WebInspector.Workspace.prototype.projectForUISourceCode):
(WebInspector.Workspace.prototype.requestFileContent):
(WebInspector.Workspace.prototype.setFileContent):
(WebInspector.Workspace.prototype.searchInFileContent):
* inspector/front-end/inspector.js:
* inspector/front-end/utilities.js:

LayoutTests:

* http/tests/inspector-enabled/dynamic-scripts.html:
* http/tests/inspector/compiler-script-mapping.html:
* http/tests/inspector/network/network-request-revision-content.html:
* http/tests/inspector/workspace-test.js:
(initialize_WorkspaceTest.InspectorTest.createWorkspace):
(initialize_WorkspaceTest.InspectorTest.addMockUISourceCodeToWorkspace):
* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/dynamic-scripts.html:
* inspector/debugger/live-edit-breakpoints-expected.txt:
* inspector/debugger/live-edit-breakpoints.html:
* inspector/debugger/resource-script-mapping-expected.txt:
* inspector/debugger/resource-script-mapping.html:
* inspector/debugger/resources/edit-me-breakpoints.js: Added.
(f):
* inspector/debugger/script-snippet-model-expected.txt:
* inspector/debugger/script-snippet-model.html:
* inspector/debugger/scripts-panel-expected.txt:
* inspector/debugger/scripts-panel.html:
* inspector/debugger/watch-expressions-preserve-expansion-expected.txt:
* inspector/debugger/watch-expressions-preserve-expansion.html:
* inspector/uisourcecode-revisions.html:

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

42 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector-enabled/dynamic-scripts.html
LayoutTests/http/tests/inspector/compiler-script-mapping.html
LayoutTests/http/tests/inspector/network/network-request-revision-content.html
LayoutTests/http/tests/inspector/workspace-test.js
LayoutTests/inspector/debugger/breakpoint-manager.html
LayoutTests/inspector/debugger/dynamic-scripts.html
LayoutTests/inspector/debugger/live-edit-breakpoints-expected.txt
LayoutTests/inspector/debugger/live-edit-breakpoints.html
LayoutTests/inspector/debugger/resource-script-mapping-expected.txt
LayoutTests/inspector/debugger/resource-script-mapping.html
LayoutTests/inspector/debugger/resources/edit-me-breakpoints.js [new file with mode: 0644]
LayoutTests/inspector/debugger/script-snippet-model-expected.txt
LayoutTests/inspector/debugger/script-snippet-model.html
LayoutTests/inspector/debugger/scripts-panel-expected.txt
LayoutTests/inspector/debugger/scripts-panel.html
LayoutTests/inspector/debugger/watch-expressions-preserve-expansion-expected.txt
LayoutTests/inspector/debugger/watch-expressions-preserve-expansion.html
LayoutTests/inspector/uisourcecode-revisions.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/BreakpointManager.js
Source/WebCore/inspector/front-end/CSSStyleModel.js
Source/WebCore/inspector/front-end/CompilerScriptMapping.js
Source/WebCore/inspector/front-end/DebuggerScriptMapping.js
Source/WebCore/inspector/front-end/DefaultScriptMapping.js
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js
Source/WebCore/inspector/front-end/LiveEditSupport.js
Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js
Source/WebCore/inspector/front-end/ResourceScriptMapping.js
Source/WebCore/inspector/front-end/RevisionHistoryView.js
Source/WebCore/inspector/front-end/SASSSourceMapping.js
Source/WebCore/inspector/front-end/ScriptSnippetModel.js
Source/WebCore/inspector/front-end/ScriptsNavigator.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/SimpleWorkspaceProvider.js
Source/WebCore/inspector/front-end/StylesSourceMapping.js
Source/WebCore/inspector/front-end/TabbedEditorContainer.js
Source/WebCore/inspector/front-end/UISourceCode.js
Source/WebCore/inspector/front-end/Workspace.js
Source/WebCore/inspector/front-end/inspector.js
Source/WebCore/inspector/front-end/utilities.js

index 7716bf9..7cc1405 100644 (file)
@@ -1,3 +1,32 @@
+2013-01-11  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Web Inspector: Workspace should support several projects and should not have temporary UISourceCodes.
+        https://bugs.webkit.org/show_bug.cgi?id=105856
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector-enabled/dynamic-scripts.html:
+        * http/tests/inspector/compiler-script-mapping.html:
+        * http/tests/inspector/network/network-request-revision-content.html:
+        * http/tests/inspector/workspace-test.js:
+        (initialize_WorkspaceTest.InspectorTest.createWorkspace):
+        (initialize_WorkspaceTest.InspectorTest.addMockUISourceCodeToWorkspace):
+        * inspector/debugger/breakpoint-manager.html:
+        * inspector/debugger/dynamic-scripts.html:
+        * inspector/debugger/live-edit-breakpoints-expected.txt:
+        * inspector/debugger/live-edit-breakpoints.html:
+        * inspector/debugger/resource-script-mapping-expected.txt:
+        * inspector/debugger/resource-script-mapping.html:
+        * inspector/debugger/resources/edit-me-breakpoints.js: Added.
+        (f):
+        * inspector/debugger/script-snippet-model-expected.txt:
+        * inspector/debugger/script-snippet-model.html:
+        * inspector/debugger/scripts-panel-expected.txt:
+        * inspector/debugger/scripts-panel.html:
+        * inspector/debugger/watch-expressions-preserve-expansion-expected.txt:
+        * inspector/debugger/watch-expressions-preserve-expansion.html:
+        * inspector/uisourcecode-revisions.html:
+
 2013-01-11  Sudarsana Nagineni  <sudarsana.nagineni@intel.com>
 
         Unreviewed EFL gardening.
index ae78965..bb952b5 100644 (file)
@@ -51,7 +51,7 @@ function test()
     function step3()
     {
         var panel = WebInspector.showPanel("scripts");
-        var uiSourceCodes = WebInspector.workspace.uiSourceCodes();
+        var uiSourceCodes = WebInspector.workspace.project(WebInspector.projectNames.Network).uiSourceCodes();
         var urls = uiSourceCodes.map(function(uiSourceCode) { return uiSourceCode.parsedURL.lastPathComponent; });
         urls.sort();
         
index 18ebe31..f7a62b3 100644 (file)
@@ -147,7 +147,7 @@ function test()
 
             function step1()
             {
-                InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(originalUISourceCodeAdded);
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
                 script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
                 script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
                 defaultScriptMapping.addScript(script);
@@ -215,7 +215,7 @@ function test()
 
             function step1()
             {
-                InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(function() { });
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(function() { });
                 script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
                 script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
                 defaultScriptMapping.addScript(script);
@@ -278,7 +278,7 @@ function test()
                 "sourcesContent":["<source content>"]
             };
             script.sourceMapURL = "data:application/json;base64," + btoa(JSON.stringify(sourceMap));
-            InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(originalUISourceCodeAdded);
+            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
 
             function originalUISourceCodeAdded(uiSourceCode)
             {
@@ -309,10 +309,9 @@ function test()
         {
             WebInspector.settings.sourceMapsEnabled.set(true);
             WebInspector.debuggerModel._reset();
-            var networkWorkspaceProvider = new WebInspector.NetworkWorkspaceProvider();
             var workspace = new WebInspector.Workspace();
-            var debuggerWorkspaceProvider = new WebInspector.DebuggerWorkspaceProvider(workspace);
-            workspace.addProject("network", networkWorkspaceProvider);
+            var networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+            workspace.addProject(WebInspector.projectNames.Network, networkWorkspaceProvider);
             var debuggerScriptMapping = new WebInspector.DebuggerScriptMapping(workspace, networkWorkspaceProvider);
 
             var script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
index 1553c4a..6590cd3 100644 (file)
@@ -19,6 +19,9 @@ function test()
     var resource;
     function step2(event)
     {
+        var eventUISourceCode = event.data;
+        if (eventUISourceCode.url.indexOf("style.css") == -1)
+            return;
         var request = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 1];
         uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(request.url);
         if (!uiSourceCode)
index 7469f36..10c3ead 100644 (file)
@@ -3,14 +3,11 @@ var initialize_WorkspaceTest = function() {
 InspectorTest.testWorkspace;
 InspectorTest.createWorkspace = function()
 {
-    InspectorTest.testNetworkWorkspaceProvider = new WebInspector.NetworkWorkspaceProvider();
     InspectorTest.testWorkspace = new WebInspector.Workspace();
-    InspectorTest.testDebuggerWorkspaceProvider = new WebInspector.DebuggerWorkspaceProvider(InspectorTest.testWorkspace);
-    InspectorTest.testWorkspace.addProject("network", InspectorTest.testNetworkWorkspaceProvider);
+    InspectorTest.testNetworkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(InspectorTest.testWorkspace);
+    InspectorTest.testWorkspace.addProject(WebInspector.projectNames.Network, InspectorTest.testNetworkWorkspaceProvider);
     InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
     InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
 }
 
 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback)
@@ -26,37 +23,11 @@ InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback)
     }
 }
 
-InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent = function(callback)
-{
-    InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, temporaryUISourceCodeAdded);
-
-    function temporaryUISourceCodeAdded(event)
-    {
-        InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, temporaryUISourceCodeAdded);
-        InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
-        callback(event.data);
-    }
-}
-
-InspectorTest.waitForWorkspaceTemporaryUISourceCodeRemovedEvent = function(callback)
-{
-    InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, temporaryUISourceCodeRemoved);
-
-    function temporaryUISourceCodeRemoved(event)
-    {
-        InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, temporaryUISourceCodeRemoved);
-        InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
-        callback(event.data);
-    }
-}
-
 InspectorTest.addMockUISourceCodeToWorkspace = function(url, type, content)
 {
     var isDocument = type === WebInspector.resourceTypes.Document;
     var mockContentProvider = new WebInspector.StaticContentProvider(type, content);
-    InspectorTest.testNetworkWorkspaceProvider.addNetworkFile(url, mockContentProvider, !isDocument);
+    InspectorTest.testNetworkWorkspaceProvider.addFileForURL(url, mockContentProvider, !isDocument);
 }
 
 InspectorTest._defaultUISourceCodeProviderEventHandler = function(event)
index 2364ae5..6b2646a 100644 (file)
@@ -128,7 +128,6 @@ function test()
         _addTemporaryUISourceCode: function(url)
         {
             var uiSourceCode = new WebInspector.UISourceCode(this, "temporary:" + url, url, WebInspector.resourceTypes.Script, false);
-            uiSourceCode.isTemporary = true;
             uiSourceCode.setSourceMapping(defaultMapping);
             uiSourceCodes[url] = uiSourceCode;
             temporaryUISourceCodes[url] = uiSourceCode;
@@ -151,7 +150,13 @@ function test()
         reset: function()
         {
             InspectorTest.addResult("  Resetting workspace.");
-            this.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset);
+            var self = this;
+            var mockProject = {};
+            mockProject.uiSourceCodes = function()
+            {
+                return self.uiSourceCodes();
+            }
+            this.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, mockProject);
         }
     }
     WorkspaceMock.prototype.__proto__ = WebInspector.Object.prototype;
index b2c93e5..e9e18fd 100644 (file)
@@ -48,7 +48,7 @@ function test()
     function step3()
     {
         var panel = WebInspector.showPanel("scripts");
-        var uiSourceCodes = WebInspector.workspace.uiSourceCodes();
+        var uiSourceCodes = WebInspector.workspace.project(WebInspector.projectNames.Network).uiSourceCodes();
         var urls = uiSourceCodes.map(function(uiSourceCode) { return uiSourceCode.parsedURL.lastPathComponent; });
         urls.sort();
 
index bf947ac..a69b8a6 100644 (file)
@@ -7,26 +7,26 @@ Running: testEditUndo
 Setting breakpoint:
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Editing source:
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
     OriginalTextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Undoing source editing:
     OriginalTextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Finally removing breakpoint:
     TextEditor.removeBreakpoint(lineNumber = 2)
     Dumping breakpoint storage
@@ -36,26 +36,26 @@ Running: testEditCommit
 Setting breakpoint:
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Editing source:
     OriginalTextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Committing edited source:
     OriginalTextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Finally removing breakpoint:
     TextEditor.removeBreakpoint(lineNumber = 2)
     Dumping breakpoint storage
@@ -65,36 +65,36 @@ Running: testEditCommitFailEditCommit
 Setting breakpoint:
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Editing source:
     OriginalTextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Committing edited source:
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Editing source again so that live edit could succeed:
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Committing edited source again:
     OriginalTextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Finally removing breakpoint:
     TextEditor.removeBreakpoint(lineNumber = 2)
     Dumping breakpoint storage
@@ -104,36 +104,36 @@ Running: testEditCommitFailUndoCommit
 Setting breakpoint:
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Editing source:
     OriginalTextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Committing edited source:
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Undoing source editing:
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: true
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: debugger
 Committing edited source again:
     OriginalTextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.removeBreakpoint(lineNumber = 2)
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
-        edit-me.js:2, enabled:true
+        edit-me-breakpoints.js:2, enabled:true
     Dumping breakpoint locations
-        url: edit-me.js, lineNumber: 2, isTemporary: false
+        url: edit-me-breakpoints.js, lineNumber: 2, project name: network
 Finally removing breakpoint:
     TextEditor.removeBreakpoint(lineNumber = 2)
     Dumping breakpoint storage
@@ -148,15 +148,15 @@ Setting breakpoint:
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
     Dumping breakpoint locations
-        url: , lineNumber: 2, isTemporary: true
+        url: , lineNumber: 2, project name: debugger
 Editing source:
     Dumping breakpoint storage
     Dumping breakpoint locations
-        url: , lineNumber: 2, isTemporary: true
+        url: , lineNumber: 2, project name: debugger
 Undoing source editing:
     Dumping breakpoint storage
     Dumping breakpoint locations
-        url: , lineNumber: 2, isTemporary: true
+        url: , lineNumber: 2, project name: debugger
 Finally removing breakpoint:
     TextEditor.removeBreakpoint(lineNumber = 2)
     Dumping breakpoint storage
@@ -171,15 +171,15 @@ Setting breakpoint:
     TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
     Dumping breakpoint storage
     Dumping breakpoint locations
-        url: , lineNumber: 2, isTemporary: true
+        url: , lineNumber: 2, project name: debugger
 Editing source:
     Dumping breakpoint storage
     Dumping breakpoint locations
-        url: , lineNumber: 2, isTemporary: true
+        url: , lineNumber: 2, project name: debugger
 Undoing source editing:
     Dumping breakpoint storage
     Dumping breakpoint locations
-        url: , lineNumber: 2, isTemporary: true
+        url: , lineNumber: 2, project name: debugger
 Finally removing breakpoint:
     TextEditor.removeBreakpoint(lineNumber = 2)
     Dumping breakpoint storage
index f0513e2..73a047d 100644 (file)
@@ -3,7 +3,7 @@
 <script src="../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../http/tests/inspector/debugger-test.js"></script>
 <script src="../../http/tests/inspector/live-edit-test.js"></script>
-<script src="resources/edit-me.js"></script>
+<script src="resources/edit-me-breakpoints.js"></script>
 <script>
 function loadDynamicAnonymousScript()
 {
@@ -30,10 +30,8 @@ function test()
         var breakpointManager = WebInspector.breakpointManager;
         var breakpoints = breakpointManager._storage._setting.get();
         InspectorTest.addResult("    Dumping breakpoint storage");
-        for (var i = 0; i < breakpoints.length; ++i) {
-            var url = 
+        for (var i = 0; i < breakpoints.length; ++i)
             InspectorTest.addResult("        " + pathToFileName(breakpoints[i].sourceFileId) + ":" + breakpoints[i].lineNumber + ", enabled:" + breakpoints[i].enabled);
-        }
 
         var breakpointManager = WebInspector.breakpointManager;
         locations = breakpointManager.allBreakpointLocations();
@@ -41,7 +39,8 @@ function test()
         for (var i = 0; i < locations.length; ++i) {
             var uiLocation = locations[i].uiLocation;
             var uiSourceCode = uiLocation.uiSourceCode;
-            InspectorTest.addResult("        url: " + pathToFileName(uiSourceCode.url) + ", lineNumber: " + uiLocation.lineNumber + ", isTemporary: " + !!uiSourceCode.isTemporary);
+            var project = WebInspector.workspace.projectForUISourceCode(uiSourceCode);
+            InspectorTest.addResult("        url: " + pathToFileName(uiSourceCode.url) + ", lineNumber: " + uiLocation.lineNumber + ", project name: " + project.name());
         }
     }
 
@@ -66,7 +65,7 @@ function test()
         {
             var javaScriptSourceFrame, uiSourceCode, script, originalJavaScriptSourceFrame, originalUISourceCode;
 
-            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+            InspectorTest.showScriptSource("edit-me-breakpoints.js", didShowScriptSource);
 
             function didShowScriptSource(sourceFrame)
             {
@@ -118,7 +117,7 @@ function test()
         {
             var javaScriptSourceFrame, uiSourceCode, script, originalJavaScriptSourceFrame, originalUISourceCode;
 
-            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+            InspectorTest.showScriptSource("edit-me-breakpoints.js", didShowScriptSource);
 
             function didShowScriptSource(sourceFrame)
             {
@@ -169,7 +168,7 @@ function test()
         {
             var javaScriptSourceFrame, uiSourceCode, script, originalJavaScriptSourceFrame, originalUISourceCode;
 
-            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+            InspectorTest.showScriptSource("edit-me-breakpoints.js", didShowScriptSource);
 
             function didShowScriptSource(sourceFrame)
             {
@@ -233,7 +232,7 @@ function test()
         {
             var javaScriptSourceFrame, uiSourceCode, script, originalJavaScriptSourceFrame, originalUISourceCode;
 
-            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+            InspectorTest.showScriptSource("edit-me-breakpoints.js", didShowScriptSource);
 
             function didShowScriptSource(sourceFrame)
             {
index aa3584a..3dab29f 100644 (file)
@@ -5,7 +5,7 @@ Running: testScriptWithPendingResource
 Adding script for pending request.
 UISourceCode: foo.js
 UISourceCode is editable: false
-UISourceCode is content script: false
+UISourceCode is content script: true
 Mime type: text/javascript
 UISourceCode content: <content script source>
 Adding uiSourceCode for finished resource.
index 262e250..24b311b 100644 (file)
@@ -29,7 +29,7 @@ function test()
             {
                 InspectorTest.addResult("Adding script for pending request.");
                 script = InspectorTest.createScriptMock(url, 0, 0, true, "<content script source>");
-                InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(originalUISourceCodeAdded);
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
                 defaultScriptMapping.addScript(script);
                 resourceScriptMapping.addScript(script);
                 
@@ -49,7 +49,6 @@ function test()
             function step2()
             {
                 InspectorTest.addResult("Adding uiSourceCode for finished resource.");
-                InspectorTest.waitForWorkspaceTemporaryUISourceCodeRemovedEvent(function() { });
                 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
                 InspectorTest.addMockUISourceCodeToWorkspace(url, WebInspector.resourceTypes.Script, "<content script resource content>");
 
@@ -110,7 +109,7 @@ function test()
             {
                 InspectorTest.addResult("Adding first script for pending request.");
                 script1 = InspectorTest.createScriptMock(url, 0, 10, false, "<script source 1>");
-                InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(originalUISourceCodeAdded);
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
                 defaultScriptMapping.addScript(script1);
                 resourceScriptMapping.addScript(script1);
                 
@@ -130,7 +129,7 @@ function test()
             {
                 InspectorTest.addResult("Adding second script for pending request.");
                 script2 = InspectorTest.createScriptMock(url, 0, 45, false, "<script source 2>");
-                InspectorTest.waitForWorkspaceTemporaryUISourceCodeAddedEvent(originalUISourceCodeAdded);
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
                 defaultScriptMapping.addScript(script2);
                 resourceScriptMapping.addScript(script2);
 
diff --git a/LayoutTests/inspector/debugger/resources/edit-me-breakpoints.js b/LayoutTests/inspector/debugger/resources/edit-me-breakpoints.js
new file mode 100644 (file)
index 0000000..36ed3f8
--- /dev/null
@@ -0,0 +1,4 @@
+function f()
+{
+    return 0;
+}
index e483c8e..0cee7cf 100644 (file)
@@ -2,10 +2,9 @@ Tests script snippet model.
 
 Debugger was enabled.
 
-Running: testWorkspaceReset
+Running: testCreateAndRename
 Snippet created.
-Resetting snippet script mapping.
-Snippet uiSourceCode was recreated.
+Snippet uiSourceCode url is correct.
 
 Running: testEvaluate
 Last evaluation source url for snippet: snippets:///1_1
index 85bbe73..5826e0b 100644 (file)
@@ -14,34 +14,25 @@ function test()
     // FIXME: Remove once snippets are taken out of experiments.
     WebInspector.experimentsSettings.snippetsSupport = {};
     WebInspector.experimentsSettings.snippetsSupport.isEnabled = function() { return true; };
-    var networkWorkspaceProvider = new WebInspector.NetworkWorkspaceProvider();
     var workspace = new WebInspector.Workspace();
-    workspace.addProject("network", networkWorkspaceProvider);
+    var snippetWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+    workspace.addProject(WebInspector.projectNames.Snippets, snippetWorkspaceProvider);
     var workspaceController = new WebInspector.WorkspaceController(workspace);
-    WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(workspace, networkWorkspaceProvider);
-    
+    WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(workspace, snippetWorkspaceProvider);
     InspectorTest.runDebuggerTestSuite([
-        function testWorkspaceReset(next)
+        function testCreateAndRename(next)
         {
             resetSnippetsSettings();
             var uiSourceCode = WebInspector.scriptSnippetModel.createScriptSnippet();
             var snippetName = "TestSnippet" + Math.random();
             InspectorTest.addResult("Snippet created.");
             WebInspector.scriptSnippetModel.renameScriptSnippet(uiSourceCode, snippetName);
-            workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
-            InspectorTest.addResult("Resetting snippet script mapping.");
-            workspaceController._mainFrameNavigated();
-
-            function uiSourceCodeAdded(event)
-            {
-                InspectorTest.assertEquals(1, workspace.uiSourceCodes().length, "Only one snippet uiSourceCode should be present after project navigation.");
-                var uiSourceCode = event.data;
-                if (uiSourceCode.url.indexOf(snippetName) === -1)
-                    return;
-                InspectorTest.addResult("Snippet uiSourceCode was recreated.");
-                workspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
-                next();
-            }
+            InspectorTest.assertEquals(1, workspace.uiSourceCodes().length, "Only one snippet uiSourceCode should be present.");
+            var uiSourceCode = workspace.uiSourceCodes()[0];
+            if (uiSourceCode.url.indexOf(snippetName) === -1)
+                return;
+            InspectorTest.addResult("Snippet uiSourceCode url is correct.");
+            next();
         },
 
         function testEvaluate(next)
index cdb682e..5ac21cb 100644 (file)
@@ -21,7 +21,7 @@ Dumping ScriptsNavigator 'Scripts' tab:
   bar.js
 Dumping ScriptsNavigator 'Content scripts' tab:
 
-Running: testTemporaryUISourceCodeAddedAndRemoved
+Running: testDebuggerUISourceCodeAddedAndRemoved
 Dumping ScriptsNavigator 'Scripts' tab:
   foo.js
 Dumping ScriptsNavigator 'Content scripts' tab:
index dd4d7e2..c0da89e 100644 (file)
@@ -20,9 +20,11 @@ function test()
     function createMockWorkspace()
     {
         var workspace = new WebInspector.Workspace();
-        var networkWorkspaceProvider = new WebInspector.NetworkWorkspaceProvider();
-        workspace.addProject("network", networkWorkspaceProvider);
-        workspace.debuggerWorkspaceProvider = new WebInspector.DebuggerWorkspaceProvider(workspace);
+        var networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+        workspace.addProject(WebInspector.projectNames.Network, networkWorkspaceProvider);
+
+        workspace.debuggerWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+        workspace.addProject(WebInspector.projectNames.Debugger, workspace.debuggerWorkspaceProvider);
         workspace.requestFileContent = function(uiSourceCode, callback)
         {
             InspectorTest.addResult("Source requested for " + uiSourceCode.url);
@@ -37,14 +39,14 @@ function test()
         {
             var workspace = createMockWorkspace();
 
-            workspace.networkWorkspaceProvider.addNetworkFile("foobar.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("foobar.js", contentProvider, false);
 
             var panel = new WebInspector.ScriptsPanel(workspace);
             panel.show();
 
-            workspace.networkWorkspaceProvider.addNetworkFile("foo.js", contentProvider, false);
-            workspace.networkWorkspaceProvider.addNetworkFile("bar.js", contentProvider, false);
-            workspace.networkWorkspaceProvider.addNetworkFile("baz.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("foo.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("bar.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("baz.js", contentProvider, false);
 
             InspectorTest.dumpScriptsNavigator(panel._navigator);
 
@@ -62,33 +64,33 @@ function test()
             var panel = new WebInspector.ScriptsPanel(workspace);
             panel.show();
 
-            workspace.networkWorkspaceProvider.addNetworkFile("foo.js", contentProvider, false);
-            workspace.networkWorkspaceProvider.addNetworkFile("bar.js", contentProvider, false);
-            workspace.networkWorkspaceProvider.addNetworkFile("baz.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("foo.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("bar.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("baz.js", contentProvider, false);
 
             InspectorTest.dumpScriptsNavigator(panel._navigator);
 
-            workspaceController._mainFrameNavigated();
-            workspace.networkWorkspaceProvider.addNetworkFile("bar.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.reset();
+            workspace.networkWorkspaceProvider.addFileForURL("bar.js", contentProvider, false);
             InspectorTest.dumpScriptsNavigator(panel._navigator);
 
             panel.detach();
             next();
         },
 
-        function testTemporaryUISourceCodeAddedAndRemoved(next)
+        function testDebuggerUISourceCodeAddedAndRemoved(next)
         {
             var workspace = createMockWorkspace();
             var panel = new WebInspector.ScriptsPanel(workspace);
             panel.show();
 
-            workspace.networkWorkspaceProvider.addNetworkFile("foo.js", contentProvider, false);
-            var temporaryUISourceCode = workspace.debuggerWorkspaceProvider.addDebuggerFile("compiled.js", contentProvider);
+            workspace.networkWorkspaceProvider.addFileForURL("foo.js", contentProvider, false);
+            workspace.debuggerWorkspaceProvider.addFile("debugger:compiled.js", "compiled.js", contentProvider);
 
             InspectorTest.dumpScriptsNavigator(panel._navigator);
 
             // Plug compiler source mapping.
-            workspace.networkWorkspaceProvider.addNetworkFile("source.js", contentProvider, false);
+            workspace.networkWorkspaceProvider.addFileForURL("source.js", contentProvider, false);
 
             InspectorTest.dumpScriptsNavigator(panel._navigator);
             next();
index 6cf0f08..69f6446 100644 (file)
@@ -1,6 +1,7 @@
 Test that watch expressions expansion state is restored after update.
 
 Bug 99304
+Debugger was enabled.
 Watch expressions added.
 expanded globalObject [object Object]
 expanded foo [object Object]
@@ -26,4 +27,5 @@ Watch expressions after page reload:
       __proto__: Object
     __proto__: Object
   windowAlias: Window
+Debugger was disabled.
 
index b92378e..7735567 100644 (file)
@@ -20,14 +20,18 @@ var test = function()
 
     // We need to initialize scripts panel so that watch expressions section is created.
     WebInspector.showPanel("scripts");
+    InspectorTest.startDebuggerTest(step1);
 
-    watchExpressionsSection = WebInspector.panels.scripts.sidebarPanes.watchExpressions.section;
-    watchExpressionsSection.watchExpressions = [];
-    watchExpressionsSection.watchExpressions.push("globalObject");
-    watchExpressionsSection.watchExpressions.push("windowAlias");
+    function step1()
+    {
+        watchExpressionsSection = WebInspector.panels.scripts.sidebarPanes.watchExpressions.section;
+        watchExpressionsSection.watchExpressions = [];
+        watchExpressionsSection.watchExpressions.push("globalObject");
+        watchExpressionsSection.watchExpressions.push("windowAlias");
 
-    InspectorTest.addSniffer(WebInspector.WatchExpressionsSection.prototype, "updateProperties", step1);
-    watchExpressionsSection.update();
+        InspectorTest.addSniffer(WebInspector.WatchExpressionsSection.prototype, "updateProperties", step2);
+        watchExpressionsSection.update();
+    }
 
     function expandProperty(parent, path, callback)
     {
@@ -56,20 +60,20 @@ var test = function()
             dumpObjectPropertiesTreeElement(treeElement.children[i], "  " + indent);
     }
 
-    function step1()
+    function step2()
     {
         InspectorTest.addResult("Watch expressions added.");
-        expandProperty(watchExpressionsSection.propertiesTreeOutline, ["globalObject", "foo", "bar"], step2);
+        expandProperty(watchExpressionsSection.propertiesTreeOutline, ["globalObject", "foo", "bar"], step3);
     }
 
-    function step2()
+    function step3()
     {
         InspectorTest.addResult("Watch expressions expanded.");
         dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
-        InspectorTest.reloadPage(step3);
+        InspectorTest.reloadPage(step4);
     }
 
-    function step3()
+    function step4()
     {
         InspectorTest.addResult("Watch expressions after page reload:");
         dumpObjectPropertiesTreeElement(watchExpressionsSection.propertiesTreeOutline, "");
@@ -77,7 +81,7 @@ var test = function()
         // Clear watch expressions after execution.
         watchExpressionsSection.watchExpressions = [];
         watchExpressionsSection.update();
-        InspectorTest.completeTest();
+        InspectorTest.completeDebuggerTest();
     }
 }
 
index 7025ad9..f96b0ac 100644 (file)
@@ -8,13 +8,17 @@ function test()
 
     function createMockWorkspace()
     {
-        var networkWorkspaceProvider = new WebInspector.NetworkWorkspaceProvider();
         var workspace = new WebInspector.Workspace();
-        workspace.addProject("network", networkWorkspaceProvider);
-        workspace.requestFileContent = function(path, callback)
+        var networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+        workspace.addProject(WebInspector.projectNames.Network, networkWorkspaceProvider);
+        workspace.requestFileContent = function(uri, callback)
         {
             callback("<script content>", false, "text/javascript");
         }
+        workspace.setFileContent = function(uri, newContent, callback)
+        {
+        }
+
         return workspace;
     }
  
index 4d755e3..5fa9d6b 100644 (file)
@@ -1,3 +1,110 @@
+2013-01-11  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Web Inspector: Workspace should support several projects and should not have temporary UISourceCodes.
+        https://bugs.webkit.org/show_bug.cgi?id=105856
+
+        Reviewed by Pavel Feldman.
+
+        Workspace now supports several projects with the networkProject being a main one.
+        Replaced temporary UISourceCodes with specific projects (debugger and liveedit).
+        The concept of workspace reset on navigation is now replaced with project reset concept instead.
+        Introduced snippets project (that is not reset on navigation).
+        Script mappings are now reset on GlobalObjectCleared event.
+
+        * inspector/front-end/BreakpointManager.js:
+        (WebInspector.BreakpointManager):
+        (WebInspector.BreakpointManager.prototype._innerSetBreakpoint):
+        (WebInspector.BreakpointManager.prototype._filteredBreakpointLocations):
+        (WebInspector.BreakpointManager.prototype.toggleAllBreakpoints):
+        (WebInspector.BreakpointManager.prototype.removeAllBreakpoints):
+        (WebInspector.BreakpointManager.prototype._projectWillReset.get for):
+        (WebInspector.BreakpointManager.prototype._projectWillReset):
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel):
+        (WebInspector.CSSStyleModel.prototype._inspectedURLChanged):
+        (WebInspector.CSSStyleModel.prototype._resetSourceMappings):
+        (WebInspector.CSSStyleModelResourceBinding):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._viaInspectorResourceURL):
+        (WebInspector.CSSStyleModelResourceBinding.prototype._reset):
+        * inspector/front-end/CompilerScriptMapping.js:
+        (WebInspector.CompilerScriptMapping):
+        (WebInspector.CompilerScriptMapping.prototype._debuggerReset):
+        * inspector/front-end/DebuggerScriptMapping.js:
+        * inspector/front-end/DefaultScriptMapping.js:
+        (WebInspector.DefaultScriptMapping):
+        (WebInspector.DefaultScriptMapping.prototype.addScript):
+        (WebInspector.DefaultScriptMapping.prototype._debuggerReset):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer.prototype._onGetPageResources):
+        * inspector/front-end/FilteredItemSelectionDialog.js:
+        (WebInspector.OpenResourceDialog.show):
+        * inspector/front-end/LiveEditSupport.js:
+        (WebInspector.LiveEditSupport):
+        (WebInspector.LiveEditSupport.prototype.uiSourceCodeForLiveEdit):
+        (WebInspector.LiveEditSupport.prototype._debuggerReset):
+        * inspector/front-end/NetworkUISourceCodeProvider.js:
+        (WebInspector.NetworkUISourceCodeProvider):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._mainFrameNavigated):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._addFile):
+        (WebInspector.NetworkUISourceCodeProvider.prototype._reset):
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping):
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAddedToWorkspace):
+        (WebInspector.ResourceScriptMapping.prototype._debuggerReset):
+        * inspector/front-end/RevisionHistoryView.js:
+        (WebInspector.RevisionHistoryView):
+        (WebInspector.RevisionHistoryView.prototype._projectWillReset):
+        * inspector/front-end/SASSSourceMapping.js:
+        (_bindUISourceCode):
+        * inspector/front-end/ScriptSnippetModel.js:
+        (WebInspector.ScriptSnippetModel):
+        (WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
+        (WebInspector.ScriptSnippetModel.prototype.reset):
+        * inspector/front-end/ScriptsNavigator.js:
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel):
+        (WebInspector.ScriptsPanel.prototype._addUISourceCode):
+        (WebInspector.ScriptsPanel.prototype._uiSourceCodeRemoved):
+        (WebInspector.ScriptsPanel.prototype._removeUISourceCodes):
+        (WebInspector.ScriptsPanel.prototype._debuggerWasDisabled):
+        (WebInspector.ScriptsPanel.prototype._debuggerReset):
+        (WebInspector.ScriptsPanel.prototype._projectWillReset):
+        (WebInspector.ScriptsPanel.prototype.canShowAnchorLocation):
+        (WebInspector.ScriptsPanel.prototype._revealExecutionLine):
+        (WebInspector.ScriptsPanel.prototype.showGoToSourceDialog):
+        * inspector/front-end/SimpleWorkspaceProvider.js:
+        (WebInspector.SimpleWorkspaceProvider):
+        (WebInspector.SimpleWorkspaceProvider.prototype.addFile):
+        (WebInspector.SimpleWorkspaceProvider.prototype.addFileForURL):
+        (WebInspector.SimpleWorkspaceProvider.prototype.reset):
+        * inspector/front-end/StylesSourceMapping.js:
+        (WebInspector.StylesSourceMapping):
+        (WebInspector.StylesSourceMapping.prototype._projectWillReset):
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer.prototype.reset):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype.project):
+        * inspector/front-end/Workspace.js:
+        (WebInspector.WorkspaceController):
+        (WebInspector.WorkspaceController.prototype._inspectedURLChanged):
+        (WebInspector.Project):
+        (WebInspector.Project.prototype.name):
+        (WebInspector.Project.prototype.isServiceProject):
+        (WebInspector.Project.prototype._reset):
+        (WebInspector.Workspace):
+        (WebInspector.Workspace.prototype.uiSourceCodeForURL):
+        (WebInspector.Workspace.prototype.uiSourceCodeForURI):
+        (WebInspector.Workspace.prototype.addProject):
+        (WebInspector.Workspace.prototype.project):
+        (WebInspector.Workspace.prototype.projects):
+        (WebInspector.Workspace.prototype.uiSourceCodes):
+        (WebInspector.Workspace.prototype.projectForUISourceCode):
+        (WebInspector.Workspace.prototype.requestFileContent):
+        (WebInspector.Workspace.prototype.setFileContent):
+        (WebInspector.Workspace.prototype.searchInFileContent):
+        * inspector/front-end/inspector.js:
+        * inspector/front-end/utilities.js:
+
 2013-01-11  Eugene Klyuchnikov  <eustas@chromium.org>
 
         Web Inspector: [Resources] Make grid columns set configurable.
index a9fd6ef..32de145 100644 (file)
@@ -41,15 +41,14 @@ WebInspector.BreakpointManager = function(breakpointStorage, debuggerModel, work
     this._debuggerModel = debuggerModel;
     this._workspace = workspace;
 
-    this._breakpoints = [];
+    this._breakpoints = new Map();
     this._breakpointForDebuggerId = {};
     this._breakpointsForUISourceCode = new Map();
     this._sourceFilesWithRestoredBreakpoints = {};
 
     this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._workspaceReset, this);
+    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
-    this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, this._uiSourceCodeAdded, this);
 }
 
 WebInspector.BreakpointManager.Events = {
@@ -137,7 +136,7 @@ WebInspector.BreakpointManager.prototype = {
             return breakpoint;
         }
         breakpoint = new WebInspector.BreakpointManager.Breakpoint(this, uiSourceCode, lineNumber, condition, enabled);
-        this._breakpoints.push(breakpoint);
+        this._breakpoints.put(breakpoint);
         return breakpoint;
     },
 
@@ -160,8 +159,9 @@ WebInspector.BreakpointManager.prototype = {
     _filteredBreakpointLocations: function(filter)
     {
         var result = [];
-        for (var i = 0; i < this._breakpoints.length; ++i) {
-            var breakpoint = this._breakpoints[i];
+        var breakpoints = /** @type {Array.<WebInspector.BreakpointManager.Breakpoint>} */ this._breakpoints.keys();
+        for (var i = 0; i < breakpoints.length; ++i) {
+            var breakpoint = breakpoints[i];
             for (var stringifiedLocation in breakpoint._uiLocations) {
                 var uiLocation = breakpoint._uiLocations[stringifiedLocation];
                 if (filter(breakpoint, uiLocation))
@@ -198,8 +198,9 @@ WebInspector.BreakpointManager.prototype = {
      */
     toggleAllBreakpoints: function(toggleState)
     {
-        for (var i = 0; i < this._breakpoints.length; ++i) {
-            var breakpoint = this._breakpoints[i];
+        var breakpoints = /** @type {Array.<WebInspector.BreakpointManager.Breakpoint>} */ this._breakpoints.keys();
+        for (var i = 0; i < breakpoints.length; ++i) {
+            var breakpoint = breakpoints[i];
             if (breakpoint.enabled() != toggleState)
                 breakpoint.setEnabled(toggleState);
         }
@@ -207,7 +208,7 @@ WebInspector.BreakpointManager.prototype = {
 
     removeAllBreakpoints: function()
     {
-        var breakpoints = this._breakpoints.slice();
+        var breakpoints = /** @type {Array.<WebInspector.BreakpointManager.Breakpoint>} */ this._breakpoints.keys();
         for (var i = 0; i < breakpoints.length; ++i)
             breakpoints[i].remove();
     },
@@ -226,16 +227,26 @@ WebInspector.BreakpointManager.prototype = {
         this._sourceFilesWithRestoredBreakpoints = {};
     },
 
-    _workspaceReset: function()
-    {
-        var breakpoints = this._breakpoints.slice();
-        for (var i = 0; i < breakpoints.length; ++i) {
-            breakpoints[i]._resetLocations();
-            breakpoints[i]._isProvisional = true;
+    _projectWillReset: function(event)
+    {
+        var project = /** @type {WebInspector.Project} */ (event.data);
+        var uiSourceCodes = project.uiSourceCodes();
+        for (var i = 0; i < uiSourceCodes.length; ++i) {
+            var uiSourceCode = uiSourceCodes[i];
+            var breakpoints = this._breakpointsForUISourceCode.get(uiSourceCode) || [];
+            for (var lineNumber in breakpoints) {
+                var lineBreakpoints = breakpoints[lineNumber];
+                for (var j = 0; j < lineBreakpoints.length; ++j) {
+                    var breakpoint = lineBreakpoints[j];
+                    this._breakpoints.remove(breakpoint);
+                    breakpoint._resetLocations();
+                    breakpoint._isProvisional = true;
+                }
+            }
+            this._breakpointsForUISourceCode.remove(uiSourceCode);
+            var sourceFileId = WebInspector.BreakpointManager.sourceFileId(uiSourceCode);
+            delete this._sourceFilesWithRestoredBreakpoints[sourceFileId];
         }
-        this._breakpoints = [];
-        this._breakpointsForUISourceCode.clear();
-        this._sourceFilesWithRestoredBreakpoints = {};
     },
 
     _breakpointResolved: function(event)
index 284fbd8..06ccdd1 100644 (file)
@@ -41,6 +41,7 @@ WebInspector.CSSStyleModel = function()
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoRequested, this._undoRedoRequested, this);
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoCompleted, this._undoRedoCompleted, this);
     this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding();
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
     this._namedFlowCollections = {};
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._resetNamedFlowCollections, this);
     InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this));
@@ -479,6 +480,15 @@ WebInspector.CSSStyleModel.prototype = {
     },
 
     /**
+     * @param {WebInspector.Event} event
+     */
+    _inspectedURLChanged: function(event)
+    {
+        this._resetSourceMappings();
+        this._resourceBinding._reset();
+    },
+
+    /**
      * @param {string} url
      * @param {WebInspector.SourceMapping} sourceMapping
      */
@@ -488,7 +498,7 @@ WebInspector.CSSStyleModel.prototype = {
         this._updateLocations();
     },
 
-    resetSourceMappings: function()
+    _resetSourceMappings: function()
     {
         this._sourceMappings = {};
     },
@@ -1173,9 +1183,7 @@ WebInspector.CSSStyleSheet.prototype = {
  */
 WebInspector.CSSStyleModelResourceBinding = function()
 {
-    this._frameAndURLToStyleSheetId = {};
-    this._styleSheetIdToHeader = {};
-    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
+    this._reset();
 }
 
 WebInspector.CSSStyleModelResourceBinding.prototype = {
@@ -1236,16 +1244,6 @@ WebInspector.CSSStyleModelResourceBinding.prototype = {
     },
 
     /**
-     * @param {WebInspector.Event} event
-     */
-    _inspectedURLChanged: function(event)
-    {
-        // Main frame navigation - clear history.
-        this._frameAndURLToStyleSheetId = {};
-        this._styleSheetIdToHeader = {};
-    },
-
-    /**
      * @param {function(?string)} callback
      */
     _loadStyleSheetHeaders: function(callback)
@@ -1348,6 +1346,13 @@ WebInspector.CSSStyleModelResourceBinding.prototype = {
             fakeURL += "/";
         fakeURL += "inspector-stylesheet";
         return fakeURL;
+    },
+
+    _reset: function()
+    {
+        // Main frame navigation - clear history.
+        this._frameAndURLToStyleSheetId = {};
+        this._styleSheetIdToHeader = {};
     }
 }
 
index ba362e8..ed15bb6 100644 (file)
@@ -32,7 +32,7 @@
  * @constructor
  * @implements {WebInspector.ScriptSourceMapping}
  * @param {WebInspector.Workspace} workspace
- * @param {WebInspector.NetworkWorkspaceProvider} networkWorkspaceProvider
+ * @param {WebInspector.SimpleWorkspaceProvider} networkWorkspaceProvider
  */
 WebInspector.CompilerScriptMapping = function(workspace, networkWorkspaceProvider)
 {
@@ -45,7 +45,7 @@ WebInspector.CompilerScriptMapping = function(workspace, networkWorkspaceProvide
     this._scriptForSourceMap = new Map();
     /** @type {Object.<string, WebInspector.PositionBasedSourceMap>} */
     this._sourceMapForURL = {};
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
 }
 
 WebInspector.CompilerScriptMapping.prototype = {
@@ -104,8 +104,7 @@ WebInspector.CompilerScriptMapping.prototype = {
                 contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, sourceContent);
             else
                 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
-            this._networkWorkspaceProvider.addNetworkFile(sourceURL, contentProvider, true);
-            var uiSourceCode = this._workspace.uiSourceCodeForURL(sourceURL);
+            var uiSourceCode = this._networkWorkspaceProvider.addFileForURL(sourceURL, contentProvider, true);
             uiSourceCode.setSourceMapping(this);
             uiSourceCode.isContentScript = script.isContentScript;
         }
@@ -141,7 +140,7 @@ WebInspector.CompilerScriptMapping.prototype = {
         return sourceMap;
     },
 
-    _reset: function()
+    _debuggerReset: function()
     {
         this._sourceMapForSourceMapURL = {};
         this._sourceMapForScriptId = {};
index 8f88b9d..822da5b 100644 (file)
@@ -31,7 +31,7 @@
 /**
  * @constructor
  * @param {WebInspector.Workspace} workspace
- * @param {WebInspector.NetworkWorkspaceProvider} networkWorkspaceProvider
+ * @param {WebInspector.SimpleWorkspaceProvider} networkWorkspaceProvider
  */
 WebInspector.DebuggerScriptMapping = function(workspace, networkWorkspaceProvider)
 {
index 396da06..b7b9d37 100644 (file)
 WebInspector.DefaultScriptMapping = function(workspace)
 {
     this._workspace = workspace;
-    this._workspaceProvider = new WebInspector.DebuggerWorkspaceProvider(workspace);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
-    this._reset();
+    this._workspaceProvider = new WebInspector.SimpleWorkspaceProvider(this._workspace);
+    workspace.addProject(WebInspector.projectNames.Debugger, this._workspaceProvider);
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
+    this._debuggerReset();
 }
 
 WebInspector.DefaultScriptMapping.prototype = {
@@ -75,7 +76,10 @@ WebInspector.DefaultScriptMapping.prototype = {
     addScript: function(script)
     {
         var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider([script]) : script;
-        var uiSourceCode = this._workspaceProvider.addDebuggerFile(script.sourceURL, contentProvider, false);
+        var uri = "debugger:" + WebInspector.SimpleWorkspaceProvider.uriForURL(script.sourceURL);
+        var uniqueURI = this._workspaceProvider.uniqueURI(uri);
+        var uiSourceCode = this._workspaceProvider.addFile(uniqueURI, script.sourceURL, contentProvider, false, script.isContentScript);
+
         this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
         this._scriptIdForUISourceCode.put(uiSourceCode, script.scriptId);
         uiSourceCode.setSourceMapping(this);
@@ -94,45 +98,11 @@ WebInspector.DefaultScriptMapping.prototype = {
         this._uiSourceCodeForScriptId[scriptId].addRevision(content);
     },
 
-    _reset: function()
+    _debuggerReset: function()
     {
         /** @type {Object.<string, WebInspector.UISourceCode>} */
         this._uiSourceCodeForScriptId = {};
         this._scriptIdForUISourceCode = new Map();
-    },
-}
-
-/**
- * @constructor
- * @extends {WebInspector.SimpleWorkspaceProvider}
- */
-WebInspector.DebuggerWorkspaceProvider = function(workspace)
-{
-    WebInspector.SimpleWorkspaceProvider.call(this);
-    this._workspace = workspace;
-}
-
-WebInspector.DebuggerWorkspaceProvider.prototype = {
-    /**
-     * @param {string} url
-     * @param {WebInspector.ContentProvider} contentProvider
-     * @param {boolean} isEditable
-     * @return {WebInspector.UISourceCode}
-     */
-    addDebuggerFile: function(url, contentProvider, isEditable)
-    {
-        var uri = "debugger:" + WebInspector.SimpleWorkspaceProvider.uriForURL(url);
-        var uniqueURI = this.uniqueURI(uri);
-        var uiSourceCode = this._workspace.addTemporaryUISourceCode(uniqueURI, url, contentProvider, isEditable);
-        // FIXME: this is a temporary hack to be removed once DefaultScriptMapping uiSourceCode become part of the workspace.
-        this._contentProviders[uniqueURI] = uiSourceCode;
-        return uiSourceCode;
-    },
-
-    __proto__: WebInspector.SimpleWorkspaceProvider.prototype
+        this._workspaceProvider.reset();
+    }
 }
-
-/**
- * @type {?WebInspector.DebuggerWorkspaceProvider}
- */
-WebInspector.debuggerWorkspaceProvider = null;
index 6d05589..aa23da5 100644 (file)
@@ -446,7 +446,8 @@ WebInspector.ExtensionServer.prototype = {
             if (!resources[contentProvider.contentURL()])
                 resources[contentProvider.contentURL()] = this._makeResource(contentProvider);
         }
-        WebInspector.workspace.uiSourceCodes().forEach(pushResourceData.bind(this));
+        var uiSourceCodes = WebInspector.workspace.project(WebInspector.projectNames.Network).uiSourceCodes();
+        uiSourceCodes.forEach(pushResourceData.bind(this));
         WebInspector.resourceTreeModel.forAllResources(pushResourceData.bind(this));
         return Object.values(resources);
     },
index 6d6cb4b..a58eabc 100644 (file)
@@ -609,14 +609,19 @@ WebInspector.JavaScriptOutlineDialog.prototype = {
  * @constructor
  * @implements {WebInspector.SelectionDialogContentProvider}
  * @param {WebInspector.ScriptsPanel} panel
- * @param {WebInspector.UISourceCodeProvider} uiSourceCodeProvider
  */
-WebInspector.OpenResourceDialog = function(panel, uiSourceCodeProvider)
+WebInspector.OpenResourceDialog = function(panel)
 {
     WebInspector.SelectionDialogContentProvider.call(this);
     this._panel = panel;
 
-    this._uiSourceCodes = uiSourceCodeProvider.uiSourceCodes();
+    var projects = WebInspector.workspace.projects();
+    this._uiSourceCodes = [];
+    for (var i = 0; i < projects.length; ++i) {
+        if (projects[i].isServiceProject())
+            continue;
+        this._uiSourceCodes = this._uiSourceCodes.concat(projects[i].uiSourceCodes());
+    }
 
     function filterOutEmptyURLs(uiSourceCode)
     {
@@ -714,14 +719,13 @@ WebInspector.OpenResourceDialog.prototype = {
 
 /**
  * @param {WebInspector.ScriptsPanel} panel
- * @param {WebInspector.UISourceCodeProvider} uiSourceCodeProvider
  * @param {Element} relativeToElement
  */
-WebInspector.OpenResourceDialog.show = function(panel, uiSourceCodeProvider, relativeToElement)
+WebInspector.OpenResourceDialog.show = function(panel, relativeToElement)
 {
     if (WebInspector.Dialog.currentInstance())
         return;
 
-    var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel, uiSourceCodeProvider));
+    var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel));
     WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
 }
index c687442..5568ad9 100644 (file)
 WebInspector.LiveEditSupport = function(workspace)
 {
     this._workspace = workspace;
-    this._workspaceProvider = new WebInspector.LiveEditWorkspaceProvider(workspace);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
-    this._reset();
+    this._workspaceProvider = new WebInspector.SimpleWorkspaceProvider(this._workspace);
+    workspace.addProject(WebInspector.projectNames.LiveEdit, this._workspaceProvider);
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
+    this._debuggerReset();
 }
 
 WebInspector.LiveEditSupport.prototype = {
@@ -57,20 +58,24 @@ WebInspector.LiveEditSupport.prototype = {
             return uiLocation.uiSourceCode;
         if (this._uiSourceCodeForScriptId[script.scriptId])
             return this._uiSourceCodeForScriptId[script.scriptId];
-        
+
         console.assert(!script.isInlineScript());
-        var liveEditUISourceCode = this._workspaceProvider.addLiveEditFile(uiSourceCode.url, script, true);
+        var uri = "liveedit:" + WebInspector.SimpleWorkspaceProvider.uriForURL(uiSourceCode.url);
+        var uniqueURI = this._workspaceProvider.uniqueURI(uri);
+        var liveEditUISourceCode = this._workspaceProvider.addFile(uniqueURI, uiSourceCode.url, script, true);
+
         liveEditUISourceCode.setScriptFile(new WebInspector.LiveEditScriptFile(uiSourceCode, liveEditUISourceCode, script.scriptId));
         this._uiSourceCodeForScriptId[script.scriptId] = liveEditUISourceCode;
         this._scriptIdForUISourceCode.put(liveEditUISourceCode, script.scriptId);
         return liveEditUISourceCode;
     },
 
-    _reset: function()
+    _debuggerReset: function()
     {
         /** @type {Object.<string, WebInspector.UISourceCode>} */
         this._uiSourceCodeForScriptId = {};
         this._scriptIdForUISourceCode = new Map();
+        this._workspaceProvider.reset();
     },
 }
 
@@ -130,32 +135,3 @@ WebInspector.LiveEditScriptFile.prototype = {
 
 /** @type {WebInspector.LiveEditSupport} */
 WebInspector.liveEditSupport = null;
-
-/**
- * @constructor
- * @extends {WebInspector.SimpleWorkspaceProvider}
- */
-WebInspector.LiveEditWorkspaceProvider = function(workspace)
-{
-    WebInspector.SimpleWorkspaceProvider.call(this);
-    this._workspace = workspace;
-}
-
-WebInspector.LiveEditWorkspaceProvider.prototype = {
-    /**
-     * @param {string} url
-     * @param {WebInspector.ContentProvider} contentProvider
-     * @param {boolean} isEditable
-     * @return {WebInspector.UISourceCode}
-     */
-    addLiveEditFile: function(url, contentProvider, isEditable)
-    {
-        var uri = "liveedit:" + WebInspector.SimpleWorkspaceProvider.uriForURL(url);
-        var uniqueURI = this.uniqueURI(uri);
-        // FIXME: this is a temporary hack to be removed once LiveEdit uiSourceCode become part of the workspace.
-        this._contentProviders[uniqueURI] = null;
-        return this._workspace.addTemporaryUISourceCode(uniqueURI, url, contentProvider, isEditable);
-    },
-
-    __proto__: WebInspector.SimpleWorkspaceProvider.prototype
-}
index 3b5f313..9d51681 100644 (file)
@@ -38,8 +38,7 @@ WebInspector.NetworkUISourceCodeProvider = function(workspace, networkWorkspaceP
     this._workspace = workspace;
     this._networkWorkspaceProvider = networkWorkspaceProvider;
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectDidReset, this._projectDidReset, this);
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
 
     this._processedURLs = {};
@@ -101,6 +100,14 @@ WebInspector.NetworkUISourceCodeProvider.prototype = {
     },
 
     /**
+     * @param {WebInspector.Event} event
+     */
+    _mainFrameNavigated: function(event)
+    {
+        this._reset();
+    },
+
+    /**
      * @param {string} url
      * @param {WebInspector.ContentProvider} contentProvider
      * @param {boolean=} isContentScript
@@ -114,48 +121,19 @@ WebInspector.NetworkUISourceCodeProvider.prototype = {
             return;
         this._processedURLs[url] = true;
         var isEditable = type !== WebInspector.resourceTypes.Document;
-        this._networkWorkspaceProvider.addNetworkFile(url, contentProvider, isEditable, isContentScript);
+        this._networkWorkspaceProvider.addFileForURL(url, contentProvider, isEditable, isContentScript);
     },
 
-    _projectWillReset: function()
+    _reset: function()
     {
         this._processedURLs = {};
         this._lastDynamicAnonymousScriptIndexForURL = {};
-    },
-
-    _projectDidReset: function()
-    {
+        this._networkWorkspaceProvider.reset();
         this._populate();
     }
 }
 
 /**
- * @constructor
- * @extends {WebInspector.SimpleWorkspaceProvider}
- */
-WebInspector.NetworkWorkspaceProvider = function()
-{
-    WebInspector.SimpleWorkspaceProvider.call(this);
-}
-
-WebInspector.NetworkWorkspaceProvider.prototype = {
-    /**
-     * @param {string} url
-     * @param {WebInspector.ContentProvider} contentProvider
-     * @param {boolean} isEditable
-     * @param {boolean=} isContentScript
-     * @param {boolean=} isSnippet
-     */
-    addNetworkFile: function(url, contentProvider, isEditable, isContentScript, isSnippet)
-    {
-        var uri = WebInspector.SimpleWorkspaceProvider.uriForURL(url);
-        this.addFile(uri, url, contentProvider, isEditable, isContentScript, isSnippet);
-    },
-
-    __proto__: WebInspector.SimpleWorkspaceProvider.prototype
-}
-
-/**
- * @type {?WebInspector.NetworkWorkspaceProvider}
+ * @type {?WebInspector.SimpleWorkspaceProvider}
  */
 WebInspector.networkWorkspaceProvider = null;
index 7802850..852d2b4 100644 (file)
 WebInspector.ResourceScriptMapping = function(workspace)
 {
     this._workspace = workspace;
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
 
-    this._reset();
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
+    this._debuggerReset();
 }
 
 WebInspector.ResourceScriptMapping.prototype = {
@@ -93,7 +93,8 @@ WebInspector.ResourceScriptMapping.prototype = {
     _uiSourceCodeAddedToWorkspace: function(event)
     {
         var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data);
-        console.assert(!!uiSourceCode.url);
+        if (!uiSourceCode.url)
+            return;
 
         var scripts = this._scriptsForUISourceCode(uiSourceCode);
         if (!scripts.length)
@@ -175,7 +176,7 @@ WebInspector.ResourceScriptMapping.prototype = {
         uiSourceCode.setSourceMapping(this);
     },
 
-    _reset: function()
+    _debuggerReset: function()
     {
         /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
         this._inlineScriptsForSourceURL = {};
index 4592e4a..de885ad 100644 (file)
@@ -56,8 +56,7 @@ WebInspector.RevisionHistoryView = function()
     WebInspector.workspace.uiSourceCodes().forEach(populateRevisions.bind(this));
     WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeContentCommitted, this._revisionAdded, this);
     WebInspector.workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
-    WebInspector.workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, this._uiSourceCodeRemoved, this);
-    WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
+    WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
 
     this._statusElement = document.createElement("span");
     this._statusElement.textContent = WebInspector.UIString("Local modifications");
@@ -172,10 +171,10 @@ WebInspector.RevisionHistoryView.prototype = {
         this._uiSourceCodeItems.remove(uiSourceCode);
     },
 
-    _reset: function()
+    _projectWillReset: function(event)
     {
-        this._treeOutline.removeChildren();
-        this._uiSourceCodeItems.clear();
+        var project = event.data;
+        project.uiSourceCodes().forEach(this._removeUISourceCode.bind(this));
     },
 
     __proto__: WebInspector.View.prototype
index d67e6d6..2a64d09 100644 (file)
@@ -32,7 +32,7 @@
  * @constructor
  * @implements {WebInspector.SourceMapping}
  * @param {WebInspector.Workspace} workspace
- * @param {WebInspector.NetworkWorkspaceProvider} networkWorkspaceProvider
+ * @param {WebInspector.SimpleWorkspaceProvider} networkWorkspaceProvider
  */
 WebInspector.SASSSourceMapping = function(workspace, networkWorkspaceProvider)
 {
@@ -157,8 +157,7 @@ WebInspector.SASSSourceMapping.prototype = {
         if (!uiSourceCode) {
             var content = InspectorFrontendHost.loadResourceSynchronously(url);
             var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Stylesheet, content, "text/x-scss");
-            this._networkWorkspaceProvider.addNetworkFile(url, contentProvider, true);
-            uiSourceCode = this._workspace.uiSourceCodeForURL(url);
+            uiSourceCode = this._networkWorkspaceProvider.addFileForURL(url, contentProvider, true);
             WebInspector.cssModel.setSourceMapping(rawURL, this);
         }
         var rawLocationString = rawURL + ":" + (rawLine + 1);  // Next line after mapping metainfo
index 9e3f031..c2ddaac 100644 (file)
  * @constructor
  * @extends {WebInspector.Object}
  * @param {WebInspector.Workspace} workspace
- * @param {WebInspector.NetworkWorkspaceProvider} networkWorkspaceProvider
  */
-WebInspector.ScriptSnippetModel = function(workspace, networkWorkspaceProvider)
+WebInspector.ScriptSnippetModel = function(workspace)
 {
     this._workspace = workspace;
-    this._networkWorkspaceProvider = networkWorkspaceProvider;
     this._uiSourceCodeForScriptId = {};
     this._scriptForUISourceCode = new Map();
     this._uiSourceCodeForSnippetId = {};
@@ -46,9 +44,9 @@ WebInspector.ScriptSnippetModel = function(workspace, networkWorkspaceProvider)
     this._snippetStorage = new WebInspector.SnippetStorage("script", "Script snippet #");
     this._lastSnippetEvaluationIndexSetting = WebInspector.settings.createSetting("lastSnippetEvaluationIndex", 0);
     this._snippetScriptMapping = new WebInspector.SnippetScriptMapping(this);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectDidReset, this._projectDidReset, this);
-    this._loadSnippets();
+    this._workspaceProvider = new WebInspector.SimpleWorkspaceProvider(this._workspace);
+    workspace.addProject(WebInspector.projectNames.Snippets, this._workspaceProvider);
+    this.reset();
 }
 
 WebInspector.ScriptSnippetModel.prototype = {
@@ -82,8 +80,7 @@ WebInspector.ScriptSnippetModel.prototype = {
      */
     _addScriptSnippet: function(snippet)
     {
-        this._networkWorkspaceProvider.addNetworkFile(snippet.name, new WebInspector.SnippetContentProvider(snippet), true, false, true);
-        var uiSourceCode = this._workspace.uiSourceCodeForURL(snippet.name);
+        var uiSourceCode = this._workspaceProvider.addFile(snippet.name, snippet.name, new WebInspector.SnippetContentProvider(snippet), true, false, true);
         var scriptFile = new WebInspector.SnippetScriptFile(this, uiSourceCode);
         uiSourceCode.setScriptFile(scriptFile);
         this._snippetIdForUISourceCode.put(uiSourceCode, snippet.id);
@@ -104,7 +101,7 @@ WebInspector.ScriptSnippetModel.prototype = {
         this._releaseSnippetScript(uiSourceCode);
         delete this._uiSourceCodeForSnippetId[snippet.id];
         this._snippetIdForUISourceCode.remove(uiSourceCode);
-        this._networkWorkspaceProvider.removeFile(snippet.name);
+        this._workspaceProvider.removeFile(snippet.name);
     },
 
     /**
@@ -370,16 +367,15 @@ WebInspector.ScriptSnippetModel.prototype = {
         return snippetId;
     },
 
-    _projectWillReset: function()
+    reset: function()
     {
+        /** @type {!Object.<string, WebInspector.UISourceCode>} */
         this._uiSourceCodeForScriptId = {};
         this._scriptForUISourceCode = new Map();
+        /** @type {!Object.<string, WebInspector.UISourceCode>} */
         this._uiSourceCodeForSnippetId = {};
         this._snippetIdForUISourceCode = new Map();
-    },
-
-    _projectDidReset: function()
-    {
+        this._workspaceProvider.reset();
         this._loadSnippets();
     },
 
index 6e48609..c0e16ea 100644 (file)
@@ -170,13 +170,6 @@ WebInspector.ScriptsNavigator.prototype = {
         this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.SnippetCreationRequested, event.data);
     },
 
-    reset: function()
-    {
-        this._scriptsView.reset();
-        this._contentScriptsView.reset();
-        this._snippetsView.reset();
-    },
-
     __proto__: WebInspector.Object.prototype
 }
 
index 0fd28c4..c254f71 100644 (file)
@@ -190,8 +190,8 @@ WebInspector.ScriptsPanel = function(workspaceForTest)
 
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
-    this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, this._uiSourceCodeRemoved, this);
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset.bind(this), this);
+    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset.bind(this), this);
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
 
     WebInspector.advancedSearchController.registerSearchScope(new WebInspector.ScriptsSearchScope(this._workspace));
 }
@@ -243,12 +243,14 @@ WebInspector.ScriptsPanel.prototype = {
     {
         if (this._toggleFormatSourceButton.toggled)
             uiSourceCode.setFormatted(true);
-
+        var projectName = uiSourceCode.project().name();
+        if (uiSourceCode.project().isServiceProject())
+            return;
         this._editorContainer.addUISourceCode(uiSourceCode);
         this._navigator.addUISourceCode(uiSourceCode);
         // Replace debugger script-based uiSourceCode with a network-based one.
-        if (this._currentUISourceCode && this._currentUISourceCode.isTemporary && this._currentUISourceCode !== uiSourceCode && this._currentUISourceCode.url === uiSourceCode.url) {
-            var currentUISourceCode = this._currentUISourceCode;
+        var currentUISourceCode = this._currentUISourceCode;
+        if (currentUISourceCode && currentUISourceCode.project().isServiceProject() && currentUISourceCode !== uiSourceCode && currentUISourceCode.url === uiSourceCode.url) {
             this._showFile(uiSourceCode);
             this._editorContainer.removeUISourceCode(currentUISourceCode);
         }
@@ -257,9 +259,19 @@ WebInspector.ScriptsPanel.prototype = {
     _uiSourceCodeRemoved: function(event)
     {
         var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data);
-        this._editorContainer.removeUISourceCode(uiSourceCode);
-        this._navigator.removeUISourceCode(uiSourceCode);
-        this._removeSourceFrame(uiSourceCode);
+        this._removeUISourceCodes([uiSourceCode]);
+    },
+
+    /**
+     * @param {Array.<WebInspector.UISourceCode>} uiSourceCodes
+     */
+    _removeUISourceCodes: function(uiSourceCodes)
+    {
+        for (var i = 0; i < uiSourceCodes.length; ++i) {
+            this._navigator.removeUISourceCode(uiSourceCodes[i]);
+            this._removeSourceFrame(uiSourceCodes[i]);
+        }
+        this._editorContainer.removeUISourceCodes(uiSourceCodes);
     },
 
     _consoleCommandEvaluatedInSelectedCallFrame: function(event)
@@ -339,26 +351,22 @@ WebInspector.ScriptsPanel.prototype = {
 
     _debuggerWasDisabled: function()
     {
-        this._reset();
+        this._debuggerReset();
     },
 
-    _reset: function()
+    _debuggerReset: function()
     {
-        delete this.currentQuery;
-        this.searchCanceled();
-
         this._debuggerResumed();
-
-        delete this._currentUISourceCode;
-        this._navigator.reset();
-        this._editorContainer.reset();
-        this._updateScriptViewStatusBarItems();
-        this.sidebarPanes.jsBreakpoints.reset();
         this.sidebarPanes.watchExpressions.reset();
+    },
 
-        var uiSourceCodes = this._workspace.uiSourceCodes();
-        for (var i = 0; i < uiSourceCodes.length; ++i)
-            this._removeSourceFrame(uiSourceCodes[i]);
+    _projectWillReset: function(event)
+    {
+        var project = event.data;
+        var uiSourceCodes = project.uiSourceCodes();
+        this._removeUISourceCodes(uiSourceCodes);
+        if (project.name() === WebInspector.projectNames.Network)
+            this._editorContainer.reset();
     },
 
     get visibleView()
@@ -382,7 +390,7 @@ WebInspector.ScriptsPanel.prototype = {
     {
         if (WebInspector.debuggerModel.debuggerEnabled() && anchor.uiSourceCode)
             return true;
-        var uiSourceCodes = this._workspace.uiSourceCodes();
+        var uiSourceCodes = this._workspace.project(WebInspector.projectNames.Network).uiSourceCodes();
         for (var i = 0; i < uiSourceCodes.length; ++i) {
             if (uiSourceCodes[i].url === anchor.href) {
                 anchor.uiSourceCode = uiSourceCodes[i];
@@ -522,13 +530,10 @@ WebInspector.ScriptsPanel.prototype = {
     {
         var uiSourceCode = uiLocation.uiSourceCode;
         // Some scripts (anonymous and snippets evaluations) are not added to files select by default.
-        if (uiSourceCode.isTemporary) {
-            if (this._currentUISourceCode && this._currentUISourceCode.scriptFile() && this._currentUISourceCode.scriptFile().isDivergingFromVM())
-                return;
-            this._editorContainer.addUISourceCode(uiSourceCode);
-            if (uiSourceCode.formatted() !== this._toggleFormatSourceButton.toggled)
-                uiSourceCode.setFormatted(this._toggleFormatSourceButton.toggled);
-        }
+        if (this._currentUISourceCode && this._currentUISourceCode.scriptFile() && this._currentUISourceCode.scriptFile().isDivergingFromVM())
+            return;
+        if (this._toggleFormatSourceButton.toggled && !uiSourceCode.formatted())
+            uiSourceCode.setFormatted(true);
         var sourceFrame = this._showFile(uiSourceCode);
         sourceFrame.revealLine(uiLocation.lineNumber);
         sourceFrame.focus();
@@ -1160,7 +1165,7 @@ WebInspector.ScriptsPanel.prototype = {
 
     showGoToSourceDialog: function()
     {
-        WebInspector.OpenResourceDialog.show(this, this._workspace, this.editorView.mainElement);
+        WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement);
     },
 
     __proto__: WebInspector.Panel.prototype
index 05668a2..07889b9 100644 (file)
@@ -33,8 +33,9 @@
  * @implements {WebInspector.WorkspaceProvider}
  * @extends {WebInspector.Object}
  */
-WebInspector.SimpleWorkspaceProvider = function()
+WebInspector.SimpleWorkspaceProvider = function(workspace)
 {
+    this._workspace = workspace;
     /** @type {Object.<string, WebInspector.ContentProvider>} */
     this._contentProviders = {};
 }
@@ -96,6 +97,20 @@ WebInspector.SimpleWorkspaceProvider.prototype = {
         var fileDescriptor = new WebInspector.FileDescriptor(uri, url, contentProvider.contentType(), isEditable, isContentScript, isSnippet);
         this._contentProviders[uri] = contentProvider;
         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileAdded, fileDescriptor);
+        return this._workspace.uiSourceCodeForURI(uri);
+    },
+
+    /**
+     * @param {string} url
+     * @param {WebInspector.ContentProvider} contentProvider
+     * @param {boolean} isEditable
+     * @param {boolean=} isContentScript
+     * @param {boolean=} isSnippet
+     */
+    addFileForURL: function(url, contentProvider, isEditable, isContentScript, isSnippet)
+    {
+        var uri = WebInspector.SimpleWorkspaceProvider.uriForURL(url);
+        return this.addFile(uri, url, contentProvider, isEditable, isContentScript, isSnippet);
     },
 
     /**
@@ -122,6 +137,7 @@ WebInspector.SimpleWorkspaceProvider.prototype = {
     reset: function()
     {
         this._contentProviders = {};
+        this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.Reset, null);
     },
     
     __proto__: WebInspector.Object.prototype
index bd7e26c..fa86acb 100644 (file)
@@ -36,7 +36,7 @@
 WebInspector.StylesSourceMapping = function(workspace)
 {
     this._workspace = workspace;
-    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
+    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
 
     this._uiSourceCodeForURL = {};
@@ -90,10 +90,12 @@ WebInspector.StylesSourceMapping.prototype = {
         WebInspector.cssModel.setSourceMapping(uiSourceCode.url, this);
     },
 
-    _reset: function()
+    _projectWillReset: function(event)
     {
-        this._uiSourceCodeForURL = {};
-        WebInspector.cssModel.resetSourceMappings();
+        var project = event.data;
+        var uiSourceCodes = project.uiSourceCodes();
+        for (var i = 0; i < uiSourceCodes; ++i)
+            delete this._uiSourceCodeForURL[uiSourceCodes[i].url];
     }
 }
 
index 2baad51..1c35ae5 100644 (file)
@@ -223,6 +223,7 @@ WebInspector.TabbedEditorContainer.prototype = {
         var tabIds = [];
         for (var i = 0; i < uiSourceCodes.length; ++i) {
             var uiSourceCode = uiSourceCodes[i];
+            delete this._loadedURIs[uiSourceCode.uri()];
             var tabId = this._tabIds.get(uiSourceCode);
             if (tabId)
                 tabIds.push(tabId);
@@ -391,12 +392,7 @@ WebInspector.TabbedEditorContainer.prototype = {
 
     reset: function()
     {
-        this._tabbedPane.closeAllTabs();
-        this._tabIds = new Map();
-        this._files = {};
-        delete this._currentFile;
         delete this._userSelectedFiles;
-        this._loadedURIs = {};
     },
 
     /**
index e6cacba..7bc8c7c 100644 (file)
@@ -164,6 +164,14 @@ WebInspector.UISourceCode.prototype = {
     },
 
     /**
+     * @return {WebInspector.Project}
+     */
+    project: function()
+    {
+        return this._workspace.projectForUISourceCode(this);
+    },
+
+    /**
      * @param {function(?string,boolean,string)} callback
      */
     requestContent: function(callback)
@@ -606,8 +614,6 @@ WebInspector.UISourceCodeProvider = function()
 
 WebInspector.UISourceCodeProvider.Events = {
     UISourceCodeAdded: "UISourceCodeAdded",
-    TemporaryUISourceCodeAdded: "TemporaryUISourceCodeAdded",
-    TemporaryUISourceCodeRemoved: "TemporaryUISourceCodeRemoved",
     UISourceCodeRemoved: "UISourceCodeRemoved"
 }
 
index 6ff4117..199dfe7 100644 (file)
 WebInspector.WorkspaceController = function(workspace)
 {
     this._workspace = workspace;
-    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
-    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
 }
 
 WebInspector.WorkspaceController.prototype = {
-    _mainFrameNavigated: function()
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _inspectedURLChanged: function(event)
     {
         WebInspector.Revision.filterOutStaleRevisions();
-        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, this._workspace.project());
-        this._workspace.project().reset();
-        this._workspace.reset();
-        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectDidReset, this._workspace.project());
-    },
-
-    _frameAdded: function(event)
-    {
-        var frame = /** @type {WebInspector.ResourceTreeFrame} */ (event.data);
-        if (frame.isMainFrame())
-            WebInspector.Revision.filterOutStaleRevisions();
     }
 }
 
@@ -82,7 +73,8 @@ WebInspector.WorkspaceProvider = function() { }
 
 WebInspector.WorkspaceProvider.Events = {
     FileAdded: "FileAdded",
-    FileRemoved: "FileRemoved"
+    FileRemoved: "FileRemoved",
+    Reset: "Reset",
 }
 
 WebInspector.WorkspaceProvider.prototype = {
@@ -130,23 +122,36 @@ WebInspector.workspaceController = null;
 
 /**
  * @param {WebInspector.Workspace} workspace
+ * @param {string} name
  * @param {WebInspector.WorkspaceProvider} workspaceProvider
  * @constructor
  */
-WebInspector.Project = function(workspace, workspaceProvider)
+WebInspector.Project = function(workspace, name, workspaceProvider)
 {
+    this._name = name;
     this._uiSourceCodes = [];
     this._workspace = workspace;
     this._workspaceProvider = workspaceProvider;
     this._workspaceProvider.addEventListener(WebInspector.WorkspaceProvider.Events.FileAdded, this._fileAdded, this);
     this._workspaceProvider.addEventListener(WebInspector.WorkspaceProvider.Events.FileRemoved, this._fileRemoved, this);
+    this._workspaceProvider.addEventListener(WebInspector.WorkspaceProvider.Events.Reset, this._reset, this);
 }
 
 WebInspector.Project.prototype = {
-    reset: function()
+    /**
+     * @return {string}
+     */
+    name: function()
     {
-        this._workspaceProvider.reset();
-        this._uiSourceCodes = [];
+        return this._name;
+    },
+
+    /**
+     * @return {boolean}
+     */
+    isServiceProject: function()
+    {
+        return this._name === WebInspector.projectNames.Debugger || this._name === WebInspector.projectNames.LiveEdit;
     },
 
     _fileAdded: function(event)
@@ -174,6 +179,12 @@ WebInspector.Project.prototype = {
         this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, uiSourceCode);
     },
 
+    _reset: function()
+    {
+        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, this);
+        this._uiSourceCodes = [];
+    },
+
     /**
      * @param {string} url
      * @return {?WebInspector.UISourceCode}
@@ -240,6 +251,14 @@ WebInspector.Project.prototype = {
     }
 }
 
+WebInspector.projectNames = {
+    Debugger: "debugger",
+    LiveEdit: "liveedit",
+    Compiler: "compiler",
+    Network: "network",
+    Snippets: "snippets",
+}
+
 /**
  * @constructor
  * @implements {WebInspector.UISourceCodeProvider}
@@ -247,16 +266,13 @@ WebInspector.Project.prototype = {
  */
 WebInspector.Workspace = function()
 {
-    /** @type {Object.<string, WebInspector.ContentProvider>} */
-    this._temporaryContentProviders = {};
-    /** @type {Object.<string, WebInspector.UISourceCode>} */
-    this._temporaryUISourceCodes = {};
+    /** @type {!Object.<string, WebInspector.Project>} */
+    this._projects = {};
 }
 
 WebInspector.Workspace.Events = {
     UISourceCodeContentCommitted: "UISourceCodeContentCommitted",
-    ProjectWillReset: "ProjectWillReset",
-    ProjectDidReset: "ProjectDidReset"
+    ProjectWillReset: "ProjectWillReset"
 }
 
 WebInspector.Workspace.prototype = {
@@ -266,7 +282,7 @@ WebInspector.Workspace.prototype = {
      */
     uiSourceCodeForURL: function(url)
     {
-        return this._project.uiSourceCodeForURL(url);
+        return this._projects[WebInspector.projectNames.Network].uiSourceCodeForURL(url);
     },
 
     /**
@@ -275,61 +291,67 @@ WebInspector.Workspace.prototype = {
      */
     uiSourceCodeForURI: function(uri)
     {
-        return this._temporaryUISourceCodes[uri] || this._project.uiSourceCodeForURI(uri);
+        for (var projectName in this._projects) {
+            var project = this._projects[projectName];
+            var uiSourceCode = project.uiSourceCodeForURI(uri);
+            if (uiSourceCode)
+                return uiSourceCode;
+        }
+        return null;
     },
 
     /**
      * @param {string} projectName
      * @param {WebInspector.WorkspaceProvider} workspaceProvider
+     * @return {WebInspector.Project}
      */
     addProject: function(projectName, workspaceProvider)
     {
-        // FIXME: support multiple projects identified by project name.
-        this._project = new WebInspector.Project(this, workspaceProvider);
+        this._projects[projectName] = new WebInspector.Project(this, projectName, workspaceProvider);
+        return this._projects[projectName];
     },
 
     /**
+     * @param {string} projectName
      * @return {WebInspector.Project}
      */
-    project: function()
+    project: function(projectName)
     {
-        return this._project;
+        return this._projects[projectName];
     },
 
     /**
-     * @return {Array.<WebInspector.UISourceCode>}
+     * @return {Array.<WebInspector.Project>}
      */
-    uiSourceCodes: function()
+    projects: function()
     {
-        return this._project.uiSourceCodes();
+        return Object.values(this._projects);
     },
 
     /**
-     * @param {string} uri
-     * @param {string} url
-     * @param {WebInspector.ContentProvider} contentProvider
-     * @param {boolean} isEditable
-     * @param {boolean=} isContentScript
+     * @return {Array.<WebInspector.UISourceCode>}
      */
-    addTemporaryUISourceCode: function(uri, url, contentProvider, isEditable, isContentScript)
+    uiSourceCodes: function()
     {
-        var uiSourceCode = new WebInspector.UISourceCode(this, uri, url, contentProvider.contentType(), isEditable);
-        this._temporaryContentProviders[uri] = contentProvider;
-        this._temporaryUISourceCodes[uri] = uiSourceCode;
-        uiSourceCode.isContentScript = isContentScript;
-        uiSourceCode.isTemporary = true;
-        this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, uiSourceCode);
-        return uiSourceCode;
+        var result = [];
+        for (var projectName in this._projects) {
+            var project = this._projects[projectName];
+            result = result.concat(project.uiSourceCodes());
+        }
+        return result;
     },
 
     /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
+     * @return {?WebInspector.Project}
      */
-    removeTemporaryUISourceCode: function(uiSourceCode)
+    projectForUISourceCode: function(uiSourceCode)
     {
-        delete this._temporaryContentProviders[uiSourceCode.uri()];
-        delete this._temporaryUISourceCodes[uiSourceCode.uri()];
-        this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, uiSourceCode);
+        for (var projectName in this._projects) {
+            var project = this._projects[projectName];
+            if (project.uiSourceCodeForURI(uiSourceCode.uri()))
+                return project;
+        }
+        return null;
     },
 
     /**
@@ -338,12 +360,8 @@ WebInspector.Workspace.prototype = {
      */
     requestFileContent: function(uiSourceCode, callback)
     {
-        var temporaryContentProvider = this._temporaryContentProviders[uiSourceCode.uri()];
-        if (temporaryContentProvider) {
-            temporaryContentProvider.requestContent(callback);
-            return;
-        }
-        this._project.requestFileContent(uiSourceCode.uri(), callback);
+        var project = this.projectForUISourceCode(uiSourceCode);
+        project.requestFileContent(uiSourceCode.uri(), callback);
     },
 
     /**
@@ -353,9 +371,8 @@ WebInspector.Workspace.prototype = {
      */
     setFileContent: function(uiSourceCode, newContent, callback)
     {
-        if (this._temporaryContentProviders[uiSourceCode.uri()])
-            return;
-        this._project.setFileContent(uiSourceCode.url, newContent, callback);
+        var project = this.projectForUISourceCode(uiSourceCode);
+        project.setFileContent(uiSourceCode.uri(), newContent, callback);
     },
 
     /**
@@ -367,18 +384,8 @@ WebInspector.Workspace.prototype = {
      */
     searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, callback)
     {
-        var temporaryContentProvider = this._temporaryContentProviders[uiSourceCode.uri()];
-        if (temporaryContentProvider) {
-            temporaryContentProvider.searchInContent(query, caseSensitive, isRegex, callback);
-            return;
-        }
-        this._project.searchInFileContent(uiSourceCode.uri(), query, caseSensitive, isRegex, callback);
-    },
-
-    reset: function()
-    {
-        this._temporaryContentProviders = {};
-        this._temporaryUISourceCodes = {};
+        var project = this.projectForUISourceCode(uiSourceCode);
+        project.searchInFileContent(uiSourceCode.uri(), query, caseSensitive, isRegex, callback);
     },
 
     __proto__: WebInspector.Object.prototype
index 056002f..880d196 100644 (file)
@@ -431,13 +431,13 @@ WebInspector._doLoadedDoneWithCapabilities = function()
     this.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; });
 
     this.workspace = new WebInspector.Workspace();
-    this.networkWorkspaceProvider = new WebInspector.NetworkWorkspaceProvider();
-    this.workspace.addProject("network", this.networkWorkspaceProvider);
+    this.networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(this.workspace);
+    this.workspace.addProject(WebInspector.projectNames.Network, this.networkWorkspaceProvider);
     this.workspaceController = new WebInspector.WorkspaceController(this.workspace);
 
     this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel, this.workspace);
 
-    this.scriptSnippetModel = new WebInspector.ScriptSnippetModel(this.workspace, this.networkWorkspaceProvider);
+    this.scriptSnippetModel = new WebInspector.ScriptSnippetModel(this.workspace);
     new WebInspector.DebuggerScriptMapping(this.workspace, this.networkWorkspaceProvider);
     this.liveEditSupport = new WebInspector.LiveEditSupport(this.workspace);
     this.styleContentBinding = new WebInspector.StyleContentBinding(this.cssModel);
index aee70bc..cea9f67 100644 (file)
@@ -686,6 +686,7 @@ Map._lastObjectIdentifier = 0;
 Map.prototype = {
     /**
      * @param {Object} key
+     * @param {*=} value
      */
     put: function(key, value)
     {