Changeset 74350 in webkit
- Timestamp:
- Dec 20, 2010 8:42:29 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r74343 r74350 1 2010-12-10 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: "Add conditional breakpoint" - create breakpoint only after condition is provided. 6 https://bugs.webkit.org/show_bug.cgi?id=50813 7 8 * inspector/front-end/SourceFrame.js: 9 (WebInspector.SourceFrame.prototype._addBreakpoint): 10 (WebInspector.SourceFrame.prototype._breakpointRemoved): 11 (WebInspector.SourceFrame.prototype._breakpointChanged): 12 (WebInspector.SourceFrame.prototype._setBreakpointDecoration): 13 (WebInspector.SourceFrame.prototype._removeBreakpointDecoration): 14 (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint.didEditBreakpointCondition): 15 (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint): 16 (WebInspector.SourceFrame.prototype._contextMenu.else.editBreakpointCondition.didEditBreakpointCondition): 17 (WebInspector.SourceFrame.prototype._contextMenu.else.editBreakpointCondition): 18 (WebInspector.SourceFrame.prototype._contextMenu): 19 (WebInspector.SourceFrame.prototype._editBreakpointCondition.finishEditing): 20 (WebInspector.SourceFrame.prototype._editBreakpointCondition): 21 (WebInspector.SourceFrame.prototype._continueToLine): 22 (WebInspector.SourceFrame.prototype._setBreakpoint): 23 1 24 2010-12-20 Andrei Popescu <andreip@google.com> 2 25 -
trunk/WebCore/inspector/front-end/SourceFrame.js
r74261 r74350 300 300 }, 301 301 302 _breakpointChanged: function(event)303 {304 var breakpoint = event.target;305 var lineNumber = breakpoint.line - 1;306 if (lineNumber >= this._textModel.linesCount)307 return;308 309 if (breakpoint.enabled)310 this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint-disabled");311 else312 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint-disabled");313 314 if (breakpoint.condition)315 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint-conditional");316 else317 this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint-conditional");318 },319 320 302 _updateExecutionLine: function(previousLine) 321 303 { … … 430 412 _addBreakpoint: function(breakpoint) 431 413 { 432 var lineNumber = breakpoint.line - 1; 433 if (lineNumber >= this._textModel.linesCount) 414 if (breakpoint.line > this._textModel.linesCount) 434 415 return; 435 416 … … 438 419 breakpoint.addEventListener("removed", this._breakpointRemoved, this); 439 420 440 breakpoint.sourceText = this._textModel.line(lineNumber); 441 442 this._textViewer.beginUpdates(); 443 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint"); 444 if (!breakpoint.enabled) 445 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint-disabled"); 446 if (breakpoint.condition) 447 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint-conditional"); 448 this._textViewer.endUpdates(); 421 breakpoint.sourceText = this._textModel.line(breakpoint.line - 1); 422 this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition); 449 423 }, 450 424 … … 457 431 breakpoint.removeEventListener("removed", null, this); 458 432 459 var lineNumber = breakpoint.line - 1; 433 this._removeBreakpointDecoration(breakpoint.line); 434 }, 435 436 _breakpointChanged: function(event) 437 { 438 var breakpoint = event.target; 439 this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition); 440 }, 441 442 _setBreakpointDecoration: function(lineNumber, enabled, hasCondition) 443 { 444 lineNumber -= 1; 445 this._textViewer.beginUpdates(); 446 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint"); 447 if (enabled) 448 this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint-disabled"); 449 else 450 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint-disabled"); 451 if (hasCondition) 452 this._textViewer.addDecoration(lineNumber, "webkit-breakpoint-conditional"); 453 else 454 this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint-conditional"); 455 this._textViewer.endUpdates(); 456 }, 457 458 _removeBreakpointDecoration: function(lineNumber) 459 { 460 lineNumber -= 1; 460 461 this._textViewer.beginUpdates(); 461 462 this._textViewer.removeDecoration(lineNumber, "webkit-breakpoint"); … … 486 487 function addConditionalBreakpoint() 487 488 { 488 this._setBreakpoint(lineNumber); 489 var breakpoint = this._findBreakpoint(lineNumber); 490 if (breakpoint) 491 this._editBreakpointCondition(breakpoint); 489 this._setBreakpointDecoration(lineNumber, true, true); 490 function didEditBreakpointCondition(committed, condition) 491 { 492 this._removeBreakpointDecoration(lineNumber); 493 if (committed) 494 this._setBreakpoint(lineNumber, condition); 495 } 496 this._editBreakpointCondition(lineNumber, "", didEditBreakpointCondition.bind(this)); 492 497 } 493 494 498 contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint…"), addConditionalBreakpoint.bind(this)); 495 499 } else { 496 500 // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable. 497 501 contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), breakpoint.remove.bind(breakpoint)); 498 contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), this._editBreakpointCondition.bind(this, breakpoint)); 502 function editBreakpointCondition() 503 { 504 function didEditBreakpointCondition(committed, condition) 505 { 506 if (committed) 507 breakpoint.condition = condition; 508 } 509 this._editBreakpointCondition(lineNumber, breakpoint.condition, didEditBreakpointCondition); 510 } 511 contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), editBreakpointCondition.bind(this)); 499 512 if (breakpoint.enabled) 500 513 contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), function() { breakpoint.enabled = false; }); … … 690 703 }, 691 704 692 _editBreakpointCondition: function(breakpoint) 693 { 694 this._showBreakpointConditionPopup(breakpoint.line); 695 696 function committed(element, newText) 705 _editBreakpointCondition: function(lineNumber, condition, callback) 706 { 707 lineNumber -= 1; 708 this._conditionElement = this._createConditionElement(lineNumber); 709 this._textViewer.addDecoration(lineNumber, this._conditionElement); 710 711 function finishEditing(committed, element, newText) 697 712 { 698 breakpoint.condition = newText; 699 dismissed.call(this); 700 } 701 702 function dismissed() 703 { 704 if (this._conditionElement) 705 this._textViewer.removeDecoration(breakpoint.line - 1, this._conditionElement); 713 this._textViewer.removeDecoration(lineNumber, this._conditionElement); 706 714 delete this._conditionEditorElement; 707 715 delete this._conditionElement; 708 } 709 710 var dismissedHandler = dismissed.bind(this); 711 this._conditionEditorElement.addEventListener("blur", dismissedHandler, false); 716 callback(committed, newText); 717 } 712 718 713 719 WebInspector.startEditing(this._conditionEditorElement, { 714 720 context: null, 715 commitHandler: committed.bind(this),716 cancelHandler: dismissedHandler721 commitHandler: finishEditing.bind(this, true), 722 cancelHandler: finishEditing.bind(this, false) 717 723 }); 718 this._conditionEditorElement.value = breakpoint.condition;724 this._conditionEditorElement.value = condition; 719 725 this._conditionEditorElement.select(); 720 },721 722 _showBreakpointConditionPopup: function(lineNumber)723 {724 this._conditionElement = this._createConditionElement(lineNumber);725 this._textViewer.addDecoration(lineNumber - 1, this._conditionElement);726 726 }, 727 727 … … 774 774 { 775 775 var sourceID = this._sourceIDForLine(lineNumber); 776 if (!sourceID) 777 return; 776 778 WebInspector.panels.scripts.continueToLine(sourceID, lineNumber); 777 779 }, … … 822 824 }, 823 825 824 _setBreakpoint: function(lineNumber )826 _setBreakpoint: function(lineNumber, condition) 825 827 { 826 828 var sourceID = this._sourceIDForLine(lineNumber); 827 WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber, true, ""); 829 if (!sourceID) 830 return; 831 WebInspector.debuggerModel.setBreakpoint(sourceID, lineNumber, true, condition); 828 832 if (!WebInspector.panels.scripts.breakpointsActivated) 829 833 WebInspector.panels.scripts.toggleBreakpointsClicked();
Note: See TracChangeset
for help on using the changeset viewer.