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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin gChanged, this); | 62 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin gChanged, this); |
| 63 this.uiSourceCode().addEventListener( | 63 this.uiSourceCode().addEventListener( |
| 64 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); | 64 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); |
| 65 this.uiSourceCode().addEventListener( | 65 this.uiSourceCode().addEventListener( |
| 66 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); | 66 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); |
| 67 this.uiSourceCode().addEventListener( | 67 this.uiSourceCode().addEventListener( |
| 68 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); | 68 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); |
| 69 | 69 |
| 70 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ | 70 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ |
| 71 this._breakpointDecorations = new Set(); | 71 this._breakpointDecorations = new Set(); |
| 72 this._waitForInlineDecorationsForTest = 0; | |
| 72 | 73 |
| 73 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ | 74 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ |
| 74 this._scriptFileForTarget = new Map(); | 75 this._scriptFileForTarget = new Map(); |
| 75 var targets = SDK.targetManager.targets(); | 76 var targets = SDK.targetManager.targets(); |
| 76 for (var i = 0; i < targets.length; ++i) { | 77 for (var i = 0; i < targets.length; ++i) { |
| 77 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode , targets[i]); | 78 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode , targets[i]); |
| 78 if (scriptFile) | 79 if (scriptFile) |
| 79 this._updateScriptFile(targets[i]); | 80 this._updateScriptFile(targets[i]); |
| 80 } | 81 } |
| 81 | 82 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 * @override | 205 * @override |
| 205 * @return {!Promise} | 206 * @return {!Promise} |
| 206 */ | 207 */ |
| 207 populateLineGutterContextMenu(contextMenu, lineNumber) { | 208 populateLineGutterContextMenu(contextMenu, lineNumber) { |
| 208 /** | 209 /** |
| 209 * @this {Sources.JavaScriptSourceFrame} | 210 * @this {Sources.JavaScriptSourceFrame} |
| 210 */ | 211 */ |
| 211 function populate(resolve, reject) { | 212 function populate(resolve, reject) { |
| 212 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); | 213 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); |
| 213 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 214 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 214 var breakpoints = this._lineBreakpointDecorations(lineNumber).map(decorati on => decoration.breakpoint); | 215 var breakpoints = this._lineBreakpointDecorations(lineNumber) |
| 216 .map(decoration => decoration.breakpoint) | |
| 217 .filter(breakpoint => !!breakpoint); | |
| 215 if (!breakpoints.length) { | 218 if (!breakpoints.length) { |
| 216 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. | |
| 217 contextMenu.appendItem( | 219 contextMenu.appendItem( |
| 218 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); | 220 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); |
| 219 contextMenu.appendItem( | 221 contextMenu.appendItem( |
| 220 Common.UIString('Add conditional breakpoint\u2026'), this._editBreak pointCondition.bind(this, lineNumber)); | 222 Common.UIString('Add conditional breakpoint\u2026'), |
| 223 this._editBreakpointCondition.bind(this, lineNumber, null, null)); | |
| 221 contextMenu.appendItem( | 224 contextMenu.appendItem( |
| 222 Common.UIString('Never pause here'), this._createNewBreakpoint.bind( this, lineNumber, 'false', true)); | 225 Common.UIString('Never pause here'), this._createNewBreakpoint.bind( this, lineNumber, 'false', true)); |
| 223 } else { | 226 } else { |
| 224 var hasOneBreakpoint = breakpoints.length === 1; | 227 var hasOneBreakpoint = breakpoints.length === 1; |
| 225 var removeTitle = | 228 var removeTitle = |
| 226 hasOneBreakpoint ? Common.UIString('Remove breakpoint') : Common.UIS tring('Remove all breakpoints in line'); | 229 hasOneBreakpoint ? Common.UIString('Remove breakpoint') : Common.UIS tring('Remove all breakpoints in line'); |
| 227 contextMenu.appendItem(removeTitle, () => breakpoints.map(breakpoint => breakpoint.remove())); | 230 contextMenu.appendItem(removeTitle, () => breakpoints.map(breakpoint => breakpoint.remove())); |
| 228 if (hasOneBreakpoint) { | 231 if (hasOneBreakpoint) { |
| 229 contextMenu.appendItem( | 232 contextMenu.appendItem( |
| 230 Common.UIString('Edit breakpoint\u2026'), | 233 Common.UIString('Edit breakpoint\u2026'), |
| 231 this._editBreakpointCondition.bind(this, lineNumber, breakpoints[0 ])); | 234 this._editBreakpointCondition.bind(this, lineNumber, breakpoints[0 ], null)); |
| 232 } | 235 } |
| 233 var hasEnabled = breakpoints.some(breakpoint => breakpoint.enabled()); | 236 var hasEnabled = breakpoints.some(breakpoint => breakpoint.enabled()); |
| 234 if (hasEnabled) { | 237 if (hasEnabled) { |
| 235 var title = hasOneBreakpoint ? Common.UIString('Disable breakpoint') : | 238 var title = hasOneBreakpoint ? Common.UIString('Disable breakpoint') : |
| 236 Common.UIString('Disable all breakpoint s in line'); | 239 Common.UIString('Disable all breakpoint s in line'); |
| 237 contextMenu.appendItem(title, () => breakpoints.map(breakpoint => brea kpoint.setEnabled(false))); | 240 contextMenu.appendItem(title, () => breakpoints.map(breakpoint => brea kpoint.setEnabled(false))); |
| 238 } | 241 } |
| 239 var hasDisabled = breakpoints.some(breakpoint => !breakpoint.enabled()); | 242 var hasDisabled = breakpoints.some(breakpoint => !breakpoint.enabled()); |
| 240 if (hasDisabled) { | 243 if (hasDisabled) { |
| 241 var title = hasOneBreakpoint ? Common.UIString('Enable breakpoint') : | 244 var title = hasOneBreakpoint ? Common.UIString('Enable breakpoint') : |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 return; | 343 return; |
| 341 } | 344 } |
| 342 | 345 |
| 343 this._restoreBreakpointsAfterEditing(); | 346 this._restoreBreakpointsAfterEditing(); |
| 344 } | 347 } |
| 345 | 348 |
| 346 _restoreBreakpointsAfterEditing() { | 349 _restoreBreakpointsAfterEditing() { |
| 347 delete this._muted; | 350 delete this._muted; |
| 348 var decorations = Array.from(this._breakpointDecorations); | 351 var decorations = Array.from(this._breakpointDecorations); |
| 349 this._breakpointDecorations.clear(); | 352 this._breakpointDecorations.clear(); |
| 353 this._textEditor.operation(() => decorations.map(decoration => decoration.hi de())); | |
| 350 for (var decoration of decorations) { | 354 for (var decoration of decorations) { |
| 355 if (!decoration.breakpoint) | |
| 356 continue; | |
| 351 decoration.breakpoint.remove(); | 357 decoration.breakpoint.remove(); |
| 352 var location = decoration.handle.resolve(); | 358 var location = decoration.handle.resolve(); |
| 353 if (location) | 359 if (location) |
| 354 this._setBreakpoint(location.lineNumber, location.columnNumber, decorati on.condition, decoration.enabled); | 360 this._setBreakpoint(location.lineNumber, location.columnNumber, decorati on.condition, decoration.enabled); |
| 355 } | 361 } |
| 356 } | 362 } |
| 357 | 363 |
| 358 /** | 364 /** |
| 359 * @param {string} tokenType | 365 * @param {string} tokenType |
| 360 * @return {boolean} | 366 * @return {boolean} |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 if (event.key === 'Escape') { | 489 if (event.key === 'Escape') { |
| 484 if (this._popoverHelper.isPopoverVisible()) { | 490 if (this._popoverHelper.isPopoverVisible()) { |
| 485 this._popoverHelper.hidePopover(); | 491 this._popoverHelper.hidePopover(); |
| 486 event.consume(); | 492 event.consume(); |
| 487 } | 493 } |
| 488 } | 494 } |
| 489 } | 495 } |
| 490 | 496 |
| 491 /** | 497 /** |
| 492 * @param {number} lineNumber | 498 * @param {number} lineNumber |
| 493 * @param {!Bindings.BreakpointManager.Breakpoint=} breakpoint | 499 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint |
| 500 * @param {?{lineNumber: number, columnNumber: number}} location | |
| 494 */ | 501 */ |
| 495 _editBreakpointCondition(lineNumber, breakpoint) { | 502 _editBreakpointCondition(lineNumber, breakpoint, location) { |
| 496 this._conditionElement = this._createConditionElement(lineNumber); | 503 this._conditionElement = this._createConditionElement(lineNumber); |
| 497 this.textEditor.addDecoration(this._conditionElement, lineNumber); | 504 this.textEditor.addDecoration(this._conditionElement, lineNumber); |
| 498 | 505 |
| 499 /** | 506 /** |
| 500 * @this {Sources.JavaScriptSourceFrame} | 507 * @this {Sources.JavaScriptSourceFrame} |
| 501 */ | 508 */ |
| 502 function finishEditing(committed, element, newText) { | 509 function finishEditing(committed, element, newText) { |
| 503 this.textEditor.removeDecoration(this._conditionElement, lineNumber); | 510 this.textEditor.removeDecoration(this._conditionElement, lineNumber); |
| 504 delete this._conditionEditorElement; | 511 delete this._conditionEditorElement; |
| 505 delete this._conditionElement; | 512 delete this._conditionElement; |
| 506 if (!committed) | 513 if (!committed) |
| 507 return; | 514 return; |
| 508 | 515 |
| 509 if (breakpoint) | 516 if (breakpoint) |
| 510 breakpoint.setCondition(newText); | 517 breakpoint.setCondition(newText); |
| 518 else if (location) | |
| 519 this._setBreakpoint(location.lineNumber, location.columnNumber, newText, true); | |
| 511 else | 520 else |
| 512 this._createNewBreakpoint(lineNumber, newText, true); | 521 this._createNewBreakpoint(lineNumber, newText, true); |
| 513 } | 522 } |
| 514 | 523 |
| 515 var config = new UI.InplaceEditor.Config(finishEditing.bind(this, true), fin ishEditing.bind(this, false)); | 524 var config = new UI.InplaceEditor.Config(finishEditing.bind(this, true), fin ishEditing.bind(this, false)); |
| 516 UI.InplaceEditor.startEditing(this._conditionEditorElement, config); | 525 UI.InplaceEditor.startEditing(this._conditionEditorElement, config); |
| 517 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : ' '; | 526 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : ' '; |
| 518 this._conditionEditorElement.select(); | 527 this._conditionEditorElement.select(); |
| 519 } | 528 } |
| 520 | 529 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 /** | 739 /** |
| 731 * @param {number} lineNumber | 740 * @param {number} lineNumber |
| 732 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} | 741 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} |
| 733 */ | 742 */ |
| 734 _lineBreakpointDecorations(lineNumber) { | 743 _lineBreakpointDecorations(lineNumber) { |
| 735 return Array.from(this._breakpointDecorations) | 744 return Array.from(this._breakpointDecorations) |
| 736 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); | 745 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); |
| 737 } | 746 } |
| 738 | 747 |
| 739 /** | 748 /** |
| 749 * @param {number} lineNumber | |
| 750 * @param {number} columnNumber | |
| 751 * @return {?Sources.JavaScriptSourceFrame.BreakpointDecoration} | |
| 752 */ | |
| 753 _breakpointDecoration(lineNumber, columnNumber) { | |
| 754 for (var decoration of this._breakpointDecorations) { | |
| 755 var location = decoration.handle.resolve(); | |
| 756 if (!location) | |
| 757 continue; | |
| 758 if (location.lineNumber === lineNumber && location.columnNumber === column Number) | |
| 759 return decoration; | |
| 760 } | |
| 761 return null; | |
| 762 } | |
| 763 | |
| 764 /** | |
| 740 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | 765 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration |
| 741 */ | 766 */ |
| 742 _updateBreakpointDecoration(decoration) { | 767 _updateBreakpointDecoration(decoration) { |
| 743 if (!this._scheduledBreakpointDecorationUpdates) { | 768 if (!this._scheduledBreakpointDecorationUpdates) { |
| 744 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ | 769 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ |
| 745 this._scheduledBreakpointDecorationUpdates = new Set(); | 770 this._scheduledBreakpointDecorationUpdates = new Set(); |
| 746 setImmediate(() => this.textEditor.operation(update.bind(this))); | 771 setImmediate(() => this.textEditor.operation(update.bind(this))); |
| 747 } | 772 } |
| 748 this._scheduledBreakpointDecorationUpdates.add(decoration); | 773 this._scheduledBreakpointDecorationUpdates.add(decoration); |
| 749 | 774 |
| 750 /** | 775 /** |
| 751 * @this {Sources.JavaScriptSourceFrame} | 776 * @this {Sources.JavaScriptSourceFrame} |
| 752 */ | 777 */ |
| 753 function update() { | 778 function update() { |
| 754 var lineNumbers = new Set(); | 779 var lineNumbers = new Set(); |
| 755 for (var decoration of this._scheduledBreakpointDecorationUpdates) { | 780 for (var decoration of this._scheduledBreakpointDecorationUpdates) { |
| 756 var location = decoration.handle.resolve(); | 781 var location = decoration.handle.resolve(); |
| 757 if (!location) | 782 if (!location) |
| 758 continue; | 783 continue; |
| 759 lineNumbers.add(location.lineNumber); | 784 lineNumbers.add(location.lineNumber); |
| 760 } | 785 } |
| 786 delete this._scheduledBreakpointDecorationUpdates; | |
| 761 for (var lineNumber of lineNumbers) { | 787 for (var lineNumber of lineNumbers) { |
| 762 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); | 788 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); |
| 763 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); | 789 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); |
| 764 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); | 790 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); |
| 791 | |
| 765 var decorations = this._lineBreakpointDecorations(lineNumber); | 792 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 793 var actualBookmarks = | |
| 794 new Set(decorations.map(decoration => decoration.bookmark).filter(bo okmark => !!bookmark)); | |
| 795 var lineEnd = this._textEditor.line(lineNumber).length; | |
| 796 var bookmarks = this._textEditor.bookmarks( | |
| 797 new Common.TextRange(lineNumber, 0, lineEnd, 0), | |
| 798 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); | |
| 799 for (var bookmark of bookmarks) { | |
| 800 if (!actualBookmarks.has(bookmark)) | |
| 801 bookmark.clear(); | |
| 802 } | |
| 766 if (!decorations.length) | 803 if (!decorations.length) |
| 767 continue; | 804 continue; |
| 768 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); | 805 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); |
| 769 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); | 806 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); |
| 770 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted); | 807 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted); |
| 771 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition); | 808 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition); |
| 809 if (decorations.length > 1) { | |
|
lushnikov
2016/11/29 03:17:11
let's hide all decorations when we're editing file
kozy
2016/11/29 19:53:25
Done.
| |
| 810 for (var decoration of decorations) | |
| 811 decoration.update(); | |
| 812 } else { | |
| 813 decorations[0].hide(); | |
| 814 } | |
| 772 } | 815 } |
| 773 delete this._scheduledBreakpointDecorationUpdates; | |
| 774 this._breakpointDecorationsUpdatedForTest(); | 816 this._breakpointDecorationsUpdatedForTest(); |
| 775 } | 817 } |
| 776 } | 818 } |
| 777 | 819 |
| 778 _breakpointDecorationsUpdatedForTest() { | 820 _breakpointDecorationsUpdatedForTest() { |
| 779 } | 821 } |
| 780 | 822 |
| 781 /** | 823 /** |
| 824 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | |
| 825 * @param {!Event} event | |
| 826 */ | |
| 827 _inlineBreakpointClick(decoration, event) { | |
| 828 event.consume(true); | |
| 829 if (decoration.breakpoint) { | |
| 830 if (event.shiftKey) | |
| 831 decoration.breakpoint.setEnabled(!decoration.breakpoint.enabled()); | |
| 832 else | |
| 833 decoration.breakpoint.remove(); | |
| 834 } else { | |
| 835 var location = decoration.handle.resolve(); | |
| 836 if (!location) | |
| 837 return; | |
| 838 this._setBreakpoint(location.lineNumber, location.columnNumber, decoration .condition, true); | |
| 839 } | |
| 840 } | |
| 841 | |
| 842 /** | |
| 843 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | |
| 844 * @param {!Event} event | |
| 845 */ | |
| 846 _inlineBreakpointContextMenu(decoration, event) { | |
| 847 event.consume(true); | |
| 848 var location = decoration.handle.resolve(); | |
| 849 if (!location) | |
| 850 return; | |
| 851 var contextMenu = new UI.ContextMenu(event); | |
| 852 if (decoration.breakpoint) { | |
| 853 contextMenu.appendItem( | |
| 854 Common.UIString('Edit breakpoint\u2026'), | |
| 855 this._editBreakpointCondition.bind(this, location.lineNumber, decorati on.breakpoint, null)); | |
| 856 } else { | |
| 857 contextMenu.appendItem( | |
| 858 Common.UIString('Add conditional breakpoint\u2026'), | |
| 859 this._editBreakpointCondition.bind(this, location.lineNumber, null, lo cation)); | |
| 860 contextMenu.appendItem( | |
| 861 Common.UIString('Never pause here'), | |
| 862 this._setBreakpoint.bind(this, location.lineNumber, location.columnNum ber, 'false', true)); | |
| 863 } | |
| 864 contextMenu.show(); | |
| 865 } | |
| 866 | |
| 867 /** | |
| 782 * @param {!Common.Event} event | 868 * @param {!Common.Event} event |
| 783 * @return {boolean} | 869 * @return {boolean} |
| 784 */ | 870 */ |
| 785 _shouldIgnoreExternalBreakpointEvents(event) { | 871 _shouldIgnoreExternalBreakpointEvents(event) { |
| 786 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | 872 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); |
| 787 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) | 873 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) |
| 788 return true; | 874 return true; |
| 789 if (this._supportsEnabledBreakpointsWhileEditing()) | 875 if (this._supportsEnabledBreakpointsWhileEditing()) |
| 790 return false; | 876 return false; |
| 791 if (this._muted) | 877 if (this._muted) |
| 792 return true; | 878 return true; |
| 793 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 879 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 794 for (var i = 0; i < scriptFiles.length; ++i) { | 880 for (var i = 0; i < scriptFiles.length; ++i) { |
| 795 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) | 881 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) |
| 796 return true; | 882 return true; |
| 797 } | 883 } |
| 798 return false; | 884 return false; |
| 799 } | 885 } |
| 800 | 886 |
| 801 /** | 887 /** |
| 802 * @param {!Common.Event} event | 888 * @param {!Common.Event} event |
| 803 */ | 889 */ |
| 804 _breakpointAdded(event) { | 890 _breakpointAdded(event) { |
| 805 if (this._shouldIgnoreExternalBreakpointEvents(event)) | 891 if (this._shouldIgnoreExternalBreakpointEvents(event)) |
| 806 return; | 892 return; |
| 807 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | 893 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); |
| 808 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumber , uiLocation.columnNumber); | 894 var lineDecorations = this._lineBreakpointDecorations(uiLocation.lineNumber) ; |
| 809 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); | 895 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); |
| 810 var decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration(hand le, breakpoint); | 896 |
| 811 this._breakpointDecorations.add(decoration); | 897 var decoration = this._breakpointDecoration(uiLocation.lineNumber, uiLocatio n.columnNumber); |
| 898 if (decoration) { | |
| 899 decoration.breakpoint = breakpoint; | |
| 900 decoration.condition = breakpoint.condition(); | |
| 901 decoration.enabled = breakpoint.enabled(); | |
| 902 } else { | |
| 903 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumb er, uiLocation.columnNumber); | |
| 904 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( | |
| 905 this._textEditor, handle, breakpoint.condition(), breakpoint.enabled() , breakpoint); | |
| 906 decoration.element.addEventListener('click', this._inlineBreakpointClick.b ind(this, decoration), true); | |
| 907 decoration.element.addEventListener( | |
| 908 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration ), true); | |
| 909 this._breakpointDecorations.add(decoration); | |
| 910 } | |
| 812 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration; | 911 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration; |
| 813 this._updateBreakpointDecoration(decoration); | 912 this._updateBreakpointDecoration(decoration); |
| 913 if (!lineDecorations.length && Runtime.experiments.isEnabled('inlineBreakpoi nts')) { | |
| 914 this._waitForInlineDecorationsForTest++; | |
|
lushnikov
2016/11/29 03:17:11
it would be nice to not introduce test's state in
kozy
2016/11/29 19:53:25
Done.
| |
| 915 this._breakpointManager | |
| 916 .possibleBreakpoints( | |
| 917 this.uiSourceCode(), new Common.TextRange(uiLocation.lineNumber, 0 , uiLocation.lineNumber + 1, 0)) | |
| 918 .then(addInlineDecorations.bind(this, uiLocation.lineNumber)); | |
| 919 } | |
| 920 | |
| 921 /** | |
| 922 * @this {Sources.JavaScriptSourceFrame} | |
| 923 * @param {number} lineNumber | |
| 924 * @param {!Array<!Workspace.UILocation>} possibleLocations | |
| 925 */ | |
| 926 function addInlineDecorations(lineNumber, possibleLocations) { | |
| 927 this._waitForInlineDecorationsForTest--; | |
| 928 var decorations = this._lineBreakpointDecorations(lineNumber); | |
| 929 if (!decorations.some(decoration => !!decoration.breakpoint) || possibleLo cations.length <= 1) { | |
|
lushnikov
2016/11/29 03:17:11
Not needed: possibleLocations.length <= 1
kozy
2016/11/29 19:53:25
Done.
| |
| 930 this._breakpointDecorationsUpdatedForTest(); | |
| 931 return; | |
| 932 } | |
| 933 /** @type {!Set<number>} */ | |
| 934 var columns = new Set(); | |
| 935 for (var decoration of decorations) { | |
| 936 var location = decoration.handle.resolve(); | |
| 937 if (!location) | |
| 938 continue; | |
| 939 columns.add(location.columnNumber); | |
| 940 } | |
| 941 var wasScheduled = false; | |
| 942 for (var location of possibleLocations) { | |
| 943 if (columns.has(location.columnNumber)) | |
| 944 continue; | |
| 945 var handle = this._textEditor.textEditorPositionHandle(location.lineNumb er, location.columnNumber); | |
| 946 var decoration = | |
| 947 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this._textEdi tor, handle, '', false, null); | |
| 948 decoration.element.addEventListener('click', this._inlineBreakpointClick .bind(this, decoration), true); | |
| 949 decoration.element.addEventListener( | |
| 950 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati on), true); | |
| 951 this._breakpointDecorations.add(decoration); | |
| 952 wasScheduled = true; | |
| 953 this._updateBreakpointDecoration(decoration); | |
| 954 } | |
| 955 if (!wasScheduled) | |
| 956 this._breakpointDecorationsUpdatedForTest(); | |
| 957 } | |
| 814 } | 958 } |
| 815 | 959 |
| 816 /** | 960 /** |
| 817 * @param {!Common.Event} event | 961 * @param {!Common.Event} event |
| 818 */ | 962 */ |
| 819 _breakpointRemoved(event) { | 963 _breakpointRemoved(event) { |
| 820 if (this._shouldIgnoreExternalBreakpointEvents(event)) | 964 if (this._shouldIgnoreExternalBreakpointEvents(event)) |
| 821 return; | 965 return; |
| 966 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | |
| 822 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); | 967 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); |
| 823 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol]; | 968 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol]; |
| 824 if (!decoration) | 969 if (!decoration) |
| 825 return; | 970 return; |
| 826 this._breakpointDecorations.delete(decoration); | |
| 827 delete breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decora tionSymbol]; | 971 delete breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decora tionSymbol]; |
| 828 this._updateBreakpointDecoration(decoration); | 972 |
| 973 decoration.breakpoint = null; | |
| 974 decoration.enabled = false; | |
| 975 | |
| 976 var lineDecorations = this._lineBreakpointDecorations(uiLocation.lineNumber) ; | |
| 977 if (!lineDecorations.some(decoration => !!decoration.breakpoint)) { | |
| 978 for (var lineDecoration of lineDecorations) { | |
| 979 this._breakpointDecorations.delete(lineDecoration); | |
| 980 this._updateBreakpointDecoration(lineDecoration); | |
| 981 } | |
| 982 } else { | |
| 983 this._updateBreakpointDecoration(decoration); | |
| 984 } | |
| 829 } | 985 } |
| 830 | 986 |
| 831 /** | 987 /** |
| 832 * @param {!Common.Event} event | 988 * @param {!Common.Event} event |
| 833 */ | 989 */ |
| 834 _onSourceMappingChanged(event) { | 990 _onSourceMappingChanged(event) { |
| 835 var data = /** @type {{target: !SDK.Target}} */ (event.data); | 991 var data = /** @type {{target: !SDK.Target}} */ (event.data); |
| 836 this._updateScriptFile(data.target); | 992 this._updateScriptFile(data.target); |
| 837 this._updateLinesWithoutMappingHighlight(); | 993 this._updateLinesWithoutMappingHighlight(); |
| 838 } | 994 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 * @param {number} lineNumber | 1122 * @param {number} lineNumber |
| 967 * @param {boolean} onlyDisable | 1123 * @param {boolean} onlyDisable |
| 968 */ | 1124 */ |
| 969 _toggleBreakpoint(lineNumber, onlyDisable) { | 1125 _toggleBreakpoint(lineNumber, onlyDisable) { |
| 970 var decorations = this._lineBreakpointDecorations(lineNumber); | 1126 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 971 if (!decorations.length) { | 1127 if (!decorations.length) { |
| 972 this._createNewBreakpoint(lineNumber, '', true); | 1128 this._createNewBreakpoint(lineNumber, '', true); |
| 973 return; | 1129 return; |
| 974 } | 1130 } |
| 975 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled'); | 1131 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled'); |
| 976 var breakpoints = decorations.map(decoration => decoration.breakpoint); | 1132 var breakpoints = decorations.map(decoration => decoration.breakpoint).filte r(breakpoint => !!breakpoint); |
| 977 for (var breakpoint of breakpoints) { | 1133 for (var breakpoint of breakpoints) { |
| 978 if (onlyDisable) | 1134 if (onlyDisable) |
| 979 breakpoint.setEnabled(hasDisabled); | 1135 breakpoint.setEnabled(hasDisabled); |
| 980 else | 1136 else |
| 981 breakpoint.remove(); | 1137 breakpoint.remove(); |
| 982 } | 1138 } |
| 983 } | 1139 } |
| 984 | 1140 |
| 985 /** | 1141 /** |
| 986 * @param {number} lineNumber | 1142 * @param {number} lineNumber |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); | 1246 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); |
| 1091 super.dispose(); | 1247 super.dispose(); |
| 1092 } | 1248 } |
| 1093 }; | 1249 }; |
| 1094 | 1250 |
| 1095 /** | 1251 /** |
| 1096 * @unrestricted | 1252 * @unrestricted |
| 1097 */ | 1253 */ |
| 1098 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { | 1254 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { |
| 1099 /** | 1255 /** |
| 1256 * @param {!TextEditor.CodeMirrorTextEditor} textEditor | |
| 1100 * @param {!TextEditor.TextEditorPositionHandle} handle | 1257 * @param {!TextEditor.TextEditorPositionHandle} handle |
| 1101 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint | 1258 * @param {string} condition |
| 1259 * @param {boolean} enabled | |
| 1260 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint | |
| 1102 */ | 1261 */ |
| 1103 constructor(handle, breakpoint) { | 1262 constructor(textEditor, handle, condition, enabled, breakpoint) { |
| 1263 this._textEditor = textEditor; | |
| 1104 this.handle = handle; | 1264 this.handle = handle; |
| 1105 this.condition = breakpoint.condition(); | 1265 this.condition = condition; |
| 1106 this.enabled = breakpoint.enabled(); | 1266 this.enabled = enabled; |
| 1107 this.breakpoint = breakpoint; | 1267 this.breakpoint = breakpoint; |
| 1268 this.element = createElementWithClass('div', 'cm-inline-breakpoint'); | |
|
lushnikov
2016/11/29 03:17:11
you don't need a wrapper element - icon is HTMLEle
kozy
2016/11/29 19:53:25
Done.
| |
| 1269 | |
| 1270 /** @type {?TextEditor.TextEditorBookMark} */ | |
| 1271 this.bookmark = null; | |
| 1108 } | 1272 } |
| 1109 | 1273 |
| 1110 /** | 1274 /** |
| 1111 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1 | 1275 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1 |
| 1112 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2 | 1276 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2 |
| 1113 * @return {number} | 1277 * @return {number} |
| 1114 */ | 1278 */ |
| 1115 static mostSpecificFirst(decoration1, decoration2) { | 1279 static mostSpecificFirst(decoration1, decoration2) { |
| 1280 if (decoration1.enabled !== decoration2.enabled) | |
| 1281 return decoration1.enabled ? -1 : 1; | |
| 1116 if (!!decoration1.condition !== !!decoration2.condition) | 1282 if (!!decoration1.condition !== !!decoration2.condition) |
| 1117 return !!decoration1.condition ? -1 : 1; | 1283 return !!decoration1.condition ? -1 : 1; |
| 1118 if (decoration1.enabled !== decoration2.enabled) | |
| 1119 return decoration1.enabled ? -1 : 1; | |
| 1120 return 0; | 1284 return 0; |
| 1121 } | 1285 } |
| 1286 | |
| 1287 update() { | |
|
lushnikov
2016/11/29 03:17:11
update -> updateAndShow
kozy
2016/11/29 19:53:26
Done.
| |
| 1288 var location = this.handle.resolve(); | |
| 1289 if (!location) | |
| 1290 return; | |
| 1291 this.element.removeChildren(); | |
| 1292 if (!!this.condition) | |
| 1293 this.element.appendChild(UI.Icon.create('smallicon-inline-breakpoint')); | |
|
lushnikov
2016/11/29 03:17:11
this._icon.setIconType(...)
kozy
2016/11/29 19:53:25
Done.
| |
| 1294 else | |
| 1295 this.element.appendChild(UI.Icon.create('smallicon-inline-breakpoint-condi tional')); | |
| 1296 this.element.classList.toggle('cm-inline-disabled', !this.enabled); | |
| 1297 if (!this.bookmark) { | |
| 1298 this.bookmark = this._textEditor.addBookmark( | |
| 1299 location.lineNumber, location.columnNumber, this.element, | |
| 1300 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); | |
| 1301 this.bookmark[Sources.JavaScriptSourceFrame.BreakpointDecoration._elementS ymbolForTest] = this.element; | |
| 1302 } | |
| 1303 } | |
| 1304 | |
| 1305 hide() { | |
| 1306 if (!this.bookmark) | |
| 1307 return; | |
| 1308 this.bookmark.clear(); | |
| 1309 this.bookmark = null; | |
| 1310 } | |
| 1122 }; | 1311 }; |
| 1123 | 1312 |
| 1124 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); | 1313 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); |
| 1314 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); | |
| 1315 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); | |
| OLD | NEW |