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

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

Issue 2849973003: DevTools: remove continue to location from behind experiment. (Closed)
Patch Set: same? Created 3 years, 7 months 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 this._popoverHelper.setDisableOnClick(true); 48 this._popoverHelper.setDisableOnClick(true);
49 this._popoverHelper.setTimeout(250, 250); 49 this._popoverHelper.setTimeout(250, 250);
50 this._popoverHelper.setHasPadding(true); 50 this._popoverHelper.setHasPadding(true);
51 this._scriptsPanel.element.addEventListener( 51 this._scriptsPanel.element.addEventListener(
52 'scroll', this._popoverHelper.hidePopover.bind(this._popoverHelper), tru e); 52 'scroll', this._popoverHelper.hidePopover.bind(this._popoverHelper), tru e);
53 53
54 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi s), true); 54 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi s), true);
55 this.textEditor.element.addEventListener('keyup', this._onKeyUp.bind(this), true); 55 this.textEditor.element.addEventListener('keyup', this._onKeyUp.bind(this), true);
56 this.textEditor.element.addEventListener('mousemove', this._onMouseMove.bind (this), false); 56 this.textEditor.element.addEventListener('mousemove', this._onMouseMove.bind (this), false);
57 this.textEditor.element.addEventListener('mousedown', this._onMouseDown.bind (this), true); 57 this.textEditor.element.addEventListener('mousedown', this._onMouseDown.bind (this), true);
58 this.textEditor.element.addEventListener('focusout', this._onBlur.bind(this) , false);
58 if (Runtime.experiments.isEnabled('continueToLocationMarkers')) { 59 if (Runtime.experiments.isEnabled('continueToLocationMarkers')) {
59 this.textEditor.element.addEventListener('wheel', event => { 60 this.textEditor.element.addEventListener('wheel', event => {
60 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event)) 61 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event))
61 event.preventDefault(); 62 event.preventDefault();
62 }, true); 63 }, true);
63 } 64 }
64 65
65 this.textEditor.addEventListener( 66 this.textEditor.addEventListener(
66 SourceFrame.SourcesTextEditor.Events.GutterClick, this._handleGutterClic k.bind(this), this); 67 SourceFrame.SourcesTextEditor.Events.GutterClick, this._handleGutterClic k.bind(this), this);
67 68
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 debuggerModel.runtimeModel().releaseObjectGroup('popover'); 479 debuggerModel.runtimeModel().releaseObjectGroup('popover');
479 this.textEditor.removeHighlight(highlightDescriptor); 480 this.textEditor.removeHighlight(highlightDescriptor);
480 } 481 }
481 }; 482 };
482 } 483 }
483 484
484 /** 485 /**
485 * @param {!KeyboardEvent} event 486 * @param {!KeyboardEvent} event
486 */ 487 */
487 _onKeyDown(event) { 488 _onKeyDown(event) {
489 this._clearControlDown();
490
488 if (event.key === 'Escape') { 491 if (event.key === 'Escape') {
489 if (this._popoverHelper.isPopoverVisible()) { 492 if (this._popoverHelper.isPopoverVisible()) {
490 this._popoverHelper.hidePopover(); 493 this._popoverHelper.hidePopover();
491 event.consume(); 494 event.consume();
492 } 495 }
493 return; 496 return;
494 } 497 }
498
495 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event) && this._executionLocation ) { 499 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event) && this._executionLocation ) {
496 if (!this._continueToLocationDecorations) 500 this._controlDown = true;
497 this._showContinueToLocations(); 501 if (event.key === UI.KeyboardShortcut.Keys.CtrlOrMeta.name) {
502 this._controlTimeout = setTimeout(() => {
503 if (this._executionLocation && this._controlDown)
504 this._showContinueToLocations();
505 }, 150);
506 }
498 } 507 }
499 } 508 }
500 509
501 /** 510 /**
502 * @param {!MouseEvent} event 511 * @param {!MouseEvent} event
503 */ 512 */
504 _onMouseMove(event) { 513 _onMouseMove(event) {
505 if (this._executionLocation && UI.KeyboardShortcut.eventHasCtrlOrMeta(event) ) { 514 if (this._executionLocation && this._controlDown && UI.KeyboardShortcut.even tHasCtrlOrMeta(event)) {
506 if (!this._continueToLocationDecorations) 515 if (!this._continueToLocationDecorations)
507 this._showContinueToLocations(); 516 this._showContinueToLocations();
508 } 517 }
509 } 518 }
510 519
511 /** 520 /**
512 * @param {!MouseEvent} event 521 * @param {!MouseEvent} event
513 */ 522 */
514 _onMouseDown(event) { 523 _onMouseDown(event) {
515 if (!this._executionLocation || !UI.KeyboardShortcut.eventHasCtrlOrMeta(even t)) 524 if (!this._executionLocation || !UI.KeyboardShortcut.eventHasCtrlOrMeta(even t))
516 return; 525 return;
517 if (!this._continueToLocationDecorations) 526 if (!this._continueToLocationDecorations)
518 return; 527 return;
519 event.consume(); 528 event.consume();
520 var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, even t.y); 529 var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, even t.y);
521 if (!textPosition) 530 if (!textPosition)
522 return; 531 return;
523 for (var decoration of this._continueToLocationDecorations.keys()) { 532 for (var decoration of this._continueToLocationDecorations.keys()) {
524 var range = decoration.find(); 533 var range = decoration.find();
525 if (range.from.line !== textPosition.startLine || range.to.line !== textPo sition.startLine) 534 if (range.from.line !== textPosition.startLine || range.to.line !== textPo sition.startLine)
526 continue; 535 continue;
527 if (range.from.ch <= textPosition.startColumn && textPosition.startColumn <= range.to.ch) { 536 if (range.from.ch <= textPosition.startColumn && textPosition.startColumn <= range.to.ch) {
528 this._continueToLocationDecorations.get(decoration)(); 537 this._continueToLocationDecorations.get(decoration)();
529 break; 538 break;
530 } 539 }
531 } 540 }
532 } 541 }
533 542
534 /** 543 /**
544 * @param {!Event} event
545 */
546 _onBlur(event) {
547 if (this.textEditor.element.isAncestor(event.target))
548 return;
549 this._clearControlDown();
550 }
551
552 /**
535 * @param {!KeyboardEvent} event 553 * @param {!KeyboardEvent} event
536 */ 554 */
537 _onKeyUp(event) { 555 _onKeyUp(event) {
538 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event)) 556 this._clearControlDown();
539 return; 557 }
558
559 _clearControlDown() {
560 this._controlDown = false;
540 this._clearContinueToLocations(); 561 this._clearContinueToLocations();
562 clearTimeout(this._controlTimeout);
541 } 563 }
542 564
543 /** 565 /**
544 * @param {number} lineNumber 566 * @param {number} lineNumber
545 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint 567 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint
546 * @param {?{lineNumber: number, columnNumber: number}} location 568 * @param {?{lineNumber: number, columnNumber: number}} location
547 */ 569 */
548 _editBreakpointCondition(lineNumber, breakpoint, location) { 570 _editBreakpointCondition(lineNumber, breakpoint, location) {
549 this._conditionElement = this._createConditionElement(lineNumber); 571 this._conditionElement = this._createConditionElement(lineNumber);
550 this.textEditor.addDecoration(this._conditionElement, lineNumber); 572 this.textEditor.addDecoration(this._conditionElement, lineNumber);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 */ 616 */
595 setExecutionLocation(uiLocation) { 617 setExecutionLocation(uiLocation) {
596 this._executionLocation = uiLocation; 618 this._executionLocation = uiLocation;
597 if (!this.loaded) 619 if (!this.loaded)
598 return; 620 return;
599 621
600 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum nNumber); 622 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum nNumber);
601 if (this.isShowing()) { 623 if (this.isShowing()) {
602 // We need SourcesTextEditor to be initialized prior to this call. @see cr bug.com/506566 624 // We need SourcesTextEditor to be initialized prior to this call. @see cr bug.com/506566
603 setImmediate(() => { 625 setImmediate(() => {
604 this._generateValuesInSource(); 626 if (this._controlDown) {
605 if (Runtime.experiments.isEnabled('continueToLocationMarkers')) { 627 if (Runtime.experiments.isEnabled('continueToLocationMarkers'))
606 if (this._continueToLocationDecorations)
607 this._showContinueToLocations(); 628 this._showContinueToLocations();
629 } else {
630 this._generateValuesInSource();
608 } 631 }
609 }); 632 });
610 } 633 }
611 } 634 }
612 635
613 _generateValuesInSource() { 636 _generateValuesInSource() {
614 if (!Common.moduleSetting('inlineVariableValues').get()) 637 if (!Common.moduleSetting('inlineVariableValues').get())
615 return; 638 return;
616 var executionContext = UI.context.flavor(SDK.ExecutionContext); 639 var executionContext = UI.context.flavor(SDK.ExecutionContext);
617 if (!executionContext) 640 if (!executionContext)
(...skipping 20 matching lines...) Expand all
638 return; 661 return;
639 this._popoverHelper.hidePopover(); 662 this._popoverHelper.hidePopover();
640 var executionContext = UI.context.flavor(SDK.ExecutionContext); 663 var executionContext = UI.context.flavor(SDK.ExecutionContext);
641 if (!executionContext) 664 if (!executionContext)
642 return; 665 return;
643 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); 666 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame);
644 if (!callFrame) 667 if (!callFrame)
645 return; 668 return;
646 var localScope = callFrame.localScope(); 669 var localScope = callFrame.localScope();
647 if (!localScope) { 670 if (!localScope) {
648 this._clearContinueToLocations(); 671 this._clearContinueToLocationsNoRestore();
649 return; 672 return;
650 } 673 }
651 var start = localScope.startLocation(); 674 var start = localScope.startLocation();
652 var end = localScope.endLocation(); 675 var end = localScope.endLocation();
653 var debuggerModel = callFrame.debuggerModel; 676 var debuggerModel = callFrame.debuggerModel;
654 debuggerModel.getPossibleBreakpoints(start, end, true) 677 debuggerModel.getPossibleBreakpoints(start, end, true)
655 .then(locations => this.textEditor.operation(renderLocations.bind(this, locations))); 678 .then(locations => this.textEditor.operation(renderLocations.bind(this, locations)));
656 679
657 /** 680 /**
658 * @param {!Array<!SDK.DebuggerModel.BreakLocation>} locations 681 * @param {!Array<!SDK.DebuggerModel.BreakLocation>} locations
659 * @this {Sources.JavaScriptSourceFrame} 682 * @this {Sources.JavaScriptSourceFrame}
660 */ 683 */
661 function renderLocations(locations) { 684 function renderLocations(locations) {
662 this._clearContinueToLocations(); 685 this._clearContinueToLocationsNoRestore();
686 this.textEditor.hideExecutionLineBackground();
687 this._clearValueWidgets();
663 this._continueToLocationDecorations = new Map(); 688 this._continueToLocationDecorations = new Map();
664 for (var location of locations) { 689 for (var location of locations) {
665 var lineNumber = location.lineNumber; 690 var lineNumber = location.lineNumber;
666 var token = this.textEditor.tokenAtTextPosition(lineNumber, location.col umnNumber); 691 var token = this.textEditor.tokenAtTextPosition(lineNumber, location.col umnNumber);
667 if (!token || !token.type) 692 if (!token || !token.type)
668 continue; 693 continue;
669 var line = this.textEditor.line(lineNumber); 694 var line = this.textEditor.line(lineNumber);
670 var tokenContent = line.substring(token.startColumn, token.endColumn); 695 var tokenContent = line.substring(token.startColumn, token.endColumn);
671 if (!this._isIdentifier(token.type) && (token.type !== 'js-keyword' || t okenContent !== 'this')) 696 if (!this._isIdentifier(token.type) && (token.type !== 'js-keyword' || t okenContent !== 'this'))
672 continue; 697 continue;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 845 }
821 } 846 }
822 } 847 }
823 848
824 clearExecutionLine() { 849 clearExecutionLine() {
825 this.textEditor.operation(() => { 850 this.textEditor.operation(() => {
826 if (this.loaded && this._executionLocation) 851 if (this.loaded && this._executionLocation)
827 this.textEditor.clearExecutionLine(); 852 this.textEditor.clearExecutionLine();
828 delete this._executionLocation; 853 delete this._executionLocation;
829 this._clearValueWidgetsTimer = setTimeout(this._clearValueWidgets.bind(thi s), 1000); 854 this._clearValueWidgetsTimer = setTimeout(this._clearValueWidgets.bind(thi s), 1000);
830 this._clearContinueToLocations(); 855 this._clearContinueToLocationsNoRestore();
831 }); 856 });
832 } 857 }
833 858
834 _clearValueWidgets() { 859 _clearValueWidgets() {
860 clearTimeout(this._clearValueWidgetsTimer);
835 delete this._clearValueWidgetsTimer; 861 delete this._clearValueWidgetsTimer;
836 this.textEditor.operation(() => { 862 this.textEditor.operation(() => {
837 for (var line of this._valueWidgets.keys()) 863 for (var line of this._valueWidgets.keys())
838 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); 864 this.textEditor.removeDecoration(this._valueWidgets.get(line), line);
839 this._valueWidgets.clear(); 865 this._valueWidgets.clear();
840 }); 866 });
841 } 867 }
842 868
869 _clearContinueToLocationsNoRestore() {
870 if (!this._continueToLocationDecorations)
871 return;
872 this.textEditor.operation(() => {
873 for (var decoration of this._continueToLocationDecorations.keys())
874 this.textEditor.removeHighlight(decoration);
875 this._continueToLocationDecorations = null;
876 });
877 }
878
843 _clearContinueToLocations() { 879 _clearContinueToLocations() {
844 if (!this._continueToLocationDecorations) 880 if (!this._continueToLocationDecorations)
845 return; 881 return;
846 this.textEditor.operation(() => { 882 this.textEditor.operation(() => {
847 for (var decoration of this._continueToLocationDecorations.keys()) 883 this.textEditor.showExecutionLineBackground();
848 this.textEditor.removeHighlight(decoration); 884 this._generateValuesInSource();
849 delete this._continueToLocationDecorations; 885 this._clearContinueToLocationsNoRestore();
850 }); 886 });
851 } 887 }
852 888
853 /** 889 /**
854 * @param {number} lineNumber 890 * @param {number} lineNumber
855 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} 891 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>}
856 */ 892 */
857 _lineBreakpointDecorations(lineNumber) { 893 _lineBreakpointDecorations(lineNumber) {
858 return Array.from(this._breakpointDecorations) 894 return Array.from(this._breakpointDecorations)
859 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); 895 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber);
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 return; 1516 return;
1481 this.bookmark.clear(); 1517 this.bookmark.clear();
1482 this.bookmark = null; 1518 this.bookmark = null;
1483 } 1519 }
1484 }; 1520 };
1485 1521
1486 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); 1522 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark');
1487 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); 1523 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element');
1488 1524
1489 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark'); 1525 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698