Title: [142259] trunk
Revision
142259
Author
[email protected]
Date
2013-02-08 04:42:31 -0800 (Fri, 08 Feb 2013)

Log Message

Web Inspector: Replace workspace with project in UISourceCode constructor.
https://bugs.webkit.org/show_bug.cgi?id=109256

Reviewed by Alexander Pavlov.

Source/WebCore:

Replaced workspace with project in UISourceCode constructor since every UISourceCode
operation is delegated to project anyway.

* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.project):
(WebInspector.UISourceCode.prototype.requestContent):
(WebInspector.UISourceCode.prototype.requestOriginalContent):
(WebInspector.UISourceCode.prototype._commitContent):
(WebInspector.UISourceCode.prototype.searchInContent):
* inspector/front-end/Workspace.js:
(WebInspector.Project.prototype._fileAdded):
(WebInspector.Project.prototype.requestFileContent):
(WebInspector.Project.prototype.setFileContent):
(WebInspector.Project.prototype.searchInFileContent):

LayoutTests:

* inspector/debugger/breakpoint-manager-expected.txt:
* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/script-formatter-search.html:
* inspector/debugger/scripts-file-selector.html:
* inspector/debugger/scripts-panel.html:
* inspector/debugger/scripts-sorting.html:
* inspector/debugger/ui-source-code-display-name.html:
* inspector/debugger/ui-source-code.html:
* inspector/uisourcecode-revisions.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142258 => 142259)


--- trunk/LayoutTests/ChangeLog	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/ChangeLog	2013-02-08 12:42:31 UTC (rev 142259)
@@ -1,3 +1,20 @@
+2013-02-08  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Replace workspace with project in UISourceCode constructor.
+        https://bugs.webkit.org/show_bug.cgi?id=109256
+
+        Reviewed by Alexander Pavlov.
+
+        * inspector/debugger/breakpoint-manager-expected.txt:
+        * inspector/debugger/breakpoint-manager.html:
+        * inspector/debugger/script-formatter-search.html:
+        * inspector/debugger/scripts-file-selector.html:
+        * inspector/debugger/scripts-panel.html:
+        * inspector/debugger/scripts-sorting.html:
+        * inspector/debugger/ui-source-code-display-name.html:
+        * inspector/debugger/ui-source-code.html:
+        * inspector/uisourcecode-revisions.html:
+
 2013-02-08  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Modified: trunk/LayoutTests/inspector/debugger/breakpoint-manager-expected.txt (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/breakpoint-manager-expected.txt	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager-expected.txt	2013-02-08 12:42:31 UTC (rev 142259)
@@ -4,7 +4,7 @@
 Running: testSetBreakpoint
   Created breakpoints manager
   Dumping Storage
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
   Setting breakpoint at a.js:30 enabled:true condition:
     debuggerModel.setBreakpoint(a.js:30:)
     breakpointAdded(a.js, 30, , true)
@@ -19,7 +19,7 @@
 Running: testSetDisabledBreakpoint
   Created breakpoints manager
   Dumping Storage
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
   Setting breakpoint at a.js:30 enabled:false condition:
     breakpointAdded(a.js, 30, , false)
   Dumping Storage
@@ -39,7 +39,7 @@
 Running: testSetConditionalBreakpoint
   Created breakpoints manager
   Dumping Storage
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
   Setting breakpoint at a.js:30 enabled:true condition:condition
     debuggerModel.setBreakpoint(a.js:30:condition)
     breakpointAdded(a.js, 30, condition, true)
@@ -66,7 +66,7 @@
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:false condition:
     b.js:3 enabled:true condition:
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10
@@ -87,12 +87,12 @@
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:false condition:
     b.js:3 enabled:true condition:
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10
     breakpointAdded(a.js, 20, , false)
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
   Dumping Storage
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:false condition:
@@ -110,12 +110,11 @@
     a.js:20 enabled:false condition:
     b.js:3 enabled:true condition:
   Adding temporary UISourceCode: a.js)
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10
     breakpointAdded(a.js, 20, , false)
