| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame { | 34 Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame { |
| 35 /** | 35 /** |
| 36 * @param {!Workspace.UISourceCode} uiSourceCode | 36 * @param {!Workspace.UISourceCode} uiSourceCode |
| 37 */ | 37 */ |
| 38 constructor(uiSourceCode) { | 38 constructor(uiSourceCode) { |
| 39 super(uiSourceCode); | 39 super(uiSourceCode); |
| 40 this._debuggerSourceCode = uiSourceCode; |
| 40 | 41 |
| 41 this._scriptsPanel = Sources.SourcesPanel.instance(); | 42 this._scriptsPanel = Sources.SourcesPanel.instance(); |
| 42 this._breakpointManager = Bindings.breakpointManager; | 43 this._breakpointManager = Bindings.breakpointManager; |
| 43 if (uiSourceCode.project().type() === Workspace.projectTypes.Debugger) | 44 if (uiSourceCode.project().type() === Workspace.projectTypes.Debugger) |
| 44 this.element.classList.add('source-frame-debugger-script'); | 45 this.element.classList.add('source-frame-debugger-script'); |
| 45 | 46 |
| 46 this._popoverHelper = new Components.ObjectPopoverHelper( | 47 this._popoverHelper = new Components.ObjectPopoverHelper( |
| 47 this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._res
olveObjectForPopover.bind(this), | 48 this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._res
olveObjectForPopover.bind(this), |
| 48 this._onHidePopover.bind(this), true); | 49 this._onHidePopover.bind(this), true); |
| 49 this._popoverHelper.setTimeout(250, 250); | 50 this._popoverHelper.setTimeout(250, 250); |
| 50 | 51 |
| 51 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi
s), true); | 52 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi
s), true); |
| 52 | 53 |
| 53 this.textEditor.addEventListener( | 54 this.textEditor.addEventListener( |
| 54 SourceFrame.SourcesTextEditor.Events.GutterClick, this._handleGutterClic
k.bind(this), this); | 55 SourceFrame.SourcesTextEditor.Events.GutterClick, this._handleGutterClic
k.bind(this), this); |
| 55 | 56 |
| 56 this._breakpointManager.addEventListener( | 57 this._breakpointManager.addEventListener( |
| 57 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded
, this); | 58 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded
, this); |
| 58 this._breakpointManager.addEventListener( | 59 this._breakpointManager.addEventListener( |
| 59 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem
oved, this); | 60 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem
oved, this); |
| 60 | 61 |
| 61 this.uiSourceCode().addEventListener( | 62 this.uiSourceCode().addEventListener( |
| 62 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin
gChanged, this); | |
| 63 this.uiSourceCode().addEventListener( | |
| 64 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); | 63 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); |
| 65 this.uiSourceCode().addEventListener( | 64 this.uiSourceCode().addEventListener( |
| 66 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); | 65 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); |
| 67 this.uiSourceCode().addEventListener( | 66 this.uiSourceCode().addEventListener( |
| 68 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); | 67 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); |
| 69 | 68 |
| 70 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ | 69 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ |
| 71 this._breakpointDecorations = new Set(); | 70 this._breakpointDecorations = new Set(); |
| 72 /** @type {!Map<!Bindings.BreakpointManager.Breakpoint, !Sources.JavaScriptS
ourceFrame.BreakpointDecoration>} */ | 71 /** @type {!Map<!Bindings.BreakpointManager.Breakpoint, !Sources.JavaScriptS
ourceFrame.BreakpointDecoration>} */ |
| 73 this._decorationByBreakpoint = new Map(); | 72 this._decorationByBreakpoint = new Map(); |
| 74 | 73 |
| 75 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ | 74 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ |
| 76 this._scriptFileForTarget = new Map(); | 75 this._scriptFileForTarget = new Map(); |
| 77 var targets = SDK.targetManager.targets(); | |
| 78 for (var i = 0; i < targets.length; ++i) { | |
| 79 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode
, targets[i]); | |
| 80 if (scriptFile) | |
| 81 this._updateScriptFile(targets[i]); | |
| 82 } | |
| 83 | |
| 84 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' || | |
| 85 uiSourceCode.project().type() === Workspace.projectTypes.Snippets) | |
| 86 this._compiler = new Sources.JavaScriptCompiler(this); | |
| 87 | 76 |
| 88 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB
lackboxInfobarIfNeeded, this); | 77 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB
lackboxInfobarIfNeeded, this); |
| 89 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack
boxInfobarIfNeeded, this); | 78 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack
boxInfobarIfNeeded, this); |
| 90 this._showBlackboxInfobarIfNeeded(); | 79 |
| 91 /** @type {!Map.<number, !Element>} */ | 80 /** @type {!Map.<number, !Element>} */ |
| 92 this._valueWidgets = new Map(); | 81 this._valueWidgets = new Map(); |
| 82 this.onBindingChanged(); |
| 93 } | 83 } |
| 94 | 84 |
| 95 /** | 85 /** |
| 96 * @override | 86 * @override |
| 97 * @return {!Array<!UI.ToolbarItem>} | 87 * @return {!Array<!UI.ToolbarItem>} |
| 98 */ | 88 */ |
| 99 syncToolbarItems() { | 89 syncToolbarItems() { |
| 100 var result = super.syncToolbarItems(); | 90 var result = super.syncToolbarItems(); |
| 101 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this.uiSou
rceCode()); | 91 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this._debu
ggerSourceCode); |
| 102 if (originURL) { | 92 if (originURL) { |
| 103 var parsedURL = originURL.asParsedURL(); | 93 var parsedURL = originURL.asParsedURL(); |
| 104 if (parsedURL) | 94 if (parsedURL) |
| 105 result.push(new UI.ToolbarText(Common.UIString('(source mapped from %s)'
, parsedURL.displayName))); | 95 result.push(new UI.ToolbarText(Common.UIString('(source mapped from %s)'
, parsedURL.displayName))); |
| 106 } | 96 } |
| 107 | 97 |
| 108 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Snippets
) { | 98 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Snippets
) { |
| 109 result.push(new UI.ToolbarSeparator(true)); | 99 result.push(new UI.ToolbarSeparator(true)); |
| 110 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet'
); | 100 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet'
); |
| 111 runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common
.UIString('Ctrl+Enter')); | 101 runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common
.UIString('Ctrl+Enter')); |
| 112 result.push(runSnippet); | 102 result.push(runSnippet); |
| 113 } | 103 } |
| 114 | 104 |
| 115 return result; | 105 return result; |
| 116 } | 106 } |
| 117 | 107 |
| 118 _showBlackboxInfobarIfNeeded() { | 108 _showBlackboxInfobarIfNeeded() { |
| 119 var uiSourceCode = this.uiSourceCode(); | 109 var uiSourceCode = this._debuggerSourceCode; |
| 120 if (!uiSourceCode.contentType().hasScripts()) | 110 if (!uiSourceCode.contentType().hasScripts()) |
| 121 return; | 111 return; |
| 122 var projectType = uiSourceCode.project().type(); | 112 var projectType = uiSourceCode.project().type(); |
| 123 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { | 113 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { |
| 124 this._hideBlackboxInfobar(); | 114 this._hideBlackboxInfobar(); |
| 125 return; | 115 return; |
| 126 } | 116 } |
| 127 | 117 |
| 128 if (this._blackboxInfobar) | 118 if (this._blackboxInfobar) |
| 129 this._blackboxInfobar.dispose(); | 119 this._blackboxInfobar.dispose(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 192 |
| 203 /** | 193 /** |
| 204 * @override | 194 * @override |
| 205 * @return {!Promise} | 195 * @return {!Promise} |
| 206 */ | 196 */ |
| 207 populateLineGutterContextMenu(contextMenu, lineNumber) { | 197 populateLineGutterContextMenu(contextMenu, lineNumber) { |
| 208 /** | 198 /** |
| 209 * @this {Sources.JavaScriptSourceFrame} | 199 * @this {Sources.JavaScriptSourceFrame} |
| 210 */ | 200 */ |
| 211 function populate(resolve, reject) { | 201 function populate(resolve, reject) { |
| 212 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber,
0); | 202 var uiLocation = new Workspace.UILocation(this._debuggerSourceCode, lineNu
mber, 0); |
| 213 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 203 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 214 var breakpoints = this._lineBreakpointDecorations(lineNumber) | 204 var breakpoints = this._lineBreakpointDecorations(lineNumber) |
| 215 .map(decoration => decoration.breakpoint) | 205 .map(decoration => decoration.breakpoint) |
| 216 .filter(breakpoint => !!breakpoint); | 206 .filter(breakpoint => !!breakpoint); |
| 217 if (!breakpoints.length) { | 207 if (!breakpoints.length) { |
| 218 contextMenu.appendItem( | 208 contextMenu.appendItem( |
| 219 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th
is, lineNumber, '', true)); | 209 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th
is, lineNumber, '', true)); |
| 220 contextMenu.appendItem( | 210 contextMenu.appendItem( |
| 221 Common.UIString('Add conditional breakpoint\u2026'), | 211 Common.UIString('Add conditional breakpoint\u2026'), |
| 222 this._editBreakpointCondition.bind(this, lineNumber, null, null)); | 212 this._editBreakpointCondition.bind(this, lineNumber, null, null)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 function addSourceMapURLDialogCallback(scriptFile, url) { | 259 function addSourceMapURLDialogCallback(scriptFile, url) { |
| 270 if (!url) | 260 if (!url) |
| 271 return; | 261 return; |
| 272 scriptFile.addSourceMapURL(url); | 262 scriptFile.addSourceMapURL(url); |
| 273 } | 263 } |
| 274 | 264 |
| 275 /** | 265 /** |
| 276 * @this {Sources.JavaScriptSourceFrame} | 266 * @this {Sources.JavaScriptSourceFrame} |
| 277 */ | 267 */ |
| 278 function populateSourceMapMembers() { | 268 function populateSourceMapMembers() { |
| 279 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Networ
k && | 269 if (this._debuggerSourceCode.project().type() === Workspace.projectTypes.N
etwork && |
| 280 Common.moduleSetting('jsSourceMapsEnabled').get() && | 270 Common.moduleSetting('jsSourceMapsEnabled').get() && |
| 281 !Bindings.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCode()
)) { | 271 !Bindings.blackboxManager.isBlackboxedUISourceCode(this._debuggerSourc
eCode)) { |
| 282 if (this._scriptFileForTarget.size) { | 272 if (this._scriptFileForTarget.size) { |
| 283 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; | 273 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; |
| 284 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma
p\u2026'); | 274 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma
p\u2026'); |
| 285 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null
, scriptFile)); | 275 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null
, scriptFile)); |
| 286 contextMenu.appendSeparator(); | 276 contextMenu.appendSeparator(); |
| 287 } | 277 } |
| 288 } | 278 } |
| 289 } | 279 } |
| 290 | 280 |
| 291 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb
er) | 281 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb
er) |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 if (!token || !token.type) { | 425 if (!token || !token.type) { |
| 436 this._popoverHelper.hidePopover(); | 426 this._popoverHelper.hidePopover(); |
| 437 return; | 427 return; |
| 438 } | 428 } |
| 439 startHighlight = token.startColumn; | 429 startHighlight = token.startColumn; |
| 440 } | 430 } |
| 441 } | 431 } |
| 442 var evaluationText = line.substring(startHighlight, endHighlight + 1); | 432 var evaluationText = line.substring(startHighlight, endHighlight + 1); |
| 443 Sources.SourceMapNamesResolver | 433 Sources.SourceMapNamesResolver |
| 444 .resolveExpression( | 434 .resolveExpression( |
| 445 selectedCallFrame, evaluationText, this.uiSourceCode(), lineNumber,
startHighlight, endHighlight) | 435 selectedCallFrame, evaluationText, this._debuggerSourceCode, lineNum
ber, startHighlight, endHighlight) |
| 446 .then(onResolve.bind(this)); | 436 .then(onResolve.bind(this)); |
| 447 | 437 |
| 448 /** | 438 /** |
| 449 * @param {?string=} text | 439 * @param {?string=} text |
| 450 * @this {Sources.JavaScriptSourceFrame} | 440 * @this {Sources.JavaScriptSourceFrame} |
| 451 */ | 441 */ |
| 452 function onResolve(text) { | 442 function onResolve(text) { |
| 453 selectedCallFrame.evaluate( | 443 selectedCallFrame.evaluate( |
| 454 text || evaluationText, objectGroupName, false, true, false, false, sh
owObjectPopover.bind(this)); | 444 text || evaluationText, objectGroupName, false, true, false, false, sh
owObjectPopover.bind(this)); |
| 455 } | 445 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 */ | 578 */ |
| 589 _prepareScopeVariables(callFrame, properties, internalProperties) { | 579 _prepareScopeVariables(callFrame, properties, internalProperties) { |
| 590 if (!properties || !properties.length || properties.length > 500) { | 580 if (!properties || !properties.length || properties.length > 500) { |
| 591 this._clearValueWidgets(); | 581 this._clearValueWidgets(); |
| 592 return; | 582 return; |
| 593 } | 583 } |
| 594 | 584 |
| 595 var functionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILo
cation( | 585 var functionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILo
cation( |
| 596 /** @type {!SDK.DebuggerModel.Location} */ (callFrame.functionLocation()
)); | 586 /** @type {!SDK.DebuggerModel.Location} */ (callFrame.functionLocation()
)); |
| 597 var executionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUIL
ocation(callFrame.location()); | 587 var executionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUIL
ocation(callFrame.location()); |
| 598 if (functionUILocation.uiSourceCode !== this.uiSourceCode() || | 588 if (functionUILocation.uiSourceCode !== this._debuggerSourceCode || |
| 599 executionUILocation.uiSourceCode !== this.uiSourceCode()) { | 589 executionUILocation.uiSourceCode !== this._debuggerSourceCode) { |
| 600 this._clearValueWidgets(); | 590 this._clearValueWidgets(); |
| 601 return; | 591 return; |
| 602 } | 592 } |
| 603 | 593 |
| 604 var fromLine = functionUILocation.lineNumber; | 594 var fromLine = functionUILocation.lineNumber; |
| 605 var fromColumn = functionUILocation.columnNumber; | 595 var fromColumn = functionUILocation.columnNumber; |
| 606 var toLine = executionUILocation.lineNumber; | 596 var toLine = executionUILocation.lineNumber; |
| 607 | 597 |
| 608 // Make sure we have a chance to update all existing widgets. | 598 // Make sure we have a chance to update all existing widgets. |
| 609 if (this._valueWidgets) { | 599 if (this._valueWidgets) { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 } | 859 } |
| 870 contextMenu.show(); | 860 contextMenu.show(); |
| 871 } | 861 } |
| 872 | 862 |
| 873 /** | 863 /** |
| 874 * @param {!Common.Event} event | 864 * @param {!Common.Event} event |
| 875 * @return {boolean} | 865 * @return {boolean} |
| 876 */ | 866 */ |
| 877 _shouldIgnoreExternalBreakpointEvents(event) { | 867 _shouldIgnoreExternalBreakpointEvents(event) { |
| 878 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); | 868 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); |
| 879 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) | 869 if (uiLocation.uiSourceCode !== this._debuggerSourceCode || !this.loaded) |
| 880 return true; | 870 return true; |
| 881 if (this._supportsEnabledBreakpointsWhileEditing()) | 871 if (this._supportsEnabledBreakpointsWhileEditing()) |
| 882 return false; | 872 return false; |
| 883 if (this._muted) | 873 if (this._muted) |
| 884 return true; | 874 return true; |
| 885 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 875 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 886 for (var i = 0; i < scriptFiles.length; ++i) { | 876 for (var i = 0; i < scriptFiles.length; ++i) { |
| 887 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) | 877 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) |
| 888 return true; | 878 return true; |
| 889 } | 879 } |
| 890 return false; | 880 return false; |
| 891 } | 881 } |
| 892 | 882 |
| 893 /** | 883 /** |
| 894 * @param {!Common.Event} event | 884 * @param {!Common.Event} event |
| 895 */ | 885 */ |
| 896 _breakpointAdded(event) { | 886 _breakpointAdded(event) { |
| 897 if (this._shouldIgnoreExternalBreakpointEvents(event)) | 887 if (this._shouldIgnoreExternalBreakpointEvents(event)) |
| 898 return; | 888 return; |
| 899 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); | 889 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); |
| 890 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even
t.data.breakpoint); |
| 891 this._addBreakpoint(uiLocation, breakpoint); |
| 892 } |
| 893 |
| 894 /** |
| 895 * @param {!Workspace.UILocation} uiLocation |
| 896 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint |
| 897 */ |
| 898 _addBreakpoint(uiLocation, breakpoint) { |
| 900 var lineDecorations = this._lineBreakpointDecorations(uiLocation.lineNumber)
; | 899 var lineDecorations = this._lineBreakpointDecorations(uiLocation.lineNumber)
; |
| 901 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even
t.data.breakpoint); | |
| 902 | |
| 903 var decoration = this._breakpointDecoration(uiLocation.lineNumber, uiLocatio
n.columnNumber); | 900 var decoration = this._breakpointDecoration(uiLocation.lineNumber, uiLocatio
n.columnNumber); |
| 904 if (decoration) { | 901 if (decoration) { |
| 905 decoration.breakpoint = breakpoint; | 902 decoration.breakpoint = breakpoint; |
| 906 decoration.condition = breakpoint.condition(); | 903 decoration.condition = breakpoint.condition(); |
| 907 decoration.enabled = breakpoint.enabled(); | 904 decoration.enabled = breakpoint.enabled(); |
| 908 } else { | 905 } else { |
| 909 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumb
er, uiLocation.columnNumber); | 906 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumb
er, uiLocation.columnNumber); |
| 910 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( | 907 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( |
| 911 this._textEditor, handle, breakpoint.condition(), breakpoint.enabled()
, breakpoint); | 908 this._textEditor, handle, breakpoint.condition(), breakpoint.enabled()
, breakpoint); |
| 912 decoration.element.addEventListener('click', this._inlineBreakpointClick.b
ind(this, decoration), true); | 909 decoration.element.addEventListener('click', this._inlineBreakpointClick.b
ind(this, decoration), true); |
| 913 decoration.element.addEventListener( | 910 decoration.element.addEventListener( |
| 914 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration
), true); | 911 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration
), true); |
| 915 this._breakpointDecorations.add(decoration); | 912 this._breakpointDecorations.add(decoration); |
| 916 } | 913 } |
| 917 this._decorationByBreakpoint.set(breakpoint, decoration); | 914 this._decorationByBreakpoint.set(breakpoint, decoration); |
| 918 this._updateBreakpointDecoration(decoration); | 915 this._updateBreakpointDecoration(decoration); |
| 919 if (!lineDecorations.length) { | 916 if (!lineDecorations.length) { |
| 920 this._willAddInlineDecorationsForTest(); | 917 this._willAddInlineDecorationsForTest(); |
| 921 this._breakpointManager | 918 this._breakpointManager |
| 922 .possibleBreakpoints( | 919 .possibleBreakpoints( |
| 923 this.uiSourceCode(), new Common.TextRange(uiLocation.lineNumber, 0
, uiLocation.lineNumber + 1, 0)) | 920 this._debuggerSourceCode, new Common.TextRange(uiLocation.lineNumb
er, 0, uiLocation.lineNumber + 1, 0)) |
| 924 .then(addInlineDecorations.bind(this, uiLocation.lineNumber)); | 921 .then(addInlineDecorations.bind(this, uiLocation.lineNumber)); |
| 925 } | 922 } |
| 926 | 923 |
| 927 /** | 924 /** |
| 928 * @this {Sources.JavaScriptSourceFrame} | 925 * @this {Sources.JavaScriptSourceFrame} |
| 929 * @param {number} lineNumber | 926 * @param {number} lineNumber |
| 930 * @param {!Array<!Workspace.UILocation>} possibleLocations | 927 * @param {!Array<!Workspace.UILocation>} possibleLocations |
| 931 */ | 928 */ |
| 932 function addInlineDecorations(lineNumber, possibleLocations) { | 929 function addInlineDecorations(lineNumber, possibleLocations) { |
| 933 var decorations = this._lineBreakpointDecorations(lineNumber); | 930 var decorations = this._lineBreakpointDecorations(lineNumber); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 for (var lineDecoration of lineDecorations) { | 988 for (var lineDecoration of lineDecorations) { |
| 992 this._breakpointDecorations.delete(lineDecoration); | 989 this._breakpointDecorations.delete(lineDecoration); |
| 993 this._updateBreakpointDecoration(lineDecoration); | 990 this._updateBreakpointDecoration(lineDecoration); |
| 994 } | 991 } |
| 995 } else { | 992 } else { |
| 996 this._updateBreakpointDecoration(decoration); | 993 this._updateBreakpointDecoration(decoration); |
| 997 } | 994 } |
| 998 } | 995 } |
| 999 | 996 |
| 1000 /** | 997 /** |
| 998 * @override |
| 999 */ |
| 1000 onBindingChanged() { |
| 1001 this._updateDebuggerSourceCode(); |
| 1002 this._updateScriptFiles(); |
| 1003 this._refreshBreakpoints(); |
| 1004 |
| 1005 var canLiveCompileJavascript = this._scriptFileForTarget.size || this._debug
gerSourceCode.extension() === 'js' || |
| 1006 this._debuggerSourceCode.project().type() === Workspace.projectTypes.Sni
ppets; |
| 1007 if (!!canLiveCompileJavascript !== !!this._compiler) |
| 1008 this._compiler = canLiveCompileJavascript ? new Sources.JavaScriptCompiler
(this) : null; |
| 1009 |
| 1010 this._showBlackboxInfobarIfNeeded(); |
| 1011 this._updateLinesWithoutMappingHighlight(); |
| 1012 } |
| 1013 |
| 1014 _refreshBreakpoints() { |
| 1015 if (!this.loaded) |
| 1016 return; |
| 1017 for (var lineDecoration of this._breakpointDecorations.valuesArray()) { |
| 1018 this._breakpointDecorations.delete(lineDecoration); |
| 1019 this._updateBreakpointDecoration(lineDecoration); |
| 1020 } |
| 1021 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo
urceCode(this._debuggerSourceCode); |
| 1022 for (var breakpointLocation of breakpointLocations) |
| 1023 this._addBreakpoint(breakpointLocation.uiLocation, breakpointLocation.brea
kpoint); |
| 1024 } |
| 1025 |
| 1026 _updateDebuggerSourceCode() { |
| 1027 if (this._debuggerSourceCode) { |
| 1028 this._debuggerSourceCode.removeEventListener( |
| 1029 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMapp
ingChanged, this); |
| 1030 } |
| 1031 |
| 1032 var binding = Persistence.persistence.binding(this.uiSourceCode()); |
| 1033 this._debuggerSourceCode = binding ? binding.network : this.uiSourceCode(); |
| 1034 this._debuggerSourceCode.addEventListener( |
| 1035 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin
gChanged, this); |
| 1036 } |
| 1037 |
| 1038 /** |
| 1001 * @param {!Common.Event} event | 1039 * @param {!Common.Event} event |
| 1002 */ | 1040 */ |
| 1003 _onSourceMappingChanged(event) { | 1041 _onSourceMappingChanged(event) { |
| 1004 var data = /** @type {{target: !SDK.Target}} */ (event.data); | 1042 var data = /** @type {{target: !SDK.Target}} */ (event.data); |
| 1005 this._updateScriptFile(data.target); | 1043 this._updateScriptFile(data.target); |
| 1006 this._updateLinesWithoutMappingHighlight(); | 1044 this._updateLinesWithoutMappingHighlight(); |
| 1007 } | 1045 } |
| 1008 | 1046 |
| 1009 _updateLinesWithoutMappingHighlight() { | 1047 _updateLinesWithoutMappingHighlight() { |
| 1010 var linesCount = this.textEditor.linesCount; | 1048 var linesCount = this.textEditor.linesCount; |
| 1011 for (var i = 0; i < linesCount; ++i) { | 1049 for (var i = 0; i < linesCount; ++i) { |
| 1012 var lineHasMapping = Bindings.debuggerWorkspaceBinding.uiLineHasMapping(th
is.uiSourceCode(), i); | 1050 var lineHasMapping = Bindings.debuggerWorkspaceBinding.uiLineHasMapping(th
is._debuggerSourceCode, i); |
| 1013 if (!lineHasMapping) | 1051 if (!lineHasMapping) |
| 1014 this._hasLineWithoutMapping = true; | 1052 this._hasLineWithoutMapping = true; |
| 1015 if (this._hasLineWithoutMapping) | 1053 if (this._hasLineWithoutMapping) |
| 1016 this.textEditor.toggleLineClass(i, 'cm-line-without-source-mapping', !li
neHasMapping); | 1054 this.textEditor.toggleLineClass(i, 'cm-line-without-source-mapping', !li
neHasMapping); |
| 1017 } | 1055 } |
| 1018 } | 1056 } |
| 1019 | 1057 |
| 1058 _updateScriptFiles() { |
| 1059 for (var target of SDK.targetManager.targets()) { |
| 1060 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this._debugg
erSourceCode, target); |
| 1061 if (scriptFile) |
| 1062 this._updateScriptFile(target); |
| 1063 } |
| 1064 } |
| 1065 |
| 1020 /** | 1066 /** |
| 1021 * @param {!SDK.Target} target | 1067 * @param {!SDK.Target} target |
| 1022 */ | 1068 */ |
| 1023 _updateScriptFile(target) { | 1069 _updateScriptFile(target) { |
| 1024 var oldScriptFile = this._scriptFileForTarget.get(target); | 1070 var oldScriptFile = this._scriptFileForTarget.get(target); |
| 1025 var newScriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this.uiSour
ceCode(), target); | 1071 var newScriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this._debug
gerSourceCode, target); |
| 1026 this._scriptFileForTarget.remove(target); | 1072 this._scriptFileForTarget.remove(target); |
| 1027 if (oldScriptFile) { | 1073 if (oldScriptFile) { |
| 1028 oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidMe
rgeToVM, this._didMergeToVM, this); | 1074 oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidMe
rgeToVM, this._didMergeToVM, this); |
| 1029 oldScriptFile.removeEventListener( | 1075 oldScriptFile.removeEventListener( |
| 1030 Bindings.ResourceScriptFile.Events.DidDivergeFromVM, this._didDivergeF
romVM, this); | 1076 Bindings.ResourceScriptFile.Events.DidDivergeFromVM, this._didDivergeF
romVM, this); |
| 1031 if (this._muted && !this.uiSourceCode().isDirty()) | 1077 if (this._muted && !this.uiSourceCode().isDirty()) |
| 1032 this._restoreBreakpointsIfConsistentScripts(); | 1078 this._restoreBreakpointsIfConsistentScripts(); |
| 1033 } | 1079 } |
| 1034 if (newScriptFile) | 1080 if (newScriptFile) |
| 1035 this._scriptFileForTarget.set(target, newScriptFile); | 1081 this._scriptFileForTarget.set(target, newScriptFile); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1056 } | 1102 } |
| 1057 | 1103 |
| 1058 /** | 1104 /** |
| 1059 * @override | 1105 * @override |
| 1060 */ | 1106 */ |
| 1061 onTextEditorContentSet() { | 1107 onTextEditorContentSet() { |
| 1062 super.onTextEditorContentSet(); | 1108 super.onTextEditorContentSet(); |
| 1063 if (this._executionLocation) | 1109 if (this._executionLocation) |
| 1064 this.setExecutionLocation(this._executionLocation); | 1110 this.setExecutionLocation(this._executionLocation); |
| 1065 | 1111 |
| 1066 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo
urceCode(this.uiSourceCode()); | 1112 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo
urceCode(this._debuggerSourceCode); |
| 1067 for (var i = 0; i < breakpointLocations.length; ++i) | 1113 for (var breakpointLocation of breakpointLocations) |
| 1068 this._breakpointAdded(/** @type {!Common.Event} */ ({data: breakpointLocat
ions[i]})); | 1114 this._addBreakpoint(breakpointLocation.uiLocation, breakpointLocation.brea
kpoint); |
| 1069 | 1115 |
| 1070 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 1116 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 1071 for (var i = 0; i < scriptFiles.length; ++i) | 1117 for (var i = 0; i < scriptFiles.length; ++i) |
| 1072 scriptFiles[i].checkMapping(); | 1118 scriptFiles[i].checkMapping(); |
| 1073 | 1119 |
| 1074 this._updateLinesWithoutMappingHighlight(); | 1120 this._updateLinesWithoutMappingHighlight(); |
| 1075 this._detectMinified(); | 1121 this._detectMinified(); |
| 1076 } | 1122 } |
| 1077 | 1123 |
| 1078 _detectMinified() { | 1124 _detectMinified() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 * @param {number} lineNumber | 1212 * @param {number} lineNumber |
| 1167 * @return {!Promise<?Array<!Workspace.UILocation>>} | 1213 * @return {!Promise<?Array<!Workspace.UILocation>>} |
| 1168 */ | 1214 */ |
| 1169 function findPossibleBreakpoints(lineNumber) { | 1215 function findPossibleBreakpoints(lineNumber) { |
| 1170 const maxLengthToCheck = 1024; | 1216 const maxLengthToCheck = 1024; |
| 1171 if (lineNumber >= this._textEditor.linesCount) | 1217 if (lineNumber >= this._textEditor.linesCount) |
| 1172 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([])
); | 1218 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([])
); |
| 1173 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) | 1219 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) |
| 1174 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([])
); | 1220 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([])
); |
| 1175 return this._breakpointManager | 1221 return this._breakpointManager |
| 1176 .possibleBreakpoints(this.uiSourceCode(), new Common.TextRange(lineNum
ber, 0, lineNumber + 1, 0)) | 1222 .possibleBreakpoints(this._debuggerSourceCode, new Common.TextRange(li
neNumber, 0, lineNumber + 1, 0)) |
| 1177 .then(locations => locations.length ? locations : null); | 1223 .then(locations => locations.length ? locations : null); |
| 1178 } | 1224 } |
| 1179 | 1225 |
| 1180 /** | 1226 /** |
| 1181 * @this {!Sources.JavaScriptSourceFrame} | 1227 * @this {!Sources.JavaScriptSourceFrame} |
| 1182 * @param {number} currentLineNumber | 1228 * @param {number} currentLineNumber |
| 1183 * @param {number} linesToCheck | 1229 * @param {number} linesToCheck |
| 1184 * @param {?Array<!Workspace.UILocation>} locations | 1230 * @param {?Array<!Workspace.UILocation>} locations |
| 1185 * @return {!Promise<?Array<!Workspace.UILocation>>} | 1231 * @return {!Promise<?Array<!Workspace.UILocation>>} |
| 1186 */ | 1232 */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1216 this._toggleBreakpoint(selection.startLine, false); | 1262 this._toggleBreakpoint(selection.startLine, false); |
| 1217 } | 1263 } |
| 1218 | 1264 |
| 1219 /** | 1265 /** |
| 1220 * @param {number} lineNumber | 1266 * @param {number} lineNumber |
| 1221 * @param {number} columnNumber | 1267 * @param {number} columnNumber |
| 1222 * @param {string} condition | 1268 * @param {string} condition |
| 1223 * @param {boolean} enabled | 1269 * @param {boolean} enabled |
| 1224 */ | 1270 */ |
| 1225 _setBreakpoint(lineNumber, columnNumber, condition, enabled) { | 1271 _setBreakpoint(lineNumber, columnNumber, condition, enabled) { |
| 1226 if (!Bindings.debuggerWorkspaceBinding.uiLineHasMapping(this.uiSourceCode(),
lineNumber)) | 1272 if (!Bindings.debuggerWorkspaceBinding.uiLineHasMapping(this._debuggerSource
Code, lineNumber)) |
| 1227 return; | 1273 return; |
| 1228 | 1274 |
| 1229 this._breakpointManager.setBreakpoint(this.uiSourceCode(), lineNumber, colum
nNumber, condition, enabled); | 1275 this._breakpointManager.setBreakpoint(this._debuggerSourceCode, lineNumber,
columnNumber, condition, enabled); |
| 1230 this._breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled); | 1276 this._breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled); |
| 1231 } | 1277 } |
| 1232 | 1278 |
| 1233 /** | 1279 /** |
| 1234 * @param {number} lineNumber | 1280 * @param {number} lineNumber |
| 1235 * @param {number} columnNumber | 1281 * @param {number} columnNumber |
| 1236 * @param {string} condition | 1282 * @param {string} condition |
| 1237 * @param {boolean} enabled | 1283 * @param {boolean} enabled |
| 1238 */ | 1284 */ |
| 1239 _breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled) { | 1285 _breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled) { |
| 1240 } | 1286 } |
| 1241 | 1287 |
| 1242 /** | 1288 /** |
| 1243 * @override | 1289 * @override |
| 1244 */ | 1290 */ |
| 1245 dispose() { | 1291 dispose() { |
| 1246 this._breakpointManager.removeEventListener( | 1292 this._breakpointManager.removeEventListener( |
| 1247 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded
, this); | 1293 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded
, this); |
| 1248 this._breakpointManager.removeEventListener( | 1294 this._breakpointManager.removeEventListener( |
| 1249 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem
oved, this); | 1295 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem
oved, this); |
| 1250 this.uiSourceCode().removeEventListener( | 1296 this.uiSourceCode().removeEventListener( |
| 1251 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin
gChanged, this); | |
| 1252 this.uiSourceCode().removeEventListener( | |
| 1253 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); | 1297 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); |
| 1254 this.uiSourceCode().removeEventListener( | 1298 this.uiSourceCode().removeEventListener( |
| 1255 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); | 1299 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); |
| 1256 this.uiSourceCode().removeEventListener( | 1300 this.uiSourceCode().removeEventListener( |
| 1257 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); | 1301 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); |
| 1302 if (this._debuggerSourceCode) { |
| 1303 this._debuggerSourceCode.removeEventListener( |
| 1304 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMapp
ingChanged, this); |
| 1305 } |
| 1306 |
| 1258 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh
owBlackboxInfobarIfNeeded, this); | 1307 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh
owBlackboxInfobarIfNeeded, this); |
| 1259 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl
ackboxInfobarIfNeeded, this); | 1308 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl
ackboxInfobarIfNeeded, this); |
| 1260 super.dispose(); | 1309 super.dispose(); |
| 1261 } | 1310 } |
| 1262 }; | 1311 }; |
| 1263 | 1312 |
| 1264 /** | 1313 /** |
| 1265 * @unrestricted | 1314 * @unrestricted |
| 1266 */ | 1315 */ |
| 1267 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { | 1316 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 hide() { | 1370 hide() { |
| 1322 if (!this.bookmark) | 1371 if (!this.bookmark) |
| 1323 return; | 1372 return; |
| 1324 this.bookmark.clear(); | 1373 this.bookmark.clear(); |
| 1325 this.bookmark = null; | 1374 this.bookmark = null; |
| 1326 } | 1375 } |
| 1327 }; | 1376 }; |
| 1328 | 1377 |
| 1329 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book
mark'); | 1378 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book
mark'); |
| 1330 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo
l('element'); | 1379 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo
l('element'); |
| OLD | NEW |