Changeset 96585 in webkit
- Timestamp:
- Oct 4, 2011 5:32:51 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96583 r96585 1 2011-09-29 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: add compiler source mapping support to RawSourceCode. 4 https://bugs.webkit.org/show_bug.cgi?id=68891 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/debugger/breakpoint-manager.html: 9 * inspector/debugger/raw-source-code-expected.txt: 10 * inspector/debugger/raw-source-code.html: 11 1 12 2011-10-04 Hans Wennborg <hans@chromium.org> 2 13 -
trunk/LayoutTests/inspector/debugger/breakpoint-manager.html
r96097 r96585 70 70 var uiSourceCodeA = createUISourceCode("a.js", "a.js", 71 71 function(rawLocation) { return rawLocation; }, 72 function( lineNumber, columnNumber) { return { scriptId: "a.js", lineNumber: lineNumber, columnNumber: columnNumber}; });72 function(uiSourceCode, lineNumber) { return { scriptId: "a.js", lineNumber: lineNumber, columnNumber: 0 }; }); 73 73 var uiSourceCodeB = createUISourceCode("b.js", "b.js", 74 74 function(rawLocation) { return rawLocation; }, 75 function( lineNumber, columnNumber) { return { scriptId: "b.js", lineNumber: lineNumber, columnNumber: columnNumber}; });75 function(uiSourceCode, lineNumber) { return { scriptId: "b.js", lineNumber: lineNumber, columnNumber: 0 }; }); 76 76 77 77 function createBreakpointManager(breakpoints) … … 206 206 var uiSourceCodeC = createUISourceCode("c.js", "c.js", 207 207 function(rawLocation) { return rawLocation; }, 208 function( lineNumber, columnNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: columnNumber}; });208 function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: 0 }; }); 209 209 var uiSourceCodeCFormatted = createUISourceCode("deobfuscated:c.js", "c.js", 210 210 function(rawLocation) { return { lineNumber: rawLocation.lineNumber * 2, columnNumber: rawLocation.columnNumber * 2 }; }, 211 function( lineNumber, columnNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: Math.floor(columnNumber / 2)}; });211 function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 }; }); 212 212 213 213 breakpointManager.uiSourceCodeAdded(uiSourceCodeC); -
trunk/LayoutTests/inspector/debugger/raw-source-code-expected.txt
r94760 r96585 16 16 Running: testFormattingWithPendingResource 17 17 18 Running: testCompilerSourceMapping 19 -
trunk/LayoutTests/inspector/debugger/raw-source-code.html
r96097 r96585 112 112 InspectorTest.assertEquals(rawSourceCode, uiSourceCode.rawSourceCode); 113 113 checkUILocation(uiSourceCode, 0, 5, sourceMapping.rawLocationToUILocation(createRawLocation(0, 5))); 114 checkRawLocation(script, 0, 10, sourceMapping.uiLocationToRawLocation(0, 10));114 checkRawLocation(script, 10, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 10)); 115 115 uiSourceCode.requestContent(didRequestContent); 116 116 … … 175 175 rawSourceCode.forceUpdateSourceMapping(); 176 176 checkUILocation(uiSourceCode, 1, 20, sourceMapping.rawLocationToUILocation(createRawLocation(1, 20))); 177 checkRawLocation(script1, 1, 20, sourceMapping.uiLocationToRawLocation(1, 20));178 checkRawLocation(script2, 6, 2, sourceMapping.uiLocationToRawLocation(6, 2));177 checkRawLocation(script1, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 1)); 178 checkRawLocation(script2, 6, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 6)); 179 179 180 180 next(); … … 284 284 var uiSourceCode = sourceMapping.uiSourceCode; 285 285 checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2))); 286 checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(1, 2));286 checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2)); 287 287 uiSourceCode.requestContent(didRequestContent); 288 288 … … 302 302 var uiSourceCode = sourceMapping.uiSourceCode; 303 303 checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2))); 304 checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(2, 4));304 checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2)); 305 305 uiSourceCode.requestContent(didRequestFormattedContent); 306 306 } … … 320 320 var uiSourceCode = sourceMapping.uiSourceCode; 321 321 checkUILocation(uiSourceCode, 1, 2, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2))); 322 checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(1, 2));322 checkRawLocation(script, 2, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2)); 323 323 uiSourceCode.requestContent(didRequestNotFormattedContent); 324 324 } … … 349 349 var uiSourceCode = sourceMapping.uiSourceCode; 350 350 checkUILocation(uiSourceCode, 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2))); 351 checkRawLocation(script, 1, 2, sourceMapping.uiLocationToRawLocation(2, 4)); 351 checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCode, 2)); 352 next(); 353 } 354 }, 355 356 function testCompilerSourceMapping(next) 357 { 358 function createCompilerSourceMappingMock() 359 { 360 return { 361 compiledLocationToSourceLocation: function(lineNumber, columnNumber) 362 { 363 if (lineNumber < 10) 364 return { sourceURL: "source1.js", lineNumber: lineNumber * 2, columnNumber: columnNumber * 2 }; 365 return { sourceURL: "source2.js", lineNumber: (lineNumber - 10) * 2, columnNumber: columnNumber * 2 }; 366 }, 367 sourceLocationToCompiledLocation: function(sourceURL, lineNumber) 368 { 369 if (sourceURL === "source1.js") 370 return { lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 }; 371 return { lineNumber: Math.floor(lineNumber / 2) + 10, columnNumber: 0 }; 372 }, 373 sources: function() { return ["source1.js", "source2.js"]; } 374 }; 375 } 376 function createCompilerSourceMappingProviderMock() 377 { 378 return { 379 loadSourceMapping: function(callback) { callback(createCompilerSourceMappingMock()); }, 380 loadSourceCode: function(url, callback) { callback("<content of " + url + ">"); } 381 } 382 } 383 384 var script = createScriptMock("compiled.js", 0, 0, true, "<script source>"); 385 var resource = createPendingResourceMock("script", "<resource content>"); 386 var rawSourceCode = createRawSourceCode(script, resource); 387 var uiSourceCodeList; 388 389 waitForSourceMappingEvent(rawSourceCode, checkMapping); 390 rawSourceCode.setCompilerSourceMappingProvider(createCompilerSourceMappingProviderMock()); 391 function checkMapping() 392 { 393 var sourceMapping = rawSourceCode.sourceMapping; 394 uiSourceCodeList = sourceMapping.uiSourceCodeList; 395 var uiSourceCodeByURL = {}; 396 for (var i = 0; i < uiSourceCodeList.length; ++i) 397 uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i]; 398 checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2))); 399 checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20))); 400 checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2)); 401 checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10)); 402 403 uiSourceCodeList[0].requestContent(didRequestContent1); 404 } 405 406 function didRequestContent1(mimeType, content) 407 { 408 InspectorTest.assertEquals("text/javascript", mimeType); 409 InspectorTest.assertEquals("<content of source1.js>", content); 410 uiSourceCodeList[1].requestContent(didRequestContent2); 411 } 412 413 function didRequestContent2(mimeType, content) 414 { 415 InspectorTest.assertEquals("text/javascript", mimeType); 416 InspectorTest.assertEquals("<content of source2.js>", content); 352 417 next(); 353 418 } -
trunk/Source/WebCore/ChangeLog
r96584 r96585 1 2011-09-29 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: add compiler source mapping support to RawSourceCode. 4 https://bugs.webkit.org/show_bug.cgi?id=68891 5 6 Reviewed by Pavel Feldman. 7 8 * WebCore.gypi: 9 * WebCore.vcproj/WebCore.vcproj: 10 * inspector/front-end/BreakpointManager.js: 11 (WebInspector.BreakpointManager.prototype.uiSourceCodeAdded): 12 (WebInspector.BreakpointManager.prototype.setBreakpoint): 13 (WebInspector.BreakpointManager.prototype._materializeBreakpoint): 14 * inspector/front-end/CompilerSourceMappingProvider.js: Added. 15 (WebInspector.CompilerSourceMappingProvider): 16 (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceMapping): 17 (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceCode): 18 * inspector/front-end/DebuggerPresentationModel.js: 19 (WebInspector.DebuggerPresentationModel.prototype.continueToLine): 20 * inspector/front-end/RawSourceCode.js: 21 (WebInspector.RawSourceCode.prototype.setCompilerSourceMappingProvider): 22 (WebInspector.RawSourceCode.prototype._resourceFinished): 23 (WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping): 24 (WebInspector.RawSourceCode.prototype._updateSourceMapping): 25 (WebInspector.RawSourceCode.prototype._createSourceMapping.didLoadSourceMapping): 26 (WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation): 27 (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation): 28 (WebInspector.RawSourceCode.CompilerSourceMapping): 29 (WebInspector.RawSourceCode.CompilerSourceMapping.prototype.rawLocationToUILocation): 30 (WebInspector.RawSourceCode.CompilerSourceMapping.prototype.uiLocationToRawLocation): 31 (WebInspector.RawSourceCode.CompilerSourceMapping.prototype.get uiSourceCodeList): 32 (WebInspector.CompilerSourceMappingProvider): 33 (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceMapping): 34 (WebInspector.CompilerSourceMappingProvider.prototype.loadSourceCode): 35 * inspector/front-end/UISourceCodeContentProviders.js: 36 (WebInspector.CompilerSourceMappingContentProvider): 37 (WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent): 38 * inspector/front-end/WebKit.qrc: 39 * inspector/front-end/inspector.html: 40 1 41 2011-10-04 Pavel Feldman <pfeldman@google.com> 2 42 -
trunk/Source/WebCore/WebCore.gypi
r96584 r96585 6216 6216 'inspector/front-end/Color.js', 6217 6217 'inspector/front-end/CompilerSourceMapping.js', 6218 'inspector/front-end/CompilerSourceMappingProvider.js', 6218 6219 'inspector/front-end/ConsoleMessage.js', 6219 6220 'inspector/front-end/ConsoleModel.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r96584 r96585 69102 69102 </File> 69103 69103 <File 69104 RelativePath="..\inspector\front-end\CompilerSourceMappingProvider.js" 69105 > 69106 </File> 69107 <File 69104 69108 RelativePath="..\inspector\front-end\ConsoleMessage.js" 69105 69109 > -
trunk/Source/WebCore/inspector/front-end/BreakpointManager.js
r96575 r96585 58 58 var breakpoint = breakpoints[lineNumber]; 59 59 breakpoint.uiSourceCode = uiSourceCode; 60 this._materializeBreakpoint(breakpoint );60 this._materializeBreakpoint(breakpoint, uiSourceCode.rawSourceCode.sourceMapping, uiSourceCode); 61 61 if (breakpoint._debuggerLocation) 62 62 this._breakpointDebuggerLocationChanged(breakpoint); … … 78 78 breakpoint.uiSourceCode = uiSourceCode; 79 79 this._addBreakpointToUI(breakpoint); 80 this._materializeBreakpoint(breakpoint );80 this._materializeBreakpoint(breakpoint, uiSourceCode.rawSourceCode.sourceMapping, uiSourceCode); 81 81 }, 82 82 … … 90 90 }, 91 91 92 _materializeBreakpoint: function(breakpoint )92 _materializeBreakpoint: function(breakpoint, sourceMapping, uiSourceCode) 93 93 { 94 94 if (!breakpoint.enabled || breakpoint._materialized) … … 96 96 97 97 breakpoint._materialized = true; 98 var rawLocation = breakpoint.uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(breakpoint.lineNumber, 0);98 var rawLocation = sourceMapping.uiLocationToRawLocation(uiSourceCode, breakpoint.lineNumber); 99 99 this._setBreakpointInDebugger(breakpoint, rawLocation); 100 100 }, -
trunk/Source/WebCore/inspector/front-end/ContentProviders.js
r96579 r96585 163 163 * @implements {WebInspector.ContentProvider} 164 164 */ 165 WebInspector.CompilerSourceMappingContentProvider = function(sourceURL, compilerSourceMappingProvider) 166 { 167 this._mimeType = "text/javascript"; 168 this._sourceURL = sourceURL; 169 this._compilerSourceMappingProvider = compilerSourceMappingProvider; 170 }; 171 172 WebInspector.CompilerSourceMappingContentProvider.prototype = { 173 requestContent: function(callback) 174 { 175 function didLoadSourceCode(sourceCode) 176 { 177 callback(this._mimeType, sourceCode); 178 } 179 this._compilerSourceMappingProvider.loadSourceCode(this._sourceURL, didLoadSourceCode.bind(this)); 180 } 181 } 182 183 WebInspector.CompilerSourceMappingContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype; 184 185 /** 186 * @constructor 187 * @implements {WebInspector.ContentProvider} 188 */ 165 189 WebInspector.StaticContentProvider = function(mimeType, content) 166 190 { -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r96579 r96585 284 284 continueToLine: function(uiSourceCode, lineNumber) 285 285 { 286 var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(lineNumber, 0); 286 // FIXME: use RawSourceCode.uiLocationToRawLocation. 287 var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber); 287 288 WebInspector.debuggerModel.continueToLocation(rawLocation); 288 289 }, -
trunk/Source/WebCore/inspector/front-end/RawSourceCode.js
r96313 r96585 79 79 }, 80 80 81 setCompilerSourceMappingProvider: function(provider) 82 { 83 if (provider) 84 this._useTemporaryContent = false; 85 this._compilerSourceMappingProvider = provider; 86 this._updateSourceMapping(); 87 }, 88 81 89 contentEdited: function() 82 90 { … … 86 94 _resourceFinished: function() 87 95 { 96 if (this._compilerSourceMappingProvider) 97 return; 88 98 this._useTemporaryContent = false; 89 99 this._updateSourceMapping(); … … 121 131 this._updateNeeded = false; 122 132 123 var originalContentProvider = this._createContentProvider(); 124 this._createSourceMapping(originalContentProvider, didCreateSourceMapping.bind(this)); 125 126 function didCreateSourceMapping(contentProvider, mapping) 133 this._createSourceMapping(didCreateSourceMapping.bind(this)); 134 135 function didCreateSourceMapping(sourceMapping) 127 136 { 128 137 this._updatingSourceMapping = false; 129 138 if (!this._updateNeeded) 130 this._saveSourceMapping( contentProvider, mapping);139 this._saveSourceMapping(sourceMapping); 131 140 else 132 141 this._updateSourceMapping(); … … 143 152 }, 144 153 145 _createSourceMapping: function(originalContentProvider, callback) 146 { 154 _createSourceMapping: function(callback) 155 { 156 if (this._compilerSourceMappingProvider) { 157 function didLoadSourceMapping(compilerSourceMapping) 158 { 159 var uiSourceCodeList = []; 160 var sourceURLs = compilerSourceMapping.sources(); 161 for (var i = 0; i < sourceURLs.length; ++i) { 162 var sourceURL = sourceURLs[i]; 163 var contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL, this._compilerSourceMappingProvider); 164 var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, this.isContentScript, this, contentProvider); 165 uiSourceCodeList.push(uiSourceCode); 166 } 167 var sourceMapping = new WebInspector.RawSourceCode.CompilerSourceMapping(this, uiSourceCodeList, compilerSourceMapping); 168 callback(sourceMapping); 169 } 170 this._compilerSourceMappingProvider.loadSourceMapping(didLoadSourceMapping.bind(this)); 171 return; 172 } 173 174 var originalContentProvider = this._createContentProvider(); 147 175 if (!this._formatted) { 148 176 var uiSourceCode = new WebInspector.UISourceCode(this.id, this.url, this.isContentScript, this, originalContentProvider); … … 194 222 }, 195 223 196 uiLocationToRawLocation: function(lineNumber, columnNumber) 197 { 198 var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber }; 224 uiLocationToRawLocation: function(uiSourceCode, lineNumber) 225 { 226 console.assert(uiSourceCode === this._uiSourceCode); 227 var rawLocation = { lineNumber: lineNumber, columnNumber: 0 }; 199 228 rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId; 200 229 return rawLocation; … … 224 253 }, 225 254 226 uiLocationToRawLocation: function(lineNumber, columnNumber) 227 { 228 var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: columnNumber }); 255 uiLocationToRawLocation: function(uiSourceCode, lineNumber) 256 { 257 console.assert(uiSourceCode === this._uiSourceCode); 258 var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: 0 }); 229 259 rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId; 230 260 return rawLocation; … … 234 264 { 235 265 return this._uiSourceCode; 266 } 267 } 268 269 /** 270 * @constructor 271 */ 272 WebInspector.RawSourceCode.CompilerSourceMapping = function(rawSourceCode, uiSourceCodeList, mapping) 273 { 274 this._rawSourceCode = rawSourceCode; 275 this._uiSourceCodeList = uiSourceCodeList; 276 this._mapping = mapping; 277 this._uiSourceCodeByURL = {}; 278 for (var i = 0; i < uiSourceCodeList.length; ++i) 279 this._uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i]; 280 } 281 282 WebInspector.RawSourceCode.CompilerSourceMapping.prototype = { 283 rawLocationToUILocation: function(rawLocation) 284 { 285 var location = this._mapping.compiledLocationToSourceLocation(rawLocation.lineNumber, rawLocation.columnNumber); 286 var uiSourceCode = this._uiSourceCodeByURL[location.sourceURL]; 287 return new WebInspector.UILocation(uiSourceCode, location.lineNumber, location.columnNumber); 288 }, 289 290 uiLocationToRawLocation: function(uiSourceCode, lineNumber) 291 { 292 var rawLocation = this._mapping.sourceLocationToCompiledLocation(uiSourceCode.url, lineNumber); 293 rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId; 294 return rawLocation; 295 }, 296 297 get uiSourceCodeList() 298 { 299 return this._uiSourceCodeList; 236 300 } 237 301 } -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r96584 r96585 17 17 <file>Color.js</file> 18 18 <file>CompilerSourceMapping.js</file> 19 <file>CompilerSourceMappingProvider.js</file> 19 20 <file>ConsoleMessage.js</file> 20 21 <file>ConsoleModel.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r96584 r96585 165 165 <script type="text/javascript" src="RawSourceCode.js"></script> 166 166 <script type="text/javascript" src="CompilerSourceMapping.js"></script> 167 <script type="text/javascript" src="CompilerSourceMappingProvider.js"></script> 167 168 <script type="text/javascript" src="DOMAgent.js"></script> 168 169 <script type="text/javascript" src="TimelineAgent.js"></script>
Note: See TracChangeset
for help on using the changeset viewer.