-  Removing temporary UISourceCode: a.js)
   Dumping Storage
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:false condition:
@@ -132,7 +131,7 @@
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:false condition:
     b.js:3 enabled:true condition:
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10
@@ -158,7 +157,7 @@
 Running: testSetBreakpointThatShifts
   Created breakpoints manager
   Dumping Storage
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
   Setting breakpoint at a.js:1015 enabled:true condition:
     debuggerModel.setBreakpoint(a.js:1015:)
     breakpointAdded(a.js, 1025, , true)
@@ -173,7 +172,7 @@
 Running: testSetBreakpointThatShiftsTwice
   Created breakpoints manager
   Dumping Storage
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
   Setting breakpoint at a.js:1015 enabled:true condition:
     debuggerModel.setBreakpoint(a.js:1015:)
     breakpointAdded(a.js, 1025, , true)
@@ -189,7 +188,7 @@
 Running: testSetBreakpointOutsideScript
   Created breakpoints manager
   Dumping Storage
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:2500:)
     breakpointAdded(a.js, 2500, , true)
   Dumping Storage
@@ -204,7 +203,7 @@
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:false condition:
     b.js:3 enabled:true condition:
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10
@@ -216,7 +215,7 @@
     breakpointRemoved(a.js, 10)
     Location disposed: a.js:10
     breakpointRemoved(a.js, 20)
-  Adding UISourceCode: b.js)
+  Adding UISourceCode: b.js
     debuggerModel.setBreakpoint(b.js:3:)
     breakpointAdded(b.js, 3, , true)
     Location created: b.js:3
@@ -227,7 +226,7 @@
     breakpointRemoved(b.js, 3)
     Location disposed: b.js:3
   Resolving provisional breakpoint.
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.removeBreakpoint(a.js:10)
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
@@ -249,7 +248,7 @@
   Dumping Storage
     a.js:10 enabled:true condition:foo == bar
     a.js:20 enabled:true condition:
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10
@@ -283,7 +282,7 @@
   Created breakpoints manager
   Dumping Storage
     a.js:10 enabled:true condition:foo == bar
-  Adding UISourceCode: a.js)
+  Adding UISourceCode: a.js
     debuggerModel.setBreakpoint(a.js:10:foo == bar)
     breakpointAdded(a.js, 10, foo == bar, true)
     Location created: a.js:10

Modified: trunk/LayoutTests/inspector/debugger/breakpoint-manager.html (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/breakpoint-manager.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -16,6 +16,8 @@
 
         uiLocationToRawLocation: function(uiSourceCode, lineNumber)
         {
+            if (!uiSourceCodes[uiSourceCode.url])
+                return null;
             return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lineNumber, 0);
         }
     };
@@ -110,62 +112,18 @@
     }
     DebuggerModelMock.prototype.__proto__ = WebInspector.Object.prototype;
 
-    function WorkspaceMock()
-    {
-    }
-
-    var temporaryUISourceCodes = {};
-    WorkspaceMock.prototype = {
-        _addUISourceCode: function(url)
-        {
-            var uiSourceCode = new WebInspector.UISourceCode(this, url, url, url, WebInspector.resourceTypes.Script, false);
-            uiSourceCodes[url] = uiSourceCode;
-            this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
-            uiSourceCode.setSourceMapping(defaultMapping);
-            return uiSourceCode;
-        },
-
-        _addTemporaryUISourceCode: function(url)
-        {
-            var uiSourceCode = new WebInspector.UISourceCode(this, "temporary:" + url, url, url, WebInspector.resourceTypes.Script, false);
-            uiSourceCodes[url] = uiSourceCode;
-            temporaryUISourceCodes[url] = uiSourceCode;
-            this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, uiSourceCode);
-            uiSourceCode.setSourceMapping(defaultMapping);
-            return uiSourceCode;
-        },
-
-        _removeTemporaryUISourceCode: function(url)
-        {
-            this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, temporaryUISourceCodes[url]);
-            delete temporaryUISourceCodes[url];
-            delete uiSourceCodes[url];
-        },
-
-        uiSourceCodes: function()
-        {
-            return Object.values(uiSourceCodes);
-        },
-
-        reset: function()
-        {
-            InspectorTest.addResult("  Resetting workspace.");
-            var self = this;
-            var mockProject = {};
-            mockProject.uiSourceCodes = function()
-            {
-                return self.uiSourceCodes();
-            }
-            this.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, mockProject);
-        }
-    }
-    WorkspaceMock.prototype.__proto__ = WebInspector.Object.prototype;
-
     var dummySetting = {
         get: function() { return []; },
         set: function(breakpoints) { }
     };
 
