Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js

Issue 2526013002: [DevTools] Added inline breakpoints (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
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
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();
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
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
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)) {
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());
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 = new Sources.JavaScriptSourceFrame.BreakpointDecoration( handle, '', false, null);
832 this._breakpointDecorations.add(decoration);
833 decorations.push(decoration);
834 }
835 // Render inline decorations.
836 for (var decoration of decorations) {
837 var element = decoration.show(this._textEditor);
838 if (!element)
839 continue;
840 element.addEventListener('click', this._inlineBreakpointClick.bind(this, decoration), true);
841 element.addEventListener('contextmenu', this._inlineBreakpointContextMen u.bind(this, decoration), true);
842 }
775 } 843 }
776 } 844 }
777 845
778 _breakpointDecorationsUpdatedForTest() { 846 _breakpointDecorationsUpdatedForTest() {
779 } 847 }
780 848
781 /** 849 /**
850 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration
851 * @param {!Event} event
852 */
853 _inlineBreakpointClick(decoration, event) {
854 event.consume(true);
855 if (decoration.breakpoint) {
856 if (event.shiftKey)
857 decoration.breakpoint.setEnabled(!decoration.breakpoint.enabled());
858 else
859 decoration.breakpoint.remove();
860 } else {
861 var location = decoration.handle.resolve();
862 if (!location)
863 return;
864 this._setBreakpoint(location.lineNumber, location.columnNumber, decoration .condition, true);
865 }
866 }
867
868 /**
869 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration
870 * @param {!Event} event
871 */
872 _inlineBreakpointContextMenu(decoration, event) {
873 event.consume(true);
874 var location = decoration.handle.resolve();
875 if (!location)
876 return;
877 var contextMenu = new UI.ContextMenu(event);
878 if (decoration.breakpoint) {
879 contextMenu.appendItem(
880 Common.UIString('Edit breakpoint\u2026'),
881 this._editBreakpointCondition.bind(this, location.lineNumber, decorati on.breakpoint, null));
882 } else {
883 contextMenu.appendItem(
884 Common.UIString('Add conditional breakpoint\u2026'),
885 this._editBreakpointCondition.bind(this, location.lineNumber, null, lo cation));
886 contextMenu.appendItem(
887 Common.UIString('Never pause here'),
888 this._setBreakpoint.bind(this, location.lineNumber, location.columnNum ber, 'false', true));
889 }
890 contextMenu.show();
891 }
892
893 /**
782 * @param {!Common.Event} event 894 * @param {!Common.Event} event
783 * @return {boolean} 895 * @return {boolean}
784 */ 896 */
785 _shouldIgnoreExternalBreakpointEvents(event) { 897 _shouldIgnoreExternalBreakpointEvents(event) {
786 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); 898 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation );
787 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) 899 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded)
788 return true; 900 return true;
789 if (this._supportsEnabledBreakpointsWhileEditing()) 901 if (this._supportsEnabledBreakpointsWhileEditing())
790 return false; 902 return false;
791 if (this._muted) 903 if (this._muted)
792 return true; 904 return true;
793 var scriptFiles = this._scriptFileForTarget.valuesArray(); 905 var scriptFiles = this._scriptFileForTarget.valuesArray();
794 for (var i = 0; i < scriptFiles.length; ++i) { 906 for (var i = 0; i < scriptFiles.length; ++i) {
795 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) 907 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM())
796 return true; 908 return true;
797 } 909 }
798 return false; 910 return false;
799 } 911 }
800 912
801 /** 913 /**
802 * @param {!Common.Event} event 914 * @param {!Common.Event} event
803 */ 915 */
804 _breakpointAdded(event) { 916 _breakpointAdded(event) {
805 if (this._shouldIgnoreExternalBreakpointEvents(event)) 917 if (this._shouldIgnoreExternalBreakpointEvents(event))
806 return; 918 return;
807 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); 919 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation );
808 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumber , uiLocation.columnNumber); 920 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumber , uiLocation.columnNumber);
809 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); 921 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint);
810 var decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration(hand le, breakpoint); 922 var decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration(
923 handle, breakpoint.condition(), breakpoint.enabled(), breakpoint);
811 this._breakpointDecorations.add(decoration); 924 this._breakpointDecorations.add(decoration);
812 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration; 925 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration;
813 this._updateBreakpointDecoration(decoration); 926 this._updateBreakpointDecoration(decoration);
814 } 927 }
815 928
816 /** 929 /**
817 * @param {!Common.Event} event 930 * @param {!Common.Event} event
818 */ 931 */
819 _breakpointRemoved(event) { 932 _breakpointRemoved(event) {
820 if (this._shouldIgnoreExternalBreakpointEvents(event)) 933 if (this._shouldIgnoreExternalBreakpointEvents(event))
821 return; 934 return;
822 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); 935 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint);
823 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol]; 936 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol];
824 if (!decoration) 937 if (!decoration)
825 return; 938 return;
826 this._breakpointDecorations.delete(decoration); 939 this._breakpointDecorations.delete(decoration);
940 decoration.hide();
827 delete breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decora tionSymbol]; 941 delete breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decora tionSymbol];
828 this._updateBreakpointDecoration(decoration); 942 this._updateBreakpointDecoration(decoration);
829 } 943 }
830 944
831 /** 945 /**
832 * @param {!Common.Event} event 946 * @param {!Common.Event} event
833 */ 947 */
834 _onSourceMappingChanged(event) { 948 _onSourceMappingChanged(event) {
835 var data = /** @type {{target: !SDK.Target}} */ (event.data); 949 var data = /** @type {{target: !SDK.Target}} */ (event.data);
836 this._updateScriptFile(data.target); 950 this._updateScriptFile(data.target);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 * @param {number} lineNumber 1080 * @param {number} lineNumber
967 * @param {boolean} onlyDisable 1081 * @param {boolean} onlyDisable
968 */ 1082 */
969 _toggleBreakpoint(lineNumber, onlyDisable) { 1083 _toggleBreakpoint(lineNumber, onlyDisable) {
970 var decorations = this._lineBreakpointDecorations(lineNumber); 1084 var decorations = this._lineBreakpointDecorations(lineNumber);
971 if (!decorations.length) { 1085 if (!decorations.length) {
972 this._createNewBreakpoint(lineNumber, '', true); 1086 this._createNewBreakpoint(lineNumber, '', true);
973 return; 1087 return;
974 } 1088 }
975 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled'); 1089 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled');
976 var breakpoints = decorations.map(decoration => decoration.breakpoint); 1090 var breakpoints = decorations.map(decoration => decoration.breakpoint).filte r(breakpoint => !!breakpoint);
977 for (var breakpoint of breakpoints) { 1091 for (var breakpoint of breakpoints) {
978 if (onlyDisable) 1092 if (onlyDisable)
979 breakpoint.setEnabled(hasDisabled); 1093 breakpoint.setEnabled(hasDisabled);
980 else 1094 else
981 breakpoint.remove(); 1095 breakpoint.remove();
982 } 1096 }
983 } 1097 }
984 1098
985 /** 1099 /**
986 * @param {number} lineNumber 1100 * @param {number} lineNumber
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); 1202 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this);
1089 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this); 1203 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this);
1090 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); 1204 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this);
1091 super.dispose(); 1205 super.dispose();
1092 } 1206 }
1093 }; 1207 };
1094 1208
1095 /** 1209 /**
1096 * @unrestricted 1210 * @unrestricted
1097 */ 1211 */
1098 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { 1212 Sources.JavaScriptSourceFrame.BreakpointDecoration = class {
lushnikov 2016/11/23 21:54:39 What is BreakpointDecoration? It used to be a gutt
kozy 2016/11/23 23:08:47 BreakpointDecoration represents decoration for bre
1099 /** 1213 /**
1100 * @param {!TextEditor.TextEditorPositionHandle} handle 1214 * @param {!TextEditor.TextEditorPositionHandle} handle
1101 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint 1215 * @param {string} condition
1216 * @param {boolean} enabled
1217 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint
1102 */ 1218 */
1103 constructor(handle, breakpoint) { 1219 constructor(handle, condition, enabled, breakpoint) {
lushnikov 2016/11/23 21:54:39 let's make decoration texteditor-aware: construct
kozy 2016/11/23 23:08:47 Done.
1104 this.handle = handle; 1220 this.handle = handle;
1105 this.condition = breakpoint.condition(); 1221 this.condition = condition;
1106 this.enabled = breakpoint.enabled(); 1222 this.enabled = enabled;
1107 this.breakpoint = breakpoint; 1223 this.breakpoint = breakpoint;
1224
1225 /** @type {?TextEditor.TextEditorBookMark} */
1226 this._bookmark = null;
1108 } 1227 }
1109 1228
1110 /** 1229 /**
1111 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1 1230 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1
1112 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2 1231 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2
1113 * @return {number} 1232 * @return {number}
1114 */ 1233 */
1115 static mostSpecificFirst(decoration1, decoration2) { 1234 static mostSpecificFirst(decoration1, decoration2) {
1116 if (!!decoration1.condition !== !!decoration2.condition) 1235 if (!!decoration1.condition !== !!decoration2.condition)
1117 return !!decoration1.condition ? -1 : 1; 1236 return !!decoration1.condition ? -1 : 1;
1118 if (decoration1.enabled !== decoration2.enabled) 1237 if (decoration1.enabled !== decoration2.enabled)
1119 return decoration1.enabled ? -1 : 1; 1238 return decoration1.enabled ? -1 : 1;
1120 return 0; 1239 return 0;
1121 } 1240 }
1241
1242 /**
1243 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
1244 * @return {?Element}
1245 */
1246 show(textEditor) {
1247 if (this._bookmark)
1248 return null;
1249 var location = this.handle.resolve();
1250 if (!location)
1251 return null;
1252 var inlineBreakpoint = createElementWithClass('div', 'cm-inline-breakpoint') ;
1253 inlineBreakpoint.classList.toggle('cm-inline-conditional', !!this.condition) ;
1254 inlineBreakpoint.classList.toggle('cm-inline-disabled', !this.enabled);
1255 this._bookmark = textEditor.addBookmark(
1256 location.lineNumber, location.columnNumber, inlineBreakpoint,
1257 Sources.JavaScriptSourceFrame.BreakpointDecoration._bookmarkSymbol);
1258 this._bookmark[Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSy mbolForTest] = inlineBreakpoint;
1259 return inlineBreakpoint;
1260 }
1261
1262 hide() {
1263 if (!this._bookmark)
1264 return;
1265 this._bookmark.clear();
1266 this._bookmark = null;
1267 }
1122 }; 1268 };
1123 1269
1124 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); 1270 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration');
1271 Sources.JavaScriptSourceFrame.BreakpointDecoration._bookmarkSymbol = Symbol('boo kmark');
1272 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698