Changeset 143451 in webkit
- Timestamp:
- Feb 20, 2013 4:33:20 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r143450 r143451 1 2013-02-19 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Make UISourceCode.path() an array of path segments. 4 https://bugs.webkit.org/show_bug.cgi?id=110229 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/workspace-mapping.html: 9 1 10 2013-02-20 Takashi Toyoshima <toyoshim@chromium.org> 2 11 -
trunk/LayoutTests/inspector/workspace-mapping.html
r143448 r143451 31 31 32 32 addUISourceCode: function(path) { 33 var fileDescriptor = new WebInspector.FileDescriptor(path , path, path, WebInspector.resourceTypes.Script, true, false);33 var fileDescriptor = new WebInspector.FileDescriptor(path.split("/"), path, path, WebInspector.resourceTypes.Script, true, false); 34 34 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileAdded, fileDescriptor); 35 35 }, -
trunk/Source/WebCore/ChangeLog
r143449 r143451 1 2013-02-19 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Make UISourceCode.path() an array of path segments. 4 https://bugs.webkit.org/show_bug.cgi?id=110229 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/front-end/FileSystemProjectDelegate.js: 9 (WebInspector.FileSystemProjectDelegate.prototype._filePathForPath): 10 (WebInspector.FileSystemProjectDelegate.prototype.innerCallback): 11 (WebInspector.FileSystemProjectDelegate.prototype.requestFileContent): 12 (WebInspector.FileSystemProjectDelegate.prototype._contentTypeForPath): 13 (WebInspector.FileSystemProjectDelegate.prototype.populate.filesLoaded): 14 (WebInspector.FileSystemProjectDelegate.prototype.populate): 15 * inspector/front-end/SimpleWorkspaceProvider.js: 16 (WebInspector.SimpleProjectDelegate.prototype.requestFileContent): 17 (WebInspector.SimpleProjectDelegate.prototype.searchInFileContent): 18 (WebInspector.SimpleProjectDelegate.prototype.addFile): 19 (WebInspector.SimpleProjectDelegate.prototype._ensureUniquePath): 20 (WebInspector.SimpleProjectDelegate.prototype.removeFile): 21 (WebInspector.SimpleWorkspaceProvider.pathForSplittedURL): 22 (WebInspector.SimpleWorkspaceProvider.prototype.addFileByName): 23 (WebInspector.SimpleWorkspaceProvider.prototype.removeFileByName): 24 * inspector/front-end/UISourceCode.js: 25 (WebInspector.UISourceCode.prototype.uri): 26 * inspector/front-end/Workspace.js: 27 (WebInspector.Project.prototype._fileAdded): 28 (WebInspector.Project.prototype._fileRemoved): 29 (WebInspector.Project.prototype.uiSourceCode): 30 (WebInspector.Workspace.prototype.uiSourceCodeForURL): 31 (WebInspector.Workspace.prototype.urlForPath): 32 1 33 2013-02-20 Yury Semikhatsky <yurys@chromium.org> 2 34 -
trunk/Source/WebCore/inspector/front-end/FileSystemProjectDelegate.js
r143448 r143451 70 70 71 71 /** 72 * @param { string} path72 * @param {Array.<string>} path 73 73 * @return {string} 74 74 */ 75 75 _filePathForPath: function(path) 76 76 { 77 return "/" + path ;78 }, 79 80 /** 81 * @param { string} path77 return "/" + path.join("/"); 78 }, 79 80 /** 81 * @param {Array.<string>} path 82 82 * @param {function(?string,boolean,string)} callback 83 83 */ … … 92 92 function innerCallback(content) 93 93 { 94 var contentType = this._contentTypeForPath( filePath);94 var contentType = this._contentTypeForPath(path); 95 95 callback(content, false, contentType.canonicalMimeType()); 96 96 } … … 98 98 99 99 /** 100 * @param { string} path100 * @param {Array.<string>} path 101 101 * @param {string} newContent 102 102 * @param {function(?string)} callback … … 109 109 110 110 /** 111 * @param { string} path111 * @param {Array.<string>} path 112 112 * @param {string} query 113 113 * @param {boolean} caseSensitive … … 134 134 135 135 /** 136 * @param { string} path136 * @param {Array.<string>} path 137 137 * @return {WebInspector.ResourceType} 138 138 */ 139 139 _contentTypeForPath: function(path) 140 140 { 141 var splittedPath = path.split("/"); 142 var fileName = splittedPath[splittedPath.length - 1]; 141 var fileName = path[path.length - 1]; 143 142 var extensionIndex = fileName.lastIndexOf("."); 144 143 var extension = ""; … … 162 161 { 163 162 for (var i = 0; i < files.length; ++i) { 163 var path = files[i].split("/"); 164 path.shift(); 165 console.assert(path.length); 164 166 var fullPath = this._fileSystem.path() + files[i]; 165 var path = files[i].substr(1);166 167 var url = this._workspace.urlForPath(fullPath); 167 168 var contentType = this._contentTypeForPath(path); … … 181 182 182 183 /** 183 * @param { string} path184 * @param {Array.<string>} path 184 185 */ 185 186 _removeFile: function(path) -
trunk/Source/WebCore/inspector/front-end/SimpleWorkspaceProvider.js
r143448 r143451 86 86 87 87 /** 88 * @param { string} path88 * @param {Array.<string>} path 89 89 * @param {function(?string,boolean,string)} callback 90 90 */ 91 91 requestFileContent: function(path, callback) 92 92 { 93 var contentProvider = this._contentProviders[path ];93 var contentProvider = this._contentProviders[path.join("/")]; 94 94 contentProvider.requestContent(callback); 95 95 }, 96 96 97 97 /** 98 * @param { string} path98 * @param {Array.<string>} path 99 99 * @param {string} newContent 100 100 * @param {function(?string)} callback … … 106 106 107 107 /** 108 * @param { string} path108 * @param {Array.<string>} path 109 109 * @param {string} query 110 110 * @param {boolean} caseSensitive … … 114 114 searchInFileContent: function(path, query, caseSensitive, isRegex, callback) 115 115 { 116 var contentProvider = this._contentProviders[path ];116 var contentProvider = this._contentProviders[path.join("/")]; 117 117 contentProvider.searchInContent(query, caseSensitive, isRegex, callback); 118 118 }, 119 119 120 120 /** 121 * @param { string} path121 * @param {Array.<string>} path 122 122 * @param {string} url 123 123 * @param {WebInspector.ContentProvider} contentProvider 124 124 * @param {boolean} isEditable 125 125 * @param {boolean=} isContentScript 126 * @return { string}126 * @return {Array.<string>} 127 127 */ 128 128 addFile: function(path, forceUniquePath, url, contentProvider, isEditable, isContentScript) 129 129 { 130 130 if (forceUniquePath) 131 path = this._uniquePath(path);131 this._ensureUniquePath(path); 132 132 var fileDescriptor = new WebInspector.FileDescriptor(path, url, url, contentProvider.contentType(), isEditable, isContentScript); 133 this._contentProviders[path ] = contentProvider;133 this._contentProviders[path.join("/")] = contentProvider; 134 134 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileAdded, fileDescriptor); 135 135 return path; … … 137 137 138 138 /** 139 * @param {string} path 140 * @return {string} 141 */ 142 _uniquePath: function(path) 143 { 144 var uniquePath = path; 145 while (this._contentProviders[uniquePath]) 146 uniquePath = path + " (" + (++this._lastUniqueSuffix) + ")"; 147 return uniquePath; 148 }, 149 150 /** 151 * @param {string} path 139 * @param {Array.<string>} path 140 */ 141 _ensureUniquePath: function(path) 142 { 143 var uniquePath = path.join("/"); 144 var suffix = ""; 145 while (this._contentProviders[uniquePath]) { 146 suffix = " (" + (++this._lastUniqueSuffix) + ")"; 147 uniquePath = path + suffix; 148 } 149 path[path.length - 1] += suffix; 150 }, 151 152 /** 153 * @param {Array.<string>} path 152 154 */ 153 155 removeFile: function(path) 154 156 { 155 delete this._contentProviders[path ];157 delete this._contentProviders[path.join("/")]; 156 158 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRemoved, path); 157 159 }, … … 212 214 /** 213 215 * @param {Array.<string>} splittedURL 214 * @return { string}216 * @return {Array.<string>} 215 217 */ 216 218 WebInspector.SimpleWorkspaceProvider.pathForSplittedURL = function(splittedURL) 217 219 { 218 splittedURL.shift(); 219 return splittedURL.join("/"); 220 var result = splittedURL.slice(); 221 result.shift(); 222 return result; 220 223 } 221 224 … … 285 288 addFileByName: function(projectName, name, contentProvider, isEditable, isContentScript) 286 289 { 287 return this._innerAddFile("", name, name, contentProvider, isEditable, false, isContentScript);290 return this._innerAddFile("", [name], name, contentProvider, isEditable, false, isContentScript); 288 291 }, 289 292 290 293 /** 291 294 * @param {string} projectName 292 * @param { string} path295 * @param {Array.<string>} path 293 296 * @param {WebInspector.ContentProvider} contentProvider 294 297 * @param {boolean} isEditable … … 306 309 /** 307 310 * @param {string} projectName 308 * @param {string} path309 */ 310 removeFileByName: function(projectName, path)311 * @param {string} name 312 */ 313 removeFileByName: function(projectName, name) 311 314 { 312 315 var projectDelegate = this._projectDelegate(projectName); 313 projectDelegate.removeFile( path);316 projectDelegate.removeFile([name]); 314 317 }, 315 318 -
trunk/Source/WebCore/inspector/front-end/UISourceCode.js
r143202 r143451 35 35 * @implements {WebInspector.ContentProvider} 36 36 * @param {WebInspector.Project} project 37 * @param { string} path37 * @param {Array.<string>} path 38 38 * @param {string} url 39 39 * @param {WebInspector.ResourceType} contentType … … 82 82 } 83 83 84 /**85 * @param {string} projectId86 * @param {string} path87 * @return {string}88 */89 WebInspector.UISourceCode.uri = function(projectId, path)90 {91 if (!projectId)92 return path;93 if (!path)94 return projectId;95 return projectId + "/" + path;96 }97 98 /**99 * @param {string} projectId100 * @param {string} uri101 * @return {?string}102 */103 WebInspector.UISourceCode.path = function(projectId, uri)104 {105 if (!projectId)106 return uri;107 if (!uri.startsWith(projectId))108 return null;109 var path = uri.substr(projectId.length);110 if (path.length && path[0] === "/")111 path = path.substr(1);112 return path;113 }114 115 84 WebInspector.UISourceCode.prototype = { 116 85 /** … … 123 92 124 93 /** 94 * @return {Array.<string>} 95 */ 96 path: function() 97 { 98 return this._path; 99 }, 100 101 /** 125 102 * @return {string} 126 103 */ 127 path: function()128 {129 return this._path;130 },131 132 /**133 * @return {string}134 */135 104 uri: function() 136 105 { 137 return WebInspector.UISourceCode.uri(this._project.id(), this._path); 106 if (!this._project.id()) 107 return this._path.join("/"); 108 if (!this._path.length) 109 return this._project.id(); 110 return this._project.id() + "/" + this._path.join("/"); 138 111 }, 139 112 -
trunk/Source/WebCore/inspector/front-end/Workspace.js
r143448 r143451 50 50 /** 51 51 * @constructor 52 * @param { string} path52 * @param {Array.<string>} path 53 53 * @param {string} originURL 54 54 * @param {string} url … … 95 95 96 96 /** 97 * @param { string} path97 * @param {Array.<string>} path 98 98 * @param {function(?string,boolean,string)} callback 99 99 */ … … 101 101 102 102 /** 103 * @param { string} path103 * @param {Array.<string>} path 104 104 * @param {string} newContent 105 105 * @param {function(?string)} callback … … 108 108 109 109 /** 110 * @param { string} path110 * @param {Array.<string>} path 111 111 * @param {string} query 112 112 * @param {boolean} caseSensitive … … 195 195 uiSourceCode = new WebInspector.UISourceCode(this, fileDescriptor.path, fileDescriptor.originURL, fileDescriptor.url, fileDescriptor.contentType, fileDescriptor.isEditable); 196 196 uiSourceCode.isContentScript = fileDescriptor.isContentScript; 197 this._uiSourceCodes[uiSourceCode.path() ] = uiSourceCode;197 this._uiSourceCodes[uiSourceCode.path().join("/")] = uiSourceCode; 198 198 this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode); 199 199 }, … … 201 201 _fileRemoved: function(event) 202 202 { 203 var path = /** @type { string} */ (event.data);203 var path = /** @type {Array.<string>} */ (event.data); 204 204 var uiSourceCode = this.uiSourceCode(path); 205 205 if (!uiSourceCode) 206 206 return; 207 delete this._uiSourceCodes[uiSourceCode.path() ];207 delete this._uiSourceCodes[uiSourceCode.path().join("/")]; 208 208 this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, uiSourceCode); 209 209 }, … … 216 216 217 217 /** 218 * @param { string} path218 * @param {Array.<string>} path 219 219 * @return {?WebInspector.UISourceCode} 220 220 */ 221 221 uiSourceCode: function(path) 222 222 { 223 return this._uiSourceCodes[path ] || null;223 return this._uiSourceCodes[path.join("/")] || null; 224 224 }, 225 225 … … 236 236 } 237 237 return null; 238 },239 240 /**241 * @param {string} uri242 * @return {?WebInspector.UISourceCode}243 */244 uiSourceCodeForURI: function(uri)245 {246 var path = WebInspector.UISourceCode.path(this.id(), uri);247 if (typeof path !== "string")248 return null;249 return this._uiSourceCodes[path];250 238 }, 251 239 … … 327 315 /** 328 316 * @param {string} projectId 329 * @param { string} path317 * @param {Array.<string>} path 330 318 * @return {?WebInspector.UISourceCode} 331 319 */ … … 346 334 var project = networkProjects[i]; 347 335 var uiSourceCode = project.uiSourceCodeForOriginURL(originURL); 348 if (uiSourceCode)349 return uiSourceCode;350 }351 return null;352 },353 354 /**355 * @param {string} uri356 * @return {?WebInspector.UISourceCode}357 */358 uiSourceCodeForURI: function(uri)359 {360 for (var projectId in this._projects) {361 var project = this._projects[projectId];362 var uiSourceCode = project.uiSourceCodeForURI(uri);363 336 if (uiSourceCode) 364 337 return uiSourceCode; … … 488 461 var path = pathPrefix + url.substr(entry.urlPrefix.length); 489 462 var project = this.project(projectId); 490 return project ? project.uiSourceCode(path ) : null;463 return project ? project.uiSourceCode(path.split("/")) : null; 491 464 }, 492 465
Note: See TracChangeset
for help on using the changeset viewer.