Changeset 142474 in webkit


Ignore:
Timestamp:
Feb 11, 2013 7:50:38 AM (11 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: WebInspector.Project refactorings.
https://bugs.webkit.org/show_bug.cgi?id=109433

Reviewed by Alexander Pavlov.

Source/WebCore:

This change prepares Workspace and Project to migration to project-per-domain mode for network based projects.
Renamed WebInspector.WorkspaceProvider to WebInspector.ProjectDelegate.
Renamed Project.name() to Project.id() and delegated it to project delegate.
Added Project.displayName() method that is delegated to project delegate.
SimpleWorkspaceProvider is now responsible for creation of SimpleWorkspaceDelegates and
isolates various mappings from Project/ProjectDelegate concept.
UISourceCode is now created based on path in the project.
UISourceCode uri is now calculated based on project and path (right now uri is equal to path).

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/compile-front-end.py:
  • inspector/front-end/FileSystemProjectDelegate.js: Renamed from Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js.

(WebInspector.FileSystemProjectDelegate):
(WebInspector.FileSystemProjectDelegate.prototype.id):
(WebInspector.FileSystemProjectDelegate.prototype.type):
(WebInspector.FileSystemProjectDelegate.prototype.displayName):
(WebInspector.FileSystemProjectDelegate.prototype.innerCallback):
(WebInspector.FileSystemProjectDelegate.prototype.requestFileContent):
(WebInspector.FileSystemProjectDelegate.prototype.setFileContent):
(WebInspector.FileSystemProjectDelegate.prototype.contentCallback):
(WebInspector.FileSystemProjectDelegate.prototype.searchInFileContent):
(WebInspector.FileSystemProjectDelegate.prototype._contentTypeForPath):
(WebInspector.FileSystemProjectDelegate.prototype._populate.filesLoaded):
(WebInspector.FileSystemProjectDelegate.prototype._populate):
(WebInspector.FileSystemProjectDelegate.prototype._addFile):
(WebInspector.FileSystemProjectDelegate.prototype._removeFile):
(WebInspector.FileSystemProjectDelegate.prototype.reset):
(WebInspector.FileSystemUtils):
(WebInspector.FileSystemUtils.errorHandler):
(WebInspector.FileSystemUtils.requestFileSystem):
(.fileSystemLoaded):
(.innerCallback):
(WebInspector.FileSystemUtils.requestFilesRecursive):
(.fileEntryLoaded):
(.fileLoaded):
(.readerLoadEnd):
(WebInspector.FileSystemUtils.requestFileContent):
(.fileWriterCreated.fileTruncated):
(.fileWriterCreated):
(.writerEnd):
(WebInspector.FileSystemUtils.setFileContent):
(WebInspector.FileSystemUtils._getDirectory):
(.toArray):
(WebInspector.FileSystemUtils._readDirectory):
(WebInspector.FileSystemUtils._requestEntries):

  • inspector/front-end/IsolatedFileSystemModel.js:

(WebInspector.IsolatedFileSystemModel.prototype._innerAddFileSystem):

  • inspector/front-end/SimpleWorkspaceProvider.js:

(WebInspector.SimpleProjectDelegate):
(WebInspector.SimpleProjectDelegate.prototype.id):
(WebInspector.SimpleProjectDelegate.prototype.displayName):
(WebInspector.SimpleProjectDelegate.prototype.requestFileContent):
(WebInspector.SimpleProjectDelegate.prototype.setFileContent):
(WebInspector.SimpleProjectDelegate.prototype.searchInFileContent):
(WebInspector.SimpleProjectDelegate.prototype.addFile):
(WebInspector.SimpleProjectDelegate.prototype._uniquePath):
(WebInspector.SimpleProjectDelegate.prototype.removeFile):
(WebInspector.SimpleProjectDelegate.prototype.reset):
(WebInspector.SimpleWorkspaceProvider):
(WebInspector.SimpleWorkspaceProvider.uriForURL):
(WebInspector.SimpleWorkspaceProvider.prototype.addFileForURL):
(WebInspector.SimpleWorkspaceProvider.prototype.addUniqueFileForURL):
(WebInspector.SimpleWorkspaceProvider.prototype._innerAddFileForURL):
(WebInspector.SimpleWorkspaceProvider.prototype.removeFile):
(WebInspector.SimpleWorkspaceProvider.prototype.reset):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.path):
(WebInspector.UISourceCode.prototype.uri):

  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/Workspace.js:

(WebInspector.FileDescriptor):
(WebInspector.ProjectDelegate):
(WebInspector.ProjectDelegate.prototype.id):
(WebInspector.ProjectDelegate.prototype.displayName):
(WebInspector.ProjectDelegate.prototype.requestFileContent):
(WebInspector.ProjectDelegate.prototype.setFileContent):
(WebInspector.ProjectDelegate.prototype.searchInFileContent):
(WebInspector.Project):
(WebInspector.Project.prototype.id):
(WebInspector.Project.prototype.type):
(WebInspector.Project.prototype.displayName):
(WebInspector.Project.prototype.isServiceProject):
(WebInspector.Project.prototype._fileAdded):
(WebInspector.Project.prototype._fileRemoved):
(WebInspector.Project.prototype._reset):
(WebInspector.Project.prototype.uiSourceCode):
(WebInspector.Project.prototype.uiSourceCodeForOriginURL):
(WebInspector.Project.prototype.uiSourceCodeForURI):
(WebInspector.Project.prototype.uiSourceCodes):
(WebInspector.Project.prototype.requestFileContent):
(WebInspector.Project.prototype.setFileContent):
(WebInspector.Project.prototype.searchInFileContent):
(WebInspector.Project.prototype.dispose):
(WebInspector.Workspace.prototype.uiSourceCode):
(WebInspector.Workspace.prototype.uiSourceCodeForURI):
(WebInspector.Workspace.prototype.addProject):
(WebInspector.Workspace.prototype.removeProject):
(WebInspector.Workspace.prototype.project):
(WebInspector.Workspace.prototype.uiSourceCodes):
(WebInspector.Workspace.prototype.projectForUISourceCode):

  • inspector/front-end/inspector.html:

