Title: [139978] trunk
Revision
139978
Author
vse...@chromium.org
Date
2013-01-17 04:39:55 -0800 (Thu, 17 Jan 2013)

Log Message

Web Inspector: Introduce FileSystemWorkspaceProvider to allow showing files from file system in workspace.
https://bugs.webkit.org/show_bug.cgi?id=107021

Reviewed by Pavel Feldman.

Source/WebCore:

Added FileSystemWorkspaceProvider that populates workspace with files
loaded from file systems registered in FileSystemMapping and listens
for FileSystemAdded / FileSystemRemoved events to update workspace.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/FileMapping.js:
(WebInspector.FileMapping.prototype.urlForURI):
(WebInspector.FileMapping.MappingEntry.prototype.urlForURI):
* inspector/front-end/FileSystemMapping.js:
(WebInspector.FileSystemMapping.prototype.uriForPath):
(WebInspector.FileSystemMapping.prototype.addEventListener):
(WebInspector.FileSystemMapping.prototype.removeEventListener):
(WebInspector.FileSystemMappingImpl):
(get WebInspector.FileSystemMappingImpl.prototype.uriForPath):
* inspector/front-end/FileSystemWorkspaceProvider.js: Added.
* inspector/front-end/IsolatedFileSystemModel.js:
(WebInspector.IsolatedFileSystemModel):
(WebInspector.IsolatedFileSystemModel.prototype._innerAddFileSystem):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/Workspace.js:
* inspector/front-end/externs.js:
* inspector/front-end/inspector.html:
* inspector/front-end/inspector.js:
* inspector/front-end/navigatorView.css:
(.navigator-other-tree-item .icon):

LayoutTests:

* inspector/file-mapping-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139977 => 139978)


--- trunk/LayoutTests/ChangeLog	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/LayoutTests/ChangeLog	2013-01-17 12:39:55 UTC (rev 139978)
@@ -1,3 +1,12 @@
+2013-01-16  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Introduce FileSystemWorkspaceProvider to allow showing files from file system in workspace.
+        https://bugs.webkit.org/show_bug.cgi?id=107021
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/file-mapping-expected.txt:
+
 2013-01-17  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed GTK gardening.

Modified: trunk/LayoutTests/inspector/file-mapping-expected.txt (139977 => 139978)


--- trunk/LayoutTests/inspector/file-mapping-expected.txt	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/LayoutTests/inspector/file-mapping-expected.txt	2013-01-17 12:39:55 UTC (rev 139978)
@@ -10,7 +10,7 @@
 http://www.example.com/
 http://localhost/index.html
 http://localhost/foo/index.html
-null
-null
+
+
 All mappings were correct.
 

Modified: trunk/Source/WebCore/ChangeLog (139977 => 139978)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 12:39:55 UTC (rev 139978)
@@ -1,3 +1,38 @@
+2013-01-16  Vsevolod Vlasov  <vse...@chromium.org>
+
+        Web Inspector: Introduce FileSystemWorkspaceProvider to allow showing files from file system in workspace.
+        https://bugs.webkit.org/show_bug.cgi?id=107021
+
+        Reviewed by Pavel Feldman.
+
+        Added FileSystemWorkspaceProvider that populates workspace with files
+        loaded from file systems registered in FileSystemMapping and listens
+        for FileSystemAdded / FileSystemRemoved events to update workspace.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/compile-front-end.py:
+        * inspector/front-end/FileMapping.js:
+        (WebInspector.FileMapping.prototype.urlForURI):
+        (WebInspector.FileMapping.MappingEntry.prototype.urlForURI):
+        * inspector/front-end/FileSystemMapping.js:
+        (WebInspector.FileSystemMapping.prototype.uriForPath):
+        (WebInspector.FileSystemMapping.prototype.addEventListener):
+        (WebInspector.FileSystemMapping.prototype.removeEventListener):
+        (WebInspector.FileSystemMappingImpl):
+        (get WebInspector.FileSystemMappingImpl.prototype.uriForPath):
+        * inspector/front-end/FileSystemWorkspaceProvider.js: Added.
+        * inspector/front-end/IsolatedFileSystemModel.js:
+        (WebInspector.IsolatedFileSystemModel):
+        (WebInspector.IsolatedFileSystemModel.prototype._innerAddFileSystem):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/Workspace.js:
+        * inspector/front-end/externs.js:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        * inspector/front-end/navigatorView.css:
+        (.navigator-other-tree-item .icon):
+
 2013-01-17  Andrey Adaikin  <aand...@chromium.org>
 
         Web Inspector: add createOption method to WebInspector.StatusBarComboBox

