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 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(); | |
| 83 } | |
| 84 | |
| 85 _updateDebuggerSourceCode() { | |
| 86 if (this._debuggerSourceCode) { | |
| 87 this._debuggerSourceCode.removeEventListener( | |
| 88 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMapp ingChanged, this); | |
| 89 } | |
| 90 | |
| 91 var binding = Persistence.persistence.binding(this.uiSourceCode()); | |
| 92 this._debuggerSourceCode = binding ? binding.network : this.uiSourceCode(); | |
| 93 this._debuggerSourceCode.addEventListener( | |
| 94 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin gChanged, this); | |
| 93 } | 95 } |
| 94 | 96 |
| 95 /** | 97 /** |
| 96 * @override | 98 * @override |
| 97 * @return {!Array<!UI.ToolbarItem>} | 99 * @return {!Array<!UI.ToolbarItem>} |
| 98 */ | 100 */ |
| 99 syncToolbarItems() { | 101 syncToolbarItems() { |
| 100 var result = super.syncToolbarItems(); | 102 var result = super.syncToolbarItems(); |
| 101 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this.uiSou rceCode()); | 103 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this._debu ggerSourceCode); |
| 102 if (originURL) { | 104 if (originURL) { |
| 103 var parsedURL = originURL.asParsedURL(); | 105 var parsedURL = originURL.asParsedURL(); |
| 104 if (parsedURL) | 106 if (parsedURL) |
| 105 result.push(new UI.ToolbarText(Common.UIString('(source mapped from %s)' , parsedURL.displayName))); | 107 result.push(new UI.ToolbarText(Common.UIString('(source mapped from %s)' , parsedURL.displayName))); |
| 106 } | 108 } |
| 107 | 109 |
| 108 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Snippets ) { | 110 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Snippets ) { |
| 109 result.push(new UI.ToolbarSeparator(true)); | 111 result.push(new UI.ToolbarSeparator(true)); |
| 110 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet' ); | 112 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet' ); |
| 111 runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common .UIString('Ctrl+Enter')); | 113 runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common .UIString('Ctrl+Enter')); |
| 112 result.push(runSnippet); | 114 result.push(runSnippet); |
| 113 } | 115 } |
| 114 | 116 |
| 115 return result; | 117 return result; |
| 116 } | 118 } |
| 117 | 119 |
| 118 _showBlackboxInfobarIfNeeded() { | 120 _showBlackboxInfobarIfNeeded() { |
| 119 var uiSourceCode = this.uiSourceCode(); | 121 var uiSourceCode = this._debuggerSourceCode; |
| 120 if (!uiSourceCode.contentType().hasScripts()) | 122 if (!uiSourceCode.contentType().hasScripts()) |
| 121 return; | 123 return; |
| 122 var projectType = uiSourceCode.project().type(); | 124 var projectType = uiSourceCode.project().type(); |
| 123 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { | 125 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { |
| 124 this._hideBlackboxInfobar(); | 126 this._hideBlackboxInfobar(); |
| 125 return; | 127 return; |
| 126 } | 128 } |
| 127 | 129 |
| 128 if (this._blackboxInfobar) | 130 if (this._blackboxInfobar) |
| 129 this._blackboxInfobar.dispose(); | 131 this._blackboxInfobar.dispose(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 | 204 |
| 203 /** | 205 /** |
| 204 * @override | 206 * @override |
| 205 * @return {!Promise} | 207 * @return {!Promise} |
| 206 */ | 208 */ |
| 207 populateLineGutterContextMenu(contextMenu, lineNumber) { | 209 populateLineGutterContextMenu(contextMenu, lineNumber) { |
| 208 /** | 210 /** |
| 209 * @this {Sources.JavaScriptSourceFrame} | 211 * @this {Sources.JavaScriptSourceFrame} |
| 210 */ | 212 */ |
| 211 function populate(resolve, reject) { | 213 function populate(resolve, reject) { |
| 212 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); | 214 var uiLocation = new Workspace.UILocation(this._debuggerSourceCode, lineNu mber, 0); |
| 213 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 215 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 214 var breakpoints = this._lineBreakpointDecorations(lineNumber) | 216 var breakpoints = this._lineBreakpointDecorations(lineNumber) |
| 215 .map(decoration => decoration.breakpoint) | 217 .map(decoration => decoration.breakpoint) |
| 216 .filter(breakpoint => !!breakpoint); | 218 .filter(breakpoint => !!breakpoint); |
| 217 if (!breakpoints.length) { | 219 if (!breakpoints.length) { |
| 218 contextMenu.appendItem( | 220 contextMenu.appendItem( |
| 219 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); | 221 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); |
| 220 contextMenu.appendItem( | 222 contextMenu.appendItem( |
| 221 Common.UIString('Add conditional breakpoint\u2026'), | 223 Common.UIString('Add conditional breakpoint\u2026'), |
| 222 this._editBreakpointCondition.bind(this, lineNumber, null, null)); | 224 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) { | 271 function addSourceMapURLDialogCallback(scriptFile, url) { |
| 270 if (!url) | 272 if (!url) |
| 271 return; | 273 return; |
| 272 scriptFile.addSourceMapURL(url); | 274 scriptFile.addSourceMapURL(url); |
| 273 } | 275 } |
| 274 | 276 |
| 275 /** | 277 /** |
| 276 * @this {Sources.JavaScriptSourceFrame} | 278 * @this {Sources.JavaScriptSourceFrame} |
| 277 */ | 279 */ |
| 278 function populateSourceMapMembers() { | 280 function populateSourceMapMembers() { |
| 279 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Networ k && | 281 if (this._debuggerSourceCode.project().type() === Workspace.projectTypes.N etwork && |
| 280 Common.moduleSetting('jsSourceMapsEnabled').get() && | 282 Common.moduleSetting('jsSourceMapsEnabled').get() && |
| 281 !Bindings.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCode() )) { | 283 !Bindings.blackboxManager.isBlackboxedUISourceCode(this._debuggerSourc eCode)) { |
| 282 if (this._scriptFileForTarget.size) { | 284 if (this._scriptFileForTarget.size) { |
| 283 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; | 285 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; |
| 284 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma p\u2026'); | 286 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma p\u2026'); |
| 285 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null , scriptFile)); | 287 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null , scriptFile)); |
| 286 contextMenu.appendSeparator(); | 288 contextMenu.appendSeparator(); |
| 287 } | 289 } |
| 288 } | 290 } |
| 289 } | 291 } |
| 290 | 292 |
| 291 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb er) | 293 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) { | 437 if (!token || !token.type) { |
| 436 this._popoverHelper.hidePopover(); | 438 this._popoverHelper.hidePopover(); |
| 437 return; | 439 return; |
| 438 } | 440 } |
| 439 startHighlight = token.startColumn; | 441 startHighlight = token.startColumn; |
| 440 } | 442 } |
| 441 } | 443 } |
| 442 var evaluationText = line.substring(startHighlight, endHighlight + 1); | 444 var evaluationText = line.substring(startHighlight, endHighlight + 1); |
| 443 Sources.SourceMapNamesResolver | 445 Sources.SourceMapNamesResolver |
| 444 .resolveExpression( | 446 .resolveExpression( |
| 445 selectedCallFrame, evaluationText, this.uiSourceCode(), lineNumber, startHighlight, endHighlight) | 447 selectedCallFrame, evaluationText, this._debuggerSourceCode, lineNum ber, startHighlight, endHighlight) |
| 446 .then(onResolve.bind(this)); | 448 .then(onResolve.bind(this)); |
| 447 | 449 |
| 448 /** | 450 /** |
| 449 * @param {?string=} text | 451 * @param {?string=} text |
| 450 * @this {Sources.JavaScriptSourceFrame} | 452 * @this {Sources.JavaScriptSourceFrame} |
| 451 */ | 453 */ |
| 452 function onResolve(text) { | 454 function onResolve(text) { |
| 453 selectedCallFrame.evaluate( | 455 selectedCallFrame.evaluate( |
| 454 text || evaluationText, objectGroupName, false, true, false, false, sh owObjectPopover.bind(this)); | 456 text || evaluationText, objectGroupName, false, true, false, false, sh owObjectPopover.bind(this)); |
| 455 } | 457 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 */ | 590 */ |
| 589 _prepareScopeVariables(callFrame, properties, internalProperties) { | 591 _prepareScopeVariables(callFrame, properties, internalProperties) { |
| 590 if (!properties || !properties.length || properties.length > 500) { | 592 if (!properties || !properties.length || properties.length > 500) { |
| 591 this._clearValueWidgets(); | 593 this._clearValueWidgets(); |
| 592 return; | 594 return; |
| 593 } | 595 } |
| 594 | 596 |
| 595 var functionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILo cation( | 597 var functionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILo cation( |
| 596 /** @type {!SDK.DebuggerModel.Location} */ (callFrame.functionLocation() )); | 598 /** @type {!SDK.DebuggerModel.Location} */ (callFrame.functionLocation() )); |
| 597 var executionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUIL ocation(callFrame.location()); | 599 var executionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUIL ocation(callFrame.location()); |
| 598 if (functionUILocation.uiSourceCode !== this.uiSourceCode() || | 600 if (functionUILocation.uiSourceCode !== this._debuggerSourceCode || |
| 599 executionUILocation.uiSourceCode !== this.uiSourceCode()) { | 601 executionUILocation.uiSourceCode !== this._debuggerSourceCode) { |
| 600 this._clearValueWidgets(); | 602 this._clearValueWidgets(); |
| 601 return; | 603 return; |
| 602 } | 604 } |
| 603 | 605 |
| 604 var fromLine = functionUILocation.lineNumber; | 606 var fromLine = functionUILocation.lineNumber; |
| 605 var fromColumn = functionUILocation.columnNumber; | 607 var fromColumn = functionUILocation.columnNumber; |
| 606 var toLine = executionUILocation.lineNumber; | 608 var toLine = executionUILocation.lineNumber; |
| 607 | 609 |
| 608 // Make sure we have a chance to update all existing widgets. | 610 // Make sure we have a chance to update all existing widgets. |
| 609 if (this._valueWidgets) { | 611 if (this._valueWidgets) { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 } | 871 } |
| 870 contextMenu.show(); | 872 contextMenu.show(); |
| 871 } | 873 } |
| 872 | 874 |
| 873 /** | 875 /** |
| 874 * @param {!Common.Event} event | 876 * @param {!Common.Event} event |
| 875 * @return {boolean} | 877 * @return {boolean} |
| 876 */ | 878 */ |
| 877 _shouldIgnoreExternalBreakpointEvents(event) { | 879 _shouldIgnoreExternalBreakpointEvents(event) { |
| 878 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | 880 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); |
| 879 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) | 881 if (uiLocation.uiSourceCode !== this._debuggerSourceCode || !this.loaded) |
| 880 return true; | 882 return true; |
| 881 if (this._supportsEnabledBreakpointsWhileEditing()) | 883 if (this._supportsEnabledBreakpointsWhileEditing()) |
| 882 return false; | 884 return false; |
| 883 if (this._muted) | 885 if (this._muted) |
| 884 return true; | 886 return true; |
| 885 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 887 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 886 for (var i = 0; i < scriptFiles.length; ++i) { | 888 for (var i = 0; i < scriptFiles.length; ++i) { |
| 887 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) | 889 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) |
| 888 return true; | 890 return true; |
| 889 } | 891 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 991 for (var lineDecoration of lineDecorations) { | 993 for (var lineDecoration of lineDecorations) { |
| 992 this._breakpointDecorations.delete(lineDecoration); | 994 this._breakpointDecorations.delete(lineDecoration); |
| 993 this._updateBreakpointDecoration(lineDecoration); | 995 this._updateBreakpointDecoration(lineDecoration); |
| 994 } | 996 } |
| 995 } else { | 997 } else { |
| 996 this._updateBreakpointDecoration(decoration); | 998 this._updateBreakpointDecoration(decoration); |
| 997 } | 999 } |
| 998 } | 1000 } |
| 999 | 1001 |
| 1000 /** | 1002 /** |
| 1003 * @override | |
| 1004 */ | |
| 1005 onBindingChanged() { | |
| 1006 this._updateDebuggerSourceCode(); | |
| 1007 this._updateScriptFiles(); | |
| 1008 this._refreshBreakpoints(); | |
| 1009 | |
| 1010 var canLiveCompileJavascript = this._scriptFileForTarget.size || this._debug gerSourceCode.extension() === 'js' || | |
| 1011 this._debuggerSourceCode.project().type() === Workspace.projectTypes.Sni ppets; | |
| 1012 if (!!canLiveCompileJavascript !== !!this._compiler) | |
| 1013 this._compiler = canLiveCompileJavascript ? new Sources.JavaScriptCompiler (this) : null; | |
| 1014 | |
| 1015 this._showBlackboxInfobarIfNeeded(); | |
| 1016 this._updateLinesWithoutMappingHighlight(); | |
| 1017 } | |
| 1018 | |
| 1019 _refreshBreakpoints() { | |
| 1020 if (!this.loaded) | |
| 1021 return; | |
| 1022 for (var lineDecoration of this._breakpointDecorations.valuesArray()) { | |
| 1023 this._breakpointDecorations.delete(lineDecoration); | |
| 1024 this._updateBreakpointDecoration(lineDecoration); | |
| 1025 } | |
| 1026 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo urceCode(this._debuggerSourceCode); | |
| 1027 for (var i = 0; i < breakpointLocations.length; ++i) | |
| 1028 this._breakpointAdded(/** @type {!Common.Event} */ ({data: breakpointLocat ions[i]})); | |
|
dgozman
2016/12/06 01:14:27
Let's do this properly please.
lushnikov
2016/12/06 02:21:05
Done.
| |
| 1029 } | |
| 1030 | |
| 1031 /** | |
| 1001 * @param {!Common.Event} event | 1032 * @param {!Common.Event} event |
| 1002 */ | 1033 */ |
| 1003 _onSourceMappingChanged(event) { | 1034 _onSourceMappingChanged(event) { |
| 1004 var data = /** @type {{target: !SDK.Target}} */ (event.data); | 1035 var data = /** @type {{target: !SDK.Target}} */ (event.data); |
| 1005 this._updateScriptFile(data.target); | 1036 this._updateScriptFile(data.target); |
| 1006 this._updateLinesWithoutMappingHighlight(); | 1037 this._updateLinesWithoutMappingHighlight(); |
| 1007 } | 1038 } |
| 1008 | 1039 |
| 1009 _updateLinesWithoutMappingHighlight() { | 1040 _updateLinesWithoutMappingHighlight() { |
| 1010 var linesCount = this.textEditor.linesCount; | 1041 var linesCount = this.textEditor.linesCount; |
| 1011 for (var i = 0; i < linesCount; ++i) { | 1042 for (var i = 0; i < linesCount; ++i) { |
| 1012 var lineHasMapping = Bindings.debuggerWorkspaceBinding.uiLineHasMapping(th is.uiSourceCode(), i); | 1043 var lineHasMapping = Bindings.debuggerWorkspaceBinding.uiLineHasMapping(th is._debuggerSourceCode, i); |
| 1013 if (!lineHasMapping) | 1044 if (!lineHasMapping) |
| 1014 this._hasLineWithoutMapping = true; | 1045 this._hasLineWithoutMapping = true; |
| 1015 if (this._hasLineWithoutMapping) | 1046 if (this._hasLineWithoutMapping) |
| 1016 this.textEditor.toggleLineClass(i, 'cm-line-without-source-mapping', !li neHasMapping); | 1047 this.textEditor.toggleLineClass(i, 'cm-line-without-source-mapping', !li neHasMapping); |
| 1017 } | 1048 } |
| 1018 } | 1049 } |
| 1019 | 1050 |
| 1051 _updateScriptFiles() { | |
| 1052 for (var target of SDK.targetManager.targets()) { | |
| 1053 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this._debugg erSourceCode, target); | |
| 1054 if (scriptFile) | |
| 1055 this._updateScriptFile(target); | |
| 1056 } | |
| 1057 } | |
| 1058 | |
| 1020 /** | 1059 /** |
| 1021 * @param {!SDK.Target} target | 1060 * @param {!SDK.Target} target |
| 1022 */ | 1061 */ |
| 1023 _updateScriptFile(target) { | 1062 _updateScriptFile(target) { |
| 1024 var oldScriptFile = this._scriptFileForTarget.get(target); | 1063 var oldScriptFile = this._scriptFileForTarget.get(target); |
| 1025 var newScriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this.uiSour ceCode(), target); | 1064 var newScriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this._debug gerSourceCode, target); |
| 1026 this._scriptFileForTarget.remove(target); | 1065 this._scriptFileForTarget.remove(target); |
| 1027 if (oldScriptFile) { | 1066 if (oldScriptFile) { |
| 1028 oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidMe rgeToVM, this._didMergeToVM, this); | 1067 oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidMe rgeToVM, this._didMergeToVM, this); |
| 1029 oldScriptFile.removeEventListener( | 1068 oldScriptFile.removeEventListener( |
| 1030 Bindings.ResourceScriptFile.Events.DidDivergeFromVM, this._didDivergeF romVM, this); | 1069 Bindings.ResourceScriptFile.Events.DidDivergeFromVM, this._didDivergeF romVM, this); |
| 1031 if (this._muted && !this.uiSourceCode().isDirty()) | 1070 if (this._muted && !this.uiSourceCode().isDirty()) |
| 1032 this._restoreBreakpointsIfConsistentScripts(); | 1071 this._restoreBreakpointsIfConsistentScripts(); |
| 1033 } | 1072 } |
| 1034 if (newScriptFile) | 1073 if (newScriptFile) |
| 1035 this._scriptFileForTarget.set(target, newScriptFile); | 1074 this._scriptFileForTarget.set(target, newScriptFile); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1056 } | 1095 } |
| 1057 | 1096 |
| 1058 /** | 1097 /** |
| 1059 * @override | 1098 * @override |
| 1060 */ | 1099 */ |
| 1061 onTextEditorContentSet() { | 1100 onTextEditorContentSet() { |
| 1062 super.onTextEditorContentSet(); | 1101 super.onTextEditorContentSet(); |
| 1063 if (this._executionLocation) | 1102 if (this._executionLocation) |
| 1064 this.setExecutionLocation(this._executionLocation); | 1103 this.setExecutionLocation(this._executionLocation); |
| 1065 | 1104 |
| 1066 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo urceCode(this.uiSourceCode()); | 1105 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo urceCode(this._debuggerSourceCode); |
| 1067 for (var i = 0; i < breakpointLocations.length; ++i) | 1106 for (var i = 0; i < breakpointLocations.length; ++i) |
| 1068 this._breakpointAdded(/** @type {!Common.Event} */ ({data: breakpointLocat ions[i]})); | 1107 this._breakpointAdded(/** @type {!Common.Event} */ ({data: breakpointLocat ions[i]})); |
| 1069 | 1108 |
| 1070 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 1109 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 1071 for (var i = 0; i < scriptFiles.length; ++i) | 1110 for (var i = 0; i < scriptFiles.length; ++i) |
| 1072 scriptFiles[i].checkMapping(); | 1111 scriptFiles[i].checkMapping(); |
| 1073 | 1112 |
| 1074 this._updateLinesWithoutMappingHighlight(); | 1113 this._updateLinesWithoutMappingHighlight(); |
| 1075 this._detectMinified(); | 1114 this._detectMinified(); |
| 1076 } | 1115 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 * @param {number} lineNumber | 1205 * @param {number} lineNumber |
| 1167 * @return {!Promise<?Array<!Workspace.UILocation>>} | 1206 * @return {!Promise<?Array<!Workspace.UILocation>>} |
| 1168 */ | 1207 */ |
| 1169 function findPossibleBreakpoints(lineNumber) { | 1208 function findPossibleBreakpoints(lineNumber) { |
| 1170 const maxLengthToCheck = 1024; | 1209 const maxLengthToCheck = 1024; |
| 1171 if (lineNumber >= this._textEditor.linesCount) | 1210 if (lineNumber >= this._textEditor.linesCount) |
| 1172 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) ); | 1211 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) ); |
| 1173 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) | 1212 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) |
| 1174 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) ); | 1213 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) ); |
| 1175 return this._breakpointManager | 1214 return this._breakpointManager |
| 1176 .possibleBreakpoints(this.uiSourceCode(), new Common.TextRange(lineNum ber, 0, lineNumber + 1, 0)) | 1215 .possibleBreakpoints(this._debuggerSourceCode, new Common.TextRange(li neNumber, 0, lineNumber + 1, 0)) |
| 1177 .then(locations => locations.length ? locations : null); | 1216 .then(locations => locations.length ? locations : null); |
| 1178 } | 1217 } |
| 1179 | 1218 |
| 1180 /** | 1219 /** |
| 1181 * @this {!Sources.JavaScriptSourceFrame} | 1220 * @this {!Sources.JavaScriptSourceFrame} |
| 1182 * @param {number} currentLineNumber | 1221 * @param {number} currentLineNumber |
| 1183 * @param {number} linesToCheck | 1222 * @param {number} linesToCheck |
| 1184 * @param {?Array<!Workspace.UILocation>} locations | 1223 * @param {?Array<!Workspace.UILocation>} locations |
| 1185 * @return {!Promise<?Array<!Workspace.UILocation>>} | 1224 * @return {!Promise<?Array<!Workspace.UILocation>>} |
| 1186 */ | 1225 */ |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1216 this._toggleBreakpoint(selection.startLine, false); | 1255 this._toggleBreakpoint(selection.startLine, false); |
| 1217 } | 1256 } |
| 1218 | 1257 |
| 1219 /** | 1258 /** |
| 1220 * @param {number} lineNumber | 1259 * @param {number} lineNumber |
| 1221 * @param {number} columnNumber | 1260 * @param {number} columnNumber |
| 1222 * @param {string} condition | 1261 * @param {string} condition |
| 1223 * @param {boolean} enabled | 1262 * @param {boolean} enabled |
| 1224 */ | 1263 */ |
| 1225 _setBreakpoint(lineNumber, columnNumber, condition, enabled) { | 1264 _setBreakpoint(lineNumber, columnNumber, condition, enabled) { |
| 1226 if (!Bindings.debuggerWorkspaceBinding.uiLineHasMapping(this.uiSourceCode(), lineNumber)) | 1265 if (!Bindings.debuggerWorkspaceBinding.uiLineHasMapping(this._debuggerSource Code, lineNumber)) |
| 1227 return; | 1266 return; |
| 1228 | 1267 |
| 1229 this._breakpointManager.setBreakpoint(this.uiSourceCode(), lineNumber, colum nNumber, condition, enabled); | 1268 this._breakpointManager.setBreakpoint(this._debuggerSourceCode, lineNumber, columnNumber, condition, enabled); |
| 1230 this._breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled); | 1269 this._breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled); |
| 1231 } | 1270 } |
| 1232 | 1271 |
| 1233 /** | 1272 /** |
| 1234 * @param {number} lineNumber | 1273 * @param {number} lineNumber |
| 1235 * @param {number} columnNumber | 1274 * @param {number} columnNumber |
| 1236 * @param {string} condition | 1275 * @param {string} condition |
| 1237 * @param {boolean} enabled | 1276 * @param {boolean} enabled |
| 1238 */ | 1277 */ |
| 1239 _breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled) { | 1278 _breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled) { |
| 1240 } | 1279 } |
| 1241 | 1280 |
| 1242 /** | 1281 /** |
| 1243 * @override | 1282 * @override |
| 1244 */ | 1283 */ |
| 1245 dispose() { | 1284 dispose() { |
| 1246 this._breakpointManager.removeEventListener( | 1285 this._breakpointManager.removeEventListener( |
| 1247 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded , this); | 1286 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded , this); |
| 1248 this._breakpointManager.removeEventListener( | 1287 this._breakpointManager.removeEventListener( |
| 1249 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem oved, this); | 1288 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem oved, this); |
| 1250 this.uiSourceCode().removeEventListener( | 1289 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); | 1290 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); |
| 1254 this.uiSourceCode().removeEventListener( | 1291 this.uiSourceCode().removeEventListener( |
| 1255 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); | 1292 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); |
| 1256 this.uiSourceCode().removeEventListener( | 1293 this.uiSourceCode().removeEventListener( |
| 1257 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); | 1294 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); |
| 1295 if (this._debuggerSourceCode) { | |
| 1296 this._debuggerSourceCode.removeEventListener( | |
| 1297 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMapp ingChanged, this); | |
| 1298 } | |
| 1299 | |
| 1258 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this); | 1300 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this); |
| 1259 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); | 1301 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); |
| 1260 super.dispose(); | 1302 super.dispose(); |
| 1261 } | 1303 } |
| 1262 }; | 1304 }; |
| 1263 | 1305 |
| 1264 /** | 1306 /** |
| 1265 * @unrestricted | 1307 * @unrestricted |
| 1266 */ | 1308 */ |
| 1267 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { | 1309 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 hide() { | 1363 hide() { |
| 1322 if (!this.bookmark) | 1364 if (!this.bookmark) |
| 1323 return; | 1365 return; |
| 1324 this.bookmark.clear(); | 1366 this.bookmark.clear(); |
| 1325 this.bookmark = null; | 1367 this.bookmark = null; |
| 1326 } | 1368 } |
| 1327 }; | 1369 }; |
| 1328 | 1370 |
| 1329 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); | 1371 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); |
| 1330 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); | 1372 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); |
| OLD | NEW |