Changeset 116398 in webkit
- Timestamp:
- May 7, 2012 11:56:55 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/http/tests/inspector/debugger-test.js
r116077 r116398 218 218 InspectorTest.removeBreakpoint = function(sourceFrame, lineNumber) 219 219 { 220 var breakpoint = sourceFrame._breakpoints[lineNumber]; 221 breakpoint.remove(); 220 sourceFrame._breakpointManager.findBreakpoint(sourceFrame._uiSourceCode, lineNumber).remove(); 222 221 }; 223 222 -
trunk/Source/WebCore/ChangeLog
r116397 r116398 1 2012-05-05 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: make JavaScriptSourceFrame use breakpoint manager's breakpoints store. 4 https://bugs.webkit.org/show_bug.cgi?id=85714 5 6 Reviewed by Yury Semikhatsky. 7 8 It is currently using its own copy of breakpoints which is not necessary. 9 10 * inspector/front-end/BreakpointManager.js: 11 (WebInspector.BreakpointManager): 12 (WebInspector.BreakpointManager.prototype.restoreBreakpoints): 13 (WebInspector.BreakpointManager.prototype.setBreakpoint): 14 (WebInspector.BreakpointManager.prototype._innerSetBreakpoint): 15 (WebInspector.BreakpointManager.prototype.findBreakpoint): 16 (WebInspector.BreakpointManager.prototype.reset): 17 (WebInspector.BreakpointManager.prototype._debuggerReset): 18 (WebInspector.BreakpointManager.prototype._breakpointResolved): 19 (WebInspector.BreakpointManager.prototype._uiLocationAdded): 20 (WebInspector.BreakpointManager.prototype._uiLocationRemoved): 21 (WebInspector.BreakpointManager.Breakpoint.prototype._breakpointStorageId): 22 (WebInspector.BreakpointManager.Storage.prototype._restoreBreakpoints): 23 (set WebInspector.BreakpointManager.Storage.Item): 24 * inspector/front-end/JavaScriptSource.js: 25 (WebInspector.JavaScriptSource.prototype.consoleMessagesCleared): 26 (WebInspector.JavaScriptSource.prototype.breakpointStorageId): 27 * inspector/front-end/JavaScriptSourceFrame.js: 28 (WebInspector.JavaScriptSourceFrame): 29 (WebInspector.JavaScriptSourceFrame.prototype._onContentChanged): 30 (WebInspector.JavaScriptSourceFrame.prototype.populateLineGutterContextMenu): 31 (WebInspector.JavaScriptSourceFrame.prototype.beforeTextChanged): 32 (WebInspector.JavaScriptSourceFrame.prototype._onMouseDown): 33 (WebInspector.JavaScriptSourceFrame.prototype._breakpointAdded): 34 (WebInspector.JavaScriptSourceFrame.prototype._breakpointRemoved): 35 (WebInspector.JavaScriptSourceFrame.prototype.onTextViewerContentLoaded): 36 (WebInspector.JavaScriptSourceFrame.prototype._continueToLine): 37 (WebInspector.JavaScriptSourceFrame.prototype._updateBreakpointsAfterLiveEdit): 38 1 39 2012-05-07 Pavel Feldman <pfeldman@chromium.org> 2 40 -
trunk/Source/WebCore/inspector/front-end/BreakpointManager.js
r116397 r116398 44 44 this._breakpoints = []; 45 45 this._breakpointForDebuggerId = {}; 46 this._breakpoint ForUILocation = {};47 this._ uiSourceCodeIds = {};46 this._breakpointsForUILocation = {}; 47 this._sourceFilesWithRestoredBreakpoints = {}; 48 48 49 49 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this); … … 62 62 restoreBreakpoints: function(uiSourceCode) 63 63 { 64 if (!uiSourceCode.id || this._uiSourceCodeIds[uiSourceCode.id]) 65 return; 66 this._uiSourceCodeIds[uiSourceCode.id] = true; 64 var sourceFileId = uiSourceCode.breakpointStorageId(); 65 if (!sourceFileId || this._sourceFilesWithRestoredBreakpoints[sourceFileId]) 66 return; 67 this._sourceFilesWithRestoredBreakpoints[sourceFileId] = true; 67 68 68 69 // Erase provisional breakpoints prior to restoring them. … … 74 75 delete this._breakpointForDebuggerId[debuggerId]; 75 76 } 76 this._storage. restoreBreakpoints(uiSourceCode);77 this._storage._restoreBreakpoints(uiSourceCode); 77 78 }, 78 79 … … 82 83 * @param {string} condition 83 84 * @param {boolean} enabled 84 * @param {boolean=} doNotActivateBreakpoints85 85 * @return {WebInspector.BreakpointManager.Breakpoint} 86 86 */ 87 setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled, doNotActivateBreakpoints) 88 { 89 if (!doNotActivateBreakpoints) 90 this._debuggerModel.setBreakpointsActive(true); 91 87 setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled) 88 { 89 this._debuggerModel.setBreakpointsActive(true); 90 return this._innerSetBreakpoint(uiSourceCode, lineNumber, condition, enabled); 91 }, 92 93 /** 94 * @param {WebInspector.UISourceCode} uiSourceCode 95 * @param {number} lineNumber 96 * @param {string} condition 97 * @param {boolean} enabled 98 * @return {WebInspector.BreakpointManager.Breakpoint} 99 */ 100 _innerSetBreakpoint: function(uiSourceCode, lineNumber, condition, enabled) 101 { 92 102 var breakpoint = this.findBreakpoint(uiSourceCode, lineNumber); 93 103 if (breakpoint) { … … 107 117 findBreakpoint: function(uiSourceCode, lineNumber) 108 118 { 109 return this._breakpointForUILocation[uiSourceCode.id + ":" + lineNumber]; 119 var breakpoints = this._breakpointsForUILocation[uiSourceCode.id + ":" + lineNumber]; 120 return breakpoints ? breakpoints[0] : null; 110 121 }, 111 122 … … 147 158 this._debuggerModel.removeBreakpoint(debuggerId); 148 159 this._breakpointForDebuggerId = {}; 149 this._ uiSourceCodeIds = {};160 this._sourceFilesWithRestoredBreakpoints = {}; 150 161 }, 151 162 … … 158 169 } 159 170 this._breakpoints = []; 160 this._breakpoint ForUILocation = {};161 this._ uiSourceCodeIds = {};171 this._breakpointsForUILocation = {}; 172 this._sourceFilesWithRestoredBreakpoints = {}; 162 173 }, 163 174 … … 190 201 _uiLocationAdded: function(breakpoint, uiLocation) 191 202 { 192 this._breakpointForUILocation[uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber] = breakpoint; 203 var key = uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber; 204 var breakpoints = this._breakpointsForUILocation[key]; 205 if (!breakpoints) { 206 breakpoints = []; 207 this._breakpointsForUILocation[key] = breakpoints; 208 } 209 breakpoints.push(breakpoint); 193 210 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointAdded, {breakpoint: breakpoint, uiLocation: uiLocation}); 194 211 }, … … 200 217 _uiLocationRemoved: function(breakpoint, uiLocation) 201 218 { 202 delete this._breakpointForUILocation[uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber]; 219 var key = uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber; 220 var breakpoints = this._breakpointsForUILocation[key]; 221 if (!breakpoints) 222 return; 223 breakpoints.remove(breakpoint); 224 if (!breakpoints.length) 225 delete this._breakpointsForUILocation[key]; 203 226 this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation}); 204 227 } … … 389 412 _breakpointStorageId: function() 390 413 { 391 return this._primaryUILocation.uiSourceCode. id+ ":" + this._primaryUILocation.lineNumber;414 return this._primaryUILocation.uiSourceCode.breakpointStorageId() + ":" + this._primaryUILocation.lineNumber; 392 415 }, 393 416 … … 422 445 * @param {WebInspector.UISourceCode} uiSourceCode 423 446 */ 424 restoreBreakpoints: function(uiSourceCode)447 _restoreBreakpoints: function(uiSourceCode) 425 448 { 426 449 this._muted = true; 450 var breakpointStorageId = uiSourceCode.breakpointStorageId(); 427 451 for (var id in this._breakpoints) { 428 452 var breakpoint = this._breakpoints[id]; 429 if (breakpoint.sourceFileId === uiSourceCode.id)430 this._breakpointManager. setBreakpoint(uiSourceCode, breakpoint.lineNumber, breakpoint.condition, breakpoint.enabled, true);453 if (breakpoint.sourceFileId === breakpointStorageId) 454 this._breakpointManager._innerSetBreakpoint(uiSourceCode, breakpoint.lineNumber, breakpoint.condition, breakpoint.enabled); 431 455 } 432 456 delete this._muted; … … 471 495 { 472 496 var primaryUILocation = breakpoint.primaryUILocation(); 473 this.sourceFileId = primaryUILocation.uiSourceCode. id;497 this.sourceFileId = primaryUILocation.uiSourceCode.breakpointStorageId(); 474 498 this.lineNumber = primaryUILocation.lineNumber; 475 499 this.condition = breakpoint.condition(); -
trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js
r115961 r116398 68 68 this._consoleMessages = []; 69 69 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessagesCleared); 70 }, 71 72 /** 73 * @return {string} 74 */ 75 breakpointStorageId: function() 76 { 77 return this.id; 70 78 } 71 79 } -
trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
r115961 r116398 42 42 this._breakpointManager = this._model.breakpointManager; 43 43 this._uiSourceCode = uiSourceCode; 44 this._breakpoints = {};45 44 46 45 var locations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode); … … 122 121 var content = /** @type {string} */ event.data.content; 123 122 124 var breakpoints = {}; 125 for (var lineNumber in this._breakpoints) { 126 breakpoints[lineNumber] = this._breakpoints[lineNumber]; 127 this._breakpoints[lineNumber].remove(); 128 } 123 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode); 124 for (var i = 0; i < breakpointLocations.length; ++i) 125 breakpointLocations[i].breakpoint.remove(); 129 126 this.setContent(content, false, "text/javascript"); 130 this._updateBreakpointsAfterLiveEdit(oldContent, content, breakpoint s);127 this._updateBreakpointsAfterLiveEdit(oldContent, content, breakpointLocations); 131 128 }, 132 129 … … 135 132 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Continue to here" : "Continue to Here"), this._continueToLine.bind(this, lineNumber)); 136 133 137 var breakpoint = this._breakpoint s[lineNumber];134 var breakpoint = this._breakpointManager.findBreakpoint(this._uiSourceCode, lineNumber); 138 135 if (!breakpoint) { 139 136 // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint. … … 182 179 if (!this._isDirty) { 183 180 // Disable all breakpoints in the model, store them as muted breakpoints. 184 for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) { 185 var breakpointAttribute = this.textModel.getAttribute(lineNumber, "breakpoint"); 186 if (breakpointAttribute) { 187 var breakpoint = this._breakpoints[lineNumber]; 188 if (breakpoint) 189 breakpoint.remove(); 190 // Re-adding decoration only. 191 this._addBreakpointDecoration(lineNumber, breakpointAttribute.condition, breakpointAttribute.enabled, true); 192 } 181 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode); 182 var lineNumbers = {}; 183 for (var i = 0; i < breakpointLocations.length; ++i) { 184 var breakpoint = breakpointLocations[i].breakpoint; 185 breakpointLocations[i].breakpoint.remove(); 186 // Re-adding decoration only. 187 this._addBreakpointDecoration(breakpointLocations[i].uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), true); 193 188 } 194 189 } … … 388 383 var lineNumber = target.lineNumber; 389 384 390 var breakpoint = this._breakpoint s[lineNumber];385 var breakpoint = this._breakpointManager.findBreakpoint(this._uiSourceCode, lineNumber); 391 386 if (breakpoint) { 392 387 if (event.shiftKey) … … 504 499 505 500 var breakpoint = /** @type {WebInspector.BreakpointManager.Breakpoint} */ event.data.breakpoint; 506 this._breakpoints[uiLocation.lineNumber] = breakpoint;507 501 if (this.loaded) 508 502 this._addBreakpointDecoration(uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), false); … … 516 510 517 511 var breakpoint = /** @type {WebInspector.BreakpointManager.Breakpoint} */ event.data.breakpoint; 518 if (this._breakpoints[uiLocation.lineNumber] !== breakpoint) 519 return; 520 delete this._breakpoints[uiLocation.lineNumber]; 521 if (this.loaded) 512 var remainingBreakpoint = this._breakpointManager.findBreakpoint(this._uiSourceCode, uiLocation.lineNumber); 513 if (!remainingBreakpoint && this.loaded) { 522 514 this._removeBreakpointDecoration(uiLocation.lineNumber); 515 } 523 516 }, 524 517 … … 540 533 this.setExecutionLine(this._executionLineNumber); 541 534 542 for (var lineNumber in this._breakpoints) { 543 var breakpoint = this._breakpoints[lineNumber]; 544 this._addBreakpointDecoration(parseInt(lineNumber, 10), breakpoint.condition(), breakpoint.enabled(), false); 535 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode); 536 for (var i = 0; i < breakpointLocations.length; ++i) { 537 var breakpoint = breakpointLocations[i].breakpoint; 538 this._addBreakpointDecoration(breakpointLocations[i].uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), false); 545 539 } 546 540 … … 573 567 * @param {string} oldSource 574 568 * @param {string} newSource 575 * @param { Object.<string, WebInspector.BreakpointManager.Breakpoint>} breakpoints576 */ 577 _updateBreakpointsAfterLiveEdit: function(oldSource, newSource, breakpoint s)569 * @param {Array.<Object>} breakpointLocations 570 */ 571 _updateBreakpointsAfterLiveEdit: function(oldSource, newSource, breakpointLocations) 578 572 { 579 573 // Clear and re-create breakpoints according to text diff. 580 574 var diff = Array.diff(oldSource.split("\n"), newSource.split("\n")); 581 for (var lineNumber in breakpoints) { 575 for (var i = 0; i < breakpointLocations.length; ++i) { 576 var lineNumber = breakpointLocations[i].uiLocation.lineNumber; 582 577 var newLineNumber = diff.left[lineNumber].row; 583 578 if (newLineNumber === undefined) { … … 595 590 } 596 591 if (newLineNumber !== undefined) { 597 var breakpoint = breakpoint s[lineNumber];592 var breakpoint = breakpointLocations[i].breakpoint; 598 593 this._setBreakpoint(newLineNumber, breakpoint.condition(), breakpoint.enabled()); 599 594 }
Note: See TracChangeset
for help on using the changeset viewer.