Modified: trunk/Source/WebCore/WebCore.gypi (139977 => 139978)


--- trunk/Source/WebCore/WebCore.gypi	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/WebCore.gypi	2013-01-17 12:39:55 UTC (rev 139978)
@@ -5159,6 +5159,7 @@
             'inspector/front-end/FileMapping.js',
             'inspector/front-end/FileSystemMapping.js',
             'inspector/front-end/FileSystemModel.js',
+            'inspector/front-end/FileSystemWorkspaceProvider.js',
             'inspector/front-end/FileUtils.js',
             'inspector/front-end/FontView.js',
             'inspector/front-end/GoToLineDialog.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (139977 => 139978)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2013-01-17 12:39:55 UTC (rev 139978)
@@ -76917,6 +76917,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\FileSystemWorkspaceProvider.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\FileUtils.js"
 					>
 				</File>

Modified: trunk/Source/WebCore/inspector/compile-front-end.py (139977 => 139978)


--- trunk/Source/WebCore/inspector/compile-front-end.py	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/compile-front-end.py	2013-01-17 12:39:55 UTC (rev 139978)
@@ -79,6 +79,7 @@
             "FileMapping.js",
             "FileSystemMapping.js",
             "FileSystemModel.js",
+            "FileSystemWorkspaceProvider.js",
             "FileUtils.js",
             "HAREntry.js",
             "IndexedDBModel.js",

Modified: trunk/Source/WebCore/inspector/front-end/FileMapping.js (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/FileMapping.js	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/FileMapping.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -75,7 +75,7 @@
     
     /**
      * @param {string} uri
-     * @return {?string}
+     * @return {string}
      */
     urlForURI: function(uri)
     {
@@ -83,7 +83,7 @@
             if (this._mappingEntries[i].matchesURI(uri))
                 return this._mappingEntries[i].urlForURI(uri);
         }
-        return null;
+        return "";
     },
 
     /**
@@ -181,13 +181,13 @@
     
     /**
      * @param {string} uri
-     * @return {?string}
+     * @return {string}
      */
     urlForURI: function(uri)
     {
         if (this.matchesURI(uri))
             return this._urlPrefix + uri.substring(this._uriPrefix.length);
-        return null;
+        return "";
     },
     
     /**

Modified: trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemMapping.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -42,6 +42,11 @@
     this.filePath = filePath;
 }
 
+WebInspector.FileSystemMapping.Events = {
+    FileSystemAdded: "FileSystemAdded",
+    FileSystemRemoved: "FileSystemRemoved"
+}
+
 WebInspector.FileSystemMapping.prototype = {
     /**
      * @return {Array.<string>}
@@ -64,7 +69,21 @@
      * @param {string} path
      * @return {?string}
      */
