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

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._controlDown = false;
490 this._clearContinueToLocations();
dgozman 2017/04/29 00:36:56 So this rebuilds inline values on every key stroke
491
488 if (event.key === 'Escape') { 492 if (event.key === 'Escape') {
489 if (this._popoverHelper.isPopoverVisible()) { 493 if (this._popoverHelper.isPopoverVisible()) {
490 this._popoverHelper.hidePopover(); 494 this._popoverHelper.hidePopover();
491 event.consume(); 495 event.consume();
492 } 496 }
493 return; 497 return;
494 } 498 }
499
495 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event) && this._executionLocation ) { 500 if (UI.KeyboardShortcut.eventHasCtrlOrMeta(event) && this._executionLocation ) {
496 if (!this._continueToLocationDecorations) 501 this._controlDown = true;
497 this._showContinueToLocations(); 502 if (event.key === 'Control') {
dgozman 2017/04/29 00:36:56 or meta
503 setTimeout(() => {
504 if (this._executionLocation && this._controlDown)
505 this._showContinueToLocations();
506 }, 150);
507 }
498 } 508 }
499 } 509 }
500 510
501 /** 511 /**
502 * @param {!MouseEvent} event 512 * @param {!MouseEvent} event
503 */ 513 */
504 _onMouseMove(event) { 514 _onMouseMove(event) {
505 if (this._executionLocation && UI.KeyboardShortcut.eventHasCtrlOrMeta(event) ) { 515 if (this._executionLocation && this._controlDown && UI.KeyboardShortcut.even tHasCtrlOrMeta(event)) {
506 if (!this._continueToLocationDecorations) 516 if (!this._continueToLocationDecorations)
507 this._showContinueToLocations(); 517 this._showContinueToLocations();
508 } 518 }
509 } 519 }
510 520
511 /** 521 /**
512 * @param {!MouseEvent} event 522 * @param {!MouseEvent} event
513 */ 523 */
514 _onMouseDown(event) { 524 _onMouseDown(event) {
515 if (!this._executionLocation || !UI.KeyboardShortcut.eventHasCtrlOrMeta(even t)) 525 if (!this._executionLocation || !UI.KeyboardShortcut.eventHasCtrlOrMeta(even t))
516 return; 526 return;
517 if (!this._continueToLocationDecorations) 527 if (!this._continueToLocationDecorations)
518 return; 528 return;
519 event.consume(); 529 event.consume();
520 var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, even t.y); 530 var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, even t.y);
521 if (!textPosition) 531 if (!textPosition)
522 return; 532 return;
523 for (var decoration of this._continueToLocationDecorations.keys()) { 533 for (var decoration of this._continueToLocationDecorations.keys()) {
524 var range = decoration.find(); 534 var range = decoration.find();
525 if (range.from.line !== textPosition.startLine || range.to.line !== textPo sition.startLine) 535 if (range.from.line !== textPosition.startLine || range.to.line !== textPo sition.startLine)
526 continue; 536 continue;
527 if (range.from.ch <= textPosition.startColumn && textPosition.startColumn <= range.to.ch) { 537 if (range.from.ch <= textPosition.startColumn && textPosition.startColumn <= range.to.ch) {
528 this._continueToLocationDecorations.get(decoration)(); 538 this._continueToLocationDecorations.get(decoration)();
529 break; 539 break;
530 } 540 }
531 } 541 }
532 } 542 }
533 543
534 /** 544 /**
545 * @param {!Event} event
546 */
547 _onBlur(event) {
548 this._clearContinueToLocations();
549 this._controlDown = this._controlDown && this.textEditor.element.isAncestor( event.target);
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._controlDown = false;
539 return;
540 this._clearContinueToLocations(); 557 this._clearContinueToLocations();
541 } 558 }
542 559
543 /** 560 /**
544 * @param {number} lineNumber 561 * @param {number} lineNumber
545 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint 562 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint
546 * @param {?{lineNumber: number, columnNumber: number}} location 563 * @param {?{lineNumber: number, columnNumber: number}} location
547 */ 564 */
548 _editBreakpointCondition(lineNumber, breakpoint, location) { 565 _editBreakpointCondition(lineNumber, breakpoint, location) {
549 this._conditionElement = this._createConditionElement(lineNumber); 566 this._conditionElement = this._createConditionElement(lineNumber);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 */ 611 */
595 setExecutionLocation(uiLocation) { 612 setExecutionLocation(uiLocation) {
596 this._executionLocation = uiLocation; 613 this._executionLocation = uiLocation;
597 if (!this.loaded) 614 if (!this.loaded)
598 return; 615 return;
599 616
600 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum nNumber); 617 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum nNumber);
601 if (this.isShowing()) { 618 if (this.isShowing()) {
602 // We need SourcesTextEditor to be initialized prior to this call. @see cr bug.com/506566 619 // We need SourcesTextEditor to be initialized prior to this call. @see cr bug.com/506566
603 setImmediate(() => { 620 setImmediate(() => {
604 this._generateValuesInSource(); 621 if (this._controlDown) {
605 if (Runtime.experiments.isEnabled('continueToLocationMarkers')) { 622 if (Runtime.experiments.isEnabled('continueToLocationMarkers'))
606 if (this._continueToLocationDecorations)
607 this._showContinueToLocations(); 623 this._showContinueToLocations();
624 } else {
625 this._generateValuesInSource();
608 } 626 }
609 }); 627 });
610 } 628 }
611 } 629 }
612 630
613 _generateValuesInSource() { 631 _generateValuesInSource() {
614 if (!Common.moduleSetting('inlineVariableValues').get()) 632 if (!Common.moduleSetting('inlineVariableValues').get())
615 return; 633 return;
616 var executionContext = UI.context.flavor(SDK.ExecutionContext); 634 var executionContext = UI.context.flavor(SDK.ExecutionContext);
617 if (!executionContext) 635 if (!executionContext)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 var debuggerModel = callFrame.debuggerModel; 671 var debuggerModel = callFrame.debuggerModel;
654 debuggerModel.getPossibleBreakpoints(start, end, true) 672 debuggerModel.getPossibleBreakpoints(start, end, true)
655 .then(locations => this.textEditor.operation(renderLocations.bind(this, locations))); 673 .then(locations => this.textEditor.operation(renderLocations.bind(this, locations)));
656 674
657 /** 675 /**
658 * @param {!Array<!SDK.DebuggerModel.BreakLocation>} locations 676 * @param {!Array<!SDK.DebuggerModel.BreakLocation>} locations
659 * @this {Sources.JavaScriptSourceFrame} 677 * @this {Sources.JavaScriptSourceFrame}
660 */ 678 */
661 function renderLocations(locations) { 679 function renderLocations(locations) {
662 this._clearContinueToLocations(); 680 this._clearContinueToLocations();
681 this.textEditor.hideExecutionLineBackground();
682 this._clearValueWidgets();
663 this._continueToLocationDecorations = new Map(); 683 this._continueToLocationDecorations = new Map();
664 for (var location of locations) { 684 for (var location of locations) {
665 var lineNumber = location.lineNumber; 685 var lineNumber = location.lineNumber;
666 var token = this.textEditor.tokenAtTextPosition(lineNumber, location.col umnNumber); 686 var token = this.textEditor.tokenAtTextPosition(lineNumber, location.col umnNumber);
667 if (!token || !token.type) 687 if (!token || !token.type)
668 continue; 688 continue;
669 var line = this.textEditor.line(lineNumber); 689 var line = this.textEditor.line(lineNumber);
670 var tokenContent = line.substring(token.startColumn, token.endColumn); 690 var tokenContent = line.substring(token.startColumn, token.endColumn);
671 if (!this._isIdentifier(token.type) && (token.type !== 'js-keyword' || t okenContent !== 'this')) 691 if (!this._isIdentifier(token.type) && (token.type !== 'js-keyword' || t okenContent !== 'this'))
672 continue; 692 continue;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 _clearValueWidgets() { 854 _clearValueWidgets() {
835 delete this._clearValueWidgetsTimer; 855 delete this._clearValueWidgetsTimer;
836 this.textEditor.operation(() => { 856 this.textEditor.operation(() => {
837 for (var line of this._valueWidgets.keys()) 857 for (var line of this._valueWidgets.keys())
838 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); 858 this.textEditor.removeDecoration(this._valueWidgets.get(line), line);
839 this._valueWidgets.clear(); 859 this._valueWidgets.clear();
840 }); 860 });
841 } 861 }
842 862
843 _clearContinueToLocations() { 863 _clearContinueToLocations() {
864 this.textEditor.showExecutionLineBackground();
865 this._generateValuesInSource();
844 if (!this._continueToLocationDecorations) 866 if (!this._continueToLocationDecorations)
845 return; 867 return;
846 this.textEditor.operation(() => { 868 this.textEditor.operation(() => {
847 for (var decoration of this._continueToLocationDecorations.keys()) 869 for (var decoration of this._continueToLocationDecorations.keys())
848 this.textEditor.removeHighlight(decoration); 870 this.textEditor.removeHighlight(decoration);
849 delete this._continueToLocationDecorations; 871 this._continueToLocationDecorations = null;
850 }); 872 });
851 } 873 }
852 874
853 /** 875 /**
854 * @param {number} lineNumber 876 * @param {number} lineNumber
855 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} 877 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>}
856 */ 878 */
857 _lineBreakpointDecorations(lineNumber) { 879 _lineBreakpointDecorations(lineNumber) {
858 return Array.from(this._breakpointDecorations) 880 return Array.from(this._breakpointDecorations)
859 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); 881 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber);
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 return; 1502 return;
1481 this.bookmark.clear(); 1503 this.bookmark.clear();
1482 this.bookmark = null; 1504 this.bookmark = null;
1483 } 1505 }
1484 }; 1506 };
1485 1507
1486 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); 1508 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark');
1487 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); 1509 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element');
1488 1510
1489 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark'); 1511 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698