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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 * @override | 204 * @override |
| 205 * @return {!Promise} | 205 * @return {!Promise} |
| 206 */ | 206 */ |
| 207 populateLineGutterContextMenu(contextMenu, lineNumber) { | 207 populateLineGutterContextMenu(contextMenu, lineNumber) { |
| 208 /** | 208 /** |
| 209 * @this {Sources.JavaScriptSourceFrame} | 209 * @this {Sources.JavaScriptSourceFrame} |
| 210 */ | 210 */ |
| 211 function populate(resolve, reject) { | 211 function populate(resolve, reject) { |
| 212 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); | 212 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); |
| 213 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 213 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 214 var breakpoints = this._lineBreakpointDecorations(lineNumber).map(decorati on => decoration.breakpoint); | 214 var breakpoints = this._lineBreakpointDecorations(lineNumber) |
| 215 .map(decoration => decoration.breakpoint) | |
| 216 .filter(breakpoint => !!breakpoint); | |
| 215 if (!breakpoints.length) { | 217 if (!breakpoints.length) { |
| 216 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. | 218 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. |
|
lushnikov
2016/11/28 20:35:19
The comment is outdated: there's no "Add and Edit
kozy
2016/11/29 02:12:36
Done.
| |
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(); |
| 350 for (var decoration of decorations) { | 353 for (var decoration of decorations) { |
| 354 decoration.hide(); | |
|
lushnikov
2016/11/28 20:35:19
don't you want to hide breakpoints in textEditor o
kozy
2016/11/29 02:12:36
Done.
| |
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 * @this {Sources.JavaScriptSourceFrame} | 760 * @this {Sources.JavaScriptSourceFrame} |
| 752 */ | 761 */ |
| 753 function update() { | 762 function update() { |
| 754 var lineNumbers = new Set(); | 763 var lineNumbers = new Set(); |
| 755 for (var decoration of this._scheduledBreakpointDecorationUpdates) { | 764 for (var decoration of this._scheduledBreakpointDecorationUpdates) { |
| 756 var location = decoration.handle.resolve(); | 765 var location = decoration.handle.resolve(); |
| 757 if (!location) | 766 if (!location) |
| 758 continue; | 767 continue; |
| 759 lineNumbers.add(location.lineNumber); | 768 lineNumbers.add(location.lineNumber); |
| 760 } | 769 } |
| 770 var promises = []; | |
| 761 for (var lineNumber of lineNumbers) { | 771 for (var lineNumber of lineNumbers) { |
| 762 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); | 772 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); |
| 763 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); | 773 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); |
| 764 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); | 774 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); |
| 765 var decorations = this._lineBreakpointDecorations(lineNumber); | 775 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 766 if (!decorations.length) | 776 if (!decorations.some(decoration => !!decoration.breakpoint)) { |
|
lushnikov
2016/11/28 20:35:19
"I can move this to breakpointRemoved" (Alexey)
kozy
2016/11/29 02:12:36
Done.
| |
| 777 for (var decoration of decorations) { | |
| 778 decoration.hide(); | |
| 779 this._breakpointDecorations.delete(decoration); | |
| 780 } | |
| 767 continue; | 781 continue; |
| 782 } | |
| 768 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); | 783 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); |
| 769 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); | 784 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); |
| 770 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted); | 785 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted); |
| 771 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition); | 786 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition); |
| 787 if (Runtime.experiments.isEnabled('inlineBreakpoints')) { | |
| 788 promises.push( | |
| 789 this._breakpointManager | |
| 790 .possibleBreakpoints(this.uiSourceCode(), new Common.TextRange (lineNumber, 0, lineNumber + 1, 0)) | |
| 791 .then( | |
| 792 locations => this._textEditor.operation(addInlineDecoratio ns.bind(this, lineNumber, locations)))); | |
| 793 } | |
| 772 } | 794 } |
| 773 delete this._scheduledBreakpointDecorationUpdates; | 795 delete this._scheduledBreakpointDecorationUpdates; |
| 774 this._breakpointDecorationsUpdatedForTest(); | 796 if (!promises.length) |
| 797 this._breakpointDecorationsUpdatedForTest(); | |
| 798 else | |
| 799 Promise.all(promises).then(() => this._breakpointDecorationsUpdatedForTe st()); | |
|
lushnikov
2016/11/28 20:35:19
don't you want to always do this?
kozy
2016/11/29 02:12:36
Done.
| |
| 800 } | |
| 801 | |
| 802 /** | |
| 803 * @this {Sources.JavaScriptSourceFrame} | |
| 804 * @param {number} lineNumber | |
| 805 * @param {!Array<!Workspace.UILocation>} possibleLocations | |
| 806 */ | |
| 807 function addInlineDecorations(lineNumber, possibleLocations) { | |
| 808 var decorations = this._lineBreakpointDecorations(lineNumber); | |
| 809 // Hide all inline decoration, remove decoration if decoration doesn't hav e a breakpoint. | |
| 810 for (var decoration of decorations) { | |
| 811 decoration.hide(); | |
| 812 if (!decoration.breakpoint) | |
| 813 this._breakpointDecorations.delete(decoration); | |
| 814 } | |
| 815 decorations = decorations.filter(decoration => !!decoration.breakpoint); | |
| 816 // If less then two locations or no real breakpoints in this line - don't show any inline decorations. | |
| 817 if (possibleLocations.length <= 1 || !decorations.length) | |
| 818 return; | |
| 819 // Add missing decorations for possible locations without breakpoint. | |
| 820 /** @type {!Set<number>} */ | |
| 821 var columns = new Set(); | |
| 822 for (var decoration of decorations) { | |
| 823 var location = decoration.handle.resolve(); | |
| 824 if (location) | |
| 825 columns.add(location.columnNumber); | |
| 826 } | |
| 827 for (var location of possibleLocations) { | |
| 828 if (columns.has(location.columnNumber)) | |
| 829 continue; | |
| 830 var handle = this._textEditor.textEditorPositionHandle(location.lineNumb er, location.columnNumber); | |
| 831 var decoration = | |
| 832 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this._textEdi tor, handle, '', false, null); | |
| 833 this._breakpointDecorations.add(decoration); | |
| 834 decorations.push(decoration); | |
| 835 } | |
| 836 // Render inline decorations. | |
| 837 for (var decoration of decorations) { | |
| 838 var element = decoration.show(); | |
| 839 if (!element) | |
| 840 continue; | |
| 841 element.addEventListener('click', this._inlineBreakpointClick.bind(this, decoration), true); | |
| 842 element.addEventListener('contextmenu', this._inlineBreakpointContextMen u.bind(this, decoration), true); | |
| 843 } | |
| 775 } | 844 } |
| 776 } | 845 } |
| 777 | 846 |
| 778 _breakpointDecorationsUpdatedForTest() { | 847 _breakpointDecorationsUpdatedForTest() { |
| 779 } | 848 } |
| 780 | 849 |
| 781 /** | 850 /** |
| 851 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | |
| 852 * @param {!Event} event | |
| 853 */ | |
| 854 _inlineBreakpointClick(decoration, event) { | |
| 855 event.consume(true); | |
| 856 if (decoration.breakpoint) { | |
| 857 if (event.shiftKey) | |
| 858 decoration.breakpoint.setEnabled(!decoration.breakpoint.enabled()); | |
| 859 else | |
| 860 decoration.breakpoint.remove(); | |
| 861 } else { | |
| 862 var location = decoration.handle.resolve(); | |
| 863 if (!location) | |
| 864 return; | |
| 865 this._setBreakpoint(location.lineNumber, location.columnNumber, decoration .condition, true); | |
| 866 } | |
| 867 } | |
| 868 | |
| 869 /** | |
| 870 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | |
| 871 * @param {!Event} event | |
| 872 */ | |
| 873 _inlineBreakpointContextMenu(decoration, event) { | |
| 874 event.consume(true); | |
| 875 var location = decoration.handle.resolve(); | |
| 876 if (!location) | |
| 877 return; | |
| 878 var contextMenu = new UI.ContextMenu(event); | |
| 879 if (decoration.breakpoint) { | |
| 880 contextMenu.appendItem( | |
| 881 Common.UIString('Edit breakpoint\u2026'), | |
| 882 this._editBreakpointCondition.bind(this, location.lineNumber, decorati on.breakpoint, null)); | |
| 883 } else { | |
| 884 contextMenu.appendItem( | |
| 885 Common.UIString('Add conditional breakpoint\u2026'), | |
| 886 this._editBreakpointCondition.bind(this, location.lineNumber, null, lo cation)); | |
| 887 contextMenu.appendItem( | |
| 888 Common.UIString('Never pause here'), | |
| 889 this._setBreakpoint.bind(this, location.lineNumber, location.columnNum ber, 'false', true)); | |
| 890 } | |
| 891 contextMenu.show(); | |
| 892 } | |
| 893 | |
| 894 /** | |
| 782 * @param {!Common.Event} event | 895 * @param {!Common.Event} event |
| 783 * @return {boolean} | 896 * @return {boolean} |
| 784 */ | 897 */ |
| 785 _shouldIgnoreExternalBreakpointEvents(event) { | 898 _shouldIgnoreExternalBreakpointEvents(event) { |
| 786 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | 899 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); |
| 787 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) | 900 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) |
| 788 return true; | 901 return true; |
| 789 if (this._supportsEnabledBreakpointsWhileEditing()) | 902 if (this._supportsEnabledBreakpointsWhileEditing()) |
| 790 return false; | 903 return false; |
| 791 if (this._muted) | 904 if (this._muted) |
| 792 return true; | 905 return true; |
| 793 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 906 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 794 for (var i = 0; i < scriptFiles.length; ++i) { | 907 for (var i = 0; i < scriptFiles.length; ++i) { |
| 795 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) | 908 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) |
| 796 return true; | 909 return true; |
| 797 } | 910 } |
| 798 return false; | 911 return false; |
| 799 } | 912 } |
| 800 | 913 |
| 801 /** | 914 /** |
| 802 * @param {!Common.Event} event | 915 * @param {!Common.Event} event |
| 803 */ | 916 */ |
| 804 _breakpointAdded(event) { | 917 _breakpointAdded(event) { |
| 805 if (this._shouldIgnoreExternalBreakpointEvents(event)) | 918 if (this._shouldIgnoreExternalBreakpointEvents(event)) |
| 806 return; | 919 return; |
| 807 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | 920 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); |
| 808 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumber , uiLocation.columnNumber); | 921 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumber , uiLocation.columnNumber); |
| 809 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); | 922 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); |
| 810 var decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration(hand le, breakpoint); | 923 var decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( |
| 924 this._textEditor, handle, breakpoint.condition(), breakpoint.enabled(), breakpoint); | |
| 811 this._breakpointDecorations.add(decoration); | 925 this._breakpointDecorations.add(decoration); |
| 812 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration; | 926 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration; |
| 813 this._updateBreakpointDecoration(decoration); | 927 this._updateBreakpointDecoration(decoration); |
| 814 } | 928 } |
| 815 | 929 |
| 816 /** | 930 /** |
| 817 * @param {!Common.Event} event | 931 * @param {!Common.Event} event |
| 818 */ | 932 */ |
| 819 _breakpointRemoved(event) { | 933 _breakpointRemoved(event) { |
| 820 if (this._shouldIgnoreExternalBreakpointEvents(event)) | 934 if (this._shouldIgnoreExternalBreakpointEvents(event)) |
| 821 return; | 935 return; |
| 822 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); | 936 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); |
| 823 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol]; | 937 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol]; |
| 824 if (!decoration) | 938 if (!decoration) |
| 825 return; | 939 return; |
| 826 this._breakpointDecorations.delete(decoration); | 940 this._breakpointDecorations.delete(decoration); |
| 941 decoration.hide(); | |
|
lushnikov
2016/11/28 20:35:19
why do you need this call? Isn't it handled in _up
kozy
2016/11/29 02:12:36
Done.
| |
| 827 delete breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decora tionSymbol]; | 942 delete breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decora tionSymbol]; |
| 828 this._updateBreakpointDecoration(decoration); | 943 this._updateBreakpointDecoration(decoration); |
| 829 } | 944 } |
| 830 | 945 |
| 831 /** | 946 /** |
| 832 * @param {!Common.Event} event | 947 * @param {!Common.Event} event |
| 833 */ | 948 */ |
| 834 _onSourceMappingChanged(event) { | 949 _onSourceMappingChanged(event) { |
| 835 var data = /** @type {{target: !SDK.Target}} */ (event.data); | 950 var data = /** @type {{target: !SDK.Target}} */ (event.data); |
| 836 this._updateScriptFile(data.target); | 951 this._updateScriptFile(data.target); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 * @param {number} lineNumber | 1081 * @param {number} lineNumber |
| 967 * @param {boolean} onlyDisable | 1082 * @param {boolean} onlyDisable |
| 968 */ | 1083 */ |
| 969 _toggleBreakpoint(lineNumber, onlyDisable) { | 1084 _toggleBreakpoint(lineNumber, onlyDisable) { |
| 970 var decorations = this._lineBreakpointDecorations(lineNumber); | 1085 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 971 if (!decorations.length) { | 1086 if (!decorations.length) { |
| 972 this._createNewBreakpoint(lineNumber, '', true); | 1087 this._createNewBreakpoint(lineNumber, '', true); |
| 973 return; | 1088 return; |
| 974 } | 1089 } |
| 975 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled'); | 1090 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled'); |
| 976 var breakpoints = decorations.map(decoration => decoration.breakpoint); | 1091 var breakpoints = decorations.map(decoration => decoration.breakpoint).filte r(breakpoint => !!breakpoint); |
| 977 for (var breakpoint of breakpoints) { | 1092 for (var breakpoint of breakpoints) { |
| 978 if (onlyDisable) | 1093 if (onlyDisable) |
| 979 breakpoint.setEnabled(hasDisabled); | 1094 breakpoint.setEnabled(hasDisabled); |
| 980 else | 1095 else |
| 981 breakpoint.remove(); | 1096 breakpoint.remove(); |
| 982 } | 1097 } |
| 983 } | 1098 } |
| 984 | 1099 |
| 985 /** | 1100 /** |
| 986 * @param {number} lineNumber | 1101 * @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); | 1205 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); |
| 1091 super.dispose(); | 1206 super.dispose(); |
| 1092 } | 1207 } |
| 1093 }; | 1208 }; |
| 1094 | 1209 |
| 1095 /** | 1210 /** |
| 1096 * @unrestricted | 1211 * @unrestricted |
| 1097 */ | 1212 */ |
| 1098 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { | 1213 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { |
| 1099 /** | 1214 /** |
| 1215 * @param {!TextEditor.CodeMirrorTextEditor} textEditor | |
| 1100 * @param {!TextEditor.TextEditorPositionHandle} handle | 1216 * @param {!TextEditor.TextEditorPositionHandle} handle |
| 1101 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint | 1217 * @param {string} condition |
| 1218 * @param {boolean} enabled | |
| 1219 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint | |
| 1102 */ | 1220 */ |
| 1103 constructor(handle, breakpoint) { | 1221 constructor(textEditor, handle, condition, enabled, breakpoint) { |
| 1222 this._textEditor = textEditor; | |
| 1104 this.handle = handle; | 1223 this.handle = handle; |
| 1105 this.condition = breakpoint.condition(); | 1224 this.condition = condition; |
| 1106 this.enabled = breakpoint.enabled(); | 1225 this.enabled = enabled; |
| 1107 this.breakpoint = breakpoint; | 1226 this.breakpoint = breakpoint; |
| 1227 | |
| 1228 /** @type {?TextEditor.TextEditorBookMark} */ | |
| 1229 this._bookmark = null; | |
| 1108 } | 1230 } |
| 1109 | 1231 |
| 1110 /** | 1232 /** |
| 1111 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1 | 1233 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1 |
| 1112 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2 | 1234 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2 |
| 1113 * @return {number} | 1235 * @return {number} |
| 1114 */ | 1236 */ |
| 1115 static mostSpecificFirst(decoration1, decoration2) { | 1237 static mostSpecificFirst(decoration1, decoration2) { |
| 1116 if (!!decoration1.condition !== !!decoration2.condition) | 1238 if (!!decoration1.condition !== !!decoration2.condition) |
| 1117 return !!decoration1.condition ? -1 : 1; | 1239 return !!decoration1.condition ? -1 : 1; |
| 1118 if (decoration1.enabled !== decoration2.enabled) | 1240 if (decoration1.enabled !== decoration2.enabled) |
| 1119 return decoration1.enabled ? -1 : 1; | 1241 return decoration1.enabled ? -1 : 1; |
| 1120 return 0; | 1242 return 0; |
| 1121 } | 1243 } |
| 1244 | |
| 1245 /** | |
| 1246 * @return {?Element} | |
| 1247 */ | |
| 1248 show() { | |
| 1249 if (this._bookmark) | |
| 1250 return null; | |
| 1251 var location = this.handle.resolve(); | |
| 1252 if (!location) | |
| 1253 return null; | |
| 1254 var inlineBreakpoint; | |
| 1255 if (!!this.condition) | |
| 1256 inlineBreakpoint = UI.Icon.create('smallicon-inline-breakpoint'); | |
| 1257 else | |
| 1258 inlineBreakpoint = UI.Icon.create('smallicon-inline-breakpoint-conditional '); | |
| 1259 inlineBreakpoint.classList.toggle('cm-inline-breakpoint', true); | |
| 1260 inlineBreakpoint.classList.toggle('cm-inline-disabled', !this.enabled); | |
| 1261 this._bookmark = this._textEditor.addBookmark( | |
| 1262 location.lineNumber, location.columnNumber, inlineBreakpoint, | |
| 1263 Sources.JavaScriptSourceFrame.BreakpointDecoration._bookmarkSymbol); | |
| 1264 this._bookmark[Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSy mbolForTest] = inlineBreakpoint; | |
| 1265 return inlineBreakpoint; | |
| 1266 } | |
| 1267 | |
| 1268 hide() { | |
| 1269 if (!this._bookmark) | |
| 1270 return; | |
| 1271 this._bookmark.clear(); | |
| 1272 this._bookmark = null; | |
| 1273 } | |
| 1122 }; | 1274 }; |
| 1123 | 1275 |
| 1124 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); | 1276 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); |
| 1277 Sources.JavaScriptSourceFrame.BreakpointDecoration._bookmarkSymbol = Symbol('boo kmark'); | |
| 1278 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); | |
| OLD | NEW |