-    uriForPath: function(path) { }
+    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) { }
 }
 
 /**
@@ -74,6 +93,7 @@
  */
 WebInspector.FileSystemMappingImpl = function()
 {
+    WebInspector.Object.call(this);
     this._fileSystemMappingSetting = WebInspector.settings.createSetting("fileSystemMapping", {});
     /** @type {!Object.<string, string>} */
     this._mappedNames = this._fileSystemMappingSetting.get();
@@ -92,6 +112,7 @@
         var uniqueMappedName = this._uniqueMappedName(mappedName);
         this._mappedNames[fileSystemPath] = mappedName;
         this._fileSystemMappingSetting.set(this._mappedNames);
+        this.dispatchEventToListeners(WebInspector.FileSystemMapping.Events.FileSystemAdded, fileSystemPath);
     },
 
     /**
@@ -113,8 +134,10 @@
      */
     removeFileSystemMapping: 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);
     },
 
     /**
@@ -174,5 +197,7 @@
             }
         }
         return null;
-    }
+    },
+
+    __proto__: WebInspector.Object.prototype
 }

Added: trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js (0 => 139978)


--- trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -0,0 +1,452 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @implements {WebInspector.WorkspaceProvider}
+ * @extends {WebInspector.Object}
+ * @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
+ */
+WebInspector.FileSystemWorkspaceProvider = function(isolatedFileSystemModel)
+{
+    this._isolatedFileSystemModel = isolatedFileSystemModel;
+    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.prototype = {
+    /**
+     * @param {string} uri
+     * @param {function(?string,boolean,string)} callback
+     */
+    requestFileContent: function(uri, callback)
+    {
+        var fileDescriptor = this._isolatedFileSystemModel.mapping().fileForURI(uri);
+        if (!fileDescriptor) {
+            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));
+        
+        function innerCallback(content)
+        {
+            var contentType = this._contentTypeForPath(fileDescriptor.filePath);
+            callback(content, false, contentType.canonicalMimeType());
+        }
+    },
+
+    /**
+     * @param {string} uri
+     * @param {string} newContent
+     * @param {function(?string)} callback
+     */
+    setFileContent: function(uri, newContent, callback)
+    {
+        var fileDescriptor = this._isolatedFileSystemModel.mapping().fileForURI(uri);
+        if (!fileDescriptor) {
+            console.error("No matching file for uri: " + uri);
+            callback("");
+            return;
+        }
+        WebInspector.FileSystemUtils.setFileContent(this._isolatedFileSystemModel, fileDescriptor.fileSystemPath, fileDescriptor.filePath, newContent, callback.bind(this, ""));
+    },
+
+    /**
+     * @param {string} uri
+     * @param {string} query
+     * @param {boolean} caseSensitive
+     * @param {boolean} isRegex
+     * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
+     */
+    searchInFileContent: function(uri, query, caseSensitive, isRegex, callback)
+    {
+        callback([]);
+    },
+
+    /**
+     * @param {string} path
+     * @return {WebInspector.ResourceType}
+     */
+    _contentTypeForPath: function(path)
+    {
+        var splittedPath = path.split("/");
+        var fileName = splittedPath[splittedPath.length - 1];
+        var extensionIndex = fileName.lastIndexOf(".");
+        var extension = "";
+        if (extensionIndex !== -1)
+            extension = fileName.substring(extensionIndex + 1);
+        var contentType = WebInspector.resourceTypes.Other;
+        if (extension === "js")
+            return WebInspector.resourceTypes.Script;
+        if (extension === "css")
+            return WebInspector.resourceTypes.Stylesheet;
+        if (extension === "html")
+            return WebInspector.resourceTypes.Document;
+        return WebInspector.resourceTypes.Other;
+    },
+
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _fileSystemAdded: function(event)
+    {
+        var fileSystemPath = /** @type {string} */ (event.data);
+        this._addFileSystem(fileSystemPath);
+    },
+
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _fileSystemRemoved: function(event)
+    {
+        var fileSystemPath = /** @type {string} */ (event.data);
+        for (var uri in this._files[fileSystemPath])
+            this._removeFile(fileSystemPath, uri);
+    },
+
+    /**
+     * @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 contentType = this._contentTypeForPath(files[i]);
+                var url = ""
+                var fileDescriptor = new WebInspector.FileDescriptor(uri, "file://" + fileSystemPath + files[i], url, contentType, true);
+                this._addFile(fileSystemPath, fileDescriptor);
+            } 
+        }
+    },
+
+    /**
+     * @param {string} fileSystemPath
+     * @param {WebInspector.FileDescriptor} fileDescriptor
+     */
+    _addFile: function(fileSystemPath, fileDescriptor)
+    {
+        if (!this._files[fileSystemPath])
+            this._files[fileSystemPath] = {};
+        this._files[fileSystemPath][fileDescriptor.uri] = true;
+        this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileAdded, fileDescriptor);
+    },
+
+    /**
+     * @param {string} fileSystemPath
+     * @param {string} uri
+     */
+    _removeFile: function(fileSystemPath, uri)
+    {
+        delete this._files[fileSystemPath][uri];
+        if (Object.keys(this._files[fileSystemPath]).length === 0)
+            delete this._files[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
+}
+
+/**
+ * @type {?WebInspector.FileSystemWorkspaceProvider}
+ */
+WebInspector.fileSystemWorkspaceProvider = null;
+
+/**
+ * @constructor
+ */
+WebInspector.FileSystemUtils = function()
+{
+}
+
+WebInspector.FileSystemUtils.errorHandler = function(error)
+{
+    var msg;
+    switch (error.code) {
+    case FileError.QUOTA_EXCEEDED_ERR:
+        msg = "QUOTA_EXCEEDED_ERR";
+        break;
+    case FileError.NOT_FOUND_ERR:
+        msg = "NOT_FOUND_ERR";
+        break;
+    case FileError.SECURITY_ERR:
+        msg = "SECURITY_ERR";
+        break;
+    case FileError.INVALID_MODIFICATION_ERR:
+        msg = "INVALID_MODIFICATION_ERR";
+        break;
+    case FileError.INVALID_STATE_ERR:
+        msg = "INVALID_STATE_ERR";
+        break;
+    default:
+        msg = "Unknown Error";
+        break;
+    };
+
+    console.error("File system error: " + msg);
+}
+
+/**
+ * @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
+ * @param {string} fileSystemPath
+ * @param {function(DOMFileSystem)} callback
+ */
+WebInspector.FileSystemUtils.requestFileSystem = function(isolatedFileSystemModel, fileSystemPath, callback)
+{
+    isolatedFileSystemModel.requestDOMFileSystem(fileSystemPath, callback);
+}
+
+/**
+ * @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
+ * @param {string} fileSystemPath
+ * @param {string} path
+ * @param {function(Array.<string>)} callback
+ */
+WebInspector.FileSystemUtils.requestFilesRecursive = function(isolatedFileSystemModel, fileSystemPath, path, callback)
+{
+    WebInspector.FileSystemUtils.requestFileSystem(isolatedFileSystemModel, fileSystemPath, fileSystemLoaded);
+
+    var fileSystem;
+    /**
+     * @param {DOMFileSystem} fs
+     */
+    function fileSystemLoaded(fs)
+    {
+        fileSystem = fs;
+        WebInspector.FileSystemUtils._requestEntries(fileSystem, path, innerCallback);
+    }
+
+    var result = [];
+    var callbacksLeft = 1;
+    /**
+     * @param {Array.<FileEntry>} entries
+     */
+    function innerCallback(entries)
+    {
+        for (var i = 0; i < entries.length; ++i) {
+            var entry = entries[i];
+            if (!entry.isDirectory)
+                result.push(entry.fullPath);
+            else {
+                callbacksLeft++;
+                WebInspector.FileSystemUtils._requestEntries(fileSystem, entry.fullPath, innerCallback);
+            }
+        }
+        if (!--callbacksLeft)
+            callback(result);
+    }
+}
+
+/**
+ * @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
+ * @param {string} fileSystemPath
+ * @param {string} path
+ * @param {function(string)} callback
+ */
+WebInspector.FileSystemUtils.requestFileContent = function(isolatedFileSystemModel, fileSystemPath, path, callback)
+{
+    WebInspector.FileSystemUtils.requestFileSystem(isolatedFileSystemModel, fileSystemPath, fileSystemLoaded);
+
+    var fileSystem;
+    /**
+     * @param {DOMFileSystem} fs
+     */
+    function fileSystemLoaded(fs)
+    {
+        fs.root.getFile(path, null, fileEntryLoaded, WebInspector.FileSystemUtils.errorHandler);
+    }
+
+    /**
+     * @param {FileEntry} entry
+     */
+    function fileEntryLoaded(entry)
+    {
+        entry.file(fileLoaded, WebInspector.FileSystemUtils.errorHandler);
+    }
+
+    /**
+     * @param {!Blob} file
+     */
+    function fileLoaded(file)
+    {
+        var reader = new FileReader();
+        reader._onloadend_ = readerLoadEnd;
+        reader.readAsText(file);
+    }
+
+    /**
+     * @this {FileReader}
+     */
+    function readerLoadEnd()
+    {
+        callback(/** @type {string} */ (this.result));
+    }
+}
+
+/**
+ * @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
+ * @param {string} fileSystemPath
+ * @param {string} path
+ * @param {string} content
+ * @param {function()} callback
+ */
+WebInspector.FileSystemUtils.setFileContent = function(isolatedFileSystemModel, fileSystemPath, path, content, callback)
+{
+    WebInspector.FileSystemUtils.requestFileSystem(isolatedFileSystemModel, fileSystemPath, fileSystemLoaded);
+
+    var fileSystem;
+    /**
+     * @param {DOMFileSystem} fs
+     */
+    function fileSystemLoaded(fs)
+    {
+        fs.root.getFile(path, null, fileEntryLoaded, WebInspector.FileSystemUtils.errorHandler);
+    }
+
+    /**
+     * @param {FileEntry} entry
+     */
+    function fileEntryLoaded(entry)
+    {
+        entry.createWriter(fileWriterCreated, WebInspector.FileSystemUtils.errorHandler);
+    }
+
+    /**
+     * @param {FileWriter} fileWriter
+     */
+    function fileWriterCreated(fileWriter)
+    {
+        fileWriter._onerror_ = WebInspector.FileSystemUtils.errorHandler;
+        fileWriter._onwriteend_ = fileTruncated;
+        fileWriter.truncate(0);
+
+        function fileTruncated()
+        {
+            fileWriter._onwriteend_ = writerEnd;
+            var blob = new Blob([content], { type: "text/plain" });
+            fileWriter.write(blob);
+        }
+    }
+
+    function writerEnd()
+    {
+        callback();
+    }
+}
+
+/**
+ * @param {DirectoryEntry} root
+ * @param {Array.<string>} folders
+ * @param {Object} flags
+ * @param {function(DirectoryEntry)} callback
+ */
+WebInspector.FileSystemUtils._getDirectory = function(root, folders, flags, callback)
+{
+    while (folders[0] == "." || folders[0] == "")
+        folders = folders.slice(1);
+    if (!folders.length)
+        callback(root);
+    else
+        root.getDirectory(folders[0], flags, innerCallback, WebInspector.FileSystemUtils.errorHandler);
+
+    /**
+     * @param {DirectoryEntry} dirEntry
+     */
+    function innerCallback(dirEntry)
+    {
+        WebInspector.FileSystemUtils._getDirectory(dirEntry, folders.slice(1), flags, callback);
+    }
+}
+
+/**
+ * @param {DirectoryEntry} dirEntry
+ * @param {function(Array.<FileEntry>)} callback
+ */
+WebInspector.FileSystemUtils._readDirectory = function(dirEntry, callback)
+{
+    var dirReader = dirEntry.createReader();
+    var entries = [];
+
+    function innerCallback(results)
+    {
+        if (!results.length)
+            callback(entries.sort());
+        else {
+            entries = entries.concat(toArray(results));
+            dirReader.readEntries(innerCallback, WebInspector.FileSystemUtils.errorHandler);
+        }
+    }
+
+    function toArray(list)
+    {
+        return Array.prototype.slice.call(list || [], 0);
+    }    
+
+    dirReader.readEntries(innerCallback, WebInspector.FileSystemUtils.errorHandler);
+}
+
+/**
+ * @param {DOMFileSystem} fileSystem
+ * @param {string} path
+ * @param {function(Array.<FileEntry>)} callback
+ */
+WebInspector.FileSystemUtils._requestEntries = function(fileSystem, path, callback)
+{
+    var folders = path.split("/");
+    WebInspector.FileSystemUtils._getDirectory(fileSystem.root, folders, null, innerCallback);
+
+    function innerCallback(dirEntry)
+    {
+        WebInspector.FileSystemUtils._readDirectory(dirEntry, callback)
+    }
+}
+
+WebInspector.FileSystemUtils.prototype = {
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -30,8 +30,9 @@
 
 /**
  * @constructor
+ * @param {WebInspector.Workspace} workspace
  */
-WebInspector.IsolatedFileSystemModel = function()
+WebInspector.IsolatedFileSystemModel = function(workspace)
 {
     /** @type {!Object.<string, WebInspector.IsolatedFileSystemModel.FileSystem>} */
     this._fileSystems = {};
@@ -41,6 +42,9 @@
 
     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}} */
@@ -103,8 +107,8 @@
      */
     _innerAddFileSystem: function(fileSystem)
     {
+        this._fileSystems[fileSystem.fileSystemPath] = fileSystem;
         this._fileSystemMapping.addFileSystemMapping(fileSystem.fileSystemPath);
-        this._fileSystems[fileSystem.fileSystemPath] = fileSystem;
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2013-01-17 12:39:55 UTC (rev 139978)
@@ -78,6 +78,7 @@
     <file>FileSystemMapping.js</file>
     <file>FileSystemModel.js</file>
     <file>FileSystemView.js</file>
+    <file>FileSystemWorkspaceProvider.js</file>
     <file>FileUtils.js</file>
     <file>FilteredItemSelectionDialog.js</file>
     <file>FontView.js</file>

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


--- trunk/Source/WebCore/inspector/front-end/Workspace.js	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/Workspace.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -257,6 +257,7 @@
     Compiler: "compiler",
     Network: "network",
     Snippets: "snippets",
+    FileSystem: "filesystem"
 }
 
 /**

Modified: trunk/Source/WebCore/inspector/front-end/externs.js (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/externs.js	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/externs.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -144,6 +144,11 @@
  */
 function DOMFileSystem() {}
 
+/**
+ * @type {DirectoryEntry}
+ */
+DOMFileSystem.prototype.root = null;
+
 /** @type {Node} */
 Range.prototype.startContainer;
 

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2013-01-17 12:39:55 UTC (rev 139978)
@@ -137,8 +137,9 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
-    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""

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


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2013-01-17 12:39:55 UTC (rev 139978)
@@ -430,21 +430,24 @@
     this.openAnchorLocationRegistry = new WebInspector.HandlerRegistry(openAnchorLocationSetting);
     this.openAnchorLocationRegistry.registerHandler(autoselectPanel, function() { return false; });
 
-    this.isolatedFileSystemModel = new WebInspector.IsolatedFileSystemModel();
+    this.workspace = new WebInspector.Workspace();
+    this.workspaceController = new WebInspector.WorkspaceController(this.workspace);
+
+    this.isolatedFileSystemModel = new WebInspector.IsolatedFileSystemModel(this.workspace);
     this.isolatedFileSystemDispatcher = new WebInspector.IsolatedFileSystemDispatcher(this.isolatedFileSystemModel);
     this.fileMapping = new WebInspector.FileMapping(this.isolatedFileSystemModel.mapping());
-    this.workspace = new WebInspector.Workspace();
+
     this.networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(this.workspace);
     this.workspace.addProject(WebInspector.projectNames.Network, this.networkWorkspaceProvider);
-    this.workspaceController = new WebInspector.WorkspaceController(this.workspace);
+    new WebInspector.NetworkUISourceCodeProvider(this.workspace, this.networkWorkspaceProvider);
 
     this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel, this.workspace);
 
     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);
-    new WebInspector.NetworkUISourceCodeProvider(this.workspace, this.networkWorkspaceProvider);
     new WebInspector.StylesSourceMapping(this.workspace);
     if (WebInspector.experimentsSettings.sass.isEnabled())
         new WebInspector.SASSSourceMapping(this.workspace, this.networkWorkspaceProvider);

Modified: trunk/Source/WebCore/inspector/front-end/navigatorView.css (139977 => 139978)


--- trunk/Source/WebCore/inspector/front-end/navigatorView.css	2013-01-17 12:25:21 UTC (rev 139977)
+++ trunk/Source/WebCore/inspector/front-end/navigatorView.css	2013-01-17 12:39:55 UTC (rev 139978)
@@ -48,6 +48,10 @@
     content: url(Images/resourceDocumentIcon.png);
 }
 
+.navigator-other-tree-item .icon {
+    content: url(Images/resourcePlainIcon.png);
+}
+
 .navigator li {
     height: 17px;
     white-space: nowrap;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to