Changeset 96588 in webkit
- Timestamp:
- Oct 4, 2011 6:24:01 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96586 r96588 1 2011-10-04 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: update call frame location when source mapping is changed. 4 https://bugs.webkit.org/show_bug.cgi?id=68997 5 6 Currently we use fake "debugger-paused" event hack to update execution line and call stack placards when source mapping is changed. 7 - add PresentationCallFrame.createPlacard method to create "live" placards that are updated on source mapping changes. 8 - remove PresentationCallFrame functionName, isInternalScript, and url getters. 9 - fire execution-line-changed event when selected call frame or source mapping is changed. 10 11 Reviewed by Pavel Feldman. 12 13 * inspector/compile-front-end.sh: 14 * inspector/front-end/CallStackSidebarPane.js: 15 (WebInspector.CallStackSidebarPane.prototype.update): 16 * inspector/front-end/CompilerSourceMapping.js: 17 (WebInspector.ClosureCompilerSourceMappingPayload): 18 (WebInspector.ClosureCompilerSourceMapping): 19 (WebInspector.ClosureCompilerSourceMapping.prototype._parseMappings): 20 * inspector/front-end/ContentProviders.js: 21 (WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent): 22 (WebInspector.CompilerSourceMappingContentProvider.prototype.searchInContent): 23 * inspector/front-end/DebuggerPresentationModel.js: 24 (WebInspector.DebuggerPresentationModel): 25 (WebInspector.DebuggerPresentationModel.prototype.createPlacard.updatePlacard): 26 (WebInspector.DebuggerPresentationModel.prototype.createPlacard): 27 (WebInspector.DebuggerPresentationModel.prototype._debuggerPaused): 28 (WebInspector.DebuggerPresentationModel.prototype._debuggerResumed): 29 (WebInspector.DebuggerPresentationModel.prototype.set selectedCallFrame): 30 (WebInspector.DebuggerPresentationModel.prototype.get selectedCallFrame): 31 (WebInspector.DebuggerPresentationModel.prototype._dispatchExecutionLineChanged): 32 (WebInspector.DebuggerPresentationModel.prototype._debuggerReset): 33 (WebInspector.PresentationCallFrame): 34 (WebInspector.PresentationCallFrame.prototype.get rawSourceCode): 35 (WebInspector.PresentationCallFrame.prototype.uiLocation): 36 * inspector/front-end/ScriptsPanel.js: 37 (WebInspector.ScriptsPanel.prototype._debuggerPaused.else.didGetUILocation): 38 (WebInspector.ScriptsPanel.prototype._debuggerPaused): 39 (WebInspector.ScriptsPanel.prototype._executionLineChanged): 40 (WebInspector.ScriptsPanel.prototype._callFrameSelected): 41 * inspector/front-end/externs.js: 42 (WebInspector.displayNameForURL): 43 1 44 2011-10-04 Pavel Feldman <pfeldman@chromium.org> 2 45 -
trunk/Source/WebCore/inspector/compile-front-end.sh
r96584 r96588 45 45 --js Source/WebCore/inspector/front-end/Settings.js \ 46 46 --js Source/WebCore/inspector/front-end/UserMetrics.js \ 47 --module jsmodule_sdk:16:jsmodule_common \ 47 --module jsmodule_sdk:18:jsmodule_common \ 48 --js Source/WebCore/inspector/front-end/CompilerSourceMapping.js \ 49 --js Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js \ 48 50 --js Source/WebCore/inspector/front-end/ConsoleModel.js \ 49 51 --js Source/WebCore/inspector/front-end/ContentProviders.js \ -
trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js
r95554 r96588 49 49 for (var i = 0; i < callFrames.length; ++i) { 50 50 var callFrame = callFrames[i]; 51 var title = callFrame.functionName || WebInspector.UIString("(anonymous function)"); 52 53 var subtitle; 54 if (!callFrame.isInternalScript) 55 subtitle = WebInspector.displayNameForURL(callFrame.url); 56 else 57 subtitle = WebInspector.UIString("(internal script)"); 58 59 var placard = new WebInspector.Placard(title, subtitle); 51 var placard = this._model.createPlacard(callFrame); 60 52 placard.callFrame = callFrame; 61 53 placard.element.addEventListener("click", this._placardSelected.bind(this, placard), false); 62 63 function didGetSourceLine(placard, uiSourceCode, lineNumber)64 {65 if (placard.subtitle)66 placard.subtitle += ":" + (lineNumber + 1);67 else68 placard.subtitle = WebInspector.UIString("line %d", lineNumber + 1);69 placard._text = WebInspector.UIString("%s() at %s", placard.title, placard.subtitle);70 }71 callFrame.sourceLine(didGetSourceLine.bind(this, placard));72 73 54 this.placards.push(placard); 74 55 this.bodyElement.appendChild(placard.element); -
trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js
r95524 r96588 54 54 55 55 /** 56 * @constructor 57 */ 58 WebInspector.ClosureCompilerSourceMappingPayload = function() 59 { 60 this.mappings = ""; 61 this.sources = []; 62 } 63 64 /** 56 65 * Implements Source Map V3 consumer. See http://code.google.com/p/closure-compiler/wiki/SourceMaps 57 66 * for format description. 58 67 * @extends {WebInspector.CompilerSourceMapping} 59 68 * @constructor 60 */ 61 WebInspector.ClosureCompilerSourceMapping = function(payload) 69 * @param {WebInspector.ClosureCompilerSourceMappingPayload} mappingPayload 70 */ 71 WebInspector.ClosureCompilerSourceMapping = function(mappingPayload) 62 72 { 63 73 if (!WebInspector.ClosureCompilerSourceMapping.prototype._base64Map) { 64 base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";74 const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 65 75 WebInspector.ClosureCompilerSourceMapping.prototype._base64Map = {}; 66 76 for (var i = 0; i < base64Digits.length; ++i) … … 68 78 } 69 79 70 this._sources = payload.sources;80 this._sources = mappingPayload.sources; 71 81 this._mappings = []; 72 82 this._reverseMappingsBySourceURL = {}; 73 83 for (var i = 0; i < this._sources.length; ++i) 74 84 this._reverseMappingsBySourceURL[this._sources[i]] = []; 75 this._parseMappings( payload.mappings);85 this._parseMappings(mappingPayload); 76 86 } 77 87 … … 116 126 }, 117 127 118 _parseMappings: function(mapping sPayload)119 { 120 var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(mapping sPayload);128 _parseMappings: function(mappingPayload) 129 { 130 var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(mappingPayload.mappings); 121 131 122 132 var lineNumber = 0; -
trunk/Source/WebCore/inspector/front-end/ContentProviders.js
r96585 r96588 178 178 } 179 179 this._compilerSourceMappingProvider.loadSourceCode(this._sourceURL, didLoadSourceCode.bind(this)); 180 }, 181 182 searchInContent: function(query, callback) 183 { 184 callback([]); 180 185 } 181 186 } -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r96585 r96588 39 39 this._rawSourceCode = {}; 40 40 this._presentationCallFrames = []; 41 this._selectedCallFrameIndex = 0;42 41 43 42 this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bind(this), WebInspector.debuggerModel); … … 64 63 DebuggerPaused: "debugger-paused", 65 64 DebuggerResumed: "debugger-resumed", 66 CallFrameSelected: "call-frame-selected" 65 CallFrameSelected: "call-frame-selected", 66 ExecutionLineChanged: "execution-line-changed" 67 67 } 68 68 … … 92 92 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, updateAnchor, this); 93 93 return anchor; 94 }, 95 96 createPlacard: function(callFrame) 97 { 98 var title = callFrame._callFrame.functionName || WebInspector.UIString("(anonymous function)"); 99 var placard = new WebInspector.Placard(title, ""); 100 101 var rawSourceCode = callFrame._rawSourceCode; 102 function updatePlacard() 103 { 104 var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(callFrame._callFrame.location); 105 placard.subtitle = WebInspector.displayNameForURL(uiLocation.uiSourceCode.url) + ":" + (uiLocation.lineNumber + 1); 106 placard._text = WebInspector.UIString("%s() at %s", placard.title, placard.subtitle); 107 } 108 if (rawSourceCode.sourceMapping) 109 updatePlacard.call(this); 110 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, updatePlacard, this); 111 return placard; 94 112 }, 95 113 … … 355 373 for (var i = 0; i < callFrames.length; ++i) { 356 374 var callFrame = callFrames[i]; 357 var rawSourceCode;358 375 var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId); 359 if (script) 360 rawSourceCode = this._rawSourceCodeForScript(script); 376 if (!script) 377 continue; 378 var rawSourceCode = this._rawSourceCodeForScript(script); 361 379 this._presentationCallFrames.push(new WebInspector.PresentationCallFrame(callFrame, i, this, rawSourceCode)); 362 380 } … … 364 382 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerPaused, { callFrames: this._presentationCallFrames, details: details }); 365 383 366 this.selectedCallFrame = this._presentationCallFrames[ this._selectedCallFrameIndex];384 this.selectedCallFrame = this._presentationCallFrames[0]; 367 385 }, 368 386 … … 370 388 { 371 389 this._presentationCallFrames = []; 372 this. _selectedCallFrameIndex = 0;390 this.selectedCallFrame = null; 373 391 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerResumed); 374 392 }, … … 376 394 set selectedCallFrame(callFrame) 377 395 { 378 this._selectedCallFrameIndex = callFrame.index; 379 callFrame.select(); 396 if (this._selectedCallFrame) 397 this._selectedCallFrame.rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, this._dispatchExecutionLineChanged, this); 398 this._selectedCallFrame = callFrame; 399 if (!this._selectedCallFrame) 400 return; 401 402 this._selectedCallFrame.rawSourceCode.forceUpdateSourceMapping(); 380 403 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, callFrame); 404 405 if (this._selectedCallFrame.rawSourceCode.sourceMapping) 406 this._dispatchExecutionLineChanged(null); 407 this._selectedCallFrame.rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, this._dispatchExecutionLineChanged, this); 381 408 }, 382 409 383 410 get selectedCallFrame() 384 411 { 385 return this._presentationCallFrames[this._selectedCallFrameIndex]; 412 return this._selectedCallFrame; 413 }, 414 415 _dispatchExecutionLineChanged: function(event) 416 { 417 var rawLocation = this._selectedCallFrame._callFrame.location; 418 var uiLocation = this._selectedCallFrame.rawSourceCode.sourceMapping.rawLocationToUILocation(rawLocation); 419 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ExecutionLineChanged, uiLocation); 386 420 }, 387 421 … … 418 452 _debuggerReset: function() 419 453 { 454 for (var id in this._rawSourceCode) 455 this._rawSourceCode[id].removeAllListeners(); 420 456 this._rawSourceCode = {}; 421 457 this._presentationCallFrames = []; 422 this._selectedCallFrame Index = 0;458 this._selectedCallFrame = null; 423 459 this._breakpointManager.debuggerReset(); 424 460 } … … 436 472 this._model = model; 437 473 this._rawSourceCode = rawSourceCode; 438 this._script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId);439 474 } 440 475 441 476 WebInspector.PresentationCallFrame.prototype = { 442 get functionName()443 {444 return this._callFrame.functionName;445 },446 447 477 get type() 448 478 { … … 450 480 }, 451 481 452 get isInternalScript()453 {454 return !this._script;455 },456 457 get url()458 {459 if (this._rawSourceCode && this._rawSourceCode.sourceMapping)460 return this._rawSourceCode.sourceMapping.uiSourceCode.url;461 },462 463 482 get scopeChain() 464 483 { … … 476 495 }, 477 496 478 select: function() 479 { 480 if (this._rawSourceCode) 481 this._rawSourceCode.forceUpdateSourceMapping(); 497 get rawSourceCode() 498 { 499 return this._rawSourceCode; 482 500 }, 483 501 … … 500 518 }, 501 519 502 sourceLine: function(callback) 503 { 504 var rawLocation = this._callFrame.location; 505 if (!this._rawSourceCode) { 506 callback(undefined, rawLocation.lineNumber); 507 return; 508 } 509 510 if (this._rawSourceCode.sourceMapping) { 511 var uiLocation = this._rawSourceCode.sourceMapping.rawLocationToUILocation(rawLocation); 512 callback(uiLocation.uiSourceCode, uiLocation.lineNumber); 513 return; 514 } 515 516 function sourceMappingUpdated() 517 { 518 this._rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this); 519 var uiLocation = this._rawSourceCode.sourceMapping.rawLocationToUILocation(rawLocation); 520 callback(uiLocation.uiSourceCode, uiLocation.lineNumber); 521 } 522 this._rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this); 520 uiLocation: function(callback) 521 { 522 function sourceMappingReady() 523 { 524 this._rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingReady, this); 525 callback(this._rawSourceCode.sourceMapping.rawLocationToUILocation(this._callFrame.location)); 526 } 527 if (this._rawSourceCode.sourceMapping) 528 sourceMappingReady.call(this); 529 else 530 this._rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingReady, this); 523 531 } 524 532 } -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r96577 r96588 175 175 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerResumed, this._debuggerResumed, this); 176 176 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, this._callFrameSelected, this); 177 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ExecutionLineChanged, this._executionLineChanged, this); 177 178 178 179 var enableDebugger = Preferences.debuggerAlwaysEnabled || WebInspector.settings.debuggerEnabled.get(); … … 513 514 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", details.auxData.description)); 514 515 } else { 515 function didGet SourceLocation(uiSourceCode, lineNumber)516 function didGetUILocation(uiLocation) 516 517 { 517 if (! uiSourceCode || !this._presentationModel.findBreakpoint(uiSourceCode,lineNumber))518 if (!this._presentationModel.findBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber)) 518 519 return; 519 this.sidebarPanes.jsBreakpoints.highlightBreakpoint(ui SourceCode,lineNumber);520 this.sidebarPanes.jsBreakpoints.highlightBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber); 520 521 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a JavaScript breakpoint.")); 521 522 } 522 callFrames[0]. sourceLine(didGetSourceLocation.bind(this));523 callFrames[0].uiLocation(didGetUILocation.bind(this)); 523 524 } 524 525 … … 731 732 }, 732 733 734 _executionLineChanged: function(event) 735 { 736 var uiLocation = event.data; 737 738 this._clearCurrentExecutionLine(); 739 if (!uiLocation) 740 return; 741 742 if (!uiLocation.uiSourceCode._option) { 743 // Anonymous scripts are not added to files select by default. 744 this._addOptionToFilesSelect(uiLocation.uiSourceCode); 745 } 746 var sourceFrame = this._showSourceFrameAndAddToHistory(uiLocation.uiSourceCode); 747 sourceFrame.setExecutionLine(uiLocation.lineNumber); 748 this._executionSourceFrame = sourceFrame; 749 }, 750 733 751 _callFrameSelected: function(event) 734 752 { 735 753 var callFrame = event.data; 736 737 this._clearCurrentExecutionLine();738 754 739 755 if (!callFrame) … … 743 759 this.sidebarPanes.watchExpressions.refreshExpressions(); 744 760 this.sidebarPanes.callstack.selectedCallFrame = this._presentationModel.selectedCallFrame; 745 746 function didGetSourceLocation(uiSourceCode, lineNumber)747 {748 if (!uiSourceCode)749 return;750 751 if (!uiSourceCode._option) {752 // Anonymous scripts are not added to files select by default.753 this._addOptionToFilesSelect(uiSourceCode);754 }755 var sourceFrame = this._showSourceFrameAndAddToHistory(uiSourceCode);756 sourceFrame.setExecutionLine(lineNumber);757 this._executionSourceFrame = sourceFrame;758 }759 callFrame.sourceLine(didGetSourceLocation.bind(this));760 761 }, 761 762 -
trunk/Source/WebCore/inspector/front-end/externs.js
r96584 r96588 55 55 */ 56 56 WebInspector.formatLinkText = function(url, lineNumber) {} 57 58 /** 59 * @param {string} url 60 */ 61 WebInspector.displayNameForURL = function(url) {} 57 62 58 63 /**
Note: See TracChangeset
for help on using the changeset viewer.