Changeset 116789 in webkit
- Timestamp:
- May 11, 2012 11:31:41 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/inspector/debugger/script-formatter-console-expected.txt
r99405 r116789 6 6 Running: testConsoleMessagesForFormattedScripts 7 7 script-formatter-console.html:10 8 Pre-format row message list: 9 ["9"] 10 ["9"] 8 11 script-formatter-console.html:13 12 Post-format row message list: 13 ["12"] 14 ["12"] 9 15 Debugger was disabled. 10 16 -
trunk/LayoutTests/inspector/debugger/script-formatter-console.html
r116775 r116789 8 8 function f1() 9 9 { 10 console. log("Test message.");10 console.error("Test message."); 11 11 } 12 12 … … 31 31 { 32 32 dumpConsoleMessageURLs(); 33 InspectorTest.addResult("Pre-format row message list:"); 34 InspectorTest.addResult(JSON.stringify(Object.keys(sourceFrame._rowMessages))); 35 InspectorTest.addResult(JSON.stringify(Object.keys(sourceFrame._messageBubbles))); 33 36 sourceFrame._uiSourceCode.setFormatted(true, didFormatLinkText); 34 37 } … … 37 40 { 38 41 dumpConsoleMessageURLs(); 42 InspectorTest.addResult("Post-format row message list:"); 43 InspectorTest.addResult(JSON.stringify(Object.keys(sourceFrame._rowMessages))); 44 InspectorTest.addResult(JSON.stringify(Object.keys(sourceFrame._messageBubbles))); 39 45 next(); 40 46 } -
trunk/Source/WebCore/ChangeLog
r116788 r116789 1 2012-05-11 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: extract PresentationConsoleMessageHelper from DebuggerPresentationModel. 4 https://bugs.webkit.org/show_bug.cgi?id=86229 5 6 Reviewed by Vsevolod Vlasov. 7 8 This change also starts tracking messages along with the live location changes. 9 10 Tested with script-formatter-console.html. 11 12 * inspector/front-end/BreakpointManager.js: 13 * inspector/front-end/DebuggerPresentationModel.js: 14 (WebInspector.DebuggerPresentationModel): 15 (WebInspector.DebuggerPresentationModel.prototype._parsedScriptSource): 16 (WebInspector.DebuggerPresentationModel.prototype._debuggerReset): 17 (WebInspector.PresentationConsoleMessageHelper): 18 (WebInspector.PresentationConsoleMessageHelper.prototype._addPendingConsoleMessage): 19 (WebInspector.PresentationConsoleMessageHelper.prototype._parsedScriptSource): 20 (WebInspector.PresentationConsoleMessageHelper.prototype._debuggerReset): 21 (WebInspector.PresentationConsoleMessage): 22 * inspector/front-end/JavaScriptSourceFrame.js: 23 (WebInspector.JavaScriptSourceFrame.prototype.populateLineGutterContextMenu): 24 (WebInspector.JavaScriptSourceFrame.prototype._consoleMessageAdded): 25 (WebInspector.JavaScriptSourceFrame.prototype._setBreakpoint): 26 1 27 2012-05-11 Emil A Eklund <eae@chromium.org> 2 28 -
trunk/Source/WebCore/inspector/front-end/BreakpointManager.js
r116775 r116789 499 499 this.enabled = breakpoint.enabled(); 500 500 } 501 502 /** @type {WebInspector.BreakpointManager} */ 503 WebInspector.breakpointManager = null; -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r116780 r116789 38 38 this._scriptMapping.addEventListener(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this); 39 39 40 this._pendingConsoleMessages = {};41 this._consoleMessageLiveLocations = [];42 43 40 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this); 44 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._ failedToParseScriptSource, this);41 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this); 45 42 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this); 46 43 47 WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);48 WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);49 50 44 new WebInspector.DebuggerPresentationModelResourceBinding(this); 45 new WebInspector.PresentationConsoleMessageHelper(); 51 46 } 52 47 … … 59 54 WebInspector.DebuggerPresentationModel.prototype = { 60 55 /** 61 * @param {DebuggerAgent.Location} rawLocation62 * @param {function(WebInspector.UILocation):(boolean|undefined)} updateDelegate63 * @return {WebInspector.LiveLocation}64 */65 createLiveLocation: function(rawLocation, updateDelegate)66 {67 var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);68 return script.createLiveLocation(rawLocation, updateDelegate);69 },70 71 /**72 56 * @param {WebInspector.Event} event 73 57 */ … … 76 60 var script = /** @type {WebInspector.Script} */ event.data; 77 61 this._scriptMapping.addScript(script); 78 this._addPendingConsoleMessagesToScript(script);79 },80 81 /**82 * @param {WebInspector.Event} event83 */84 _failedToParseScriptSource: function(event)85 {86 this._parsedScriptSource(event);87 62 }, 88 63 … … 153 128 }, 154 129 130 _debuggerReset: function() 131 { 132 this._scriptMapping.reset(); 133 } 134 } 135 136 WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.Object.prototype; 137 138 /** 139 * @constructor 140 */ 141 WebInspector.PresentationConsoleMessageHelper = function() 142 { 143 this._pendingConsoleMessages = {}; 144 this._presentationConsoleMessages = []; 145 146 WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this); 147 WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this); 148 149 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this); 150 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this); 151 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this); 152 } 153 154 WebInspector.PresentationConsoleMessageHelper.prototype = { 155 155 /** 156 156 * @param {WebInspector.Event} event … … 175 175 _addConsoleMessageToScript: function(message, rawLocation) 176 176 { 177 function updateLocation(uiLocation) 178 { 179 var presentationMessage = new WebInspector.PresentationConsoleMessage(uiLocation.uiSourceCode, uiLocation.lineNumber, message); 180 uiLocation.uiSourceCode.consoleMessageAdded(presentationMessage); 181 } 182 var liveLocation = this.createLiveLocation(rawLocation, updateLocation.bind(this)); 183 this._consoleMessageLiveLocations.push(liveLocation); 177 this._presentationConsoleMessages.push(new WebInspector.PresentationConsoleMessage(message, rawLocation)); 184 178 }, 185 179 … … 195 189 196 190 /** 197 * @param {WebInspector.Script} script 198 */ 199 _addPendingConsoleMessagesToScript: function(script) 200 { 191 * @param {WebInspector.Event} event 192 */ 193 _parsedScriptSource: function(event) 194 { 195 var script = /** @type {WebInspector.Script} */ event.data; 196 201 197 var messages = this._pendingConsoleMessages[script.sourceURL]; 202 198 if (!messages) … … 222 218 { 223 219 this._pendingConsoleMessages = {}; 224 for (var i = 0; i < this._ consoleMessageLiveLocations.length; ++i)225 this._ consoleMessageLiveLocations[i].dispose();226 this._ consoleMessageLiveLocations = [];227 var uiSourceCodes = this.uiSourceCodes();220 for (var i = 0; i < this._presentationConsoleMessages.length; ++i) 221 this._presentationConsoleMessages[i].dispose(); 222 this._presentationConsoleMessages = []; 223 var uiSourceCodes = WebInspector.debuggerPresentationModel.uiSourceCodes(); 228 224 for (var i = 0; i < uiSourceCodes.length; ++i) 229 225 uiSourceCodes[i].consoleMessagesCleared(); 230 226 }, 231 227 232 /**233 * @param {WebInspector.UISourceCode} uiSourceCode234 * @param {number} lineNumber235 */236 continueToLine: function(uiSourceCode, lineNumber)237 {238 var rawLocation = uiSourceCode.uiLocationToRawLocation(lineNumber, 0);239 WebInspector.debuggerModel.continueToLocation(rawLocation);240 },241 242 228 _debuggerReset: function() 243 229 { 244 this._scriptMapping.reset();245 230 this._pendingConsoleMessages = {}; 246 this._ consoleMessageLiveLocations = [];231 this._presentationConsoleMessages = []; 247 232 } 248 233 } 249 234 250 WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.Object.prototype;251 252 235 /** 253 236 * @constructor 254 * @param {WebInspector.UISourceCode} uiSourceCode 255 * @param {number} lineNumber 256 * @param {WebInspector.ConsoleMessage} originalMessage 257 */ 258 WebInspector.PresentationConsoleMessage = function(uiSourceCode, lineNumber, originalMessage) 237 * @param {WebInspector.ConsoleMessage} message 238 * @param {DebuggerAgent.Location} rawLocation 239 */ 240 WebInspector.PresentationConsoleMessage = function(message, rawLocation) 259 241 { 260 this.uiSourceCode = uiSourceCode; 261 this.lineNumber = lineNumber; 262 this.originalMessage = originalMessage; 242 this.originalMessage = message; 243 this._liveLocation = WebInspector.debuggerModel.createLiveLocation(rawLocation, this._updateLocation.bind(this)); 244 } 245 246 WebInspector.PresentationConsoleMessage.prototype = { 247 /** 248 * @param {WebInspector.UILocation} uiLocation 249 */ 250 _updateLocation: function(uiLocation) 251 { 252 if (this._uiLocation) 253 this._uiLocation.uiSourceCode.consoleMessageRemoved(this); 254 this._uiLocation = uiLocation; 255 this._uiLocation.uiSourceCode.consoleMessageAdded(this); 256 }, 257 258 get lineNumber() 259 { 260 return this._uiLocation.lineNumber; 261 }, 262 263 dispose: function() 264 { 265 this._liveLocation.dispose(); 266 } 263 267 } 264 268 -
trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js
r116780 r116789 41 41 WebInspector.UISourceCode.call(this, id, url, contentProvider, sourceMapping); 42 42 43 /**44 * @type {Array.<WebInspector.PresentationConsoleMessage>}45 */46 this._consoleMessages = [];47 43 this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping(); 48 44 // FIXME: postpone breakpoints restore to after the mapping has been established. … … 54 50 55 51 WebInspector.JavaScriptSource.prototype = { 56 /**57 * @return {Array.<WebInspector.PresentationConsoleMessage>}58 */59 consoleMessages: function()60 {61 return this._consoleMessages;62 },63 64 /**65 * @param {WebInspector.PresentationConsoleMessage} message66 */67 consoleMessageAdded: function(message)68 {69 this._consoleMessages.push(message);70 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessageAdded, message);71 },72 73 consoleMessagesCleared: function()74 {75 this._consoleMessages = [];76 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessagesCleared);77 },78 79 52 /** 80 53 * @param {?string} content -
trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
r116780 r116789 60 60 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this); 61 61 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded, this._consoleMessageAdded, this); 62 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageRemoved, this._consoleMessageRemoved, this); 62 63 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this); 63 64 } … … 143 144 } else { 144 145 // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable. 145 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove breakpoint" : "Remove Breakpoint"), breakpoint.remove.bind( this));146 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove breakpoint" : "Remove Breakpoint"), breakpoint.remove.bind(breakpoint)); 146 147 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Edit breakpoint…" : "Edit Breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber, breakpoint)); 147 148 if (breakpoint.enabled()) … … 521 522 _consoleMessageAdded: function(event) 522 523 { 523 var message = event.data;524 var message = /** @type {WebInspector.PresentationConsoleMessage} */ event.data; 524 525 if (this.loaded) 525 526 this.addMessageToSource(message.lineNumber, message.originalMessage); 527 }, 528 529 _consoleMessageRemoved: function(event) 530 { 531 var message = /** @type {WebInspector.PresentationConsoleMessage} */ event.data; 532 if (this.loaded) 533 this.removeMessageFromSource(message.lineNumber, message.originalMessage); 526 534 }, 527 535 … … 564 572 _continueToLine: function(lineNumber) 565 573 { 566 this._model.continueToLine(this._uiSourceCode, lineNumber); 574 var rawLocation = this._uiSourceCode.uiLocationToRawLocation(lineNumber, 0); 575 WebInspector.debuggerModel.continueToLocation(rawLocation); 567 576 }, 568 577 -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r115813 r116789 474 474 }, 475 475 476 removeMessageFromSource: function(lineNumber, msg) 477 { 478 if (lineNumber >= this._textModel.linesCount) 479 lineNumber = this._textModel.linesCount - 1; 480 if (lineNumber < 0) 481 lineNumber = 0; 482 483 var rowMessages = this._rowMessages[lineNumber]; 484 for (var i = 0; rowMessages && i < rowMessages.length; ++i) { 485 var rowMessage = rowMessages[i]; 486 if (rowMessage.consoleMessage !== msg) 487 continue; 488 489 var messageLineElement = rowMessage.element; 490 var messageBubbleElement = messageLineElement.parentElement; 491 messageBubbleElement.removeChild(messageLineElement); 492 rowMessages.remove(rowMessage); 493 if (!rowMessages.length) 494 delete this._rowMessages[lineNumber]; 495 if (!messageBubbleElement.childElementCount) { 496 this._textViewer.removeDecoration(lineNumber, messageBubbleElement); 497 delete this._messageBubbles[lineNumber]; 498 } 499 break; 500 } 501 }, 502 476 503 populateLineGutterContextMenu: function(contextMenu, lineNumber) 477 504 { -
trunk/Source/WebCore/inspector/front-end/UISourceCode.js
r116775 r116789 52 52 this._requestContentCallbacks = []; 53 53 this._liveLocations = []; 54 /** 55 * @type {Array.<WebInspector.PresentationConsoleMessage>} 56 */ 57 this._consoleMessages = []; 54 58 } 55 59 … … 57 61 ContentChanged: "ContentChanged", 58 62 ConsoleMessageAdded: "ConsoleMessageAdded", 63 ConsoleMessageRemoved: "ConsoleMessageRemoved", 59 64 ConsoleMessagesCleared: "ConsoleMessagesCleared" 60 65 } … … 207 212 * @return {Array.<WebInspector.PresentationConsoleMessage>} 208 213 */ 209 consoleMessages: function() {} 214 consoleMessages: function() 215 { 216 return this._consoleMessages; 217 }, 218 219 /** 220 * @param {WebInspector.PresentationConsoleMessage} message 221 */ 222 consoleMessageAdded: function(message) 223 { 224 this._consoleMessages.push(message); 225 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessageAdded, message); 226 }, 227 228 /** 229 * @param {WebInspector.PresentationConsoleMessage} message 230 */ 231 consoleMessageRemoved: function(message) 232 { 233 this._consoleMessages.remove(message); 234 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessageRemoved, message); 235 }, 236 237 consoleMessagesCleared: function() 238 { 239 this._consoleMessages = []; 240 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessagesCleared); 241 } 210 242 } 211 243
Note: See TracChangeset
for help on using the changeset viewer.