+    function resetWorkspace(breakpointManager)
+    {
+        InspectorTest.addResult("  Resetting workspace.");
+        breakpointManager._networkWorkspaceProvider.reset();
+        breakpointManager._debuggerWorkspaceProvider.reset();
+    }
+
     function breakpointAdded(event)
     {
         var breakpoint = event.data.breakpoint;
@@ -191,23 +149,28 @@
     function addUISourceCode(breakpointManager, url)
     {
         breakpointManager._debuggerModel._addScript(url, url);
-        InspectorTest.addResult("  Adding UISourceCode: " + url + ")");
-        return breakpointManager._workspace._addUISourceCode(url);
+        InspectorTest.addResult("  Adding UISourceCode: " + url);
+        var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "", "text/_javascript_");
+        var uiSourceCode = breakpointManager._networkWorkspaceProvider.addFileForURL(url, contentProvider, true);
+        uiSourceCodes[url] = uiSourceCode;
+        uiSourceCode.setSourceMapping(defaultMapping);
+        return uiSourceCode;
     }
 
     function addTemporaryUISourceCode(breakpointManager, url)
     {
+
         breakpointManager._debuggerModel._addScript(url, url);
         InspectorTest.addResult("  Adding temporary UISourceCode: " + url + ")");
-        return breakpointManager._workspace._addTemporaryUISourceCode(url);
+        var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "", "text/_javascript_");
+        var uri = "debugger:" + WebInspector.SimpleWorkspaceProvider.uriForURL(url);
+        var uniqueURI = breakpointManager._debuggerWorkspaceProvider.uniqueURI(uri);
+        var uiSourceCode = breakpointManager._debuggerWorkspaceProvider.addFile(uniqueURI, url, contentProvider, false);
+        uiSourceCode.setSourceMapping(defaultMapping);
+        uiSourceCodes[url] = uiSourceCode;
+        return uiSourceCode;
     }
 
-    function removeTemporaryUISourceCode(breakpointManager, url)
-    {
-        InspectorTest.addResult("  Removing temporary UISourceCode: " + url + ")");
-        breakpointManager._workspace._removeTemporaryUISourceCode(url);
-    }
-
     function createBreakpoint(uiSourceCodeId, lineNumber, condition, enabled)
     {
         return { sourceFileId: uiSourceCodeId, lineNumber: lineNumber, condition: condition, enabled: enabled };
@@ -228,8 +191,14 @@
 
         var sourceMapping = sourceMapping || defaultMapping;
         var debuggerModel = new DebuggerModelMock(sourceMapping);
-        var workspaceMock = new WorkspaceMock();
-        var breakpointManager = new WebInspector.BreakpointManager(setting, debuggerModel, workspaceMock);
+        var workspace = new WebInspector.Workspace();
+        var breakpointManager = new WebInspector.BreakpointManager(setting, debuggerModel, workspace);
+
+        breakpointManager._networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+        workspace.addProject("network", breakpointManager._networkWorkspaceProvider);
+        breakpointManager._debuggerWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+        workspace.addProject("debugger", breakpointManager._debuggerWorkspaceProvider);
+
         breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, breakpointAdded);
         breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, breakpointRemoved);
         InspectorTest.addResult("  Created breakpoints manager");
@@ -317,7 +286,6 @@
             var breakpointManager = createBreakpointManager(serializedBreakpoints);
             addTemporaryUISourceCode(breakpointManager, "a.js");
             addUISourceCode(breakpointManager, "a.js");
-            removeTemporaryUISourceCode(breakpointManager, "a.js");
             resetBreakpointManager(breakpointManager, next);
         },
 
@@ -365,12 +333,12 @@
 
             InspectorTest.addResult("\n  Navigating to B.");
             breakpointManager._debuggerModel.reset();
