Changeset 92051 in webkit
- Timestamp:
- Jul 30, 2011 5:42:56 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r92049 r92051 1 2011-07-26 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: move location conversion functions to SourceFile. 4 https://bugs.webkit.org/show_bug.cgi?id=65185 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/debugger/source-file-expected.txt: Added. 9 * inspector/debugger/source-file.html: Added. 10 1 11 2011-07-30 Csaba Osztrogonác <ossy@webkit.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r92047 r92051 1 2011-07-26 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: move location conversion functions to SourceFile. 4 https://bugs.webkit.org/show_bug.cgi?id=65185 5 6 Reviewed by Pavel Feldman. 7 8 Test: inspector/debugger/source-file.html 9 10 * inspector/front-end/DebuggerPresentationModel.js: 11 (WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation.didCreateSourceMapping): 12 (WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation): 13 (WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation.didCreateSourceMapping): 14 (WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation): 15 * inspector/front-end/SourceFile.js: 16 (WebInspector.SourceFile.prototype.rawLocationToUILocation): 17 (WebInspector.SourceFile.prototype.uiLocationToRawLocation): 18 (WebInspector.SourceFile.prototype._scriptForRawLocation): 19 (WebInspector.SourceFile.prototype.createSourceMappingIfNeeded): 20 (WebInspector.FormattedSourceFile.prototype.createSourceMappingIfNeeded): 21 (WebInspector.FormattedSourceFile.prototype._didRequestContent): 22 1 23 2011-07-29 Rob Buis <rbuis@rim.com> 2 24 -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r91568 r92051 88 88 { 89 89 var sourceFile = this._sourceFileForScript(sourceURL, sourceId); 90 var scriptLocation = { lineNumber: lineNumber, columnNumber: columnNumber }; 91 92 function didRequestSourceMapping(mapping) 93 { 94 var lineNumber = mapping.scriptLocationToSourceLine(scriptLocation); 95 callback(sourceFile.id, lineNumber); 96 } 97 sourceFile.requestSourceMapping(didRequestSourceMapping); 90 91 function didCreateSourceMapping() 92 { 93 var uiLocation = sourceFile.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber }); 94 callback(uiLocation.sourceFile.id, uiLocation.lineNumber); 95 } 96 // FIXME: force source formatting if needed. This will go away once formatting 97 // is fully encapsulated in SourceFile. 98 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping); 98 99 }, 99 100 100 101 _uiLocationToScriptLocation: function(sourceFileId, lineNumber, callback) 101 102 { 102 function didRequestSourceMapping(mapping) 103 { 104 callback(mapping.sourceLineToScriptLocation(lineNumber)); 105 } 106 this._sourceFiles[sourceFileId].requestSourceMapping(didRequestSourceMapping.bind(this)); 103 var sourceFile = this._sourceFiles[sourceFileId]; 104 105 function didCreateSourceMapping() 106 { 107 var rawLocation = sourceFile.uiLocationToRawLocation(lineNumber, 0); 108 callback(rawLocation); 109 } 110 // FIXME: force source formatting if needed. This will go away once formatting 111 // is fully encapsulated in SourceFile. 112 sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping); 107 113 }, 108 114 -
trunk/Source/WebCore/inspector/front-end/SourceFile.js
r89428 r92051 53 53 }, 54 54 55 rawLocationToUILocation: function(rawLocation) 56 { 57 var uiLocation = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation; 58 uiLocation.sourceFile = this; 59 return uiLocation; 60 }, 61 62 uiLocationToRawLocation: function(lineNumber, columnNumber) 63 { 64 var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber }; 65 if (this._mapping) 66 rawLocation = this._mapping.formattedToOriginal(rawLocation); 67 rawLocation.sourceId = this._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).sourceId; 68 return rawLocation; 69 }, 70 71 _scriptForRawLocation: function(lineNumber, columnNumber) 72 { 73 var closestScript = this._scripts[0]; 74 for (var i = 1; i < this._scripts.length; ++i) { 75 script = this._scripts[i]; 76 if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber)) 77 continue; 78 if (script.lineOffset > closestScript.lineOffset || 79 (script.lineOffset === closestScript.lineOffset && script.columnOffset > closestScript.columnOffset)) 80 closestScript = script; 81 } 82 return closestScript; 83 }, 84 55 85 requestContent: function(callback) 56 86 { … … 75 105 }, 76 106 77 requestSourceMapping: function(callback) 78 { 79 if (!this._mapping) 80 this._mapping = new WebInspector.SourceMapping(this._scripts); 81 callback(this._mapping); 107 createSourceMappingIfNeeded: function(callback) 108 { 109 // Plain source without mapping. 110 callback(); 82 111 }, 83 112 … … 237 266 238 267 WebInspector.FormattedSourceFile.prototype = { 239 requestSourceMapping: function(callback)268 createSourceMappingIfNeeded: function(callback) 240 269 { 241 270 function didRequestContent() 242 271 { 243 callback(this._mapping); 244 } 272 callback(); 273 } 274 // Force content formatting to obtain the mapping. 245 275 this.requestContent(didRequestContent.bind(this)); 246 276 }, … … 250 280 function didFormatContent(formattedText, mapping) 251 281 { 252 this._mapping = new WebInspector.SourceMappingForFormattedSourceFile(this._scripts, mapping);282 this._mapping = mapping; 253 283 WebInspector.SourceFile.prototype._didRequestContent.call(this, mimeType, formattedText); 254 284 } … … 258 288 259 289 WebInspector.FormattedSourceFile.prototype.__proto__ = WebInspector.SourceFile.prototype; 260 261 WebInspector.SourceMapping = function(scripts)262 {263 this._sortedScripts = scripts.slice();264 this._sortedScripts.sort(function(x, y) { return x.lineOffset - y.lineOffset || x.columnOffset - y.columnOffset; });265 }266 267 WebInspector.SourceMapping.prototype = {268 scriptLocationToSourceLine: function(location)269 {270 return location.lineNumber;271 },272 273 sourceLineToScriptLocation: function(lineNumber)274 {275 return this._sourceLocationToScriptLocation(lineNumber, 0);276 },277 278 _sourceLocationToScriptLocation: function(lineNumber, columnNumber)279 {280 var closestScript = this._sortedScripts[0];281 for (var i = 1; i < this._sortedScripts.length; ++i) {282 script = this._sortedScripts[i];283 if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber))284 break;285 closestScript = script;286 }287 return { sourceId: closestScript.sourceId, lineNumber: lineNumber, columnNumber: columnNumber };288 }289 }290 291 WebInspector.SourceMappingForFormattedSourceFile = function(scripts, mapping)292 {293 WebInspector.SourceMapping.call(this, scripts);294 this._mapping = mapping;295 }296 297 WebInspector.SourceMappingForFormattedSourceFile.prototype = {298 scriptLocationToSourceLine: function(location)299 {300 return this._mapping.originalToFormatted(location).lineNumber;301 },302 303 sourceLineToScriptLocation: function(lineNumber)304 {305 var originalLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: 0 });306 return WebInspector.SourceMapping.prototype._sourceLocationToScriptLocation.call(this, originalLocation.lineNumber, originalLocation.columnNumber);307 }308 }309 310 WebInspector.SourceMappingForFormattedSourceFile.prototype.__proto__ = WebInspector.SourceMapping.prototype;
Note: See TracChangeset
for help on using the changeset viewer.