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

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

Issue 2500493003: [DevTools] make breakpoints better (Closed)
Patch Set: fixed context menu items for gutter Created 4 years, 1 month 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 */ 246 */
247 populateLineGutterContextMenu(contextMenu, lineNumber) { 247 populateLineGutterContextMenu(contextMenu, lineNumber) {
248 /** 248 /**
249 * @this {Sources.JavaScriptSourceFrame} 249 * @this {Sources.JavaScriptSourceFrame}
250 */ 250 */
251 function populate(resolve, reject) { 251 function populate(resolve, reject) {
252 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); 252 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0);
253 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); 253 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation);
254 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod e(), lineNumber); 254 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod e(), lineNumber);
255 if (!breakpoints.length) { 255 if (!breakpoints.length) {
256 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint.
257 contextMenu.appendItem( 256 contextMenu.appendItem(
258 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); 257 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true));
259 contextMenu.appendItem( 258 contextMenu.appendItem(
260 Common.UIString('Add conditional breakpoint…'), this._editBreakpoint Condition.bind(this, lineNumber)); 259 Common.UIString('Add conditional breakpoint…'), this._editBreakpoint Condition.bind(this, lineNumber));
261 contextMenu.appendItem( 260 contextMenu.appendItem(
262 Common.UIString('Never pause here'), this._createNewBreakpoint.bind( this, lineNumber, 'false', true)); 261 Common.UIString('Never pause here'), this._createNewBreakpoint.bind( this, lineNumber, 'false', true));
263 } else { 262 } else {
264 var breakpoint = breakpoints[0]; 263 var hasOneBreakpoint = breakpoints.length === 1;
265 264 var removeTitle = hasOneBreakpoint ? 'Remove breakpoint' : 'Remove all b reakpoints in line';
266 // This row has a breakpoint, we want to show edit and remove breakpoint , and either disable or enable. 265 contextMenu.appendItem(Common.UIString(removeTitle), () => breakpoints.m ap(breakpoint => breakpoint.remove()));
267 contextMenu.appendItem(Common.UIString('Remove breakpoint'), breakpoint. remove.bind(breakpoint)); 266 if (hasOneBreakpoint) {
268 contextMenu.appendItem( 267 contextMenu.appendItem(
269 Common.UIString('Edit breakpoint…'), this._editBreakpointCondition.b ind(this, lineNumber, breakpoint)); 268 Common.UIString('Edit breakpoint\u2026'),
270 if (breakpoint.enabled()) 269 this._editBreakpointCondition.bind(this, lineNumber, breakpoints[0 ]));
271 contextMenu.appendItem(Common.UIString('Disable breakpoint'), breakpoi nt.setEnabled.bind(breakpoint, false)); 270 }
272 else 271 if (breakpoints.some(breakpoint => breakpoint.enabled())) {
273 contextMenu.appendItem(Common.UIString('Enable breakpoint'), breakpoin t.setEnabled.bind(breakpoint, true)); 272 var disableTitle = hasOneBreakpoint ? 'Disable breakpoint' : 'Disable all breakpoints in line';
273 contextMenu.appendItem(
274 Common.UIString(disableTitle), () => breakpoints.map(breakpoint => breakpoint.setEnabled(false)));
dgozman 2016/11/15 23:35:13 Always wrap a literal in Common.UIString() instead
275 }
276 if (breakpoints.some(breakpoint => !breakpoint.enabled())) {
277 var enableTitle = hasOneBreakpoint ? 'Enable breakpoint' : 'Enable all breakpoints in line';
278 contextMenu.appendItem(
279 Common.UIString(enableTitle), () => breakpoints.map(breakpoint => breakpoint.setEnabled(true)));
280 }
274 } 281 }
275 resolve(); 282 resolve();
276 } 283 }
277 return new Promise(populate.bind(this)); 284 return new Promise(populate.bind(this));
278 } 285 }
279 286
280 /** 287 /**
281 * @override 288 * @override
282 * @return {!Promise} 289 * @return {!Promise}
283 */ 290 */
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (this._supportsEnabledBreakpointsWhileEditing()) 356 if (this._supportsEnabledBreakpointsWhileEditing())
350 return; 357 return;
351 this._updateDivergedInfobar(); 358 this._updateDivergedInfobar();
352 this._muteBreakpointsWhileEditing(); 359 this._muteBreakpointsWhileEditing();
353 } 360 }
354 361
355 _muteBreakpointsWhileEditing() { 362 _muteBreakpointsWhileEditing() {
356 if (this._muted) 363 if (this._muted)
357 return; 364 return;
358 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNum ber) { 365 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNum ber) {
359 var breakpointDecoration = this._textEditor.getAttribute(lineNumber, 'brea kpoint'); 366 if (!this.textEditor.hasLineClass(lineNumber, 'cm-breakpoint'))
360 if (!breakpointDecoration)
361 continue; 367 continue;
362 this._removeBreakpointDecoration(lineNumber); 368 this._updateBreakpointDecoration(lineNumber);
363 this._addBreakpointDecoration(
364 lineNumber, breakpointDecoration.columnNumber, breakpointDecoration.co ndition, breakpointDecoration.enabled,
365 true);
366 } 369 }
367 this._muted = true; 370 this._muted = true;
368 } 371 }
369 372
370 _updateDivergedInfobar() { 373 _updateDivergedInfobar() {
371 if (this.uiSourceCode().project().type() !== Workspace.projectTypes.FileSyst em) { 374 if (this.uiSourceCode().project().type() !== Workspace.projectTypes.FileSyst em) {
372 this._hideDivergedInfobar(); 375 this._hideDivergedInfobar();
373 return; 376 return;
374 } 377 }
375 378
(...skipping 20 matching lines...) Expand all
396 for (var i = 0; i < scriptFiles.length; ++i) { 399 for (var i = 0; i < scriptFiles.length; ++i) {
397 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM()) 400 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM())
398 return; 401 return;
399 } 402 }
400 403
401 this._restoreBreakpointsAfterEditing(); 404 this._restoreBreakpointsAfterEditing();
402 } 405 }
403 406
404 _restoreBreakpointsAfterEditing() { 407 _restoreBreakpointsAfterEditing() {
405 delete this._muted; 408 delete this._muted;
406 var breakpoints = {}; 409 /** @type {!Map<number, !{enabled: boolean, condition: string, lineNumber: n umber}>} */
410 var linesWithBreakpoints = new Map();
407 // Save and remove muted breakpoint decorations. 411 // Save and remove muted breakpoint decorations.
408 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNum ber) { 412 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNum ber) {
409 var breakpointDecoration = this._textEditor.getAttribute(lineNumber, 'brea kpoint'); 413 if (this.textEditor.hasLineClass(lineNumber, 'cm-breakpoint')) {
410 if (breakpointDecoration) { 414 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceC ode(), lineNumber);
411 breakpoints[lineNumber] = breakpointDecoration; 415 breakpoints = breakpoints.filter(breakpoint => breakpoint.enabled());
412 this._removeBreakpointDecoration(lineNumber); 416 var condition = breakpoints.length ? breakpoints[0].condition() : '';
417 linesWithBreakpoints.set(lineNumber,
418 {enabled: !!breakpoints.length, condition: condition, lineNumber: line Number});
413 } 419 }
414 } 420 }
415 421
416 // Remove all breakpoints. 422 // Remove all breakpoints.
417 this._removeAllBreakpoints(); 423 this._removeAllBreakpoints();
418 424
419 // Restore all breakpoints from saved decorations. 425 // Restore first in line breakpoints from saved decorations.
420 for (var lineNumberString in breakpoints) { 426 for (var breakpoint of linesWithBreakpoints.valuesArray())
421 var lineNumber = parseInt(lineNumberString, 10); 427 this._createNewBreakpoint(breakpoint.lineNumber, breakpoint.condition, bre akpoint.enabled);
422 if (isNaN(lineNumber))
423 continue;
424 var breakpointDecoration = breakpoints[lineNumberString];
425 this._setBreakpoint(
426 lineNumber, breakpointDecoration.columnNumber, breakpointDecoration.co ndition, breakpointDecoration.enabled);
427 }
428 } 428 }
429 429
430 _removeAllBreakpoints() { 430 _removeAllBreakpoints() {
431 var breakpoints = this._breakpointManager.breakpointsForUISourceCode(this.ui SourceCode()); 431 var breakpoints = this._breakpointManager.breakpointsForUISourceCode(this.ui SourceCode());
432 for (var i = 0; i < breakpoints.length; ++i) 432 for (var i = 0; i < breakpoints.length; ++i)
433 breakpoints[i].remove(); 433 breakpoints[i].remove();
434 } 434 }
435 435
436 /** 436 /**
437 * @param {string} tokenType 437 * @param {string} tokenType
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 _onHidePopover() { 552 _onHidePopover() {
553 if (!this._popoverAnchorBox) 553 if (!this._popoverAnchorBox)
554 return; 554 return;
555 if (this._popoverAnchorBox._highlightDescriptor) 555 if (this._popoverAnchorBox._highlightDescriptor)
556 this.textEditor.removeHighlight(this._popoverAnchorBox._highlightDescripto r); 556 this.textEditor.removeHighlight(this._popoverAnchorBox._highlightDescripto r);
557 delete this._popoverAnchorBox; 557 delete this._popoverAnchorBox;
558 } 558 }
559 559
560 /** 560 /**
561 * @param {number} lineNumber 561 * @param {number} lineNumber
562 * @param {number} columnNumber
563 * @param {string} condition
564 * @param {boolean} enabled
565 * @param {boolean} mutedWhileEditing
566 */ 562 */
567 _addBreakpointDecoration(lineNumber, columnNumber, condition, enabled, mutedWh ileEditing) { 563 _updateBreakpointDecoration(lineNumber) {
lushnikov 2016/11/15 22:42:33 _updateBreakpointDecorations
568 var breakpoint = {condition: condition, enabled: enabled, columnNumber: colu mnNumber}; 564 if (!this._scheduledBreakpointDecorationUpdates)
565 this._scheduledBreakpointDecorationUpdates = /** @type {!Set<number>} */(n ew Set());
569 566
570 this.textEditor.setAttribute(lineNumber, 'breakpoint', breakpoint); 567 if (this._scheduledBreakpointDecorationUpdates.has(lineNumber))
568 return;
569 if (!this._scheduledBreakpointDecorationUpdates.size)
570 setImmediate(() => this.textEditor.operation(update.bind(this)));
571 this._scheduledBreakpointDecorationUpdates.add(lineNumber);
571 572
572 var disabled = !enabled || mutedWhileEditing; 573 /**
573 this.textEditor.addBreakpoint(lineNumber, disabled, !!condition); 574 * @this {!Sources.JavaScriptSourceFrame}
575 */
576 function update() {
577 for (var lineNumber of this._scheduledBreakpointDecorationUpdates) {
578 if (lineNumber >= this.textEditor.linesCount)
579 continue;
580 var lineRange = new Common.TextRange(lineNumber, 0, lineNumber, this.tex tEditor.line(lineNumber).length);
581 var bookmarks = this.textEditor.bookmarks(lineRange, Sources.JavaScriptS ourceFrame._inlineBreakpointSymbol);
582 for (var bookmark of bookmarks)
583 bookmark.clear();
584
585 var breakpointLocations = this._breakpointManager.breakpontLocationsForL ineNumber(this.uiSourceCode(), lineNumber);
586 var breakpoints = breakpointLocations.map(location => location.breakpoin t);
587 var hasBreakpoints = !!breakpoints.length;
588 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', hasBreakpoi nts);
589 var hasEnabled = breakpoints.some(breakpoint => breakpoint.enabled()) && !this._muted;
590 var hasConditional = breakpoints.some(breakpoint => !!breakpoint.conditi on());
591 var hasEnabledConditional = breakpoints.some(breakpoint => !!breakpoint. condition() && breakpoint.enabled());
592 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !h asEnabled && hasBreakpoints);
593 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', hasBreakpoints && (hasEnabledConditional || (!hasEnabled && hasConditional)));
594
595 if (hasBreakpoints)
596 this.addBreakpointForTest(lineNumber, hasEnabled);
597 else
598 this.removeBreakpointForTest(lineNumber);
599
600 if (hasBreakpoints && Runtime.experiments.isEnabled('inlineBreakpoints') ) {
601 this._breakpointManager.possibleBreakpoints(this.uiSourceCode(), new C ommon.TextRange(lineNumber, 0, lineNumber + 1, 0))
602 .then(addMissingBreakpoints.bind(this, lineNumber));
lushnikov 2016/11/17 04:31:50 what if during this asynchronous code the breakpoi
603 }
604
605 if (breakpoints.length <= 1 || this._muted || !Runtime.experiments.isEna bled('inlineBreakpoints'))
606 continue;
607
608 for (let i = 0; i < breakpointLocations.length; ++i) {
609 var breakpoint = breakpointLocations[i].breakpoint;
610 var inlineBreakpoint = createElementWithClass('div', 'cm-inline-breakp oint');
611 inlineBreakpoint.classList.toggle('cm-inline-conditional', !!breakpoin ts[i].condition());
612 inlineBreakpoint.classList.toggle('cm-inline-disabled', !breakpoints[i ].enabled());
613 inlineBreakpoint.addEventListener('click', () => breakpoints[i].setEna bled(!breakpoints[i].enabled()), true);
614 inlineBreakpoint.addEventListener('contextmenu', this._populateInlineB reakpointContextMenu.bind(this, breakpoints[i]));
615 this.textEditor.addBookmark(lineNumber, breakpointLocations[i].uiLocat ion.columnNumber, inlineBreakpoint, Sources.JavaScriptSourceFrame._inlineBreakpo intSymbol);
616 }
617 }
618 this._scheduledBreakpointDecorationUpdates.clear();
619 }
620
621 /**
622 * @this {!Sources.JavaScriptSourceFrame}
623 * @param {number} lineNumber
624 * @param {!Array<!Workspace.UILocation>} locations
625 */
626 function addMissingBreakpoints(lineNumber, locations) {
lushnikov 2016/11/17 04:31:50 addInlineBreakpoints
627 var breakpoints = this._breakpointManager.breakpontLocationsForLineNumber( this.uiSourceCode(), lineNumber);
628 if (!breakpoints.length)
629 return;
630 var columns = new Set(breakpoints.map(breakpoint => breakpoint.uiLocation. columnNumber));
631 locations = locations.filter(location => !columns.has(location.columnNumbe r));
632 for (var location of locations)
633 this._setBreakpoint(location.lineNumber, location.columnNumber, '', fals e);
634 }
574 } 635 }
575 636
576 _removeBreakpointDecoration(lineNumber) { 637 /**
577 this.textEditor.removeAttribute(lineNumber, 'breakpoint'); 638 * @param {number} lineNumber
578 this.textEditor.removeBreakpoint(lineNumber); 639 * @param {boolean} disabled
640 */
641 addBreakpointForTest(lineNumber, disabled) {
642 }
643
644 /**
645 * @param {number} lineNumber
646 */
647 removeBreakpointForTest(lineNumber) {
648 }
649
650 /**
651 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint
652 * @param {!Event} event
653 */
654 _populateInlineBreakpointContextMenu(breakpoint, event) {
655 var contextMenu = new UI.ContextMenu(event);
656 if (!breakpoint.enabled()) {
657 contextMenu.appendItem(
658 Common.UIString('Add conditional breakpoint…'), this._editBreakpointCond ition.bind(this, breakpoint.lineNumber(), breakpoint));
lushnikov 2016/11/17 04:31:50 nit: let's use \u... for the ellipsis
659 contextMenu.appendItem(
660 Common.UIString('Never pause here'),
661 () => { breakpoint.setCondition('false'); breakpoint.setEnabled(true); } );
lushnikov 2016/11/17 04:31:50 It would be easier for me to read if the function
662 } else {
663 contextMenu.appendItem(
664 Common.UIString('Edit breakpoint…'),
lushnikov 2016/11/17 04:31:50 let's use \u... for the ellipsis
665 this._editBreakpointCondition.bind(this, breakpoint.lineNumber(), brea kpoint));
666 }
667 contextMenu.show();
668 event.consume();
579 } 669 }
580 670
581 _onKeyDown(event) { 671 _onKeyDown(event) {
582 if (event.key === 'Escape') { 672 if (event.key === 'Escape') {
583 if (this._popoverHelper.isPopoverVisible()) { 673 if (this._popoverHelper.isPopoverVisible()) {
584 this._popoverHelper.hidePopover(); 674 this._popoverHelper.hidePopover();
585 event.consume(); 675 event.consume();
586 } 676 }
587 } 677 }
588 } 678 }
589 679
590 /** 680 /**
591 * @param {number} lineNumber 681 * @param {number} lineNumber
592 * @param {!Bindings.BreakpointManager.Breakpoint=} breakpoint 682 * @param {!Bindings.BreakpointManager.Breakpoint=} breakpoint
593 */ 683 */
594 _editBreakpointCondition(lineNumber, breakpoint) { 684 _editBreakpointCondition(lineNumber, breakpoint) {
595 this._conditionElement = this._createConditionElement(lineNumber); 685 this._conditionElement = this._createConditionElement(lineNumber);
596 this.textEditor.addDecoration(this._conditionElement, lineNumber); 686 this.textEditor.addDecoration(this._conditionElement, lineNumber);
597 687
598 /** 688 /**
599 * @this {Sources.JavaScriptSourceFrame} 689 * @this {Sources.JavaScriptSourceFrame}
600 */ 690 */
601 function finishEditing(committed, element, newText) { 691 function finishEditing(committed, element, newText) {
602 this.textEditor.removeDecoration(this._conditionElement, lineNumber); 692 this.textEditor.removeDecoration(this._conditionElement, lineNumber);
603 delete this._conditionEditorElement; 693 delete this._conditionEditorElement;
604 delete this._conditionElement; 694 delete this._conditionElement;
605 if (!committed) 695 if (!committed)
606 return; 696 return;
607 697
608 if (breakpoint) 698 if (breakpoint) {
609 breakpoint.setCondition(newText); 699 breakpoint.setCondition(newText);
610 else 700 breakpoint.setEnabled(true);
701 } else {
611 this._createNewBreakpoint(lineNumber, newText, true); 702 this._createNewBreakpoint(lineNumber, newText, true);
703 }
612 } 704 }
613 705
614 var config = new UI.InplaceEditor.Config(finishEditing.bind(this, true), fin ishEditing.bind(this, false)); 706 var config = new UI.InplaceEditor.Config(finishEditing.bind(this, true), fin ishEditing.bind(this, false));
615 UI.InplaceEditor.startEditing(this._conditionEditorElement, config); 707 UI.InplaceEditor.startEditing(this._conditionEditorElement, config);
616 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : ' '; 708 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : ' ';
617 this._conditionEditorElement.select(); 709 this._conditionEditorElement.select();
618 } 710 }
619 711
620 _createConditionElement(lineNumber) { 712 _createConditionElement(lineNumber) {
621 var conditionElement = createElementWithClass('div', 'source-frame-breakpoin t-condition'); 713 var conditionElement = createElementWithClass('div', 'source-frame-breakpoin t-condition');
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 } 933 }
842 return false; 934 return false;
843 } 935 }
844 936
845 _breakpointAdded(event) { 937 _breakpointAdded(event) {
846 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); 938 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation );
847 if (uiLocation.uiSourceCode !== this.uiSourceCode()) 939 if (uiLocation.uiSourceCode !== this.uiSourceCode())
848 return; 940 return;
849 if (this._shouldIgnoreExternalBreakpointEvents()) 941 if (this._shouldIgnoreExternalBreakpointEvents())
850 return; 942 return;
851 943 if (this.loaded)
852 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); 944 this._updateBreakpointDecoration(uiLocation.lineNumber);
853 if (this.loaded) {
854 this._addBreakpointDecoration(
855 uiLocation.lineNumber, uiLocation.columnNumber, breakpoint.condition() , breakpoint.enabled(), false);
856 }
857 } 945 }
858 946
859 _breakpointRemoved(event) { 947 _breakpointRemoved(event) {
860 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); 948 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation );
861 if (uiLocation.uiSourceCode !== this.uiSourceCode()) 949 if (uiLocation.uiSourceCode !== this.uiSourceCode())
862 return; 950 return;
863 if (this._shouldIgnoreExternalBreakpointEvents()) 951 if (this._shouldIgnoreExternalBreakpointEvents())
864 return; 952 return;
865 953 if (this.loaded)
866 var remainingBreakpoints = this._breakpointManager.findBreakpoints(this.uiSo urceCode(), uiLocation.lineNumber); 954 this._updateBreakpointDecoration(uiLocation.lineNumber);
867 if (!remainingBreakpoints.length && this.loaded)
868 this._removeBreakpointDecoration(uiLocation.lineNumber);
869 } 955 }
870 956
871 /** 957 /**
872 * @param {!Common.Event} event 958 * @param {!Common.Event} event
873 */ 959 */
874 _onSourceMappingChanged(event) { 960 _onSourceMappingChanged(event) {
875 var data = /** @type {{target: !SDK.Target}} */ (event.data); 961 var data = /** @type {{target: !SDK.Target}} */ (event.data);
876 this._updateScriptFile(data.target); 962 this._updateScriptFile(data.target);
877 this._updateLinesWithoutMappingHighlight(); 963 this._updateLinesWithoutMappingHighlight();
878 } 964 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 this._toggleBreakpoint(lineNumber, eventObject.shiftKey); 1089 this._toggleBreakpoint(lineNumber, eventObject.shiftKey);
1004 eventObject.consume(true); 1090 eventObject.consume(true);
1005 } 1091 }
1006 1092
1007 /** 1093 /**
1008 * @param {number} lineNumber 1094 * @param {number} lineNumber
1009 * @param {boolean} onlyDisable 1095 * @param {boolean} onlyDisable
1010 */ 1096 */
1011 _toggleBreakpoint(lineNumber, onlyDisable) { 1097 _toggleBreakpoint(lineNumber, onlyDisable) {
1012 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCode( ), lineNumber); 1098 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCode( ), lineNumber);
1013 if (breakpoints.length) { 1099 if (!breakpoints.length) {
1100 this._createNewBreakpoint(lineNumber, '', true);
1101 return;
1102 }
1103 for (var breakpoint of breakpoints) {
1014 if (onlyDisable) 1104 if (onlyDisable)
1015 breakpoints[0].setEnabled(!breakpoints[0].enabled()); 1105 breakpoint.setEnabled(false);
1016 else 1106 else
1017 breakpoints[0].remove(); 1107 breakpoint.remove();
1018 } else {
1019 this._createNewBreakpoint(lineNumber, '', true);
1020 } 1108 }
1021 } 1109 }
1022 1110
1023 /** 1111 /**
1024 * @param {number} lineNumber 1112 * @param {number} lineNumber
1025 * @param {string} condition 1113 * @param {string} condition
1026 * @param {boolean} enabled 1114 * @param {boolean} enabled
1027 */ 1115 */
1028 _createNewBreakpoint(lineNumber, condition, enabled) { 1116 _createNewBreakpoint(lineNumber, condition, enabled) {
1029 findPossibleBreakpoints.call(this, lineNumber) 1117 findPossibleBreakpoints.call(this, lineNumber)
(...skipping 28 matching lines...) Expand all
1058 return Promise.resolve(locations); 1146 return Promise.resolve(locations);
1059 return findPossibleBreakpoints.call(this, currentLineNumber + 1) 1147 return findPossibleBreakpoints.call(this, currentLineNumber + 1)
1060 .then(checkNextLineIfNeeded.bind(this, currentLineNumber + 1, linesToC heck - 1)); 1148 .then(checkNextLineIfNeeded.bind(this, currentLineNumber + 1, linesToC heck - 1));
1061 } 1149 }
1062 1150
1063 /** 1151 /**
1064 * @this {!Sources.JavaScriptSourceFrame} 1152 * @this {!Sources.JavaScriptSourceFrame}
1065 * @param {?Array<!Workspace.UILocation>} locations 1153 * @param {?Array<!Workspace.UILocation>} locations
1066 */ 1154 */
1067 function setBreakpoint(locations) { 1155 function setBreakpoint(locations) {
1068 if (!locations || !locations.length) 1156 if (!locations || !locations.length) {
1069 this._setBreakpoint(lineNumber, 0, condition, enabled); 1157 this._setBreakpoint(lineNumber, 0, condition, enabled);
1070 else 1158 } else {
1071 this._setBreakpoint(locations[0].lineNumber, locations[0].columnNumber, condition, enabled); 1159 var maximumBreakpointsAmount = Runtime.experiments.isEnabled('inlineBrea kpoints') ? locations.length : 1;
lushnikov 2016/11/17 04:31:50 let's make the experiment check simpler: if (Runt
1160 for (var i = 0; i < locations.length && i < maximumBreakpointsAmount; ++ i)
1161 this._setBreakpoint(locations[i].lineNumber, locations[i].columnNumber , i === 0 ? condition : '', i === 0 && enabled);
1162 }
1072 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ScriptsBreakpointSet) ; 1163 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ScriptsBreakpointSet) ;
1073 } 1164 }
1074 } 1165 }
1075 1166
1076 toggleBreakpointOnCurrentLine() { 1167 toggleBreakpointOnCurrentLine() {
1077 if (this._muted) 1168 if (this._muted)
1078 return; 1169 return;
1079 1170
1080 var selection = this.textEditor.selection(); 1171 var selection = this.textEditor.selection();
1081 if (!selection) 1172 if (!selection)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); 1211 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this);
1121 this.uiSourceCode().removeEventListener( 1212 this.uiSourceCode().removeEventListener(
1122 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); 1213 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this);
1123 this.uiSourceCode().removeEventListener( 1214 this.uiSourceCode().removeEventListener(
1124 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); 1215 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this);
1125 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this); 1216 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this);
1126 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); 1217 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this);
1127 super.dispose(); 1218 super.dispose();
1128 } 1219 }
1129 }; 1220 };
1221
1222 Sources.JavaScriptSourceFrame._inlineBreakpointSymbol = Symbol('inline-breakpoin t');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698