Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 * @param {!Workspace.UILocation} uiLocation | 546 * @param {!Workspace.UILocation} uiLocation |
| 547 */ | 547 */ |
| 548 setExecutionLocation(uiLocation) { | 548 setExecutionLocation(uiLocation) { |
| 549 this._executionLocation = uiLocation; | 549 this._executionLocation = uiLocation; |
| 550 if (!this.loaded) | 550 if (!this.loaded) |
| 551 return; | 551 return; |
| 552 | 552 |
| 553 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum nNumber); | 553 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum nNumber); |
| 554 if (this.isShowing()) { | 554 if (this.isShowing()) { |
| 555 // We need SourcesTextEditor to be initialized prior to this call. @see cr bug.com/506566 | 555 // We need SourcesTextEditor to be initialized prior to this call. @see cr bug.com/506566 |
| 556 setImmediate(this._generateValuesInSource.bind(this)); | 556 setImmediate(() => { |
| 557 this._generateValuesInSource(); | |
| 558 if (Runtime.experiments.isEnabled('inlineContinueToLocation')) | |
| 559 this._showContinueToLocations(); | |
| 560 }); | |
| 557 } | 561 } |
| 558 } | 562 } |
| 559 | 563 |
| 560 _generateValuesInSource() { | 564 _generateValuesInSource() { |
| 561 if (!Common.moduleSetting('inlineVariableValues').get()) | 565 if (!Common.moduleSetting('inlineVariableValues').get()) |
| 562 return; | 566 return; |
| 563 var executionContext = UI.context.flavor(SDK.ExecutionContext); | 567 var executionContext = UI.context.flavor(SDK.ExecutionContext); |
| 564 if (!executionContext) | 568 if (!executionContext) |
| 565 return; | 569 return; |
| 566 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); | 570 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); |
| 567 if (!callFrame) | 571 if (!callFrame) |
| 568 return; | 572 return; |
| 569 | 573 |
| 570 var localScope = callFrame.localScope(); | 574 var localScope = callFrame.localScope(); |
| 571 var functionLocation = callFrame.functionLocation(); | 575 var functionLocation = callFrame.functionLocation(); |
| 572 if (localScope && functionLocation) { | 576 if (localScope && functionLocation) { |
| 573 Sources.SourceMapNamesResolver.resolveScopeInObject(localScope) | 577 Sources.SourceMapNamesResolver.resolveScopeInObject(localScope) |
| 574 .getAllProperties(false, false, this._prepareScopeVariables.bind(this, callFrame)); | 578 .getAllProperties(false, false, this._prepareScopeVariables.bind(this, callFrame)); |
| 575 } | 579 } |
| 576 | 580 |
| 577 if (this._clearValueWidgetsTimer) { | 581 if (this._clearValueWidgetsTimer) { |
| 578 clearTimeout(this._clearValueWidgetsTimer); | 582 clearTimeout(this._clearValueWidgetsTimer); |
| 579 delete this._clearValueWidgetsTimer; | 583 delete this._clearValueWidgetsTimer; |
| 580 } | 584 } |
| 581 } | 585 } |
| 582 | 586 |
| 587 _showContinueToLocations() { | |
| 588 var executionContext = UI.context.flavor(SDK.ExecutionContext); | |
| 589 if (!executionContext) | |
| 590 return; | |
| 591 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); | |
| 592 if (!callFrame) | |
| 593 return; | |
| 594 var localScope = callFrame.localScope(); | |
| 595 if (!localScope) | |
| 596 return; | |
| 597 var start = localScope.startLocation(); | |
| 598 var end = localScope.endLocation(); | |
| 599 var executionLocation = callFrame.location(); | |
| 600 var debuggerModel = callFrame.debuggerModel; | |
| 601 debuggerModel.getPossibleBreakpoints(start, end, true) | |
| 602 .then(locations => this.textEditor.operation(renderLocations.bind(this, locations))); | |
| 603 | |
| 604 if (this._clearContinueToLocationsTimer) { | |
| 605 clearTimeout(this._clearContinueToLocationsTimer); | |
| 606 delete this._clearContinueToLocationsTimer; | |
| 607 } | |
| 608 | |
| 609 /** | |
| 610 * @param {!Array<!SDK.DebuggerModel.Location>} locations | |
| 611 * @this {Sources.JavaScriptSourceFrame} | |
| 612 */ | |
| 613 function renderLocations(locations) { | |
| 614 var bookmarks = this.textEditor.bookmarks( | |
| 615 this.textEditor.fullRange(), Sources.JavaScriptSourceFrame.continueToL ocationDecorationSymbol); | |
| 616 this.textEditor.operation(() => bookmarks.map(bookmark => bookmark.clear() )); | |
|
dgozman
2017/02/24 19:49:42
This function is already run as operation. Just ca
kozy
2017/02/24 20:04:46
Done.
| |
| 617 | |
| 618 for (var location of locations) { | |
| 619 if (location.lineNumber === executionLocation.lineNumber && | |
| 620 location.columnNumber === executionLocation.columnNumber) | |
| 621 continue; | |
|
dgozman
2017/02/24 19:49:42
So, the current one will appear/disappear anyway?
kozy
2017/02/24 20:04:46
Yes..
I removed this logic because in case of more
| |
| 622 var icon = UI.Icon.create('smallicon-green-ball'); | |
| 623 icon.classList.add('cm-continue-to-location'); | |
| 624 icon.addEventListener('click', location.continueToLocation.bind(location )); | |
| 625 icon.addEventListener('mousemove', hidePopoverAndConsumeEvent.bind(this) ); | |
| 626 this.textEditor.addBookmark( | |
| 627 location.lineNumber, location.columnNumber, icon, | |
| 628 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol); | |
| 629 } | |
| 630 } | |
| 631 | |
| 632 /** | |
| 633 * @param {!Event} event | |
| 634 * @this {Sources.JavaScriptSourceFrame} | |
| 635 */ | |
| 636 function hidePopoverAndConsumeEvent(event) { | |
| 637 event.consume(true); | |
| 638 this._popoverHelper.hidePopover(); | |
| 639 } | |
| 640 } | |
| 641 | |
| 583 /** | 642 /** |
| 584 * @param {!SDK.DebuggerModel.CallFrame} callFrame | 643 * @param {!SDK.DebuggerModel.CallFrame} callFrame |
| 585 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 644 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 586 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 645 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 587 */ | 646 */ |
| 588 _prepareScopeVariables(callFrame, properties, internalProperties) { | 647 _prepareScopeVariables(callFrame, properties, internalProperties) { |
| 589 if (!properties || !properties.length || properties.length > 500 || !this.is Showing()) { | 648 if (!properties || !properties.length || properties.length > 500 || !this.is Showing()) { |
| 590 this._clearValueWidgets(); | 649 this._clearValueWidgets(); |
| 591 return; | 650 return; |
| 592 } | 651 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 this.textEditor.addDecoration(widget, i); | 780 this.textEditor.addDecoration(widget, i); |
| 722 } | 781 } |
| 723 } | 782 } |
| 724 } | 783 } |
| 725 | 784 |
| 726 clearExecutionLine() { | 785 clearExecutionLine() { |
| 727 if (this.loaded && this._executionLocation) | 786 if (this.loaded && this._executionLocation) |
| 728 this.textEditor.clearExecutionLine(); | 787 this.textEditor.clearExecutionLine(); |
| 729 delete this._executionLocation; | 788 delete this._executionLocation; |
| 730 this._clearValueWidgetsTimer = setTimeout(this._clearValueWidgets.bind(this) , 1000); | 789 this._clearValueWidgetsTimer = setTimeout(this._clearValueWidgets.bind(this) , 1000); |
| 790 if (Runtime.experiments.isEnabled('inlineContinueToLocation')) | |
| 791 this._clearContinueToLocationsTimer = setTimeout(this._clearContinueToLoca tions.bind(this), 1000); | |
| 731 } | 792 } |
| 732 | 793 |
| 733 _clearValueWidgets() { | 794 _clearValueWidgets() { |
| 734 delete this._clearValueWidgetsTimer; | 795 delete this._clearValueWidgetsTimer; |
| 735 for (var line of this._valueWidgets.keys()) | 796 for (var line of this._valueWidgets.keys()) |
| 736 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); | 797 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); |
| 737 this._valueWidgets.clear(); | 798 this._valueWidgets.clear(); |
| 738 } | 799 } |
| 739 | 800 |
| 801 _clearContinueToLocations() { | |
| 802 delete this._clearContinueToLocationsTimer; | |
| 803 var bookmarks = this.textEditor.bookmarks( | |
| 804 this.textEditor.fullRange(), Sources.JavaScriptSourceFrame.continueToLoc ationDecorationSymbol); | |
| 805 this.textEditor.operation(() => bookmarks.map(bookmark => bookmark.clear())) ; | |
| 806 } | |
| 807 | |
| 740 /** | 808 /** |
| 741 * @param {number} lineNumber | 809 * @param {number} lineNumber |
| 742 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} | 810 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} |
| 743 */ | 811 */ |
| 744 _lineBreakpointDecorations(lineNumber) { | 812 _lineBreakpointDecorations(lineNumber) { |
| 745 return Array.from(this._breakpointDecorations) | 813 return Array.from(this._breakpointDecorations) |
| 746 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); | 814 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); |
| 747 } | 815 } |
| 748 | 816 |
| 749 /** | 817 /** |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1375 hide() { | 1443 hide() { |
| 1376 if (!this.bookmark) | 1444 if (!this.bookmark) |
| 1377 return; | 1445 return; |
| 1378 this.bookmark.clear(); | 1446 this.bookmark.clear(); |
| 1379 this.bookmark = null; | 1447 this.bookmark = null; |
| 1380 } | 1448 } |
| 1381 }; | 1449 }; |
| 1382 | 1450 |
| 1383 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); | 1451 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); |
| 1384 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); | 1452 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); |
| 1453 | |
| 1454 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark'); | |
| OLD | NEW |