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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 /** | 242 /** |
| 243 * @this {WebInspector.JavaScriptSourceFrame} | 243 * @this {WebInspector.JavaScriptSourceFrame} |
| 244 */ | 244 */ |
| 245 function populate(resolve, reject) { | 245 function populate(resolve, reject) { |
| 246 var uiLocation = new WebInspector.UILocation(this.uiSourceCode(), lineNumb er, 0); | 246 var uiLocation = new WebInspector.UILocation(this.uiSourceCode(), lineNumb er, 0); |
| 247 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 247 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 248 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod e(), lineNumber); | 248 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod e(), lineNumber); |
| 249 if (!breakpoints.length) { | 249 if (!breakpoints.length) { |
| 250 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. | 250 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. |
| 251 contextMenu.appendItem( | 251 contextMenu.appendItem( |
| 252 WebInspector.UIString('Add breakpoint'), this._createNewBreakpoint.b ind(this, lineNumber, 0, '', true)); | 252 WebInspector.UIString('Add breakpoint'), this._createNewBreakpoint.b ind(this, lineNumber, '', true)); |
| 253 contextMenu.appendItem( | 253 contextMenu.appendItem( |
| 254 WebInspector.UIString('Add conditional breakpoint…'), this._editBrea kpointCondition.bind(this, lineNumber)); | 254 WebInspector.UIString('Add conditional breakpoint…'), this._editBrea kpointCondition.bind(this, lineNumber)); |
| 255 contextMenu.appendItem( | 255 contextMenu.appendItem( |
| 256 WebInspector.UIString('Never pause here'), | 256 WebInspector.UIString('Never pause here'), |
| 257 this._createNewBreakpoint.bind(this, lineNumber, 0, 'false', true)); | 257 this._createNewBreakpoint.bind(this, lineNumber, 'false', true)); |
| 258 } else { | 258 } else { |
| 259 var breakpoint = breakpoints[0]; | 259 var breakpoint = breakpoints[0]; |
| 260 | 260 |
| 261 // This row has a breakpoint, we want to show edit and remove breakpoint , and either disable or enable. | 261 // This row has a breakpoint, we want to show edit and remove breakpoint , and either disable or enable. |
| 262 contextMenu.appendItem(WebInspector.UIString('Remove breakpoint'), break point.remove.bind(breakpoint)); | 262 contextMenu.appendItem(WebInspector.UIString('Remove breakpoint'), break point.remove.bind(breakpoint)); |
| 263 contextMenu.appendItem( | 263 contextMenu.appendItem( |
| 264 WebInspector.UIString('Edit breakpoint…'), | 264 WebInspector.UIString('Edit breakpoint…'), |
| 265 this._editBreakpointCondition.bind(this, lineNumber, breakpoint)); | 265 this._editBreakpointCondition.bind(this, lineNumber, breakpoint)); |
| 266 if (breakpoint.enabled()) | 266 if (breakpoint.enabled()) |
| 267 contextMenu.appendItem( | 267 contextMenu.appendItem( |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 function finishEditing(committed, element, newText) { | 598 function finishEditing(committed, element, newText) { |
| 599 this.textEditor.removeDecoration(this._conditionElement, lineNumber); | 599 this.textEditor.removeDecoration(this._conditionElement, lineNumber); |
| 600 delete this._conditionEditorElement; | 600 delete this._conditionEditorElement; |
| 601 delete this._conditionElement; | 601 delete this._conditionElement; |
| 602 if (!committed) | 602 if (!committed) |
| 603 return; | 603 return; |
| 604 | 604 |
| 605 if (breakpoint) | 605 if (breakpoint) |
| 606 breakpoint.setCondition(newText); | 606 breakpoint.setCondition(newText); |
| 607 else | 607 else |
| 608 this._createNewBreakpoint(lineNumber, 0, newText, true); | 608 this._createNewBreakpoint(lineNumber, newText, true); |
| 609 } | 609 } |
| 610 | 610 |
| 611 var config = new WebInspector.InplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, false)); | 611 var config = new WebInspector.InplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, false)); |
| 612 WebInspector.InplaceEditor.startEditing(this._conditionEditorElement, config ); | 612 WebInspector.InplaceEditor.startEditing(this._conditionEditorElement, config ); |
| 613 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : ' '; | 613 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : ' '; |
| 614 this._conditionEditorElement.select(); | 614 this._conditionEditorElement.select(); |
| 615 } | 615 } |
| 616 | 616 |
| 617 _createConditionElement(lineNumber) { | 617 _createConditionElement(lineNumber) { |
| 618 var conditionElement = createElementWithClass('div', 'source-frame-breakpoin t-condition'); | 618 var conditionElement = createElementWithClass('div', 'source-frame-breakpoin t-condition'); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1005 * @param {boolean} onlyDisable | 1005 * @param {boolean} onlyDisable |
| 1006 */ | 1006 */ |
| 1007 _toggleBreakpoint(lineNumber, onlyDisable) { | 1007 _toggleBreakpoint(lineNumber, onlyDisable) { |
| 1008 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCode( ), lineNumber); | 1008 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCode( ), lineNumber); |
| 1009 if (breakpoints.length) { | 1009 if (breakpoints.length) { |
| 1010 if (onlyDisable) | 1010 if (onlyDisable) |
| 1011 breakpoints[0].setEnabled(!breakpoints[0].enabled()); | 1011 breakpoints[0].setEnabled(!breakpoints[0].enabled()); |
| 1012 else | 1012 else |
| 1013 breakpoints[0].remove(); | 1013 breakpoints[0].remove(); |
| 1014 } else | 1014 } else |
| 1015 this._createNewBreakpoint(lineNumber, 0, '', true); | 1015 this._createNewBreakpoint(lineNumber, '', true); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 /** | 1018 /** |
| 1019 * @param {number} lineNumber | 1019 * @param {number} lineNumber |
| 1020 * @param {number} columnNumber | |
| 1021 * @param {string} condition | 1020 * @param {string} condition |
| 1022 * @param {boolean} enabled | 1021 * @param {boolean} enabled |
| 1023 */ | 1022 */ |
| 1024 _createNewBreakpoint(lineNumber, columnNumber, condition, enabled) { | 1023 _createNewBreakpoint(lineNumber, condition, enabled) { |
| 1025 this._setBreakpoint(lineNumber, columnNumber, condition, enabled); | 1024 const linesToCheck = 5; |
| 1026 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Scripts BreakpointSet); | 1025 var promise = Promise.resolve(); |
| 1026 for (let i = 0; i < linesToCheck; ++i) | |
|
dgozman
2016/11/09 20:44:03
let! Oh my!
kozy
2016/11/10 03:17:36
Done.
| |
| 1027 promise = promise.then(locations => locations ? locations : findPossibleBr eakpoints.call(this, lineNumber + i)); | |
|
dgozman
2016/11/09 20:44:03
From my tests on DevTools engineers;
- one failed
kozy
2016/11/10 03:17:36
Done.
| |
| 1028 promise.then(setBreakpoint.bind(this)); | |
| 1029 | |
| 1030 /** | |
| 1031 * @this {!WebInspector.JavaScriptSourceFrame} | |
| 1032 * @param {number} lineNumber | |
| 1033 * @return {!Promise<!Array<!WebInspector.UILocation>>} | |
|
dgozman
2016/11/09 20:44:03
?Array
kozy
2016/11/10 03:17:36
Done.
| |
| 1034 */ | |
| 1035 function findPossibleBreakpoints(lineNumber) { | |
| 1036 const maxLengthToCheck = 1024; | |
| 1037 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) | |
| 1038 return Promise.resolve([]); | |
| 1039 return this._breakpointManager.possibleBreakpoints(this.uiSourceCode(), ne w WebInspector.TextRange(lineNumber, 0, lineNumber + 1, 0)) | |
| 1040 .then(locations => locations.length ? locations : null); | |
| 1041 } | |
| 1042 | |
| 1043 /** | |
| 1044 * @this {!WebInspector.JavaScriptSourceFrame} | |
| 1045 * @param {!Array<!WebInspector.UILocation>} locations | |
|
dgozman
2016/11/09 20:44:03
?Array
kozy
2016/11/10 03:17:36
Done.
| |
| 1046 */ | |
| 1047 function setBreakpoint(locations) { | |
| 1048 if (!locations || !locations.length) | |
| 1049 this._setBreakpoint(lineNumber, 0, condition, enabled); | |
| 1050 else | |
| 1051 this._setBreakpoint(locations[0].lineNumber, locations[0].columnNumber, condition, enabled); | |
| 1052 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Scrip tsBreakpointSet); | |
| 1053 } | |
| 1027 } | 1054 } |
| 1028 | 1055 |
| 1029 toggleBreakpointOnCurrentLine() { | 1056 toggleBreakpointOnCurrentLine() { |
| 1030 if (this._muted) | 1057 if (this._muted) |
| 1031 return; | 1058 return; |
| 1032 | 1059 |
| 1033 var selection = this.textEditor.selection(); | 1060 var selection = this.textEditor.selection(); |
| 1034 if (!selection) | 1061 if (!selection) |
| 1035 return; | 1062 return; |
| 1036 this._toggleBreakpoint(selection.startLine, false); | 1063 this._toggleBreakpoint(selection.startLine, false); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1063 WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyCh anged, this); | 1090 WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyCh anged, this); |
| 1064 this.uiSourceCode().removeEventListener( | 1091 this.uiSourceCode().removeEventListener( |
| 1065 WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopy Committed, this); | 1092 WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopy Committed, this); |
| 1066 this.uiSourceCode().removeEventListener( | 1093 this.uiSourceCode().removeEventListener( |
| 1067 WebInspector.UISourceCode.Events.TitleChanged, this._showBlackboxInfobar IfNeeded, this); | 1094 WebInspector.UISourceCode.Events.TitleChanged, this._showBlackboxInfobar IfNeeded, this); |
| 1068 WebInspector.moduleSetting('skipStackFramesPattern').removeChangeListener(th is._showBlackboxInfobarIfNeeded, this); | 1095 WebInspector.moduleSetting('skipStackFramesPattern').removeChangeListener(th is._showBlackboxInfobarIfNeeded, this); |
| 1069 WebInspector.moduleSetting('skipContentScripts').removeChangeListener(this._ showBlackboxInfobarIfNeeded, this); | 1096 WebInspector.moduleSetting('skipContentScripts').removeChangeListener(this._ showBlackboxInfobarIfNeeded, this); |
| 1070 super.dispose(); | 1097 super.dispose(); |
| 1071 } | 1098 } |
| 1072 }; | 1099 }; |
| OLD | NEW |