Changeset 139860 in webkit
- Timestamp:
- Jan 16, 2013 2:26:36 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r139859 r139860 1 2013-01-15 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Introduce file mapping allowing to map network loaded scripts and stylesheets to file system files. 4 https://bugs.webkit.org/show_bug.cgi?id=106795 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/file-mapping-expected.txt: Added. 9 * inspector/file-mapping.html: Added. 10 1 11 2013-01-15 Vsevolod Vlasov <vsevik@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r139859 r139860 1 2013-01-15 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Introduce file mapping allowing to map network loaded scripts and stylesheets to file system files. 4 https://bugs.webkit.org/show_bug.cgi?id=106795 5 6 Reviewed by Pavel Feldman. 7 8 Introduced file mapping for inspector. 9 FileMapping is essentially an array of MappingEntries where each MappingEntry is a pair of urlPrefix and pathPrefix. 10 When scripts and stylesheets are mapped to uiSourceCodes FileMapping methods are used to establish 11 prefix based matching with file system uiSourceCodes if possible. 12 13 Test: inspector/file-mapping.html 14 15 * WebCore.gypi: 16 * WebCore.vcproj/WebCore.vcproj: 17 * inspector/compile-front-end.py: 18 * inspector/front-end/CompilerScriptMapping.js: 19 (WebInspector.CompilerScriptMapping): 20 (WebInspector.CompilerScriptMapping.prototype.rawLocationToUILocation): 21 (WebInspector.CompilerScriptMapping.prototype.uiLocationToRawLocation): 22 (WebInspector.CompilerScriptMapping.prototype.get addScript.get this): 23 (WebInspector.CompilerScriptMapping.prototype.get addScript): 24 (WebInspector.CompilerScriptMapping.prototype._bindUISourceCode): 25 (WebInspector.CompilerScriptMapping.prototype._uiSourceCodeAddedToWorkspace): 26 * inspector/front-end/FileMapping.js: Added. 27 (WebInspector.FileMapping): 28 (WebInspector.FileMapping.prototype.hasMappingForURL): 29 (WebInspector.FileMapping.prototype.uriForURL): 30 (WebInspector.FileMapping.prototype.urlForURI): 31 (WebInspector.FileMapping.prototype.setMappings): 32 (WebInspector.FileMapping.prototype.mappings): 33 (WebInspector.FileMapping.prototype._deserialize): 34 (WebInspector.FileMapping.prototype._serialize): 35 (WebInspector.FileMapping.MappingEntry): 36 (WebInspector.FileMapping.MappingEntry.deserialize): 37 (WebInspector.FileMapping.MappingEntry.prototype.matchesURL): 38 (WebInspector.FileMapping.MappingEntry.prototype.matchesURI): 39 (WebInspector.FileMapping.MappingEntry.prototype.uriForURL): 40 (WebInspector.FileMapping.MappingEntry.prototype.urlForURI): 41 (WebInspector.FileMapping.MappingEntry.prototype.serialize): 42 * inspector/front-end/NetworkUISourceCodeProvider.js: 43 (WebInspector.NetworkUISourceCodeProvider.prototype._addFile): 44 * inspector/front-end/ResourceScriptMapping.js: 45 (WebInspector.ResourceScriptMapping.prototype._workspaceUISourceCodeForScript): 46 (WebInspector.ResourceScriptMapping.prototype._scriptsForUISourceCode): 47 * inspector/front-end/ResourceUtils.js: 48 (WebInspector.displayNameForURL): 49 * inspector/front-end/SASSSourceMapping.js: 50 (WebInspector.SASSSourceMapping): 51 (WebInspector.SASSSourceMapping.prototype._reloadCSS): 52 (_addURLMapping): 53 (rawLocationToUILocation): 54 (_reset): 55 (WebInspector.SASSSourceMapping.MappingEntry): 56 * inspector/front-end/StylesSourceMapping.js: 57 (WebInspector.StylesSourceMapping): 58 (WebInspector.StylesSourceMapping.prototype.rawLocationToUILocation): 59 (WebInspector.StylesSourceMapping.prototype._uiSourceCodeAddedToWorkspace): 60 (WebInspector.StylesSourceMapping.prototype._projectWillReset): 61 (WebInspector.StyleContentBinding.prototype.): 62 (WebInspector.StyleContentBinding.prototype._innerStyleSheetChanged): 63 * inspector/front-end/WebKit.qrc: 64 * inspector/front-end/Workspace.js: 65 * inspector/front-end/inspector.html: 66 * inspector/front-end/inspector.js: 67 1 68 2013-01-15 Vsevolod Vlasov <vsevik@chromium.org> 2 69 -
trunk/Source/WebCore/WebCore.gypi
r139774 r139860 5148 5148 'inspector/front-end/ExtensionView.js', 5149 5149 'inspector/front-end/FileManager.js', 5150 'inspector/front-end/FileMapping.js', 5150 5151 'inspector/front-end/FileSystemMapping.js', 5151 5152 'inspector/front-end/FileSystemModel.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r139726 r139860 76718 76718 </File> 76719 76719 <File 76720 RelativePath="..\inspector\front-end\FileMapping.js" 76721 > 76722 </File> 76723 <File 76720 76724 RelativePath="..\inspector\front-end\FileSystemMapping.js" 76721 76725 > -
trunk/Source/WebCore/inspector/compile-front-end.py
r139726 r139860 77 77 "DebuggerScriptMapping.js", 78 78 "FileManager.js", 79 "FileMapping.js", 79 80 "FileSystemMapping.js", 80 81 "FileSystemModel.js", -
trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js
r139454 r139860 38 38 { 39 39 this._workspace = workspace; 40 this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); 40 41 this._networkWorkspaceProvider = networkWorkspaceProvider; 41 42 /** @type {Object.<string, WebInspector.PositionBasedSourceMap>} */ … … 63 64 if (entry.length === 2) 64 65 return null; 65 var uiSourceCode = this._workspace.uiSourceCodeForURL(entry[2]); 66 var url = entry[2]; 67 var uri = WebInspector.fileMapping.uriForURL(url); 68 var uiSourceCode = this._workspace.uiSourceCodeForURI(uri); 69 if (!uiSourceCode) 70 return null; 66 71 return new WebInspector.UILocation(uiSourceCode, entry[3], entry[4]); 67 72 }, … … 75 80 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) 76 81 { 82 if (!uiSourceCode.url) 83 return null; 77 84 var sourceMap = this._sourceMapForURL[uiSourceCode.url]; 85 if (!sourceMap) 86 return null; 78 87 var entry = sourceMap.findEntryReversed(uiSourceCode.url, lineNumber); 79 88 return WebInspector.debuggerModel.createRawLocation(this._scriptForSourceMap.get(sourceMap), entry[0], entry[1]); … … 96 105 for (var i = 0; i < sourceURLs.length; ++i) { 97 106 var sourceURL = sourceURLs[i]; 98 if (this._workspace.uiSourceCodeForURL(sourceURL)) 107 var uri = WebInspector.fileMapping.uriForURL(sourceURL); 108 if (this._sourceMapForURL[sourceURL]) 99 109 continue; 100 110 this._sourceMapForURL[sourceURL] = sourceMap; 101 var sourceContent = sourceMap.sourceContent(sourceURL); 102 var contentProvider; 103 if (sourceContent) 104 contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, sourceContent); 105 else 106 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL); 107 var uiSourceCode = this._networkWorkspaceProvider.addFileForURL(sourceURL, contentProvider, true); 108 uiSourceCode.setSourceMapping(this); 109 uiSourceCode.isContentScript = script.isContentScript; 111 if (!WebInspector.fileMapping.hasMappingForURL(sourceURL) && !this._workspace.uiSourceCodeForURI(uri)) { 112 var sourceContent = sourceMap.sourceContent(sourceURL); 113 var contentProvider; 114 if (sourceContent) 115 contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, sourceContent); 116 else 117 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL); 118 this._networkWorkspaceProvider.addFileForURL(sourceURL, contentProvider, true); 119 } 120 var uiSourceCode = this._workspace.uiSourceCodeForURI(uri); 121 if (uiSourceCode) { 122 this._bindUISourceCode(this._workspace.uiSourceCodeForURI(uri)); 123 uiSourceCode.isContentScript = script.isContentScript; 124 } 110 125 } 111 112 126 this._sourceMapForScriptId[script.scriptId] = sourceMap; 113 127 this._scriptForSourceMap.put(sourceMap, script); 114 128 script.pushSourceMapping(this); 129 }, 130 131 /** 132 * @param {WebInspector.UISourceCode} uiSourceCode 133 */ 134 _bindUISourceCode: function(uiSourceCode) 135 { 136 uiSourceCode.setSourceMapping(this); 137 }, 138 139 /** 140 * @param {WebInspector.Event} event 141 */ 142 _uiSourceCodeAddedToWorkspace: function(event) 143 { 144 var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data); 145 if (!uiSourceCode.url || !this._sourceMapForURL[uiSourceCode.url]) 146 return; 147 this._bindUISourceCode(uiSourceCode); 115 148 }, 116 149 -
trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js
r139454 r139860 115 115 _addFile: function(url, contentProvider, isContentScript) 116 116 { 117 if (WebInspector.fileMapping.hasMappingForURL(url)) 118 return; 119 117 120 var type = contentProvider.contentType(); 118 121 if (type !== WebInspector.resourceTypes.Stylesheet && type !== WebInspector.resourceTypes.Document && type !== WebInspector.resourceTypes.Script) -
trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js
r139454 r139860 139 139 if (!script.isInlineScript() && this._inlineScriptsForSourceURL[script.sourceURL]) 140 140 return null; 141 return this._workspace.uiSourceCodeForURL(script.sourceURL); 141 var uri = WebInspector.fileMapping.uriForURL(script.sourceURL); 142 return this._workspace.uiSourceCodeForURI(uri); 142 143 }, 143 144 … … 159 160 return []; 160 161 } 162 if (!uiSourceCode.url) 163 return []; 161 164 var scriptsForSourceURL = isInlineScript ? this._inlineScriptsForSourceURL : this._nonInlineScriptsForSourceURL; 162 165 return scriptsForSourceURL[uiSourceCode.url] || []; -
trunk/Source/WebCore/inspector/front-end/ResourceUtils.js
r136104 r139860 59 59 return resource.displayName; 60 60 61 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url); 61 var uri = WebInspector.fileMapping.uriForURL(url); 62 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURI(uri); 62 63 if (uiSourceCode) 63 64 return uiSourceCode.parsedURL.displayName; -
trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js
r139859 r139860 39 39 this._workspace = workspace; 40 40 this._networkWorkspaceProvider = networkWorkspaceProvider; 41 this._ uiLocations = {};41 this._mappingEntries = {}; 42 42 this._cssURLsForSASSURL = {}; 43 43 this._timeoutForURL = {}; … … 68 68 _fileSaveFinished: function(event) 69 69 { 70 // FIXME: add support for FileMapping. 70 71 var sassURL = /** @type {string} */ (event.data); 71 72 function callback() … … 93 94 _reloadCSS: function(url) 94 95 { 95 var uiSourceCode = this._workspace.uiSourceCodeForURL(url); 96 var uri = WebInspector.fileMapping.uriForURL(url); 97 var uiSourceCode = this._workspace.uiSourceCodeForURI(uri); 96 98 if (!uiSourceCode) 97 99 return; … … 152 154 * @param {number} rawLine 153 155 */ 154 _ bindUISourceCode: function(url, line, rawURL, rawLine)155 { 156 var u iSourceCode = this._workspace.uiSourceCodeForURL(url);157 if (! uiSourceCode) {156 _addURLMapping: function(url, line, rawURL, rawLine) 157 { 158 var uri = WebInspector.fileMapping.uriForURL(url); 159 if (!WebInspector.fileMapping.hasMappingForURL(url) && !this._workspace.uiSourceCodeForURI(uri)) { 158 160 var content = InspectorFrontendHost.loadResourceSynchronously(url); 159 161 var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Stylesheet, content, "text/x-scss"); 160 uiSourceCode = this._networkWorkspaceProvider.addFileForURL(url, contentProvider, true); 161 WebInspector.cssModel.setSourceMapping(rawURL, this); 162 this._networkWorkspaceProvider.addFileForURL(url, contentProvider, true); 162 163 } 163 164 var rawLocationString = rawURL + ":" + (rawLine + 1); // Next line after mapping metainfo 164 this._ uiLocations[rawLocationString] = new WebInspector.UILocation(uiSourceCode, line - 1, 0);165 this._mappingEntries[rawLocationString] = new WebInspector.SASSSourceMapping.MappingEntry(uri, line - 1, 0); 165 166 this._addCSSURLforSASSURL(rawURL, url); 167 WebInspector.cssModel.setSourceMapping(rawURL, this); 166 168 }, 167 169 … … 190 192 { 191 193 var location = /** @type WebInspector.CSSLocation */ (rawLocation); 192 var uiLocation = this._uiLocations[location.url + ":" + location.lineNumber]; 194 var mappingEntry = this._mappingEntries[location.url + ":" + location.lineNumber]; 195 var uiLocation = null; 196 if (mappingEntry) { 197 var uiSourceCode = this._workspace.uiSourceCodeForURI(mappingEntry.uri); 198 if (uiSourceCode) 199 uiLocation = new WebInspector.UILocation(uiSourceCode, mappingEntry.lineNumber, mappingEntry.columnNumber); 200 } 193 201 if (!uiLocation) { 194 var uiSourceCode = this._workspace.uiSourceCodeForURL(location.url); 195 uiLocation = new WebInspector.UILocation(uiSourceCode, location.lineNumber, 0); 202 var uri = WebInspector.fileMapping.uriForURL(location.url); 203 var uiSourceCode = this._workspace.uiSourceCodeForURI(uri); 204 if (uiSourceCode) 205 uiLocation = new WebInspector.UILocation(uiSourceCode, location.lineNumber, 0); 196 206 } 197 207 return uiLocation; … … 212 222 _reset: function() 213 223 { 214 this._ uiLocations = {};224 this._mappingEntries = {}; 215 225 this._populate(); 216 226 } 217 227 } 218 228 229 /** 230 * @constructor 231 * @param {string} uri 232 * @param {number} lineNumber 233 */ 234 WebInspector.SASSSourceMapping.MappingEntry = function(uri, lineNumber, columnNumber) 235 { 236 this.uri = uri; 237 this.lineNumber = lineNumber; 238 this.columnNumber = columnNumber; 239 } 240 -
trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js
r139859 r139860 40 40 this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); 41 41 42 this._ uiSourceCodeForURL= {};42 this._mappedURLs = {}; 43 43 } 44 44 … … 51 51 { 52 52 var location = /** @type WebInspector.CSSLocation */ (rawLocation); 53 var uiSourceCode = this._uiSourceCodeForURL[location.url]; 53 var uri = WebInspector.fileMapping.uriForURL(location.url); 54 var uiSourceCode = this._workspace.uiSourceCodeForURI(uri); 54 55 return new WebInspector.UILocation(uiSourceCode, location.lineNumber, 0); 55 56 }, … … 69 70 { 70 71 var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data); 71 if (!uiSourceCode.url || this._uiSourceCodeForURL[uiSourceCode.url])72 return;73 72 if (uiSourceCode.contentType() !== WebInspector.resourceTypes.Stylesheet) 74 73 return; 75 if (!WebInspector.resourceForURL(uiSourceCode.url)) 76 return; 77 78 this._addUISourceCode(uiSourceCode); 79 }, 80 81 /** 82 * @param {WebInspector.UISourceCode} uiSourceCode 83 */ 84 _addUISourceCode: function(uiSourceCode) 85 { 86 this._uiSourceCodeForURL[uiSourceCode.url] = uiSourceCode; 74 if (!uiSourceCode.url || !WebInspector.resourceForURL(uiSourceCode.url)) 75 return; 76 if (this._mappedURLs[uiSourceCode.url]) 77 return; 78 this._mappedURLs[uiSourceCode.url] = true; 87 79 uiSourceCode.setSourceMapping(this); 88 80 var styleFile = new WebInspector.StyleFile(uiSourceCode); … … 96 88 var uiSourceCodes = project.uiSourceCodes(); 97 89 for (var i = 0; i < uiSourceCodes; ++i) 98 delete this._ uiSourceCodeForURL[uiSourceCodes[i].url];90 delete this._mappedURLs[uiSourceCodes[i].url]; 99 91 } 100 92 } … … 267 259 return; 268 260 269 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(styleSheetURL); 261 var uri = WebInspector.fileMapping.uriForURL(styleSheetURL); 262 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURI(uri); 270 263 if (!uiSourceCode) 271 264 return; -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r139726 r139860 75 75 <file>FileContentView.js</file> 76 76 <file>FileManager.js</file> 77 <file>FileMapping.js</file> 77 78 <file>FileSystemMapping.js</file> 78 79 <file>FileSystemModel.js</file> -
trunk/Source/WebCore/inspector/front-end/Workspace.js
r139859 r139860 189 189 190 190 /** 191 * @param {string} url192 * @return {?WebInspector.UISourceCode}193 */194 uiSourceCodeForURL: function(url)195 {196 for (var i = 0; i < this._uiSourceCodes.length; ++i) {197 if (this._uiSourceCodes[i].url === url)198 return this._uiSourceCodes[i];199 }200 return null;201 },202 203 /**204 191 * @param {string} originURL 205 192 * @return {?WebInspector.UISourceCode} … … 302 289 303 290 /** 304 * @param {string} url305 * @return {?WebInspector.UISourceCode}306 */307 uiSourceCodeForURL: function(url)308 {309 return this._projects[WebInspector.projectNames.Network].uiSourceCodeForURL(url);310 },311 312 /**313 291 * @param {string} uri 314 292 * @return {?WebInspector.UISourceCode} -
trunk/Source/WebCore/inspector/front-end/inspector.html
r139726 r139860 140 140 <script type="text/javascript" src="IsolatedFileSystemModel.js"></script> 141 141 <script type="text/javascript" src="FileSystemMapping.js"></script> 142 <script type="text/javascript" src="FileMapping.js"></script> 142 143 <script type="text/javascript" src="Workspace.js"></script> 143 144 <script type="text/javascript" src="SimpleWorkspaceProvider.js"></script> -
trunk/Source/WebCore/inspector/front-end/inspector.js
r139726 r139860 433 433 this.isolatedFileSystemModel = new WebInspector.IsolatedFileSystemModel(); 434 434 this.isolatedFileSystemDispatcher = new WebInspector.IsolatedFileSystemDispatcher(this.isolatedFileSystemModel); 435 this.fileMapping = new WebInspector.FileMapping(this.isolatedFileSystemModel.mapping()); 435 436 this.workspace = new WebInspector.Workspace(); 436 437 this.networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(this.workspace);
Note: See TracChangeset
for help on using the changeset viewer.