-            breakpointManager._workspace.reset();
+            resetWorkspace(breakpointManager);
             var uiSourceCodeB = addUISourceCode(breakpointManager, "b.js");
 
             InspectorTest.addResult("\n  Navigating back to A.");
             breakpointManager._debuggerModel.reset();
-            breakpointManager._workspace.reset();
+            resetWorkspace(breakpointManager);
             InspectorTest.addResult("  Resolving provisional breakpoint.");
             var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
             breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
@@ -404,7 +372,7 @@
             var breakpointManager = createBreakpointManager(serializedBreakpoints);
             var uiSourceCode = addUISourceCode(breakpointManager, "a.js");
             breakpointManager._debuggerModel.reset();
-            breakpointManager._workspace.reset();
+            resetWorkspace(breakpointManager);
             InspectorTest.addResult("  Resolving provisional breakpoint.");
             var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
             breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);

Modified: trunk/LayoutTests/inspector/debugger/script-formatter-search.html (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/script-formatter-search.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/script-formatter-search.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -21,7 +21,7 @@
     function didShowScriptSource(frame)
     {
         scriptSource = frame._uiSourceCode;
-        InspectorTest.addSniffer(scriptSource._workspace, "requestFileContent", requestContentSniffer);
+        InspectorTest.addSniffer(scriptSource._project, "requestFileContent", requestContentSniffer);
         scriptSource.searchInContent("magic-string", true, false, dump1);
     }
 

Modified: trunk/LayoutTests/inspector/debugger/scripts-file-selector.html (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/scripts-file-selector.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/scripts-file-selector.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -21,11 +21,7 @@
     var uiSourceCodes = [];
     function addUISourceCode(url, isContentScript)
     {
-        var uiSourceCode = new WebInspector.UISourceCode(WebInspector.workspace, url, url, url, WebInspector.resourceTypes.Script, null);
-        uiSourceCode.project = function()
-        {
-            return new MockProject();
-        }
+        var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), url, url, url, WebInspector.resourceTypes.Script, null);
         uiSourceCode.isContentScript = isContentScript;
         navigator.addUISourceCode(uiSourceCode);
         uiSourceCodes.push(uiSourceCode);

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


--- trunk/LayoutTests/inspector/debugger/scripts-panel.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -21,11 +21,11 @@
     {
         var workspace = new WebInspector.Workspace();
         var networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
-        workspace.addProject(WebInspector.projectNames.Network, networkWorkspaceProvider);
+        var project = workspace.addProject(WebInspector.projectNames.Network, networkWorkspaceProvider);
 
         workspace.debuggerWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
         workspace.addProject(WebInspector.projectNames.Debugger, workspace.debuggerWorkspaceProvider);
-        workspace.requestFileContent = function(uiSourceCode, callback)
+        project.requestFileContent = function(uiSourceCode, callback)
         {
             InspectorTest.addResult("Source requested for " + uiSourceCode.originURL());
             callback("");

Modified: trunk/LayoutTests/inspector/debugger/scripts-sorting.html (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/scripts-sorting.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/scripts-sorting.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -21,11 +21,7 @@
     var uiSourceCodes = [];
     function addUISourceCode(url, isContentScript)
     {
-        var uiSourceCode = new WebInspector.UISourceCode(WebInspector.workspace, url, url, url, WebInspector.resourceTypes.Script, null);
-        uiSourceCode.project = function()
-        {
-            return new MockProject();
-        }
+        var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), url, url, url, WebInspector.resourceTypes.Script, null);
         uiSourceCode.isContentScript = isContentScript;
         navigator.addUISourceCode(uiSourceCode);
         uiSourceCodes.push(uiSourceCode);

Modified: trunk/LayoutTests/inspector/debugger/ui-source-code-display-name.html (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/ui-source-code-display-name.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/ui-source-code-display-name.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -7,7 +7,7 @@
     WebInspector.showPanel("scripts");
     function dumpUISourceCodeDisplayName(url)
     {
-        var uiSourceCode = new WebInspector.UISourceCode(WebInspector.workspace, url, url, url, null);
+        var uiSourceCode = new WebInspector.UISourceCode(null, url, url, url, null);
         InspectorTest.addResult("UISourceCode display name for url \"" + url + "\" is \"" + WebInspector.TabbedEditorContainer.prototype._titleForFile(uiSourceCode) + "\".");
     }
 

Modified: trunk/LayoutTests/inspector/debugger/ui-source-code.html (142258 => 142259)


--- trunk/LayoutTests/inspector/debugger/ui-source-code.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/debugger/ui-source-code.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -6,15 +6,17 @@
 
 function test()
 {
+    var MockProject = function() {}
+    MockProject.prototype.requestFileContent = function(uri, callback)
+    {
+        InspectorTest.addResult("Content is requested from SourceCodeProvider.");
+        setTimeout(callback.bind(null, "var x = 0;", false, "text/_javascript_"), 0);
+    }
+
     InspectorTest.runTestSuite([
         function testUISourceCode(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(WebInspector.workspace, "uri", "originURL", "url", WebInspector.resourceTypes.Script, true);
-            WebInspector.workspace.requestFileContent = function(path, callback)
-            {
-                InspectorTest.addResult("Content is requested from SourceCodeProvider.");
-                setTimeout(callback.bind(null, "var x = 0;", false, "text/_javascript_"), 0);
-            }
+            var uiSourceCode = new WebInspector.UISourceCode(new MockProject(), "uri", "originURL", "url", WebInspector.resourceTypes.Script, true);
             function didRequestContent(callNumber, content, contentEncoded, mimeType)
             {
                 InspectorTest.addResult("Callback " + callNumber + " is invoked.");

Modified: trunk/LayoutTests/inspector/uisourcecode-revisions.html (142258 => 142259)


--- trunk/LayoutTests/inspector/uisourcecode-revisions.html	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/LayoutTests/inspector/uisourcecode-revisions.html	2013-02-08 12:42:31 UTC (rev 142259)
@@ -6,20 +6,21 @@
 {
     WebInspector.showPanel("scripts");
 
-    function createMockWorkspace()
+    function createMockProject()
     {
         var workspace = new WebInspector.Workspace();
         var networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace);
+        var project = new WebInspector.Project(workspace, "network", networkWorkspaceProvider);
         workspace.addProject(WebInspector.projectNames.Network, networkWorkspaceProvider);
-        workspace.requestFileContent = function(uri, callback)
+        project.requestFileContent = function(uri, callback)
         {
             callback("<script content>", false, "text/_javascript_");
         }
-        workspace.setFileContent = function(uri, newContent, callback)
+        project.setFileContent = function(uri, newContent, callback)
         {
         }
 
-        return workspace;
+        return project;
     }
  
     function dumpUISourceCodeWithRevisions(uiSourceCode)
@@ -39,7 +40,7 @@
     InspectorTest.runTestSuite([
         function testAddRevisionsRevertToOriginal(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(createMockWorkspace(), "uri", "originURL", "url", WebInspector.resourceTypes.Script);
+            var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "uri", "originURL", "url", WebInspector.resourceTypes.Script);
             uiSourceCode.setWorkingCopy("content1");
             uiSourceCode.setWorkingCopy("content2");
             uiSourceCode.commitWorkingCopy(function() { });
@@ -60,7 +61,7 @@
 
         function testAddRevisionsRevertAndClearHistory(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(createMockWorkspace(), "uri2", "originURL2", "url2", WebInspector.resourceTypes.Script);
+            var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "uri2", "originURL2", "url2", WebInspector.resourceTypes.Script);
 
             uiSourceCode.setWorkingCopy("content1");
             uiSourceCode.setWorkingCopy("content2");
@@ -86,7 +87,7 @@
 
         function testAddRevisionsRevertToPrevious(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(createMockWorkspace(), "uri3", "originURL3", "url3", WebInspector.resourceTypes.Script);
+            var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "uri3", "originURL3", "url3", WebInspector.resourceTypes.Script);
 
             uiSourceCode.setWorkingCopy("content1");
             uiSourceCode.setWorkingCopy("content2");
@@ -108,7 +109,7 @@
 
         function testRequestContentAddRevisionsRevertToOriginal(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(createMockWorkspace(), "uri4", "originURL4", "url4", WebInspector.resourceTypes.Script);
+            var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "uri4", "originURL4", "url4", WebInspector.resourceTypes.Script);
             uiSourceCode.requestContent(contentReceived);
 
             function contentReceived()
@@ -136,7 +137,7 @@
 
         function testRequestContentAddRevisionsRevertAndClearHistory(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(createMockWorkspace(), "uri5", "originURL5", "url5", WebInspector.resourceTypes.Script);
+            var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "uri5", "originURL5", "url5", WebInspector.resourceTypes.Script);
             uiSourceCode.requestContent(contentReceived);
 
             function contentReceived()
@@ -168,7 +169,7 @@
 
         function testRequestContentAddRevisionsRevertToPrevious(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode(createMockWorkspace(), "uri6", "originURL6", "url6", WebInspector.resourceTypes.Script);
+            var uiSourceCode = new WebInspector.UISourceCode(createMockProject(), "uri6", "originURL6", "url6", WebInspector.resourceTypes.Script);
             uiSourceCode.requestContent(contentReceived);
 
             function contentReceived()

Modified: trunk/Source/WebCore/ChangeLog (142258 => 142259)


--- trunk/Source/WebCore/ChangeLog	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/Source/WebCore/ChangeLog	2013-02-08 12:42:31 UTC (rev 142259)
@@ -1,3 +1,26 @@
+2013-02-08  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Replace workspace with project in UISourceCode constructor.
+        https://bugs.webkit.org/show_bug.cgi?id=109256
+
+        Reviewed by Alexander Pavlov.
+
+        Replaced workspace with project in UISourceCode constructor since every UISourceCode
+        operation is delegated to project anyway.
+
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode):
+        (WebInspector.UISourceCode.prototype.project):
+        (WebInspector.UISourceCode.prototype.requestContent):
+        (WebInspector.UISourceCode.prototype.requestOriginalContent):
+        (WebInspector.UISourceCode.prototype._commitContent):
+        (WebInspector.UISourceCode.prototype.searchInContent):
+        * inspector/front-end/Workspace.js:
+        (WebInspector.Project.prototype._fileAdded):
+        (WebInspector.Project.prototype.requestFileContent):
+        (WebInspector.Project.prototype.setFileContent):
+        (WebInspector.Project.prototype.searchInFileContent):
+
 2013-02-08  Patrick Gansterer  <[email protected]>
 
         Build fix for Windows after r141981.

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (142258 => 142259)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2013-02-08 12:42:31 UTC (rev 142259)
@@ -33,15 +33,15 @@
  * @constructor
  * @extends {WebInspector.Object}
  * @implements {WebInspector.ContentProvider}
- * @param {WebInspector.Workspace} workspace
+ * @param {WebInspector.Project} project
  * @param {string} uri
  * @param {string} url
  * @param {WebInspector.ResourceType} contentType
  * @param {boolean} isEditable
  */
-WebInspector.UISourceCode = function(workspace, uri, originURL, url, contentType, isEditable)
+WebInspector.UISourceCode = function(project, uri, originURL, url, contentType, isEditable)
 {
-    this._workspace = workspace;
+    this._project = project;
     this._uri = uri;
     this._originURL = originURL;
     this._url = url;
@@ -178,7 +178,7 @@
      */
     project: function()
     {
-        return this._workspace.projectForUISourceCode(this);
+        return this._project;
     },
 
     /**
@@ -192,7 +192,7 @@
         }
         this._requestContentCallbacks.push(callback);
         if (this._requestContentCallbacks.length === 1)
-            this._workspace.requestFileContent(this, this._fireContentAvailable.bind(this));
+            this._project.requestFileContent(this, this._fireContentAvailable.bind(this));
     },
 
     /**
@@ -200,7 +200,7 @@
      */
     requestOriginalContent: function(callback)
     {
-        this._workspace.requestFileContent(this, callback);
+        this._project.requestFileContent(this, callback);
     },
 
     /**
@@ -221,12 +221,11 @@
         var oldWorkingCopy = this._workingCopy;
         delete this._workingCopy;
         this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyCommitted, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()});
-        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: this, content: this._content });
         if (this._url && WebInspector.fileManager.isURLSaved(this._url)) {
             WebInspector.fileManager.save(this._url, this._content, false);
             WebInspector.fileManager.close(this._url);
         }
-        this._workspace.setFileContent(this, this._content, function() { });
+        this._project.setFileContent(this, this._content, function() { });
     },
 
     /**
@@ -423,7 +422,7 @@
             return;
         }
 
-        this._workspace.searchInFileContent(this, query, caseSensitive, isRegex, callback);
+        this._project.searchInFileContent(this, query, caseSensitive, isRegex, callback);
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/Workspace.js (142258 => 142259)


--- trunk/Source/WebCore/inspector/front-end/Workspace.js	2013-02-08 12:39:06 UTC (rev 142258)
+++ trunk/Source/WebCore/inspector/front-end/Workspace.js	2013-02-08 12:42:31 UTC (rev 142259)
@@ -163,7 +163,7 @@
             // FIXME: Implement
             return;
         }
-        uiSourceCode = new WebInspector.UISourceCode(this._workspace, fileDescriptor.uri, fileDescriptor.originURL, fileDescriptor.url, fileDescriptor.contentType, fileDescriptor.isEditable);
+        uiSourceCode = new WebInspector.UISourceCode(this, fileDescriptor.uri, fileDescriptor.originURL, fileDescriptor.url, fileDescriptor.contentType, fileDescriptor.isEditable);
         uiSourceCode.isContentScript = fileDescriptor.isContentScript;
         this._uiSourceCodesForURI[uiSourceCode.uri()] = uiSourceCode;
         this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
@@ -217,34 +217,35 @@
     },
 
     /**
-     * @param {string} uri
+     * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {function(?string,boolean,string)} callback
      */
-    requestFileContent: function(uri, callback)
+    requestFileContent: function(uiSourceCode, callback)
     {
-        this._workspaceProvider.requestFileContent(uri, callback);
+        this._workspaceProvider.requestFileContent(uiSourceCode.uri(), callback);
     },
 
     /**
-     * @param {string} uri
+     * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {string} newContent
      * @param {function(?string)} callback
      */
-    setFileContent: function(uri, newContent, callback)
+    setFileContent: function(uiSourceCode, newContent, callback)
     {
-        this._workspaceProvider.setFileContent(uri, newContent, callback);
+        this._workspaceProvider.setFileContent(uiSourceCode.uri(), newContent, callback);
+        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: uiSourceCode, content: newContent });
     },
 
     /**
-     * @param {string} uri
+     * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {string} query
      * @param {boolean} caseSensitive
      * @param {boolean} isRegex
      * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
      */
-    searchInFileContent: function(uri, query, caseSensitive, isRegex, callback)
+    searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, callback)
     {
-        this._workspaceProvider.searchInFileContent(uri, query, caseSensitive, isRegex, callback);
+        this._workspaceProvider.searchInFileContent(uiSourceCode.uri(), query, caseSensitive, isRegex, callback);
     },
 
     dispose: function()
@@ -368,40 +369,6 @@
         return null;
     },
 
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {function(?string,boolean,string)} callback
-     */
-    requestFileContent: function(uiSourceCode, callback)
-    {
-        var project = this.projectForUISourceCode(uiSourceCode);
-        project.requestFileContent(uiSourceCode.uri(), callback);
-    },
-
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {string} newContent
-     * @param {function(?string)} callback
-     */
-    setFileContent: function(uiSourceCode, newContent, callback)
-    {
-        var project = this.projectForUISourceCode(uiSourceCode);
-        project.setFileContent(uiSourceCode.uri(), newContent, callback);
-    },
-
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {string} query
-     * @param {boolean} caseSensitive
-     * @param {boolean} isRegex
-     * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
-     */
-    searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, callback)
-    {
-        var project = this.projectForUISourceCode(uiSourceCode);
-        project.searchInFileContent(uiSourceCode.uri(), query, caseSensitive, isRegex, callback);
-    },
-
     __proto__: WebInspector.Object.prototype
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to