Diff
Modified: trunk/LayoutTests/ChangeLog (141887 => 141888)
--- trunk/LayoutTests/ChangeLog 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/LayoutTests/ChangeLog 2013-02-05 13:52:22 UTC (rev 141888)
@@ -1,3 +1,14 @@
+2013-02-04 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Create separate project for each file system added to inspector.
+ https://bugs.webkit.org/show_bug.cgi?id=108652
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/file-mapping.html:
+ * inspector/file-system-mapping-expected.txt: Added.
+ * inspector/file-system-mapping.html: Added.
+
2013-02-05 Kent Tamura <[email protected]>
INPUT_MULTIPLE_FIELDS_UI: Should not move focus if the element already has focus
Modified: trunk/LayoutTests/inspector/file-mapping.html (141887 => 141888)
--- trunk/LayoutTests/inspector/file-mapping.html 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/LayoutTests/inspector/file-mapping.html 2013-02-05 13:52:22 UTC (rev 141888)
@@ -6,8 +6,8 @@
{
function MockFileSystemMapping() {}
MockFileSystemMapping.prototype = {
- uriForPath: function(path) {
- return "uri:" + path;
+ uriPrefixForPathPrefix: function(pathPrefix) {
+ return "uri:" + pathPrefix;
}
};
Added: trunk/LayoutTests/inspector/file-system-mapping-expected.txt (0 => 141888)
--- trunk/LayoutTests/inspector/file-system-mapping-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/file-system-mapping-expected.txt 2013-02-05 13:52:22 UTC (rev 141888)
@@ -0,0 +1,136 @@
+Tests FileSystemMapping
+
+Testing file system mapping.
+ file system pathes:
+ uriPrefixForPathPrefix:
+ uriForFile:
+ fileForURI:
+
+Adding file system /home/username/projects/foo
+Testing file system mapping.
+ file system pathes:
+ - /home/username/projects/foo(id = 0@foo)
+ uriPrefixForPathPrefix:
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/foo => 0@foo/
+ uriForFile:
+ /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
+ /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
+ fileForURI:
+ /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
+ /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
+
+Adding file system /home/username/projects/bar
+Testing file system mapping.
+ file system pathes:
+ - /home/username/projects/foo(id = 0@foo)
+ - /home/username/projects/bar(id = 1@bar)
+ uriPrefixForPathPrefix:
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/bar => 1@bar/
+ /home/username/projects/bar => 1@bar/
+ uriForFile:
+ /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
+ /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
+ /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
+ /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
+ fileForURI:
+ /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
+ /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
+ /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
+ /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
+
+Adding file system /www/site1
+Testing file system mapping.
+ file system pathes:
+ - /home/username/projects/foo(id = 0@foo)
+ - /home/username/projects/bar(id = 1@bar)
+ - /www/site1(id = 2@site1)
+ uriPrefixForPathPrefix:
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/bar => 1@bar/
+ /home/username/projects/bar => 1@bar/
+ /www/site1 => 2@site1/
+ uriForFile:
+ /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
+ /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
+ /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
+ /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
+ /www/site1, /site1.txt => 2@site1/site1.txt
+ fileForURI:
+ /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
+ /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
+ /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
+ /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
+ /www/site1, 2@site1/site1.txt => /site1.txt
+
+Creating another file system mapping.
+Testing file system mapping.
+ file system pathes:
+ - /home/username/projects/foo(id = 0@foo)
+ - /home/username/projects/bar(id = 1@bar)
+ - /www/site1(id = 2@site1)
+ uriPrefixForPathPrefix:
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/bar => 1@bar/
+ /home/username/projects/bar => 1@bar/
+ /www/site1 => 2@site1/
+ uriForFile:
+ /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
+ /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
+ /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
+ /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
+ /www/site1, /site1.txt => 2@site1/site1.txt
+ fileForURI:
+ /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
+ /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
+ /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
+ /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
+ /www/site1, 2@site1/site1.txt => /site1.txt
+
+Removing file system /www/site1
+Testing file system mapping.
+ file system pathes:
+ - /home/username/projects/foo(id = 0@foo)
+ - /home/username/projects/bar(id = 1@bar)
+ uriPrefixForPathPrefix:
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/foo => 0@foo/
+ /home/username/projects/bar => 1@bar/
+ /home/username/projects/bar => 1@bar/
+ uriForFile:
+ /home/username/projects/foo, /foo.txt => 0@foo/foo.txt
+ /home/username/projects/foo, /src/foo.cpp => 0@foo/src/foo.cpp
+ /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
+ /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
+ fileForURI:
+ /home/username/projects/foo, 0@foo/foo.txt => /foo.txt
+ /home/username/projects/foo, 0@foo/src/foo.cpp => /src/foo.cpp
+ /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
+ /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
+
+Removing file system /home/username/projects/foo
+Testing file system mapping.
+ file system pathes:
+ - /home/username/projects/bar(id = 1@bar)
+ uriPrefixForPathPrefix:
+ /home/username/projects/bar => 1@bar/
+ /home/username/projects/bar => 1@bar/
+ uriForFile:
+ /home/username/projects/bar, /bar.txt => 1@bar/bar.txt
+ /home/username/projects/bar, /src/bar.cpp => 1@bar/src/bar.cpp
+ fileForURI:
+ /home/username/projects/bar, 1@bar/bar.txt => /bar.txt
+ /home/username/projects/bar, 1@bar/src/bar.cpp => /src/bar.cpp
+
+Removing file system /home/username/projects/bar
+Testing file system mapping.
+ file system pathes:
+ uriPrefixForPathPrefix:
+ uriForFile:
+ fileForURI:
+
+
Added: trunk/LayoutTests/inspector/file-system-mapping.html (0 => 141888)
--- trunk/LayoutTests/inspector/file-system-mapping.html (rev 0)
+++ trunk/LayoutTests/inspector/file-system-mapping.html 2013-02-05 13:52:22 UTC (rev 141888)
@@ -0,0 +1,102 @@
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ var pathes = {
+ FOO: "/home/username/projects/foo",
+ BAR: "/home/username/projects/bar",
+ SITE1: "/www/site1"
+ };
+ var files = [{fileSystemPath: pathes.FOO, filePath: "/foo.txt"},
+ {fileSystemPath: pathes.FOO, filePath: "/src/foo.cpp"},
+ {fileSystemPath: pathes.BAR, filePath: "/bar.txt"},
+ {fileSystemPath: pathes.BAR, filePath: "/src/bar.cpp"},
+ {fileSystemPath: pathes.SITE1, filePath: "/site1.txt"}];
+
+ function addFileSystem(fileSystemMapping, path)
+ {
+ InspectorTest.addResult("Adding file system " + path);
+ fileSystemMapping.addFileSystemMapping(path);
+ }
+
+ function removeFileSystem(fileSystemMapping, path)
+ {
+ InspectorTest.addResult("Removing file system " + path);
+ fileSystemMapping.removeFileSystemMapping(path);
+ }
+
+ function checkAndDumpFileSystemMapping(fileSystemMapping)
+ {
+ var fileSystemPaths = fileSystemMapping.fileSystemPaths();
+ InspectorTest.addResult("Testing file system mapping.");
+ InspectorTest.addResult(" file system pathes:");
+ for (var i = 0; i < fileSystemPaths.length; ++i) {
+ var id = fileSystemMapping.fileSystemId(fileSystemPaths[i]);
+ InspectorTest.addResult(" - " + fileSystemPaths[i] + "(id = " + id + ")");
+ }
+ InspectorTest.addResult(" uriPrefixForPathPrefix:");
+ for (var i = 0; i < files.length; ++i) {
+ var pathPrefix = files[i].fileSystemPath;
+ var uriPrefix = fileSystemMapping.uriPrefixForPathPrefix(pathPrefix + "/");
+ if (!uriPrefix)
+ continue;
+ InspectorTest.addResult(" " + pathPrefix + " => " + uriPrefix);
+ }
+
+ var uris = [];
+ InspectorTest.addResult(" uriForFile:");
+ for (var i = 0; i < files.length; ++i) {
+ var uri = fileSystemMapping.uriForFile(files[i].fileSystemPath, files[i].filePath);
+ uris.push(uri);
+ if (!uri)
+ continue;
+ InspectorTest.addResult(" " + files[i].fileSystemPath + ", " + files[i].filePath + " => " + uri);
+ }
+ InspectorTest.addResult(" fileForURI:");
+ for (var i = 0; i < files.length; ++i) {
+ if (!uris[i])
+ continue;
+ var filePath = fileSystemMapping.fileForURI(files[i].fileSystemPath, uris[i]);
+ InspectorTest.addResult(" " + files[i].fileSystemPath + ", " + uris[i] + " => " + filePath);
+ }
+ InspectorTest.addResult("");
+ }
+
+ // At first create file system mapping and clear it.
+ var fileSystemMapping = new WebInspector.FileSystemMappingImpl();
+ var fileSystemPaths = fileSystemMapping.fileSystemPaths();
+ for (var i = 0; i < fileSystemPaths.length; ++i)
+ fileSystemMapping.removeFileSystemMapping(fileSystemPaths[i]);
+
+ // Now fill it with file systems and test.
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+ addFileSystem(fileSystemMapping, pathes.FOO)
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+ addFileSystem(fileSystemMapping, pathes.BAR)
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+ addFileSystem(fileSystemMapping, pathes.SITE1)
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+
+ // Then create another file mapping to make sure it is correctly restored from the settings.
+ InspectorTest.addResult("Creating another file system mapping.");
+ var fileSystemMapping = new WebInspector.FileSystemMappingImpl();
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+
+ // Now remove file systems and test.
+ removeFileSystem(fileSystemMapping, pathes.SITE1)
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+ removeFileSystem(fileSystemMapping, pathes.FOO)
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+ removeFileSystem(fileSystemMapping, pathes.BAR)
+ checkAndDumpFileSystemMapping(fileSystemMapping);
+
+ InspectorTest.completeTest();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests FileSystemMapping</p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (141887 => 141888)
--- trunk/Source/WebCore/ChangeLog 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/Source/WebCore/ChangeLog 2013-02-05 13:52:22 UTC (rev 141888)
@@ -1,3 +1,52 @@
+2013-02-04 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Create separate project for each file system added to inspector.
+ https://bugs.webkit.org/show_bug.cgi?id=108652
+
+ Reviewed by Pavel Feldman.
+
+ Every file system added to web inspector is now represented by its own project in workspace.
+ FileSystemMapping changed accrodingly.
+
+ Test: inspector/file-system-mapping.html
+
+ * inspector/front-end/FileMapping.js:
+ (WebInspector.FileMapping.prototype._entryURIPrefix):
+ * inspector/front-end/FileSystemMapping.js:
+ (WebInspector.FileSystemMapping.prototype.fileForURI):
+ (WebInspector.FileSystemMapping.prototype.uriForFile):
+ (WebInspector.FileSystemMapping.prototype.uriPrefixForPathPrefix):
+ (WebInspector.FileSystemMappingImpl):
+ (WebInspector.FileSystemMappingImpl.prototype._loadFromSettings.get this):
+ (WebInspector.FileSystemMappingImpl.prototype._loadFromSettings):
+ (WebInspector.FileSystemMappingImpl.prototype._saveToSettings):
+ (WebInspector.FileSystemMappingImpl.prototype.set _fileSystemName):
+ (WebInspector.FileSystemMappingImpl.prototype.fileSystemId):
+ (WebInspector.FileSystemMappingImpl.prototype.addFileSystemMapping):
+ (WebInspector.FileSystemMappingImpl.prototype.removeFileSystemMapping):
+ (WebInspector.FileSystemMappingImpl.prototype.fileSystemPaths):
+ (WebInspector.FileSystemMappingImpl.prototype.fileForURI):
+ (WebInspector.FileSystemMappingImpl.prototype.uriForFile):
+ (WebInspector.FileSystemMappingImpl.prototype.uriPrefixForPathPrefix):
+ * inspector/front-end/FileSystemWorkspaceProvider.js:
+ (WebInspector.FileSystemWorkspaceProvider):
+ (WebInspector.FileSystemWorkspaceProvider.prototype.innerCallback):
+ (WebInspector.FileSystemWorkspaceProvider.prototype.requestFileContent):
+ (WebInspector.FileSystemWorkspaceProvider.prototype.setFileContent):
+ (WebInspector.FileSystemWorkspaceProvider.prototype._populate.filesLoaded):
+ (WebInspector.FileSystemWorkspaceProvider.prototype._populate):
+ (WebInspector.FileSystemWorkspaceProvider.prototype._addFile):
+ (WebInspector.FileSystemWorkspaceProvider.prototype._removeFile):
+ (WebInspector.FileSystemWorkspaceProvider.prototype.reset):
+ * inspector/front-end/IsolatedFileSystemModel.js:
+ (WebInspector.IsolatedFileSystemModel):
+ (WebInspector.IsolatedFileSystemModel.prototype._innerAddFileSystem):
+ (WebInspector.IsolatedFileSystemModel.prototype._fileSystemRemoved):
+ * inspector/front-end/Workspace.js:
+ (WebInspector.Project.prototype.searchInFileContent):
+ (WebInspector.Project.prototype.dispose):
+ (WebInspector.Workspace.prototype.removeProject):
+
2013-02-05 Kent Tamura <[email protected]>
INPUT_MULTIPLE_FIELDS_UI: Should not move focus if the element already has focus
Modified: trunk/Source/WebCore/inspector/front-end/FileMapping.js (141887 => 141888)
--- trunk/Source/WebCore/inspector/front-end/FileMapping.js 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/Source/WebCore/inspector/front-end/FileMapping.js 2013-02-05 13:52:22 UTC (rev 141888)
@@ -58,7 +58,7 @@
*/
_entryURIPrefix: function(entry)
{
- return this._fileSystemMapping.uriForPath(entry.pathPrefix);
+ return this._fileSystemMapping.uriPrefixForPathPrefix(entry.pathPrefix);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js (141887 => 141888)
--- trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js 2013-02-05 13:52:22 UTC (rev 141888)
@@ -33,20 +33,6 @@
*/
WebInspector.FileSystemMapping = function() { }
-/**
- * @constructor
- */
-WebInspector.FileSystemMapping.FileDescriptor = function(fileSystemPath, filePath)
-{
- this.fileSystemPath = fileSystemPath;
- this.filePath = filePath;
-}
-
-WebInspector.FileSystemMapping.Events = {
- FileSystemAdded: "FileSystemAdded",
- FileSystemRemoved: "FileSystemRemoved"
-}
-
WebInspector.FileSystemMapping.prototype = {
/**
* @return {Array.<string>}
@@ -54,36 +40,24 @@
fileSystemPaths: function() { },
/**
+ * @param {string} fileSystemPath
* @param {string} uri
- * @return {?WebInspector.FileSystemMapping.FileDescriptor}
+ * @return {?string}
*/
- fileForURI: function(uri) { },
+ fileForURI: function(fileSystemPath, uri) { },
/**
- * @param {WebInspector.FileSystemMapping.FileDescriptor} fileDescriptor
+ * @param {string} fileSystemPath
+ * @param {string} filePath
* @return {string}
*/
- uriForFile: function(fileDescriptor) { },
+ uriForFile: function(fileSystemPath, filePath) { },
/**
- * @param {string} path
+ * @param {string} pathPrefix
* @return {?string}
*/
- uriForPath: function(path) { },
-
- /**
- * @param {string} eventType
- * @param {function(WebInspector.Event)} listener
- * @param {Object=} thisObject
- */
- addEventListener: function(eventType, listener, thisObject) { },
-
- /**
- * @param {string} eventType
- * @param {function(WebInspector.Event)} listener
- * @param {Object=} thisObject
- */
- removeEventListener: function(eventType, listener, thisObject) { }
+ uriPrefixForPathPrefix: function(pathPrefix) { },
}
/**
@@ -96,107 +70,144 @@
WebInspector.Object.call(this);
this._fileSystemMappingSetting = WebInspector.settings.createSetting("fileSystemMapping", {});
/** @type {!Object.<string, string>} */
- this._mappedNames = this._fileSystemMappingSetting.get();
+ this._fileSystemPaths = {};
+ /** @type {!Object.<string, string>} */
+ this._fileSystemIds = {};
+ /** @type {!Object.<string, string>} */
+ this._fileSystemNames = {};
+ this._loadFromSettings();
}
WebInspector.FileSystemMappingImpl.prototype = {
+ _loadFromSettings: function()
+ {
+ var savedMapping = this._fileSystemMappingSetting.get();
+ this._nextUniqueId = savedMapping ? savedMapping._nextUniqueId || 0 : 0;
+ this._fileSystemPaths = savedMapping ? /** @type {!Object.<string, string>} */ (savedMapping.fileSystemPaths) || {} : {};
+ for (var id in this._fileSystemPaths) {
+ var fileSystemPath = this._fileSystemPaths[id];
+ var name = this._fileSystemName(fileSystemPath);
+ this._fileSystemIds[fileSystemPath] = id;
+ this._fileSystemNames[id] = name;
+ }
+ },
+
+ _saveToSettings: function()
+ {
+ var savedMapping = {};
+ savedMapping.nextUniqueId = this._nextUniqueId;
+ savedMapping.fileSystemPaths = this._fileSystemPaths;
+ this._fileSystemMappingSetting.set(savedMapping);
+ },
+
/**
* @param {string} fileSystemPath
*/
- addFileSystemMapping: function(fileSystemPath)
+ _fileSystemName: function(fileSystemPath)
{
- if (this._mappedNames[fileSystemPath])
- return;
- var pathSegments = fileSystemPath.split("/");
- var mappedName = pathSegments[pathSegments.length - 1];
- var uniqueMappedName = this._uniqueMappedName(mappedName);
- this._mappedNames[fileSystemPath] = mappedName;
- this._fileSystemMappingSetting.set(this._mappedNames);
- this.dispatchEventToListeners(WebInspector.FileSystemMapping.Events.FileSystemAdded, fileSystemPath);
+ var lastIndexOfSlash = fileSystemPath.lastIndexOf("/");
+ return fileSystemPath.substr(lastIndexOfSlash + 1);
},
/**
- * @param {string} mappedName
+ * @param {string} fileSystemPath
+ * @return {?string}
*/
- _uniqueMappedName: function(mappedName)
+ fileSystemId: function(fileSystemPath)
{
- var uniqueMappedName = mappedName;
- var i = 1;
- while (Object.values(this._mappedNames).indexOf(uniqueMappedName) !== -1) {
- uniqueMappedName = mappedName + " (" + i + ")";
- ++i;
- }
- return uniqueMappedName;
+ return this._fileSystemIds[fileSystemPath];
},
/**
* @param {string} fileSystemPath
+ * @return {?string}
*/
- removeFileSystemMapping: function(fileSystemPath)
+ addFileSystemMapping: function(fileSystemPath)
{
- var uriPrefix = this._uriPrefixForMappedName(this._mappedNames[fileSystemPath]);
- delete this._mappedNames[fileSystemPath];
- this._fileSystemMappingSetting.set(this._mappedNames);
- this.dispatchEventToListeners(WebInspector.FileSystemMapping.Events.FileSystemRemoved, fileSystemPath);
+ if (this._fileSystemIds[fileSystemPath])
+ return this._fileSystemIds[fileSystemPath];
+
+ var name = this._fileSystemName(fileSystemPath);
+ var id = String(this._nextUniqueId++) + "@" + name;
+ this._fileSystemIds[fileSystemPath] = id;
+ this._fileSystemNames[id] = name;
+ this._fileSystemPaths[id] = fileSystemPath;
+ this._saveToSettings();
+ delete this._cachedURIPrefixes;
+ return id;
},
/**
- * @return {Array.<string>}
+ * @param {string} fileSystemPath
*/
- fileSystemPaths: function()
+ removeFileSystemMapping: function(fileSystemPath)
{
- return Object.keys(this._mappedNames);
+ var id = this._fileSystemIds[fileSystemPath];
+ if (!id)
+ return;
+ delete this._fileSystemIds[fileSystemPath];
+ delete this._fileSystemNames[id];
+ delete this._fileSystemPaths[id];
+ this._saveToSettings();
+ delete this._cachedURIPrefixes;
},
/**
- * @return {string}
+ * @return {Array.<string>}
*/
- _uriPrefixForMappedName: function(mappedName)
+ fileSystemPaths: function()
{
- return "file:///" + mappedName + "/";
+ return Object.values(this._fileSystemPaths);
},
/**
+ * @param {string} fileSystemPath
* @param {string} uri
- * @return {?WebInspector.FileSystemMapping.FileDescriptor}
+ * @return {?string}
*/
- fileForURI: function(uri)
+ fileForURI: function(fileSystemPath, uri)
{
- for (var fileSystemPath in this._mappedNames) {
- var uriPrefix = this._uriPrefixForMappedName(this._mappedNames[fileSystemPath]);
- if (uri.startsWith(uriPrefix))
- return new WebInspector.FileSystemMapping.FileDescriptor(fileSystemPath, "/" + uri.substring(uriPrefix.length));
- }
- return null;
+ var indexOfSlash = uri.indexOf("/");
+ var uriId = uri.substr(0, indexOfSlash);
+ var id = this._fileSystemIds[fileSystemPath]
+ if (!uriId || uriId !== id)
+ return null;
+ var filePath = uri.substr(indexOfSlash);
+ return filePath;
},
/**
- * @param {WebInspector.FileSystemMapping.FileDescriptor} fileDescriptor
- * @return {string}
+ * @param {string} fileSystemPath
+ * @param {string} filePath
+ * @return {?string}
*/
- uriForFile: function(fileDescriptor)
+ uriForFile: function(fileSystemPath, filePath)
{
- var uriPrefix = this._uriPrefixForMappedName(this._mappedNames[fileDescriptor.fileSystemPath]);
- return uriPrefix + fileDescriptor.filePath.substring("/".length);
+ var id = this._fileSystemIds[fileSystemPath];
+ if (!id)
+ return null;
+ return id + filePath;
},
/**
- * @param {string} path
+ * @param {string} pathPrefix
* @return {?string}
*/
- uriForPath: function(path)
+ uriPrefixForPathPrefix: function(pathPrefix)
{
- for (var fileSystemPath in this._mappedNames) {
- if (path.startsWith(fileSystemPath)) {
- var uriPrefix = this._uriPrefixForMappedName(this._mappedNames[fileSystemPath]);
- var subPath = path.substring(fileSystemPath.length);
- if (subPath.length === 0)
- return uriPrefix;
- else if (subPath[0] === "/")
- return uriPrefix + subPath.substring("/".length);
+ this._cachedURIPrefixes = this._cachedURIPrefixes || {};
+ if (this._cachedURIPrefixes.hasOwnProperty(pathPrefix))
+ return this._cachedURIPrefixes[pathPrefix];
+ var uriPrefix;
+ for (var id in this._fileSystemPaths) {
+ var fileSystemPath = this._fileSystemPaths[id];
+ if (pathPrefix.startsWith(fileSystemPath + "/")) {
+ uriPrefix = id + pathPrefix.substr(fileSystemPath.length);
+ break;
}
}
- return null;
+ this._cachedURIPrefixes[pathPrefix] = uriPrefix;
+ return uriPrefix;
},
__proto__: WebInspector.Object.prototype
Modified: trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js (141887 => 141888)
--- trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js 2013-02-05 13:52:22 UTC (rev 141888)
@@ -34,14 +34,12 @@
* @extends {WebInspector.Object}
* @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
*/
-WebInspector.FileSystemWorkspaceProvider = function(isolatedFileSystemModel)
+WebInspector.FileSystemWorkspaceProvider = function(isolatedFileSystemModel, fileSystemPath)
{
this._isolatedFileSystemModel = isolatedFileSystemModel;
+ this._fileSystemPath = fileSystemPath;
this._files = {};
-
this._populate();
- this._isolatedFileSystemModel.mapping().addEventListener(WebInspector.FileSystemMapping.Events.FileSystemAdded, this._fileSystemAdded, this);
- this._isolatedFileSystemModel.mapping().addEventListener(WebInspector.FileSystemMapping.Events.FileSystemRemoved, this._fileSystemRemoved, this);
}
WebInspector.FileSystemWorkspaceProvider._scriptExtensions = ["js", "java", "cc", "cpp", "h", "cs", "py", "php"].keySet();
@@ -53,17 +51,17 @@
*/
requestFileContent: function(uri, callback)
{
- var fileDescriptor = this._isolatedFileSystemModel.mapping().fileForURI(uri);
- if (!fileDescriptor) {
+ var filePath = this._isolatedFileSystemModel.mapping().fileForURI(this._fileSystemPath, uri);
+ if (!filePath) {
console.error("No matching file for uri: " + uri);
callback(null, false, WebInspector.resourceTypes.Other.canonicalMimeType());
return;
}
- WebInspector.FileSystemUtils.requestFileContent(this._isolatedFileSystemModel, fileDescriptor.fileSystemPath, fileDescriptor.filePath, innerCallback.bind(this));
+ WebInspector.FileSystemUtils.requestFileContent(this._isolatedFileSystemModel, this._fileSystemPath, filePath, innerCallback.bind(this));
function innerCallback(content)
{
- var contentType = this._contentTypeForPath(fileDescriptor.filePath);
+ var contentType = this._contentTypeForPath(filePath);
callback(content, false, contentType.canonicalMimeType());
}
},
@@ -75,13 +73,13 @@
*/
setFileContent: function(uri, newContent, callback)
{
- var fileDescriptor = this._isolatedFileSystemModel.mapping().fileForURI(uri);
- if (!fileDescriptor) {
+ var filePath = this._isolatedFileSystemModel.mapping().fileForURI(this._fileSystemPath, uri);
+ if (!filePath) {
console.error("No matching file for uri: " + uri);
callback("");
return;
}
- WebInspector.FileSystemUtils.setFileContent(this._isolatedFileSystemModel, fileDescriptor.fileSystemPath, fileDescriptor.filePath, newContent, callback.bind(this, ""));
+ WebInspector.FileSystemUtils.setFileContent(this._isolatedFileSystemModel, this._fileSystemPath, filePath, newContent, callback.bind(this, ""));
},
/**
@@ -131,81 +129,47 @@
return WebInspector.resourceTypes.Other;
},
- /**
- * @param {WebInspector.Event} event
- */
- _fileSystemAdded: function(event)
+ _populate: function()
{
- var fileSystemPath = /** @type {string} */ (event.data);
- this._addFileSystem(fileSystemPath);
- },
+ WebInspector.FileSystemUtils.requestFilesRecursive(this._isolatedFileSystemModel, this._fileSystemPath, "", filesLoaded.bind(this));
- /**
- * @param {WebInspector.Event} event
- */
- _fileSystemRemoved: function(event)
- {
- WebInspector.startBatchUpdate();
- var fileSystemPath = /** @type {string} */ (event.data);
- for (var uri in this._files[fileSystemPath])
- this._removeFile(fileSystemPath, uri);
- WebInspector.endBatchUpdate();
- },
-
- /**
- * @param {string} fileSystemPath
- */
- _addFileSystem: function(fileSystemPath)
- {
- WebInspector.FileSystemUtils.requestFilesRecursive(this._isolatedFileSystemModel, fileSystemPath, "", filesLoaded.bind(this));
-
function filesLoaded(files)
{
for (var i = 0; i < files.length; ++i) {
- var uri = this._isolatedFileSystemModel.mapping().uriForFile(new WebInspector.FileSystemMapping.FileDescriptor(fileSystemPath, files[i]));
+ var uri = this._isolatedFileSystemModel.mapping().uriForFile(this._fileSystemPath, files[i]);
var contentType = this._contentTypeForPath(files[i]);
var url = ""
- var fileDescriptor = new WebInspector.FileDescriptor(uri, "file://" + fileSystemPath + files[i], url, contentType, true);
- this._addFile(fileSystemPath, fileDescriptor);
+ var fileDescriptor = new WebInspector.FileDescriptor(uri, "file://" + this._fileSystemPath + files[i], url, contentType, true);
+ this._addFile(fileDescriptor);
}
}
},
/**
- * @param {string} fileSystemPath
* @param {WebInspector.FileDescriptor} fileDescriptor
*/
- _addFile: function(fileSystemPath, fileDescriptor)
+ _addFile: function(fileDescriptor)
{
- if (!this._files[fileSystemPath])
- this._files[fileSystemPath] = {};
- this._files[fileSystemPath][fileDescriptor.uri] = true;
+ if (!this._files[this._fileSystemPath])
+ this._files[this._fileSystemPath] = {};
+ this._files[this._fileSystemPath][fileDescriptor.uri] = true;
this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileAdded, fileDescriptor);
},
/**
- * @param {string} fileSystemPath
* @param {string} uri
*/
- _removeFile: function(fileSystemPath, uri)
+ _removeFile: function(uri)
{
- delete this._files[fileSystemPath][uri];
- if (Object.keys(this._files[fileSystemPath]).length === 0)
- delete this._files[fileSystemPath];
+ delete this._files[this._fileSystemPath][uri];
+ if (Object.keys(this._files[this._fileSystemPath]).length === 0)
+ delete this._files[this._fileSystemPath];
this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileRemoved, uri);
},
- _populate: function()
- {
- var fileSystemPaths = this._isolatedFileSystemModel.mapping().fileSystemPaths();
- for (var i = 0; i < fileSystemPaths.length; ++i)
- this._addFileSystem(fileSystemPaths[i]);
- },
-
reset: function()
{
this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.Reset, null);
- this._populate();
},
__proto__: WebInspector.Object.prototype
Modified: trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js (141887 => 141888)
--- trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js 2013-02-05 13:52:22 UTC (rev 141888)
@@ -34,6 +34,7 @@
*/
WebInspector.IsolatedFileSystemModel = function(workspace)
{
+ this._workspace = workspace;
/** @type {!Object.<string, WebInspector.IsolatedFileSystemModel.FileSystem>} */
this._fileSystems = {};
/** @type {Object.<string, Array.<function(DOMFileSystem)>>} */
@@ -42,9 +43,6 @@
if (this.supportsFileSystems())
this._requestFileSystems();
-
- this._fileSystemWorkspaceProvider = new WebInspector.FileSystemWorkspaceProvider(this);
- workspace.addProject(WebInspector.projectNames.FileSystem, this._fileSystemWorkspaceProvider);
}
/** @typedef {{fileSystemName: string, rootURL: string, fileSystemPath: string}} */
@@ -107,8 +105,11 @@
*/
_innerAddFileSystem: function(fileSystem)
{
- this._fileSystems[fileSystem.fileSystemPath] = fileSystem;
- this._fileSystemMapping.addFileSystemMapping(fileSystem.fileSystemPath);
+ var fileSystemPath = fileSystem.fileSystemPath;
+ this._fileSystems[fileSystemPath] = fileSystem;
+ var fileSystemId = this._fileSystemMapping.addFileSystemMapping(fileSystemPath);
+ console.assert(!this._workspace.project(fileSystemId));
+ this._workspace.addProject(fileSystemId, new WebInspector.FileSystemWorkspaceProvider(this, fileSystemPath));
},
/**
@@ -154,9 +155,10 @@
*/
_fileSystemRemoved: function(fileSystemPath)
{
+ var fileSystemId = this._fileSystemMapping.fileSystemId(fileSystemPath);
+ this._workspace.removeProject(fileSystemId);
+ this._fileSystemMapping.removeFileSystemMapping(fileSystemPath);
delete this._fileSystems[fileSystemPath];
- this._fileSystemMapping.removeFileSystemMapping(fileSystemPath);
-
if (this._removeFileSystemCallback) {
this._removeFileSystemCallback(fileSystemPath);
delete this._removeFileSystemCallback;
Modified: trunk/Source/WebCore/inspector/front-end/Workspace.js (141887 => 141888)
--- trunk/Source/WebCore/inspector/front-end/Workspace.js 2013-02-05 13:03:38 UTC (rev 141887)
+++ trunk/Source/WebCore/inspector/front-end/Workspace.js 2013-02-05 13:52:22 UTC (rev 141888)
@@ -248,6 +248,11 @@
searchInFileContent: function(uri, query, caseSensitive, isRegex, callback)
{
this._workspaceProvider.searchInFileContent(uri, query, caseSensitive, isRegex, callback);
+ },
+
+ dispose: function()
+ {
+ this._workspaceProvider.reset();
}
}
@@ -256,8 +261,7 @@
LiveEdit: "liveedit",
Compiler: "compiler",
Network: "network",
- Snippets: "snippets",
- FileSystem: "filesystem"
+ Snippets: "snippets"
}
/**
@@ -314,6 +318,18 @@
/**
* @param {string} projectName
+ */
+ removeProject: function(projectName)
+ {
+ var project = this._projects[projectName];
+ if (!project)
+ return;
+ project.dispose();
+ delete this._projects[projectName];
+ },
+
+ /**
+ * @param {string} projectName
* @return {WebInspector.Project}
*/
project: function(projectName)