LayoutTests:

  • inspector/debugger/live-edit-breakpoints.html:
  • inspector/uisourcecode-revisions.html:
Location:
trunk
Files:
13 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142470 r142474  
     12013-02-11  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: WebInspector.Project refactorings.
     4        https://bugs.webkit.org/show_bug.cgi?id=109433
     5
     6        Reviewed by Alexander Pavlov.
     7
     8        * inspector/debugger/live-edit-breakpoints.html:
     9        * inspector/uisourcecode-revisions.html:
     10
    1112013-02-11  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    212
  • trunk/LayoutTests/inspector/debugger/live-edit-breakpoints.html

    r139859 r142474  
    4141            var uiSourceCode = uiLocation.uiSourceCode;
    4242            var project = WebInspector.workspace.projectForUISourceCode(uiSourceCode);
    43             InspectorTest.addResult("        url: " + pathToFileName(uiSourceCode.originURL()) + ", lineNumber: " + uiLocation.lineNumber + ", project name: " + project.name());
     43            InspectorTest.addResult("        url: " + pathToFileName(uiSourceCode.originURL()) + ", lineNumber: " + uiLocation.lineNumber + ", project name: " + project.id());
    4444        }
    4545    }
  • trunk/LayoutTests/inspector/uisourcecode-revisions.html

    r142269 r142474  
    1010    {
    1111        var workspace = new WebInspector.Workspace();
    12         var workspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace, WebInspector.projectTypes.Network);
    13         var project = workspace.addProject(WebInspector.projectTypes.Network, workspaceProvider);
     12        var projectDelegate = new WebInspector.SimpleProjectDelegate(WebInspector.projectTypes.Network);
     13        var project = workspace.addProject(projectDelegate);
    1414        project.requestFileContent = function(uri, callback)
    1515        {
  • trunk/Source/WebCore/ChangeLog

    r142473 r142474  
     12013-02-11  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: WebInspector.Project refactorings.
     4        https://bugs.webkit.org/show_bug.cgi?id=109433
     5
     6        Reviewed by Alexander Pavlov.
     7
     8        This change prepares Workspace and Project to migration to project-per-domain mode for network based projects.
     9        Renamed WebInspector.WorkspaceProvider to WebInspector.ProjectDelegate.
     10        Renamed Project.name() to Project.id() and delegated it to project delegate.
     11        Added Project.displayName() method that is delegated to project delegate.
     12        SimpleWorkspaceProvider is now responsible for creation of SimpleWorkspaceDelegates and
     13        isolates various mappings from Project/ProjectDelegate concept.
     14        UISourceCode is now created based on path in the project.
     15        UISourceCode uri is now calculated based on project and path (right now uri is equal to path).
     16
     17        * WebCore.gypi:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * inspector/compile-front-end.py:
     20        * inspector/front-end/FileSystemProjectDelegate.js: Renamed from Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js.
     21        (WebInspector.FileSystemProjectDelegate):
     22        (WebInspector.FileSystemProjectDelegate.prototype.id):
     23        (WebInspector.FileSystemProjectDelegate.prototype.type):
     24        (WebInspector.FileSystemProjectDelegate.prototype.displayName):
     25        (WebInspector.FileSystemProjectDelegate.prototype.innerCallback):
     26        (WebInspector.FileSystemProjectDelegate.prototype.requestFileContent):
     27        (WebInspector.FileSystemProjectDelegate.prototype.setFileContent):
     28        (WebInspector.FileSystemProjectDelegate.prototype.contentCallback):
     29        (WebInspector.FileSystemProjectDelegate.prototype.searchInFileContent):
     30        (WebInspector.FileSystemProjectDelegate.prototype._contentTypeForPath):
     31        (WebInspector.FileSystemProjectDelegate.prototype._populate.filesLoaded):
     32        (WebInspector.FileSystemProjectDelegate.prototype._populate):
     33        (WebInspector.FileSystemProjectDelegate.prototype._addFile):
     34        (WebInspector.FileSystemProjectDelegate.prototype._removeFile):
     35        (WebInspector.FileSystemProjectDelegate.prototype.reset):
     36        (WebInspector.FileSystemUtils):
     37        (WebInspector.FileSystemUtils.errorHandler):
     38        (WebInspector.FileSystemUtils.requestFileSystem):
     39        (.fileSystemLoaded):
     40        (.innerCallback):
     41        (WebInspector.FileSystemUtils.requestFilesRecursive):
     42        (.fileEntryLoaded):
     43        (.fileLoaded):
     44        (.readerLoadEnd):
     45        (WebInspector.FileSystemUtils.requestFileContent):
     46        (.fileWriterCreated.fileTruncated):
     47        (.fileWriterCreated):
     48        (.writerEnd):
     49        (WebInspector.FileSystemUtils.setFileContent):
     50        (WebInspector.FileSystemUtils._getDirectory):
     51        (.toArray):
     52        (WebInspector.FileSystemUtils._readDirectory):
     53        (WebInspector.FileSystemUtils._requestEntries):
     54        * inspector/front-end/IsolatedFileSystemModel.js:
     55        (WebInspector.IsolatedFileSystemModel.prototype._innerAddFileSystem):
     56        * inspector/front-end/SimpleWorkspaceProvider.js:
     57        (WebInspector.SimpleProjectDelegate):
     58        (WebInspector.SimpleProjectDelegate.prototype.id):
     59        (WebInspector.SimpleProjectDelegate.prototype.displayName):
     60        (WebInspector.SimpleProjectDelegate.prototype.requestFileContent):
     61        (WebInspector.SimpleProjectDelegate.prototype.setFileContent):
     62        (WebInspector.SimpleProjectDelegate.prototype.searchInFileContent):
     63        (WebInspector.SimpleProjectDelegate.prototype.addFile):
     64        (WebInspector.SimpleProjectDelegate.prototype._uniquePath):
     65        (WebInspector.SimpleProjectDelegate.prototype.removeFile):
     66        (WebInspector.SimpleProjectDelegate.prototype.reset):
     67        (WebInspector.SimpleWorkspaceProvider):
     68        (WebInspector.SimpleWorkspaceProvider.uriForURL):
     69        (WebInspector.SimpleWorkspaceProvider.prototype.addFileForURL):
     70        (WebInspector.SimpleWorkspaceProvider.prototype.addUniqueFileForURL):
     71        (WebInspector.SimpleWorkspaceProvider.prototype._innerAddFileForURL):
     72        (WebInspector.SimpleWorkspaceProvider.prototype.removeFile):
     73        (WebInspector.SimpleWorkspaceProvider.prototype.reset):
     74        * inspector/front-end/UISourceCode.js:
     75        (WebInspector.UISourceCode):
     76        (WebInspector.UISourceCode.prototype.path):
     77        (WebInspector.UISourceCode.prototype.uri):
     78        * inspector/front-end/WebKit.qrc:
     79        * inspector/front-end/Workspace.js:
     80        (WebInspector.FileDescriptor):
     81        (WebInspector.ProjectDelegate):
     82        (WebInspector.ProjectDelegate.prototype.id):
     83        (WebInspector.ProjectDelegate.prototype.displayName):
     84        (WebInspector.ProjectDelegate.prototype.requestFileContent):
     85        (WebInspector.ProjectDelegate.prototype.setFileContent):
     86        (WebInspector.ProjectDelegate.prototype.searchInFileContent):
     87        (WebInspector.Project):
     88        (WebInspector.Project.prototype.id):
     89        (WebInspector.Project.prototype.type):
     90        (WebInspector.Project.prototype.displayName):
     91        (WebInspector.Project.prototype.isServiceProject):
     92        (WebInspector.Project.prototype._fileAdded):
     93        (WebInspector.Project.prototype._fileRemoved):
     94        (WebInspector.Project.prototype._reset):
     95        (WebInspector.Project.prototype.uiSourceCode):
     96        (WebInspector.Project.prototype.uiSourceCodeForOriginURL):
     97        (WebInspector.Project.prototype.uiSourceCodeForURI):
     98        (WebInspector.Project.prototype.uiSourceCodes):
     99        (WebInspector.Project.prototype.requestFileContent):
     100        (WebInspector.Project.prototype.setFileContent):
     101        (WebInspector.Project.prototype.searchInFileContent):
     102        (WebInspector.Project.prototype.dispose):
     103        (WebInspector.Workspace.prototype.uiSourceCode):
     104        (WebInspector.Workspace.prototype.uiSourceCodeForURI):
     105        (WebInspector.Workspace.prototype.addProject):
     106        (WebInspector.Workspace.prototype.removeProject):
     107        (WebInspector.Workspace.prototype.project):
     108        (WebInspector.Workspace.prototype.uiSourceCodes):
     109        (WebInspector.Workspace.prototype.projectForUISourceCode):
     110        * inspector/front-end/inspector.html:
     111
    11122013-02-11  Yury Semikhatsky  <yurys@chromium.org>
    2113
  • trunk/Source/WebCore/WebCore.gypi

    r142471 r142474  
    52195219            'inspector/front-end/FileSystemMapping.js',
    52205220            'inspector/front-end/FileSystemModel.js',
    5221             'inspector/front-end/FileSystemWorkspaceProvider.js',
     5221            'inspector/front-end/FileSystemProjectDelegate.js',
    52225222            'inspector/front-end/FileUtils.js',
    52235223            'inspector/front-end/FontView.js',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r142471 r142474  
    7716377163                                </File>
    7716477164                                <File
    77165                                         RelativePath="..\inspector\front-end\FileSystemWorkspaceProvider.js"
     77165                                        RelativePath="..\inspector\front-end\FileSystemProjectDelegate.js"
    7716677166                                        >
    7716777167                                </File>
  • trunk/Source/WebCore/inspector/compile-front-end.py

    r142471 r142474  
    8080            "FileSystemMapping.js",
    8181            "FileSystemModel.js",
    82             "FileSystemWorkspaceProvider.js",
     82            "FileSystemProjectDelegate.js",
    8383            "FileUtils.js",
    8484            "HAREntry.js",
  • trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js

    r142473 r142474  
    3131/**
    3232 * @constructor
    33  * @implements {WebInspector.WorkspaceProvider}
     33 * @implements {WebInspector.ProjectDelegate}
    3434 * @extends {WebInspector.Object}
    3535 * @param {WebInspector.IsolatedFileSystemModel} isolatedFileSystemModel
     36 * @param {string} fileSystemId
    3637 * @param {string} fileSystemPath
    3738 */
    38 WebInspector.FileSystemWorkspaceProvider = function(isolatedFileSystemModel, fileSystemPath)
     39WebInspector.FileSystemProjectDelegate = function(isolatedFileSystemModel, fileSystemId, fileSystemPath)
    3940{
    4041    this._isolatedFileSystemModel = isolatedFileSystemModel;
     42    this._fileSystemId = fileSystemId;
    4143    this._fileSystemPath = fileSystemPath;
    4244    this._files = {};
     
    4446}
    4547
    46 WebInspector.FileSystemWorkspaceProvider._scriptExtensions = ["js", "java", "cc", "cpp", "h", "cs", "py", "php"].keySet();
    47 
    48 WebInspector.FileSystemWorkspaceProvider.prototype = {
     48WebInspector.FileSystemProjectDelegate._scriptExtensions = ["js", "java", "cc", "cpp", "h", "cs", "py", "php"].keySet();
     49
     50WebInspector.FileSystemProjectDelegate.prototype = {
    4951    /**
    5052     * @return {string}
    5153     */
     54    id: function()
     55    {
     56        return this._fileSystemId;
     57    },
     58
     59    /**
     60     * @return {string}
     61     */
    5262    type: function()
    5363    {
    5464        return WebInspector.projectTypes.FileSystem;
     65    },
     66
     67    /**
     68     * @return {string}
     69     */
     70    displayName: function()
     71    {
     72        return this._fileSystemPath.substr(this._fileSystemPath.lastIndexOf("/") + 1);
    5573    },
    5674
     
    130148            extension = fileName.substring(extensionIndex + 1);
    131149        var contentType = WebInspector.resourceTypes.Other;
    132         if (WebInspector.FileSystemWorkspaceProvider._scriptExtensions[extension])
     150        if (WebInspector.FileSystemProjectDelegate._scriptExtensions[extension])
    133151            return WebInspector.resourceTypes.Script;
    134152        if (extension === "css")
     
    162180        if (!this._files[this._fileSystemPath])
    163181            this._files[this._fileSystemPath] = {};
    164         this._files[this._fileSystemPath][fileDescriptor.uri] = true;
    165         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileAdded, fileDescriptor);
     182        this._files[this._fileSystemPath][fileDescriptor.path] = true;
     183        this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileAdded, fileDescriptor);
    166184    },
    167185
     
    174192        if (Object.keys(this._files[this._fileSystemPath]).length === 0)
    175193            delete this._files[this._fileSystemPath];
    176         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileRemoved, uri);
     194        this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRemoved, uri);
    177195    },
    178196
    179197    reset: function()
    180198    {
    181         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.Reset, null);
     199        this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.Reset, null);
    182200    },
    183201   
     
    186204
    187205/**
    188  * @type {?WebInspector.FileSystemWorkspaceProvider}
    189  */
    190 WebInspector.fileSystemWorkspaceProvider = null;
     206 * @type {?WebInspector.FileSystemProjectDelegate}
     207 */
     208WebInspector.fileSystemProjectDelegate = null;
    191209
    192210/**
  • trunk/Source/WebCore/inspector/front-end/IsolatedFileSystemModel.js

    r142107 r142474  
    110110        var fileSystemId = this._fileSystemMapping.addFileSystemMapping(fileSystemPath);
    111111        console.assert(!this._workspace.project(fileSystemId));
    112         this._workspace.addProject(fileSystemId, new WebInspector.FileSystemWorkspaceProvider(this, fileSystemPath));
     112        this._workspace.addProject(new WebInspector.FileSystemProjectDelegate(this, fileSystemId, fileSystemPath));
    113113    },
    114114
  • trunk/Source/WebCore/inspector/front-end/SimpleWorkspaceProvider.js

    r142269 r142474  
    3131/**
    3232 * @constructor
    33  * @implements {WebInspector.WorkspaceProvider}
     33 * @implements {WebInspector.ProjectDelegate}
     34 * @extends {WebInspector.Object}
     35 */
     36WebInspector.SimpleProjectDelegate = function(type)
     37{
     38    this._type = type;
     39    /** @type {Object.<string, WebInspector.ContentProvider>} */
     40    this._contentProviders = {};
     41    this._lastUniqueSuffix = 0;
     42}
     43
     44WebInspector.SimpleProjectDelegate.prototype = {
     45    /**
     46     * @return {string}
     47     */
     48    id: function()
     49    {
     50        return this._type;
     51    },
     52
     53    /**
     54     * @return {string}
     55     */
     56    type: function()
     57    {
     58        return this._type;
     59    },
     60
     61    /**
     62     * @return {string}
     63     */
     64    displayName: function()
     65    {
     66        return "";
     67    },
     68
     69    /**
     70     * @param {string} path
     71     * @param {function(?string,boolean,string)} callback
     72     */
     73    requestFileContent: function(path, callback)
     74    {
     75        var contentProvider = this._contentProviders[path];
     76        contentProvider.requestContent(callback);
     77    },
     78
     79    /**
     80     * @param {string} path
     81     * @param {string} newContent
     82     * @param {function(?string)} callback
     83     */
     84    setFileContent: function(path, newContent, callback)
     85    {
     86        callback(null);
     87    },
     88
     89    /**
     90     * @param {string} query
     91     * @param {boolean} caseSensitive
     92     * @param {boolean} isRegex
     93     * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
     94     */
     95    searchInFileContent: function(path, query, caseSensitive, isRegex, callback)
     96    {
     97        var contentProvider = this._contentProviders[path];
     98        contentProvider.searchInContent(query, caseSensitive, isRegex, callback);
     99    },
     100
     101    /**
     102     * @param {string} path
     103     * @param {string} url
     104     * @param {WebInspector.ContentProvider} contentProvider
     105     * @param {boolean} isEditable
     106     * @param {boolean=} isContentScript
     107     */
     108    addFile: function(path, forceUniquePath, url, contentProvider, isEditable, isContentScript)
     109    {
     110        if (forceUniquePath)
     111            path = this._uniquePath(path);
     112        console.assert(!this._contentProviders[path]);
     113        var fileDescriptor = new WebInspector.FileDescriptor(path, url, url, contentProvider.contentType(), isEditable, isContentScript);
     114        this._contentProviders[path] = contentProvider;
     115        this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileAdded, fileDescriptor);
     116        return path;
     117    },
     118
     119    /**
     120     * @param {string} path
     121     * @return {string}
     122     */
     123    _uniquePath: function(path)
     124    {
     125        var uniquePath = path;
     126        while (this._contentProviders[uniquePath])
     127            uniquePath = path + " (" + (++this._lastUniqueSuffix) + ")";
     128        return uniquePath;
     129    },
     130
     131    /**
     132     * @param {string} path
     133     */
     134    removeFile: function(path)
     135    {
     136        delete this._contentProviders[path];
     137        this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRemoved, path);
     138    },
     139
     140    reset: function()
     141    {
     142        this._contentProviders = {};
     143        this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.Reset, null);
     144    },
     145   
     146    __proto__: WebInspector.Object.prototype
     147}
     148
     149/**
     150 * @constructor
    34151 * @extends {WebInspector.Object}
    35152 * @param {WebInspector.Workspace} workspace
     
    40157    this._workspace = workspace;
    41158    this._type = type;
    42     /** @type {Object.<string, WebInspector.ContentProvider>} */
    43     this._contentProviders = {};
    44     this._lastUniqueSuffix = 0;
    45     this._workspace.addProject(this._type, this);
     159    this._simpleProjectDelegate = new WebInspector.SimpleProjectDelegate(this._type);
     160    this._workspace.addProject(this._simpleProjectDelegate);
    46161}
    47162
    48163/**
    49164 * @param {string} url
    50  * @param {string} type
    51165 * @return {string}
    52166 */
    53167WebInspector.SimpleWorkspaceProvider.uriForURL = function(url, type)
    54 {
     168{   
    55169    var uriTypePrefix = type !== WebInspector.projectTypes.Network ? (type + ":") : "";
    56170    var uri = uriTypePrefix + url;
    57171    return uri;
    58 },
     172}
    59173
    60174WebInspector.SimpleWorkspaceProvider.prototype = {
    61175    /**
    62      * @return {string}
    63      */
    64     type: function()
    65     {
    66         return this._type;
    67     },
    68 
    69     /**
    70      * @param {string} uri
    71      * @param {function(?string,boolean,string)} callback
    72      */
    73     requestFileContent: function(uri, callback)
    74     {
    75         var contentProvider = this._contentProviders[uri];
    76         contentProvider.requestContent(callback);
    77     },
    78 
    79     /**
    80      * @param {string} uri
    81      * @param {string} newContent
    82      * @param {function(?string)} callback
    83      */
    84     setFileContent: function(uri, newContent, callback)
    85     {
    86         callback(null);
    87     },
    88 
    89     /**
    90      * @param {string} query
    91      * @param {boolean} caseSensitive
    92      * @param {boolean} isRegex
    93      * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
    94      */
    95     searchInFileContent: function(uri, query, caseSensitive, isRegex, callback)
    96     {
    97         var contentProvider = this._contentProviders[uri];
    98         contentProvider.searchInContent(query, caseSensitive, isRegex, callback);
    99     },
    100 
    101    /**
    102176     * @param {string} url
    103177     * @param {WebInspector.ContentProvider} contentProvider
     
    129203    _innerAddFileForURL: function(url, contentProvider, isEditable, forceUnique, isContentScript)
    130204    {
    131         var uri = WebInspector.SimpleWorkspaceProvider.uriForURL(url, this._type);
    132         if (forceUnique)
    133             uri = this._uniqueURI(uri);
    134         console.assert(!this._contentProviders[uri]);
    135         var fileDescriptor = new WebInspector.FileDescriptor(uri, url, url, contentProvider.contentType(), isEditable, isContentScript);
    136         this._contentProviders[uri] = contentProvider;
    137         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileAdded, fileDescriptor);
    138         return this._workspace.uiSourceCodeForURI(uri);
    139     },
    140 
    141     /**
    142      * @param {string} uri
    143      */
    144     removeFile: function(uri)
    145     {
    146         delete this._contentProviders[uri];
    147         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.FileRemoved, uri);
    148     },
    149 
    150     /**
    151      * @param {string} uri
    152      * @return {string}
    153      */
    154     _uniqueURI: function(uri)
    155     {
    156         var uniqueURI = uri;
    157         while (this._contentProviders[uniqueURI])
    158             uniqueURI = uri + " (" + (++this._lastUniqueSuffix) + ")";
    159         return uniqueURI;
     205        var path = WebInspector.SimpleWorkspaceProvider.uriForURL(url, this._type);
     206        path = this._simpleProjectDelegate.addFile(path, forceUnique, url, contentProvider, isEditable, isContentScript);
     207        return this._workspace.uiSourceCode(this._simpleProjectDelegate.id(), path);
     208    },
     209
     210    /**
     211     * @param {string} url
     212     */
     213    removeFile: function(url)
     214    {
     215        var path = WebInspector.SimpleWorkspaceProvider.uriForURL(url, this._type);
     216        this._simpleProjectDelegate.removeFile(path);
    160217    },
    161218
    162219    reset: function()
    163220    {
    164         this._contentProviders = {};
    165         this.dispatchEventToListeners(WebInspector.WorkspaceProvider.Events.Reset, null);
     221        this._simpleProjectDelegate.reset();
    166222    },
    167223   
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r142259 r142474  
    3535 * @implements {WebInspector.ContentProvider}
    3636 * @param {WebInspector.Project} project
    37  * @param {string} uri
     37 * @param {string} path
    3838 * @param {string} url
    3939 * @param {WebInspector.ResourceType} contentType
    4040 * @param {boolean} isEditable
    4141 */
    42 WebInspector.UISourceCode = function(project, uri, originURL, url, contentType, isEditable)
     42WebInspector.UISourceCode = function(project, path, originURL, url, contentType, isEditable)
    4343{
    4444    this._project = project;
    45     this._uri = uri;
     45    this._path = path;
    4646    this._originURL = originURL;
    4747    this._url = url;
     
    9494     * @return {string}
    9595     */
     96    path: function()
     97    {
     98        return this._path;
     99    },
     100
     101    /**
     102     * @return {string}
     103     */
    96104    uri: function()
    97105    {
    98         return this._uri;
     106        return this._path;
    99107    },
    100108
  • trunk/Source/WebCore/inspector/front-end/WebKit.qrc

    r142471 r142474  
    7979    <file>FileSystemModel.js</file>
    8080    <file>FileSystemView.js</file>
    81     <file>FileSystemWorkspaceProvider.js</file>
     81    <file>FileSystemProjectDelegate.js</file>
    8282    <file>FileUtils.js</file>
    8383    <file>FilteredItemSelectionDialog.js</file>
  • trunk/Source/WebCore/inspector/front-end/Workspace.js

    r142269 r142474  
    5050/**
    5151 * @constructor
    52  * @param {string} uri
     52 * @param {string} path
    5353 * @param {string} originURL
    5454 * @param {string} url
     
    5757 * @param {boolean=} isContentScript
    5858 */
    59 WebInspector.FileDescriptor = function(uri, originURL, url, contentType, isEditable, isContentScript)
     59WebInspector.FileDescriptor = function(path, originURL, url, contentType, isEditable, isContentScript)
    6060{
    61     this.uri = uri;
     61    this.path = path;
    6262    this.originURL = originURL;
    6363    this.url = url;
     
    7070 * @interface
    7171 */
    72 WebInspector.WorkspaceProvider = function() { }
    73 
    74 WebInspector.WorkspaceProvider.Events = {
     72WebInspector.ProjectDelegate = function() { }
     73
     74WebInspector.ProjectDelegate.Events = {
    7575    FileAdded: "FileAdded",
    7676    FileRemoved: "FileRemoved",
     
    7878}
    7979
    80 WebInspector.WorkspaceProvider.prototype = {
     80WebInspector.ProjectDelegate.prototype = {
     81    /**
     82     * @return {string}
     83     */
     84    id: function() { },
     85
    8186    /**
    8287     * @return {string}
     
    8590
    8691    /**
    87      * @param {string} uri
     92     * @return {string}
     93     */
     94    displayName: function() { },
     95
     96    /**
     97     * @param {string} path
    8898     * @param {function(?string,boolean,string)} callback
    8999     */
    90     requestFileContent: function(uri, callback) { },
    91 
    92     /**
    93      * @param {string} uri
     100    requestFileContent: function(path, callback) { },
     101
     102    /**
     103     * @param {string} path
    94104     * @param {string} newContent
    95105     * @param {function(?string)} callback
    96106     */
    97     setFileContent: function(uri, newContent, callback) { },
    98 
    99     /**
    100      * @param {string} uri
     107    setFileContent: function(path, newContent, callback) { },
     108
     109    /**
     110     * @param {string} path
    101111     * @param {string} query
    102112     * @param {boolean} caseSensitive
     
    104114     * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
    105115     */
    106     searchInFileContent: function(uri, query, caseSensitive, isRegex, callback) { },
     116    searchInFileContent: function(path, query, caseSensitive, isRegex, callback) { },
    107117
    108118    /**
     
    128138/**
    129139 * @param {WebInspector.Workspace} workspace
    130  * @param {string} name
    131  * @param {WebInspector.WorkspaceProvider} workspaceProvider
     140 * @param {WebInspector.ProjectDelegate} projectDelegate
    132141 * @constructor
    133142 */
    134 WebInspector.Project = function(workspace, name, workspaceProvider)
     143WebInspector.Project = function(workspace, projectDelegate)
    135144{
    136     this._name = name;
    137145    /** @type {Object.<string, WebInspector.UISourceCode>} */
    138     this._uiSourceCodesForURI = {};
     146    this._uiSourceCodes = {};
    139147    this._workspace = workspace;
    140     this._workspaceProvider = workspaceProvider;
    141     this._workspaceProvider.addEventListener(WebInspector.WorkspaceProvider.Events.FileAdded, this._fileAdded, this);
    142     this._workspaceProvider.addEventListener(WebInspector.WorkspaceProvider.Events.FileRemoved, this._fileRemoved, this);
    143     this._workspaceProvider.addEventListener(WebInspector.WorkspaceProvider.Events.Reset, this._reset, this);
     148    this._projectDelegate = projectDelegate;
     149    this._projectDelegate.addEventListener(WebInspector.ProjectDelegate.Events.FileAdded, this._fileAdded, this);
     150    this._projectDelegate.addEventListener(WebInspector.ProjectDelegate.Events.FileRemoved, this._fileRemoved, this);
     151    this._projectDelegate.addEventListener(WebInspector.ProjectDelegate.Events.Reset, this._reset, this);
    144152}
    145153
     
    148156     * @return {string}
    149157     */
    150     name: function()
    151     {
    152         return this._name;
     158    id: function()
     159    {
     160        return this._projectDelegate.id();
    153161    },
    154162
     
    158166    type: function()
    159167    {
    160         return this._workspaceProvider.type();
     168        return this._projectDelegate.type();
     169    },
     170
     171    /**
     172     * @return {string}
     173     */
     174    displayName: function()
     175    {
     176        return this._projectDelegate.displayName();
    161177    },
    162178
     
    166182    isServiceProject: function()
    167183    {
    168         return this._workspaceProvider.type() === WebInspector.projectTypes.Debugger || this._workspaceProvider.type() === WebInspector.projectTypes.LiveEdit;
     184        return this._projectDelegate.type() === WebInspector.projectTypes.Debugger || this._projectDelegate.type() === WebInspector.projectTypes.LiveEdit;
    169185    },
    170186
     
    172188    {
    173189        var fileDescriptor = /** @type {WebInspector.FileDescriptor} */ (event.data);
    174         var uiSourceCode = this.uiSourceCodeForURI(fileDescriptor.uri);
     190        var uiSourceCode = this.uiSourceCodeForURI(fileDescriptor.path);
    175191        if (uiSourceCode) {
    176192            // FIXME: Implement
    177193            return;
    178194        }
    179         uiSourceCode = new WebInspector.UISourceCode(this, fileDescriptor.uri, fileDescriptor.originURL, fileDescriptor.url, fileDescriptor.contentType, fileDescriptor.isEditable);
     195        uiSourceCode = new WebInspector.UISourceCode(this, fileDescriptor.path, fileDescriptor.originURL, fileDescriptor.url, fileDescriptor.contentType, fileDescriptor.isEditable);
    180196        uiSourceCode.isContentScript = fileDescriptor.isContentScript;
    181         this._uiSourceCodesForURI[uiSourceCode.uri()] = uiSourceCode;
     197        this._uiSourceCodes[uiSourceCode.path()] = uiSourceCode;
    182198        this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
    183199    },
     
    185201    _fileRemoved: function(event)
    186202    {
    187         var uri = /** @type {string} */ (event.data);
    188         var uiSourceCode = this.uiSourceCodeForURI(uri);
     203        var path = /** @type {string} */ (event.data);
     204        var uiSourceCode = this.uiSourceCodeForURI(path);
    189205        if (!uiSourceCode)
    190206            return;
    191         delete this._uiSourceCodesForURI[uiSourceCode.uri()];
     207        delete this._uiSourceCodes[uiSourceCode.path()];
    192208        this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, uiSourceCode);
    193209    },
     
    196212    {
    197213        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, this);
    198         this._uiSourceCodesForURI = {};
     214        this._uiSourceCodes = {};
     215    },
     216
     217    /**
     218     * @param {string} path
     219     * @return {?WebInspector.UISourceCode}
     220     */
     221    uiSourceCode: function(path)
     222    {
     223        return this._uiSourceCodes[path] || null;
    199224    },
    200225
     
    205230    uiSourceCodeForOriginURL: function(originURL)
    206231    {
    207         for (var uri in this._uiSourceCodesForURI) {
    208             var uiSourceCode = this._uiSourceCodesForURI[uri];
     232        for (var path in this._uiSourceCodes) {
     233            var uiSourceCode = this._uiSourceCodes[path];
    209234            if (uiSourceCode.originURL() === originURL)
    210235                return uiSourceCode;
     
    219244    uiSourceCodeForURI: function(uri)
    220245    {
    221         return this._uiSourceCodesForURI[uri];
     246        return this.uiSourceCode(uri);
    222247    },
    223248
     
    227252    uiSourceCodes: function()
    228253    {
    229         return Object.values(this._uiSourceCodesForURI);
     254        return Object.values(this._uiSourceCodes);
    230255    },
    231256
     
    236261    requestFileContent: function(uiSourceCode, callback)
    237262    {
    238         this._workspaceProvider.requestFileContent(uiSourceCode.uri(), callback);
     263        this._projectDelegate.requestFileContent(uiSourceCode.path(), callback);
    239264    },
    240265
     
    246271    setFileContent: function(uiSourceCode, newContent, callback)
    247272    {
    248         this._workspaceProvider.setFileContent(uiSourceCode.uri(), newContent, callback);
     273        this._projectDelegate.setFileContent(uiSourceCode.path(), newContent, callback);
    249274        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: uiSourceCode, content: newContent });
    250275    },
     
    259284    searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, callback)
    260285    {
    261         this._workspaceProvider.searchInFileContent(uiSourceCode.uri(), query, caseSensitive, isRegex, callback);
     286        this._projectDelegate.searchInFileContent(uiSourceCode.path(), query, caseSensitive, isRegex, callback);
    262287    },
    263288
    264289    dispose: function()
    265290    {
    266         this._workspaceProvider.reset();
     291        this._projectDelegate.reset();
    267292    }
    268293}
     
    295320WebInspector.Workspace.prototype = {
    296321    /**
     322     * @param {string} projectId
     323     * @param {string} path
     324     * @return {?WebInspector.UISourceCode}
     325     */
     326    uiSourceCode: function(projectId, path)
     327    {
     328        var project = this._projects[projectId];
     329        return project ? project.uiSourceCode(path) : null;
     330    },
     331
     332    /**
    297333     * @param {string} originURL
    298334     * @return {?WebInspector.UISourceCode}
     
    316352    uiSourceCodeForURI: function(uri)
    317353    {
    318         for (var projectName in this._projects) {
    319             var project = this._projects[projectName];
     354        for (var projectId in this._projects) {
     355            var project = this._projects[projectId];
    320356            var uiSourceCode = project.uiSourceCodeForURI(uri);
    321357            if (uiSourceCode)
     
    341377
    342378    /**
    343      * @param {string} projectName
    344      * @param {WebInspector.WorkspaceProvider} workspaceProvider
     379     * @param {WebInspector.ProjectDelegate} projectDelegate
    345380     * @return {WebInspector.Project}
    346381     */
    347     addProject: function(projectName, workspaceProvider)
    348     {
    349         this._projects[projectName] = new WebInspector.Project(this, projectName, workspaceProvider);
    350         return this._projects[projectName];
    351     },
    352 
    353     /**
    354      * @param {string} projectName
    355      */
    356     removeProject: function(projectName)
    357     {
    358         var project = this._projects[projectName];
     382    addProject: function(projectDelegate)
     383    {
     384        var projectId = projectDelegate.id();
     385        this._projects[projectId] = new WebInspector.Project(this, projectDelegate);
     386        return this._projects[projectId];
     387    },
     388
     389    /**
     390     * @param {string} projectId
     391     */
     392    removeProject: function(projectId)
     393    {
     394        var project = this._projects[projectId];
    359395        if (!project)
    360396            return;
    361397        project.dispose();
    362         delete this._projects[projectName];
    363     },
    364 
    365     /**
    366      * @param {string} projectName
     398        delete this._projects[projectId];
     399    },
     400
     401    /**
     402     * @param {string} projectId
    367403     * @return {WebInspector.Project}
    368404     */
    369     project: function(projectName)
    370     {
    371         return this._projects[projectName];
     405    project: function(projectId)
     406    {
     407        return this._projects[projectId];
    372408    },
    373409
     
    399435    {
    400436        var result = [];
    401         for (var projectName in this._projects) {
    402             var project = this._projects[projectName];
     437        for (var projectId in this._projects) {
     438            var project = this._projects[projectId];
    403439            result = result.concat(project.uiSourceCodes());
    404440        }
     
    411447    projectForUISourceCode: function(uiSourceCode)
    412448    {
    413         for (var projectName in this._projects) {
    414             var project = this._projects[projectName];
     449        for (var projectId in this._projects) {
     450            var project = this._projects[projectId];
    415451            if (project.uiSourceCodeForURI(uiSourceCode.uri()))
    416452                return project;
  • trunk/Source/WebCore/inspector/front-end/inspector.html

    r142471 r142474  
    140140    <script type="text/javascript" src="DebuggerScriptMapping.js"></script>
    141141    <script type="text/javascript" src="PresentationConsoleMessageHelper.js"></script>
    142     <script type="text/javascript" src="FileSystemWorkspaceProvider.js"></script>
     142    <script type="text/javascript" src="FileSystemProjectDelegate.js"></script>
    143143    <script type="text/javascript" src="FileSystemMapping.js"></script>
    144144    <script type="text/javascript" src="IsolatedFileSystemModel.js"></script>
Note: See TracChangeset for help on using the changeset viewer.