| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.JavaScriptSourceFrame = class extends WebInspector.UISourceCodeFram
e { | 34 Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.UISourceCode} uiSourceCode | 36 * @param {!Workspace.UISourceCode} uiSourceCode |
| 37 */ | 37 */ |
| 38 constructor(uiSourceCode) { | 38 constructor(uiSourceCode) { |
| 39 super(uiSourceCode); | 39 super(uiSourceCode); |
| 40 | 40 |
| 41 this._scriptsPanel = WebInspector.SourcesPanel.instance(); | 41 this._scriptsPanel = Sources.SourcesPanel.instance(); |
| 42 this._breakpointManager = WebInspector.breakpointManager; | 42 this._breakpointManager = Bindings.breakpointManager; |
| 43 if (uiSourceCode.project().type() === WebInspector.projectTypes.Debugger) | 43 if (uiSourceCode.project().type() === Workspace.projectTypes.Debugger) |
| 44 this.element.classList.add('source-frame-debugger-script'); | 44 this.element.classList.add('source-frame-debugger-script'); |
| 45 | 45 |
| 46 this._popoverHelper = new WebInspector.ObjectPopoverHelper( | 46 this._popoverHelper = new Components.ObjectPopoverHelper( |
| 47 this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._res
olveObjectForPopover.bind(this), | 47 this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._res
olveObjectForPopover.bind(this), |
| 48 this._onHidePopover.bind(this), true); | 48 this._onHidePopover.bind(this), true); |
| 49 this._popoverHelper.setTimeout(250, 250); | 49 this._popoverHelper.setTimeout(250, 250); |
| 50 | 50 |
| 51 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi
s), true); | 51 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi
s), true); |
| 52 | 52 |
| 53 this.textEditor.addEventListener( | 53 this.textEditor.addEventListener( |
| 54 WebInspector.SourcesTextEditor.Events.GutterClick, this._handleGutterCli
ck.bind(this), this); | 54 SourceFrame.SourcesTextEditor.Events.GutterClick, this._handleGutterClic
k.bind(this), this); |
| 55 | 55 |
| 56 this._breakpointManager.addEventListener( | 56 this._breakpointManager.addEventListener( |
| 57 WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointA
dded, this); | 57 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded
, this); |
| 58 this._breakpointManager.addEventListener( | 58 this._breakpointManager.addEventListener( |
| 59 WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpoin
tRemoved, this); | 59 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem
oved, this); |
| 60 | 60 |
| 61 this.uiSourceCode().addEventListener( | 61 this.uiSourceCode().addEventListener( |
| 62 WebInspector.UISourceCode.Events.SourceMappingChanged, this._onSourceMap
pingChanged, this); | 62 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin
gChanged, this); |
| 63 this.uiSourceCode().addEventListener( | 63 this.uiSourceCode().addEventListener( |
| 64 WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyCh
anged, this); | 64 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); |
| 65 this.uiSourceCode().addEventListener( | 65 this.uiSourceCode().addEventListener( |
| 66 WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopy
Committed, this); | 66 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); |
| 67 this.uiSourceCode().addEventListener( | 67 this.uiSourceCode().addEventListener( |
| 68 WebInspector.UISourceCode.Events.TitleChanged, this._showBlackboxInfobar
IfNeeded, this); | 68 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); |
| 69 | 69 |
| 70 /** @type {!Map.<!WebInspector.Target, !WebInspector.ResourceScriptFile>}*/ | 70 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ |
| 71 this._scriptFileForTarget = new Map(); | 71 this._scriptFileForTarget = new Map(); |
| 72 var targets = WebInspector.targetManager.targets(); | 72 var targets = SDK.targetManager.targets(); |
| 73 for (var i = 0; i < targets.length; ++i) { | 73 for (var i = 0; i < targets.length; ++i) { |
| 74 var scriptFile = WebInspector.debuggerWorkspaceBinding.scriptFile(uiSource
Code, targets[i]); | 74 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode
, targets[i]); |
| 75 if (scriptFile) | 75 if (scriptFile) |
| 76 this._updateScriptFile(targets[i]); | 76 this._updateScriptFile(targets[i]); |
| 77 } | 77 } |
| 78 | 78 |
| 79 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' || | 79 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' || |
| 80 uiSourceCode.project().type() === WebInspector.projectTypes.Snippets) | 80 uiSourceCode.project().type() === Workspace.projectTypes.Snippets) |
| 81 this._compiler = new WebInspector.JavaScriptCompiler(this); | 81 this._compiler = new Sources.JavaScriptCompiler(this); |
| 82 | 82 |
| 83 WebInspector.moduleSetting('skipStackFramesPattern').addChangeListener(this.
_showBlackboxInfobarIfNeeded, this); | 83 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB
lackboxInfobarIfNeeded, this); |
| 84 WebInspector.moduleSetting('skipContentScripts').addChangeListener(this._sho
wBlackboxInfobarIfNeeded, this); | 84 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack
boxInfobarIfNeeded, this); |
| 85 this._showBlackboxInfobarIfNeeded(); | 85 this._showBlackboxInfobarIfNeeded(); |
| 86 /** @type {!Map.<number, !Element>} */ | 86 /** @type {!Map.<number, !Element>} */ |
| 87 this._valueWidgets = new Map(); | 87 this._valueWidgets = new Map(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * @override | 91 * @override |
| 92 * @return {!Array<!WebInspector.ToolbarItem>} | 92 * @return {!Array<!UI.ToolbarItem>} |
| 93 */ | 93 */ |
| 94 syncToolbarItems() { | 94 syncToolbarItems() { |
| 95 var result = super.syncToolbarItems(); | 95 var result = super.syncToolbarItems(); |
| 96 var originURL = WebInspector.CompilerScriptMapping.uiSourceCodeOrigin(this.u
iSourceCode()); | 96 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this.uiSou
rceCode()); |
| 97 if (originURL) { | 97 if (originURL) { |
| 98 var parsedURL = originURL.asParsedURL(); | 98 var parsedURL = originURL.asParsedURL(); |
| 99 if (parsedURL) | 99 if (parsedURL) |
| 100 result.push( | 100 result.push( |
| 101 new WebInspector.ToolbarText(WebInspector.UIString('(source mapped f
rom %s)', parsedURL.displayName))); | 101 new UI.ToolbarText(Common.UIString('(source mapped from %s)', parsed
URL.displayName))); |
| 102 } | 102 } |
| 103 | 103 |
| 104 if (this.uiSourceCode().project().type() === WebInspector.projectTypes.Snipp
ets) { | 104 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Snippets
) { |
| 105 result.push(new WebInspector.ToolbarSeparator(true)); | 105 result.push(new UI.ToolbarSeparator(true)); |
| 106 var runSnippet = WebInspector.Toolbar.createActionButtonForId('debugger.ru
n-snippet'); | 106 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet'
); |
| 107 runSnippet.setText(WebInspector.isMac() ? | 107 runSnippet.setText(Host.isMac() ? |
| 108 WebInspector.UIString('\u2318+Enter') : | 108 Common.UIString('\u2318+Enter') : |
| 109 WebInspector.UIString('Ctrl+Enter')); | 109 Common.UIString('Ctrl+Enter')); |
| 110 result.push(runSnippet); | 110 result.push(runSnippet); |
| 111 } | 111 } |
| 112 | 112 |
| 113 return result; | 113 return result; |
| 114 } | 114 } |
| 115 | 115 |
| 116 _updateInfobars() { | 116 _updateInfobars() { |
| 117 this.attachInfobars([this._blackboxInfobar, this._divergedInfobar]); | 117 this.attachInfobars([this._blackboxInfobar, this._divergedInfobar]); |
| 118 } | 118 } |
| 119 | 119 |
| 120 _showDivergedInfobar() { | 120 _showDivergedInfobar() { |
| 121 if (!this.uiSourceCode().contentType().isScript()) | 121 if (!this.uiSourceCode().contentType().isScript()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 if (this._divergedInfobar) | 124 if (this._divergedInfobar) |
| 125 this._divergedInfobar.dispose(); | 125 this._divergedInfobar.dispose(); |
| 126 | 126 |
| 127 var infobar = new WebInspector.Infobar( | 127 var infobar = new UI.Infobar( |
| 128 WebInspector.Infobar.Type.Warning, WebInspector.UIString('Workspace mapp
ing mismatch')); | 128 UI.Infobar.Type.Warning, Common.UIString('Workspace mapping mismatch')); |
| 129 this._divergedInfobar = infobar; | 129 this._divergedInfobar = infobar; |
| 130 | 130 |
| 131 var fileURL = this.uiSourceCode().url(); | 131 var fileURL = this.uiSourceCode().url(); |
| 132 infobar.createDetailsRowMessage(WebInspector.UIString('The content of this f
ile on the file system:\u00a0')) | 132 infobar.createDetailsRowMessage(Common.UIString('The content of this file on
the file system:\u00a0')) |
| 133 .appendChild(WebInspector.linkifyURLAsNode(fileURL, fileURL, 'source-fra
me-infobar-details-url', true)); | 133 .appendChild(UI.linkifyURLAsNode(fileURL, fileURL, 'source-frame-infobar
-details-url', true)); |
| 134 | 134 |
| 135 var scriptURL = this.uiSourceCode().url(); | 135 var scriptURL = this.uiSourceCode().url(); |
| 136 infobar.createDetailsRowMessage(WebInspector.UIString('does not match the lo
aded script:\u00a0')) | 136 infobar.createDetailsRowMessage(Common.UIString('does not match the loaded s
cript:\u00a0')) |
| 137 .appendChild(WebInspector.linkifyURLAsNode(scriptURL, scriptURL, 'source
-frame-infobar-details-url', true)); | 137 .appendChild(UI.linkifyURLAsNode(scriptURL, scriptURL, 'source-frame-inf
obar-details-url', true)); |
| 138 | 138 |
| 139 infobar.createDetailsRowMessage(); | 139 infobar.createDetailsRowMessage(); |
| 140 infobar.createDetailsRowMessage(WebInspector.UIString('Possible solutions ar
e:')); | 140 infobar.createDetailsRowMessage(Common.UIString('Possible solutions are:')); |
| 141 | 141 |
| 142 if (WebInspector.moduleSetting('cacheDisabled').get()) | 142 if (Common.moduleSetting('cacheDisabled').get()) |
| 143 infobar.createDetailsRowMessage(' - ').createTextChild(WebInspector.UIStri
ng('Reload inspected page')); | 143 infobar.createDetailsRowMessage(' - ').createTextChild(Common.UIString('Re
load inspected page')); |
| 144 else | 144 else |
| 145 infobar.createDetailsRowMessage(' - ').createTextChild(WebInspector.UIStri
ng( | 145 infobar.createDetailsRowMessage(' - ').createTextChild(Common.UIString( |
| 146 'Check "Disable cache" in settings and reload inspected page (recommen
ded setup for authoring and debugging)')); | 146 'Check "Disable cache" in settings and reload inspected page (recommen
ded setup for authoring and debugging)')); |
| 147 infobar.createDetailsRowMessage(' - ').createTextChild(WebInspector.UIString
( | 147 infobar.createDetailsRowMessage(' - ').createTextChild(Common.UIString( |
| 148 'Check that your file and script are both loaded from the correct source
and their contents match')); | 148 'Check that your file and script are both loaded from the correct source
and their contents match')); |
| 149 | 149 |
| 150 this._updateInfobars(); | 150 this._updateInfobars(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 _hideDivergedInfobar() { | 153 _hideDivergedInfobar() { |
| 154 if (!this._divergedInfobar) | 154 if (!this._divergedInfobar) |
| 155 return; | 155 return; |
| 156 this._divergedInfobar.dispose(); | 156 this._divergedInfobar.dispose(); |
| 157 delete this._divergedInfobar; | 157 delete this._divergedInfobar; |
| 158 } | 158 } |
| 159 | 159 |
| 160 _showBlackboxInfobarIfNeeded() { | 160 _showBlackboxInfobarIfNeeded() { |
| 161 var uiSourceCode = this.uiSourceCode(); | 161 var uiSourceCode = this.uiSourceCode(); |
| 162 if (!uiSourceCode.contentType().hasScripts()) | 162 if (!uiSourceCode.contentType().hasScripts()) |
| 163 return; | 163 return; |
| 164 var projectType = uiSourceCode.project().type(); | 164 var projectType = uiSourceCode.project().type(); |
| 165 if (projectType === WebInspector.projectTypes.Snippets) | 165 if (projectType === Workspace.projectTypes.Snippets) |
| 166 return; | 166 return; |
| 167 if (!WebInspector.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { | 167 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { |
| 168 this._hideBlackboxInfobar(); | 168 this._hideBlackboxInfobar(); |
| 169 return; | 169 return; |
| 170 } | 170 } |
| 171 | 171 |
| 172 if (this._blackboxInfobar) | 172 if (this._blackboxInfobar) |
| 173 this._blackboxInfobar.dispose(); | 173 this._blackboxInfobar.dispose(); |
| 174 | 174 |
| 175 var infobar = new WebInspector.Infobar( | 175 var infobar = new UI.Infobar( |
| 176 WebInspector.Infobar.Type.Warning, WebInspector.UIString('This script is
blackboxed in debugger')); | 176 UI.Infobar.Type.Warning, Common.UIString('This script is blackboxed in d
ebugger')); |
| 177 this._blackboxInfobar = infobar; | 177 this._blackboxInfobar = infobar; |
| 178 | 178 |
| 179 infobar.createDetailsRowMessage( | 179 infobar.createDetailsRowMessage( |
| 180 WebInspector.UIString('Debugger will skip stepping through this script,
and will not stop on exceptions')); | 180 Common.UIString('Debugger will skip stepping through this script, and wi
ll not stop on exceptions')); |
| 181 | 181 |
| 182 var scriptFile = this._scriptFileForTarget.size ? this._scriptFileForTarget.
valuesArray()[0] : null; | 182 var scriptFile = this._scriptFileForTarget.size ? this._scriptFileForTarget.
valuesArray()[0] : null; |
| 183 if (scriptFile && scriptFile.hasSourceMapURL()) | 183 if (scriptFile && scriptFile.hasSourceMapURL()) |
| 184 infobar.createDetailsRowMessage(WebInspector.UIString('Source map found, b
ut ignored for blackboxed file.')); | 184 infobar.createDetailsRowMessage(Common.UIString('Source map found, but ign
ored for blackboxed file.')); |
| 185 infobar.createDetailsRowMessage(); | 185 infobar.createDetailsRowMessage(); |
| 186 infobar.createDetailsRowMessage(WebInspector.UIString('Possible ways to canc
el this behavior are:')); | 186 infobar.createDetailsRowMessage(Common.UIString('Possible ways to cancel thi
s behavior are:')); |
| 187 | 187 |
| 188 infobar.createDetailsRowMessage(' - ').createTextChild( | 188 infobar.createDetailsRowMessage(' - ').createTextChild( |
| 189 WebInspector.UIString('Go to "%s" tab in settings', WebInspector.UIStrin
g('Blackboxing'))); | 189 Common.UIString('Go to "%s" tab in settings', Common.UIString('Blackboxi
ng'))); |
| 190 var unblackboxLink = infobar.createDetailsRowMessage(' - ').createChild('spa
n', 'link'); | 190 var unblackboxLink = infobar.createDetailsRowMessage(' - ').createChild('spa
n', 'link'); |
| 191 unblackboxLink.textContent = WebInspector.UIString('Unblackbox this script')
; | 191 unblackboxLink.textContent = Common.UIString('Unblackbox this script'); |
| 192 unblackboxLink.addEventListener('click', unblackbox, false); | 192 unblackboxLink.addEventListener('click', unblackbox, false); |
| 193 | 193 |
| 194 function unblackbox() { | 194 function unblackbox() { |
| 195 WebInspector.blackboxManager.unblackboxUISourceCode(uiSourceCode); | 195 Bindings.blackboxManager.unblackboxUISourceCode(uiSourceCode); |
| 196 if (projectType === WebInspector.projectTypes.ContentScripts) | 196 if (projectType === Workspace.projectTypes.ContentScripts) |
| 197 WebInspector.blackboxManager.unblackboxContentScripts(); | 197 Bindings.blackboxManager.unblackboxContentScripts(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 this._updateInfobars(); | 200 this._updateInfobars(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 _hideBlackboxInfobar() { | 203 _hideBlackboxInfobar() { |
| 204 if (!this._blackboxInfobar) | 204 if (!this._blackboxInfobar) |
| 205 return; | 205 return; |
| 206 this._blackboxInfobar.dispose(); | 206 this._blackboxInfobar.dispose(); |
| 207 delete this._blackboxInfobar; | 207 delete this._blackboxInfobar; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (this._compiler) | 243 if (this._compiler) |
| 244 this._compiler.scheduleCompile(); | 244 this._compiler.scheduleCompile(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 /** | 247 /** |
| 248 * @override | 248 * @override |
| 249 * @return {!Promise} | 249 * @return {!Promise} |
| 250 */ | 250 */ |
| 251 populateLineGutterContextMenu(contextMenu, lineNumber) { | 251 populateLineGutterContextMenu(contextMenu, lineNumber) { |
| 252 /** | 252 /** |
| 253 * @this {WebInspector.JavaScriptSourceFrame} | 253 * @this {Sources.JavaScriptSourceFrame} |
| 254 */ | 254 */ |
| 255 function populate(resolve, reject) { | 255 function populate(resolve, reject) { |
| 256 var uiLocation = new WebInspector.UILocation(this.uiSourceCode(), lineNumb
er, 0); | 256 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber,
0); |
| 257 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 257 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 258 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod
e(), lineNumber); | 258 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod
e(), lineNumber); |
| 259 if (!breakpoints.length) { | 259 if (!breakpoints.length) { |
| 260 // This row doesn't have a breakpoint: We want to show Add Breakpoint an
d Add and Edit Breakpoint. | 260 // This row doesn't have a breakpoint: We want to show Add Breakpoint an
d Add and Edit Breakpoint. |
| 261 contextMenu.appendItem( | 261 contextMenu.appendItem( |
| 262 WebInspector.UIString('Add breakpoint'), this._createNewBreakpoint.b
ind(this, lineNumber, '', true)); | 262 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th
is, lineNumber, '', true)); |
| 263 contextMenu.appendItem( | 263 contextMenu.appendItem( |
| 264 WebInspector.UIString('Add conditional breakpoint…'), this._editBrea
kpointCondition.bind(this, lineNumber)); | 264 Common.UIString('Add conditional breakpoint…'), this._editBreakpoint
Condition.bind(this, lineNumber)); |
| 265 contextMenu.appendItem( | 265 contextMenu.appendItem( |
| 266 WebInspector.UIString('Never pause here'), | 266 Common.UIString('Never pause here'), |
| 267 this._createNewBreakpoint.bind(this, lineNumber, 'false', true)); | 267 this._createNewBreakpoint.bind(this, lineNumber, 'false', true)); |
| 268 } else { | 268 } else { |
| 269 var breakpoint = breakpoints[0]; | 269 var breakpoint = breakpoints[0]; |
| 270 | 270 |
| 271 // This row has a breakpoint, we want to show edit and remove breakpoint
, and either disable or enable. | 271 // This row has a breakpoint, we want to show edit and remove breakpoint
, and either disable or enable. |
| 272 contextMenu.appendItem(WebInspector.UIString('Remove breakpoint'), break
point.remove.bind(breakpoint)); | 272 contextMenu.appendItem(Common.UIString('Remove breakpoint'), breakpoint.
remove.bind(breakpoint)); |
| 273 contextMenu.appendItem( | 273 contextMenu.appendItem( |
| 274 WebInspector.UIString('Edit breakpoint…'), | 274 Common.UIString('Edit breakpoint…'), |
| 275 this._editBreakpointCondition.bind(this, lineNumber, breakpoint)); | 275 this._editBreakpointCondition.bind(this, lineNumber, breakpoint)); |
| 276 if (breakpoint.enabled()) | 276 if (breakpoint.enabled()) |
| 277 contextMenu.appendItem( | 277 contextMenu.appendItem( |
| 278 WebInspector.UIString('Disable breakpoint'), breakpoint.setEnabled
.bind(breakpoint, false)); | 278 Common.UIString('Disable breakpoint'), breakpoint.setEnabled.bind(
breakpoint, false)); |
| 279 else | 279 else |
| 280 contextMenu.appendItem( | 280 contextMenu.appendItem( |
| 281 WebInspector.UIString('Enable breakpoint'), breakpoint.setEnabled.
bind(breakpoint, true)); | 281 Common.UIString('Enable breakpoint'), breakpoint.setEnabled.bind(b
reakpoint, true)); |
| 282 } | 282 } |
| 283 resolve(); | 283 resolve(); |
| 284 } | 284 } |
| 285 return new Promise(populate.bind(this)); | 285 return new Promise(populate.bind(this)); |
| 286 } | 286 } |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * @override | 289 * @override |
| 290 * @return {!Promise} | 290 * @return {!Promise} |
| 291 */ | 291 */ |
| 292 populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber) { | 292 populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber) { |
| 293 /** | 293 /** |
| 294 * @param {!WebInspector.ResourceScriptFile} scriptFile | 294 * @param {!Bindings.ResourceScriptFile} scriptFile |
| 295 */ | 295 */ |
| 296 function addSourceMapURL(scriptFile) { | 296 function addSourceMapURL(scriptFile) { |
| 297 WebInspector.AddSourceMapURLDialog.show(addSourceMapURLDialogCallback.bind
(null, scriptFile)); | 297 Sources.AddSourceMapURLDialog.show(addSourceMapURLDialogCallback.bind(null
, scriptFile)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * @param {!WebInspector.ResourceScriptFile} scriptFile | 301 * @param {!Bindings.ResourceScriptFile} scriptFile |
| 302 * @param {string} url | 302 * @param {string} url |
| 303 */ | 303 */ |
| 304 function addSourceMapURLDialogCallback(scriptFile, url) { | 304 function addSourceMapURLDialogCallback(scriptFile, url) { |
| 305 if (!url) | 305 if (!url) |
| 306 return; | 306 return; |
| 307 scriptFile.addSourceMapURL(url); | 307 scriptFile.addSourceMapURL(url); |
| 308 } | 308 } |
| 309 | 309 |
| 310 /** | 310 /** |
| 311 * @this {WebInspector.JavaScriptSourceFrame} | 311 * @this {Sources.JavaScriptSourceFrame} |
| 312 */ | 312 */ |
| 313 function populateSourceMapMembers() { | 313 function populateSourceMapMembers() { |
| 314 if (this.uiSourceCode().project().type() === WebInspector.projectTypes.Net
work && | 314 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Networ
k && |
| 315 WebInspector.moduleSetting('jsSourceMapsEnabled').get() && | 315 Common.moduleSetting('jsSourceMapsEnabled').get() && |
| 316 !WebInspector.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCo
de())) { | 316 !Bindings.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCode()
)) { |
| 317 if (this._scriptFileForTarget.size) { | 317 if (this._scriptFileForTarget.size) { |
| 318 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; | 318 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; |
| 319 var addSourceMapURLLabel = WebInspector.UIString.capitalize('Add ^sour
ce ^map\u2026'); | 319 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma
p\u2026'); |
| 320 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null
, scriptFile)); | 320 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null
, scriptFile)); |
| 321 contextMenu.appendSeparator(); | 321 contextMenu.appendSeparator(); |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb
er) | 326 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb
er) |
| 327 .then(populateSourceMapMembers.bind(this)); | 327 .then(populateSourceMapMembers.bind(this)); |
| 328 } | 328 } |
| 329 | 329 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 continue; | 369 continue; |
| 370 this._removeBreakpointDecoration(lineNumber); | 370 this._removeBreakpointDecoration(lineNumber); |
| 371 this._addBreakpointDecoration( | 371 this._addBreakpointDecoration( |
| 372 lineNumber, breakpointDecoration.columnNumber, breakpointDecoration.co
ndition, breakpointDecoration.enabled, | 372 lineNumber, breakpointDecoration.columnNumber, breakpointDecoration.co
ndition, breakpointDecoration.enabled, |
| 373 true); | 373 true); |
| 374 } | 374 } |
| 375 this._muted = true; | 375 this._muted = true; |
| 376 } | 376 } |
| 377 | 377 |
| 378 _updateDivergedInfobar() { | 378 _updateDivergedInfobar() { |
| 379 if (this.uiSourceCode().project().type() !== WebInspector.projectTypes.FileS
ystem) { | 379 if (this.uiSourceCode().project().type() !== Workspace.projectTypes.FileSyst
em) { |
| 380 this._hideDivergedInfobar(); | 380 this._hideDivergedInfobar(); |
| 381 return; | 381 return; |
| 382 } | 382 } |
| 383 | 383 |
| 384 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 384 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 385 var hasDivergedScript = false; | 385 var hasDivergedScript = false; |
| 386 for (var i = 0; i < scriptFiles.length; ++i) | 386 for (var i = 0; i < scriptFiles.length; ++i) |
| 387 hasDivergedScript = hasDivergedScript || scriptFiles[i].hasDivergedFromVM(
); | 387 hasDivergedScript = hasDivergedScript || scriptFiles[i].hasDivergedFromVM(
); |
| 388 | 388 |
| 389 if (this._divergedInfobar) { | 389 if (this._divergedInfobar) { |
| 390 if (!hasDivergedScript) | 390 if (!hasDivergedScript) |
| 391 this._hideDivergedInfobar(); | 391 this._hideDivergedInfobar(); |
| 392 } else { | 392 } else { |
| 393 if (hasDivergedScript && !this.uiSourceCode().isDirty()) | 393 if (hasDivergedScript && !this.uiSourceCode().isDirty()) |
| 394 this._showDivergedInfobar(); | 394 this._showDivergedInfobar(); |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 _supportsEnabledBreakpointsWhileEditing() { | 398 _supportsEnabledBreakpointsWhileEditing() { |
| 399 return this.uiSourceCode().project().type() === WebInspector.projectTypes.Sn
ippets; | 399 return this.uiSourceCode().project().type() === Workspace.projectTypes.Snipp
ets; |
| 400 } | 400 } |
| 401 | 401 |
| 402 _restoreBreakpointsIfConsistentScripts() { | 402 _restoreBreakpointsIfConsistentScripts() { |
| 403 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 403 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 404 for (var i = 0; i < scriptFiles.length; ++i) | 404 for (var i = 0; i < scriptFiles.length; ++i) |
| 405 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM()) | 405 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM()) |
| 406 return; | 406 return; |
| 407 | 407 |
| 408 this._restoreBreakpointsAfterEditing(); | 408 this._restoreBreakpointsAfterEditing(); |
| 409 } | 409 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 442 |
| 443 /** | 443 /** |
| 444 * @param {string} tokenType | 444 * @param {string} tokenType |
| 445 * @return {boolean} | 445 * @return {boolean} |
| 446 */ | 446 */ |
| 447 _isIdentifier(tokenType) { | 447 _isIdentifier(tokenType) { |
| 448 return tokenType.startsWith('js-variable') || tokenType.startsWith('js-prope
rty') || tokenType === 'js-def'; | 448 return tokenType.startsWith('js-variable') || tokenType.startsWith('js-prope
rty') || tokenType === 'js-def'; |
| 449 } | 449 } |
| 450 | 450 |
| 451 _getPopoverAnchor(element, event) { | 451 _getPopoverAnchor(element, event) { |
| 452 var target = WebInspector.context.flavor(WebInspector.Target); | 452 var target = UI.context.flavor(SDK.Target); |
| 453 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 453 var debuggerModel = SDK.DebuggerModel.fromTarget(target); |
| 454 if (!debuggerModel || !debuggerModel.isPaused()) | 454 if (!debuggerModel || !debuggerModel.isPaused()) |
| 455 return; | 455 return; |
| 456 | 456 |
| 457 var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, even
t.y); | 457 var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, even
t.y); |
| 458 if (!textPosition) | 458 if (!textPosition) |
| 459 return; | 459 return; |
| 460 var mouseLine = textPosition.startLine; | 460 var mouseLine = textPosition.startLine; |
| 461 var mouseColumn = textPosition.startColumn; | 461 var mouseColumn = textPosition.startColumn; |
| 462 var textSelection = this.textEditor.selection().normalize(); | 462 var textSelection = this.textEditor.selection().normalize(); |
| 463 if (textSelection && !textSelection.isEmpty()) { | 463 if (textSelection && !textSelection.isEmpty()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 491 var leftCorner = this.textEditor.cursorPositionToCoordinates(lineNumber, tok
en.startColumn); | 491 var leftCorner = this.textEditor.cursorPositionToCoordinates(lineNumber, tok
en.startColumn); |
| 492 var rightCorner = this.textEditor.cursorPositionToCoordinates(lineNumber, to
ken.endColumn - 1); | 492 var rightCorner = this.textEditor.cursorPositionToCoordinates(lineNumber, to
ken.endColumn - 1); |
| 493 var anchorBox = new AnchorBox(leftCorner.x, leftCorner.y, rightCorner.x - le
ftCorner.x, leftCorner.height); | 493 var anchorBox = new AnchorBox(leftCorner.x, leftCorner.y, rightCorner.x - le
ftCorner.x, leftCorner.height); |
| 494 | 494 |
| 495 anchorBox.highlight = {lineNumber: lineNumber, startColumn: token.startColum
n, endColumn: token.endColumn - 1}; | 495 anchorBox.highlight = {lineNumber: lineNumber, startColumn: token.startColum
n, endColumn: token.endColumn - 1}; |
| 496 | 496 |
| 497 return anchorBox; | 497 return anchorBox; |
| 498 } | 498 } |
| 499 | 499 |
| 500 _resolveObjectForPopover(anchorBox, showCallback, objectGroupName) { | 500 _resolveObjectForPopover(anchorBox, showCallback, objectGroupName) { |
| 501 var target = WebInspector.context.flavor(WebInspector.Target); | 501 var target = UI.context.flavor(SDK.Target); |
| 502 var selectedCallFrame = WebInspector.context.flavor(WebInspector.DebuggerMod
el.CallFrame); | 502 var selectedCallFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); |
| 503 if (!selectedCallFrame) { | 503 if (!selectedCallFrame) { |
| 504 this._popoverHelper.hidePopover(); | 504 this._popoverHelper.hidePopover(); |
| 505 return; | 505 return; |
| 506 } | 506 } |
| 507 var lineNumber = anchorBox.highlight.lineNumber; | 507 var lineNumber = anchorBox.highlight.lineNumber; |
| 508 var startHighlight = anchorBox.highlight.startColumn; | 508 var startHighlight = anchorBox.highlight.startColumn; |
| 509 var endHighlight = anchorBox.highlight.endColumn; | 509 var endHighlight = anchorBox.highlight.endColumn; |
| 510 var line = this.textEditor.line(lineNumber); | 510 var line = this.textEditor.line(lineNumber); |
| 511 if (!anchorBox.forSelection) { | 511 if (!anchorBox.forSelection) { |
| 512 while (startHighlight > 1 && line.charAt(startHighlight - 1) === '.') { | 512 while (startHighlight > 1 && line.charAt(startHighlight - 1) === '.') { |
| 513 var token = this.textEditor.tokenAtTextPosition(lineNumber, startHighlig
ht - 2); | 513 var token = this.textEditor.tokenAtTextPosition(lineNumber, startHighlig
ht - 2); |
| 514 if (!token || !token.type) { | 514 if (!token || !token.type) { |
| 515 this._popoverHelper.hidePopover(); | 515 this._popoverHelper.hidePopover(); |
| 516 return; | 516 return; |
| 517 } | 517 } |
| 518 startHighlight = token.startColumn; | 518 startHighlight = token.startColumn; |
| 519 } | 519 } |
| 520 } | 520 } |
| 521 var evaluationText = line.substring(startHighlight, endHighlight + 1); | 521 var evaluationText = line.substring(startHighlight, endHighlight + 1); |
| 522 WebInspector.SourceMapNamesResolver | 522 Sources.SourceMapNamesResolver |
| 523 .resolveExpression( | 523 .resolveExpression( |
| 524 selectedCallFrame, evaluationText, this.uiSourceCode(), lineNumber,
startHighlight, endHighlight) | 524 selectedCallFrame, evaluationText, this.uiSourceCode(), lineNumber,
startHighlight, endHighlight) |
| 525 .then(onResolve.bind(this)); | 525 .then(onResolve.bind(this)); |
| 526 | 526 |
| 527 /** | 527 /** |
| 528 * @param {?string=} text | 528 * @param {?string=} text |
| 529 * @this {WebInspector.JavaScriptSourceFrame} | 529 * @this {Sources.JavaScriptSourceFrame} |
| 530 */ | 530 */ |
| 531 function onResolve(text) { | 531 function onResolve(text) { |
| 532 selectedCallFrame.evaluate( | 532 selectedCallFrame.evaluate( |
| 533 text || evaluationText, objectGroupName, false, true, false, false, sh
owObjectPopover.bind(this)); | 533 text || evaluationText, objectGroupName, false, true, false, false, sh
owObjectPopover.bind(this)); |
| 534 } | 534 } |
| 535 | 535 |
| 536 /** | 536 /** |
| 537 * @param {?Protocol.Runtime.RemoteObject} result | 537 * @param {?Protocol.Runtime.RemoteObject} result |
| 538 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 538 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails |
| 539 * @this {WebInspector.JavaScriptSourceFrame} | 539 * @this {Sources.JavaScriptSourceFrame} |
| 540 */ | 540 */ |
| 541 function showObjectPopover(result, exceptionDetails) { | 541 function showObjectPopover(result, exceptionDetails) { |
| 542 var target = WebInspector.context.flavor(WebInspector.Target); | 542 var target = UI.context.flavor(SDK.Target); |
| 543 var potentiallyUpdatedCallFrame = WebInspector.context.flavor(WebInspector
.DebuggerModel.CallFrame); | 543 var potentiallyUpdatedCallFrame = UI.context.flavor(SDK.DebuggerModel.Call
Frame); |
| 544 if (selectedCallFrame !== potentiallyUpdatedCallFrame || !result) { | 544 if (selectedCallFrame !== potentiallyUpdatedCallFrame || !result) { |
| 545 this._popoverHelper.hidePopover(); | 545 this._popoverHelper.hidePopover(); |
| 546 return; | 546 return; |
| 547 } | 547 } |
| 548 this._popoverAnchorBox = anchorBox; | 548 this._popoverAnchorBox = anchorBox; |
| 549 showCallback(target.runtimeModel.createRemoteObject(result), !!exceptionDe
tails, this._popoverAnchorBox); | 549 showCallback(target.runtimeModel.createRemoteObject(result), !!exceptionDe
tails, this._popoverAnchorBox); |
| 550 // Popover may have been removed by showCallback(). | 550 // Popover may have been removed by showCallback(). |
| 551 if (this._popoverAnchorBox) { | 551 if (this._popoverAnchorBox) { |
| 552 var highlightRange = new WebInspector.TextRange(lineNumber, startHighlig
ht, lineNumber, endHighlight); | 552 var highlightRange = new Common.TextRange(lineNumber, startHighlight, li
neNumber, endHighlight); |
| 553 this._popoverAnchorBox._highlightDescriptor = | 553 this._popoverAnchorBox._highlightDescriptor = |
| 554 this.textEditor.highlightRange(highlightRange, 'source-frame-eval-ex
pression'); | 554 this.textEditor.highlightRange(highlightRange, 'source-frame-eval-ex
pression'); |
| 555 } | 555 } |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 | 558 |
| 559 _onHidePopover() { | 559 _onHidePopover() { |
| 560 if (!this._popoverAnchorBox) | 560 if (!this._popoverAnchorBox) |
| 561 return; | 561 return; |
| 562 if (this._popoverAnchorBox._highlightDescriptor) | 562 if (this._popoverAnchorBox._highlightDescriptor) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 589 if (event.key === 'Escape') { | 589 if (event.key === 'Escape') { |
| 590 if (this._popoverHelper.isPopoverVisible()) { | 590 if (this._popoverHelper.isPopoverVisible()) { |
| 591 this._popoverHelper.hidePopover(); | 591 this._popoverHelper.hidePopover(); |
| 592 event.consume(); | 592 event.consume(); |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 /** | 597 /** |
| 598 * @param {number} lineNumber | 598 * @param {number} lineNumber |
| 599 * @param {!WebInspector.BreakpointManager.Breakpoint=} breakpoint | 599 * @param {!Bindings.BreakpointManager.Breakpoint=} breakpoint |
| 600 */ | 600 */ |
| 601 _editBreakpointCondition(lineNumber, breakpoint) { | 601 _editBreakpointCondition(lineNumber, breakpoint) { |
| 602 this._conditionElement = this._createConditionElement(lineNumber); | 602 this._conditionElement = this._createConditionElement(lineNumber); |
| 603 this.textEditor.addDecoration(this._conditionElement, lineNumber); | 603 this.textEditor.addDecoration(this._conditionElement, lineNumber); |
| 604 | 604 |
| 605 /** | 605 /** |
| 606 * @this {WebInspector.JavaScriptSourceFrame} | 606 * @this {Sources.JavaScriptSourceFrame} |
| 607 */ | 607 */ |
| 608 function finishEditing(committed, element, newText) { | 608 function finishEditing(committed, element, newText) { |
| 609 this.textEditor.removeDecoration(this._conditionElement, lineNumber); | 609 this.textEditor.removeDecoration(this._conditionElement, lineNumber); |
| 610 delete this._conditionEditorElement; | 610 delete this._conditionEditorElement; |
| 611 delete this._conditionElement; | 611 delete this._conditionElement; |
| 612 if (!committed) | 612 if (!committed) |
| 613 return; | 613 return; |
| 614 | 614 |
| 615 if (breakpoint) | 615 if (breakpoint) |
| 616 breakpoint.setCondition(newText); | 616 breakpoint.setCondition(newText); |
| 617 else | 617 else |
| 618 this._createNewBreakpoint(lineNumber, newText, true); | 618 this._createNewBreakpoint(lineNumber, newText, true); |
| 619 } | 619 } |
| 620 | 620 |
| 621 var config = new WebInspector.InplaceEditor.Config(finishEditing.bind(this,
true), finishEditing.bind(this, false)); | 621 var config = new UI.InplaceEditor.Config(finishEditing.bind(this, true), fin
ishEditing.bind(this, false)); |
| 622 WebInspector.InplaceEditor.startEditing(this._conditionEditorElement, config
); | 622 UI.InplaceEditor.startEditing(this._conditionEditorElement, config); |
| 623 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : '
'; | 623 this._conditionEditorElement.value = breakpoint ? breakpoint.condition() : '
'; |
| 624 this._conditionEditorElement.select(); | 624 this._conditionEditorElement.select(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 _createConditionElement(lineNumber) { | 627 _createConditionElement(lineNumber) { |
| 628 var conditionElement = createElementWithClass('div', 'source-frame-breakpoin
t-condition'); | 628 var conditionElement = createElementWithClass('div', 'source-frame-breakpoin
t-condition'); |
| 629 | 629 |
| 630 var labelElement = conditionElement.createChild('label', 'source-frame-break
point-message'); | 630 var labelElement = conditionElement.createChild('label', 'source-frame-break
point-message'); |
| 631 labelElement.htmlFor = 'source-frame-breakpoint-condition'; | 631 labelElement.htmlFor = 'source-frame-breakpoint-condition'; |
| 632 labelElement.createTextChild( | 632 labelElement.createTextChild( |
| 633 WebInspector.UIString('The breakpoint on line %d will stop only if this
expression is true:', lineNumber + 1)); | 633 Common.UIString('The breakpoint on line %d will stop only if this expres
sion is true:', lineNumber + 1)); |
| 634 | 634 |
| 635 var editorElement = conditionElement.createChild('input', 'monospace'); | 635 var editorElement = conditionElement.createChild('input', 'monospace'); |
| 636 editorElement.id = 'source-frame-breakpoint-condition'; | 636 editorElement.id = 'source-frame-breakpoint-condition'; |
| 637 editorElement.type = 'text'; | 637 editorElement.type = 'text'; |
| 638 this._conditionEditorElement = editorElement; | 638 this._conditionEditorElement = editorElement; |
| 639 | 639 |
| 640 return conditionElement; | 640 return conditionElement; |
| 641 } | 641 } |
| 642 | 642 |
| 643 /** | 643 /** |
| 644 * @param {!WebInspector.UILocation} uiLocation | 644 * @param {!Workspace.UILocation} uiLocation |
| 645 */ | 645 */ |
| 646 setExecutionLocation(uiLocation) { | 646 setExecutionLocation(uiLocation) { |
| 647 this._executionLocation = uiLocation; | 647 this._executionLocation = uiLocation; |
| 648 if (!this.loaded) | 648 if (!this.loaded) |
| 649 return; | 649 return; |
| 650 | 650 |
| 651 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum
nNumber); | 651 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum
nNumber); |
| 652 if (this.isShowing()) { | 652 if (this.isShowing()) { |
| 653 // We need SourcesTextEditor to be initialized prior to this call. @see cr
bug.com/506566 | 653 // We need SourcesTextEditor to be initialized prior to this call. @see cr
bug.com/506566 |
| 654 setImmediate(this._generateValuesInSource.bind(this)); | 654 setImmediate(this._generateValuesInSource.bind(this)); |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 _generateValuesInSource() { | 658 _generateValuesInSource() { |
| 659 if (!WebInspector.moduleSetting('inlineVariableValues').get()) | 659 if (!Common.moduleSetting('inlineVariableValues').get()) |
| 660 return; | 660 return; |
| 661 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); | 661 var executionContext = UI.context.flavor(SDK.ExecutionContext); |
| 662 if (!executionContext) | 662 if (!executionContext) |
| 663 return; | 663 return; |
| 664 var callFrame = WebInspector.context.flavor(WebInspector.DebuggerModel.CallF
rame); | 664 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); |
| 665 if (!callFrame) | 665 if (!callFrame) |
| 666 return; | 666 return; |
| 667 | 667 |
| 668 var localScope = callFrame.localScope(); | 668 var localScope = callFrame.localScope(); |
| 669 var functionLocation = callFrame.functionLocation(); | 669 var functionLocation = callFrame.functionLocation(); |
| 670 if (localScope && functionLocation) | 670 if (localScope && functionLocation) |
| 671 WebInspector.SourceMapNamesResolver.resolveScopeInObject(localScope) | 671 Sources.SourceMapNamesResolver.resolveScopeInObject(localScope) |
| 672 .getAllProperties(false, this._prepareScopeVariables.bind(this, callFr
ame)); | 672 .getAllProperties(false, this._prepareScopeVariables.bind(this, callFr
ame)); |
| 673 | 673 |
| 674 if (this._clearValueWidgetsTimer) { | 674 if (this._clearValueWidgetsTimer) { |
| 675 clearTimeout(this._clearValueWidgetsTimer); | 675 clearTimeout(this._clearValueWidgetsTimer); |
| 676 delete this._clearValueWidgetsTimer; | 676 delete this._clearValueWidgetsTimer; |
| 677 } | 677 } |
| 678 } | 678 } |
| 679 | 679 |
| 680 /** | 680 /** |
| 681 * @param {!WebInspector.DebuggerModel.CallFrame} callFrame | 681 * @param {!SDK.DebuggerModel.CallFrame} callFrame |
| 682 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties | 682 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 683 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties | 683 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 684 */ | 684 */ |
| 685 _prepareScopeVariables(callFrame, properties, internalProperties) { | 685 _prepareScopeVariables(callFrame, properties, internalProperties) { |
| 686 if (!properties || !properties.length || properties.length > 500) { | 686 if (!properties || !properties.length || properties.length > 500) { |
| 687 this._clearValueWidgets(); | 687 this._clearValueWidgets(); |
| 688 return; | 688 return; |
| 689 } | 689 } |
| 690 | 690 |
| 691 var functionUILocation = WebInspector.debuggerWorkspaceBinding.rawLocationTo
UILocation( | 691 var functionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILo
cation( |
| 692 /** @type {!WebInspector.DebuggerModel.Location} */ (callFrame.functionL
ocation())); | 692 /** @type {!SDK.DebuggerModel.Location} */ (callFrame.functionLocation()
)); |
| 693 var executionUILocation = WebInspector.debuggerWorkspaceBinding.rawLocationT
oUILocation(callFrame.location()); | 693 var executionUILocation = Bindings.debuggerWorkspaceBinding.rawLocationToUIL
ocation(callFrame.location()); |
| 694 if (functionUILocation.uiSourceCode !== this.uiSourceCode() || | 694 if (functionUILocation.uiSourceCode !== this.uiSourceCode() || |
| 695 executionUILocation.uiSourceCode !== this.uiSourceCode()) { | 695 executionUILocation.uiSourceCode !== this.uiSourceCode()) { |
| 696 this._clearValueWidgets(); | 696 this._clearValueWidgets(); |
| 697 return; | 697 return; |
| 698 } | 698 } |
| 699 | 699 |
| 700 var fromLine = functionUILocation.lineNumber; | 700 var fromLine = functionUILocation.lineNumber; |
| 701 var fromColumn = functionUILocation.columnNumber; | 701 var fromColumn = functionUILocation.columnNumber; |
| 702 var toLine = executionUILocation.lineNumber; | 702 var toLine = executionUILocation.lineNumber; |
| 703 | 703 |
| 704 // Make sure we have a chance to update all existing widgets. | 704 // Make sure we have a chance to update all existing widgets. |
| 705 if (this._valueWidgets) { | 705 if (this._valueWidgets) { |
| 706 for (var line of this._valueWidgets.keys()) | 706 for (var line of this._valueWidgets.keys()) |
| 707 toLine = Math.max(toLine, line + 1); | 707 toLine = Math.max(toLine, line + 1); |
| 708 } | 708 } |
| 709 if (fromLine >= toLine || toLine - fromLine > 500 || fromLine < 0 || toLine
>= this.textEditor.linesCount) { | 709 if (fromLine >= toLine || toLine - fromLine > 500 || fromLine < 0 || toLine
>= this.textEditor.linesCount) { |
| 710 this._clearValueWidgets(); | 710 this._clearValueWidgets(); |
| 711 return; | 711 return; |
| 712 } | 712 } |
| 713 | 713 |
| 714 var valuesMap = new Map(); | 714 var valuesMap = new Map(); |
| 715 for (var property of properties) | 715 for (var property of properties) |
| 716 valuesMap.set(property.name, property.value); | 716 valuesMap.set(property.name, property.value); |
| 717 | 717 |
| 718 /** @type {!Map.<number, !Set<string>>} */ | 718 /** @type {!Map.<number, !Set<string>>} */ |
| 719 var namesPerLine = new Map(); | 719 var namesPerLine = new Map(); |
| 720 var skipObjectProperty = false; | 720 var skipObjectProperty = false; |
| 721 var tokenizer = new WebInspector.CodeMirrorUtils.TokenizerFactory().createTo
kenizer('text/javascript'); | 721 var tokenizer = new TextEditor.CodeMirrorUtils.TokenizerFactory().createToke
nizer('text/javascript'); |
| 722 tokenizer(this.textEditor.line(fromLine).substring(fromColumn), processToken
.bind(this, fromLine)); | 722 tokenizer(this.textEditor.line(fromLine).substring(fromColumn), processToken
.bind(this, fromLine)); |
| 723 for (var i = fromLine + 1; i < toLine; ++i) | 723 for (var i = fromLine + 1; i < toLine; ++i) |
| 724 tokenizer(this.textEditor.line(i), processToken.bind(this, i)); | 724 tokenizer(this.textEditor.line(i), processToken.bind(this, i)); |
| 725 | 725 |
| 726 /** | 726 /** |
| 727 * @param {number} lineNumber | 727 * @param {number} lineNumber |
| 728 * @param {string} tokenValue | 728 * @param {string} tokenValue |
| 729 * @param {?string} tokenType | 729 * @param {?string} tokenType |
| 730 * @param {number} column | 730 * @param {number} column |
| 731 * @param {number} newColumn | 731 * @param {number} newColumn |
| 732 * @this {WebInspector.JavaScriptSourceFrame} | 732 * @this {Sources.JavaScriptSourceFrame} |
| 733 */ | 733 */ |
| 734 function processToken(lineNumber, tokenValue, tokenType, column, newColumn)
{ | 734 function processToken(lineNumber, tokenValue, tokenType, column, newColumn)
{ |
| 735 if (!skipObjectProperty && tokenType && this._isIdentifier(tokenType) && v
aluesMap.get(tokenValue)) { | 735 if (!skipObjectProperty && tokenType && this._isIdentifier(tokenType) && v
aluesMap.get(tokenValue)) { |
| 736 var names = namesPerLine.get(lineNumber); | 736 var names = namesPerLine.get(lineNumber); |
| 737 if (!names) { | 737 if (!names) { |
| 738 names = new Set(); | 738 names = new Set(); |
| 739 namesPerLine.set(lineNumber, names); | 739 namesPerLine.set(lineNumber, names); |
| 740 } | 740 } |
| 741 names.add(tokenValue); | 741 names.add(tokenValue); |
| 742 } | 742 } |
| 743 skipObjectProperty = tokenValue === '.'; | 743 skipObjectProperty = tokenValue === '.'; |
| 744 } | 744 } |
| 745 this.textEditor.operation(this._renderDecorations.bind(this, valuesMap, name
sPerLine, fromLine, toLine)); | 745 this.textEditor.operation(this._renderDecorations.bind(this, valuesMap, name
sPerLine, fromLine, toLine)); |
| 746 } | 746 } |
| 747 | 747 |
| 748 /** | 748 /** |
| 749 * @param {!Map.<string,!WebInspector.RemoteObject>} valuesMap | 749 * @param {!Map.<string,!SDK.RemoteObject>} valuesMap |
| 750 * @param {!Map.<number, !Set<string>>} namesPerLine | 750 * @param {!Map.<number, !Set<string>>} namesPerLine |
| 751 * @param {number} fromLine | 751 * @param {number} fromLine |
| 752 * @param {number} toLine | 752 * @param {number} toLine |
| 753 */ | 753 */ |
| 754 _renderDecorations(valuesMap, namesPerLine, fromLine, toLine) { | 754 _renderDecorations(valuesMap, namesPerLine, fromLine, toLine) { |
| 755 var formatter = new WebInspector.RemoteObjectPreviewFormatter(); | 755 var formatter = new Components.RemoteObjectPreviewFormatter(); |
| 756 for (var i = fromLine; i < toLine; ++i) { | 756 for (var i = fromLine; i < toLine; ++i) { |
| 757 var names = namesPerLine.get(i); | 757 var names = namesPerLine.get(i); |
| 758 var oldWidget = this._valueWidgets.get(i); | 758 var oldWidget = this._valueWidgets.get(i); |
| 759 if (!names) { | 759 if (!names) { |
| 760 if (oldWidget) { | 760 if (oldWidget) { |
| 761 this._valueWidgets.delete(i); | 761 this._valueWidgets.delete(i); |
| 762 this.textEditor.removeDecoration(oldWidget, i); | 762 this.textEditor.removeDecoration(oldWidget, i); |
| 763 } | 763 } |
| 764 continue; | 764 continue; |
| 765 } | 765 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 782 widget.createTextChild(', '); | 782 widget.createTextChild(', '); |
| 783 var nameValuePair = widget.createChild('span'); | 783 var nameValuePair = widget.createChild('span'); |
| 784 widget.__nameToToken.set(name, nameValuePair); | 784 widget.__nameToToken.set(name, nameValuePair); |
| 785 nameValuePair.createTextChild(name + ' = '); | 785 nameValuePair.createTextChild(name + ' = '); |
| 786 var value = valuesMap.get(name); | 786 var value = valuesMap.get(name); |
| 787 var propertyCount = value.preview ? value.preview.properties.length : 0; | 787 var propertyCount = value.preview ? value.preview.properties.length : 0; |
| 788 var entryCount = value.preview && value.preview.entries ? value.preview.
entries.length : 0; | 788 var entryCount = value.preview && value.preview.entries ? value.preview.
entries.length : 0; |
| 789 if (value.preview && propertyCount + entryCount < 10) | 789 if (value.preview && propertyCount + entryCount < 10) |
| 790 formatter.appendObjectPreview(nameValuePair, value.preview); | 790 formatter.appendObjectPreview(nameValuePair, value.preview); |
| 791 else | 791 else |
| 792 nameValuePair.appendChild(WebInspector.ObjectPropertiesSection.createV
alueElement(value, false)); | 792 nameValuePair.appendChild(Components.ObjectPropertiesSection.createVal
ueElement(value, false)); |
| 793 ++renderedNameCount; | 793 ++renderedNameCount; |
| 794 } | 794 } |
| 795 | 795 |
| 796 var widgetChanged = true; | 796 var widgetChanged = true; |
| 797 if (oldWidget) { | 797 if (oldWidget) { |
| 798 widgetChanged = false; | 798 widgetChanged = false; |
| 799 for (var name of widget.__nameToToken.keys()) { | 799 for (var name of widget.__nameToToken.keys()) { |
| 800 var oldText = oldWidget.__nameToToken.get(name) ? oldWidget.__nameToTo
ken.get(name).textContent : ''; | 800 var oldText = oldWidget.__nameToToken.get(name) ? oldWidget.__nameToTo
ken.get(name).textContent : ''; |
| 801 var newText = widget.__nameToToken.get(name) ? widget.__nameToToken.ge
t(name).textContent : ''; | 801 var newText = widget.__nameToToken.get(name) ? widget.__nameToToken.ge
t(name).textContent : ''; |
| 802 if (newText !== oldText) { | 802 if (newText !== oldText) { |
| 803 widgetChanged = true; | 803 widgetChanged = true; |
| 804 // value has changed, update it. | 804 // value has changed, update it. |
| 805 WebInspector.runCSSAnimationOnce( | 805 UI.runCSSAnimationOnce( |
| 806 /** @type {!Element} */ (widget.__nameToToken.get(name)), 'sourc
e-frame-value-update-highlight'); | 806 /** @type {!Element} */ (widget.__nameToToken.get(name)), 'sourc
e-frame-value-update-highlight'); |
| 807 } | 807 } |
| 808 } | 808 } |
| 809 if (widgetChanged) { | 809 if (widgetChanged) { |
| 810 this._valueWidgets.delete(i); | 810 this._valueWidgets.delete(i); |
| 811 this.textEditor.removeDecoration(oldWidget, i); | 811 this.textEditor.removeDecoration(oldWidget, i); |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 if (widgetChanged) { | 814 if (widgetChanged) { |
| 815 this._valueWidgets.set(i, widget); | 815 this._valueWidgets.set(i, widget); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 842 return true; | 842 return true; |
| 843 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 843 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 844 for (var i = 0; i < scriptFiles.length; ++i) { | 844 for (var i = 0; i < scriptFiles.length; ++i) { |
| 845 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) | 845 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) |
| 846 return true; | 846 return true; |
| 847 } | 847 } |
| 848 return false; | 848 return false; |
| 849 } | 849 } |
| 850 | 850 |
| 851 _breakpointAdded(event) { | 851 _breakpointAdded(event) { |
| 852 var uiLocation = /** @type {!WebInspector.UILocation} */ (event.data.uiLocat
ion); | 852 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); |
| 853 if (uiLocation.uiSourceCode !== this.uiSourceCode()) | 853 if (uiLocation.uiSourceCode !== this.uiSourceCode()) |
| 854 return; | 854 return; |
| 855 if (this._shouldIgnoreExternalBreakpointEvents()) | 855 if (this._shouldIgnoreExternalBreakpointEvents()) |
| 856 return; | 856 return; |
| 857 | 857 |
| 858 var breakpoint = /** @type {!WebInspector.BreakpointManager.Breakpoint} */ (
event.data.breakpoint); | 858 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even
t.data.breakpoint); |
| 859 if (this.loaded) | 859 if (this.loaded) |
| 860 this._addBreakpointDecoration( | 860 this._addBreakpointDecoration( |
| 861 uiLocation.lineNumber, uiLocation.columnNumber, breakpoint.condition()
, breakpoint.enabled(), false); | 861 uiLocation.lineNumber, uiLocation.columnNumber, breakpoint.condition()
, breakpoint.enabled(), false); |
| 862 } | 862 } |
| 863 | 863 |
| 864 _breakpointRemoved(event) { | 864 _breakpointRemoved(event) { |
| 865 var uiLocation = /** @type {!WebInspector.UILocation} */ (event.data.uiLocat
ion); | 865 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); |
| 866 if (uiLocation.uiSourceCode !== this.uiSourceCode()) | 866 if (uiLocation.uiSourceCode !== this.uiSourceCode()) |
| 867 return; | 867 return; |
| 868 if (this._shouldIgnoreExternalBreakpointEvents()) | 868 if (this._shouldIgnoreExternalBreakpointEvents()) |
| 869 return; | 869 return; |
| 870 | 870 |
| 871 var remainingBreakpoints = this._breakpointManager.findBreakpoints(this.uiSo
urceCode(), uiLocation.lineNumber); | 871 var remainingBreakpoints = this._breakpointManager.findBreakpoints(this.uiSo
urceCode(), uiLocation.lineNumber); |
| 872 if (!remainingBreakpoints.length && this.loaded) | 872 if (!remainingBreakpoints.length && this.loaded) |
| 873 this._removeBreakpointDecoration(uiLocation.lineNumber); | 873 this._removeBreakpointDecoration(uiLocation.lineNumber); |
| 874 } | 874 } |
| 875 | 875 |
| 876 /** | 876 /** |
| 877 * @param {!WebInspector.Event} event | 877 * @param {!Common.Event} event |
| 878 */ | 878 */ |
| 879 _onSourceMappingChanged(event) { | 879 _onSourceMappingChanged(event) { |
| 880 var data = /** @type {{target: !WebInspector.Target}} */ (event.data); | 880 var data = /** @type {{target: !SDK.Target}} */ (event.data); |
| 881 this._updateScriptFile(data.target); | 881 this._updateScriptFile(data.target); |
| 882 this._updateLinesWithoutMappingHighlight(); | 882 this._updateLinesWithoutMappingHighlight(); |
| 883 } | 883 } |
| 884 | 884 |
| 885 _updateLinesWithoutMappingHighlight() { | 885 _updateLinesWithoutMappingHighlight() { |
| 886 var linesCount = this.textEditor.linesCount; | 886 var linesCount = this.textEditor.linesCount; |
| 887 for (var i = 0; i < linesCount; ++i) { | 887 for (var i = 0; i < linesCount; ++i) { |
| 888 var lineHasMapping = WebInspector.debuggerWorkspaceBinding.uiLineHasMappin
g(this.uiSourceCode(), i); | 888 var lineHasMapping = Bindings.debuggerWorkspaceBinding.uiLineHasMapping(th
is.uiSourceCode(), i); |
| 889 if (!lineHasMapping) | 889 if (!lineHasMapping) |
| 890 this._hasLineWithoutMapping = true; | 890 this._hasLineWithoutMapping = true; |
| 891 if (this._hasLineWithoutMapping) | 891 if (this._hasLineWithoutMapping) |
| 892 this.textEditor.toggleLineClass(i, 'cm-line-without-source-mapping', !li
neHasMapping); | 892 this.textEditor.toggleLineClass(i, 'cm-line-without-source-mapping', !li
neHasMapping); |
| 893 } | 893 } |
| 894 } | 894 } |
| 895 | 895 |
| 896 /** | 896 /** |
| 897 * @param {!WebInspector.Target} target | 897 * @param {!SDK.Target} target |
| 898 */ | 898 */ |
| 899 _updateScriptFile(target) { | 899 _updateScriptFile(target) { |
| 900 var oldScriptFile = this._scriptFileForTarget.get(target); | 900 var oldScriptFile = this._scriptFileForTarget.get(target); |
| 901 var newScriptFile = WebInspector.debuggerWorkspaceBinding.scriptFile(this.ui
SourceCode(), target); | 901 var newScriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(this.uiSour
ceCode(), target); |
| 902 this._scriptFileForTarget.remove(target); | 902 this._scriptFileForTarget.remove(target); |
| 903 if (oldScriptFile) { | 903 if (oldScriptFile) { |
| 904 oldScriptFile.removeEventListener(WebInspector.ResourceScriptFile.Events.D
idMergeToVM, this._didMergeToVM, this); | 904 oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidMe
rgeToVM, this._didMergeToVM, this); |
| 905 oldScriptFile.removeEventListener( | 905 oldScriptFile.removeEventListener( |
| 906 WebInspector.ResourceScriptFile.Events.DidDivergeFromVM, this._didDive
rgeFromVM, this); | 906 Bindings.ResourceScriptFile.Events.DidDivergeFromVM, this._didDivergeF
romVM, this); |
| 907 if (this._muted && !this.uiSourceCode().isDirty()) | 907 if (this._muted && !this.uiSourceCode().isDirty()) |
| 908 this._restoreBreakpointsIfConsistentScripts(); | 908 this._restoreBreakpointsIfConsistentScripts(); |
| 909 } | 909 } |
| 910 if (newScriptFile) | 910 if (newScriptFile) |
| 911 this._scriptFileForTarget.set(target, newScriptFile); | 911 this._scriptFileForTarget.set(target, newScriptFile); |
| 912 | 912 |
| 913 this._updateDivergedInfobar(); | 913 this._updateDivergedInfobar(); |
| 914 | 914 |
| 915 if (newScriptFile) { | 915 if (newScriptFile) { |
| 916 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Events.DidM
ergeToVM, this._didMergeToVM, this); | 916 newScriptFile.addEventListener(Bindings.ResourceScriptFile.Events.DidMerge
ToVM, this._didMergeToVM, this); |
| 917 newScriptFile.addEventListener( | 917 newScriptFile.addEventListener( |
| 918 WebInspector.ResourceScriptFile.Events.DidDivergeFromVM, this._didDive
rgeFromVM, this); | 918 Bindings.ResourceScriptFile.Events.DidDivergeFromVM, this._didDivergeF
romVM, this); |
| 919 if (this.loaded) | 919 if (this.loaded) |
| 920 newScriptFile.checkMapping(); | 920 newScriptFile.checkMapping(); |
| 921 if (newScriptFile.hasSourceMapURL()) { | 921 if (newScriptFile.hasSourceMapURL()) { |
| 922 var sourceMapInfobar = WebInspector.Infobar.create( | 922 var sourceMapInfobar = UI.Infobar.create( |
| 923 WebInspector.Infobar.Type.Info, WebInspector.UIString('Source Map de
tected.'), | 923 UI.Infobar.Type.Info, Common.UIString('Source Map detected.'), |
| 924 WebInspector.settings.createSetting('sourceMapInfobarDisabled', fals
e)); | 924 Common.settings.createSetting('sourceMapInfobarDisabled', false)); |
| 925 if (sourceMapInfobar) { | 925 if (sourceMapInfobar) { |
| 926 sourceMapInfobar.createDetailsRowMessage(WebInspector.UIString( | 926 sourceMapInfobar.createDetailsRowMessage(Common.UIString( |
| 927 'Associated files should be added to the file tree. You can debug
these resolved source files as regular JavaScript files.')); | 927 'Associated files should be added to the file tree. You can debug
these resolved source files as regular JavaScript files.')); |
| 928 sourceMapInfobar.createDetailsRowMessage(WebInspector.UIString( | 928 sourceMapInfobar.createDetailsRowMessage(Common.UIString( |
| 929 'Associated files are available via file tree or %s.', | 929 'Associated files are available via file tree or %s.', |
| 930 WebInspector.shortcutRegistry.shortcutTitleForAction('sources.go-t
o-source'))); | 930 UI.shortcutRegistry.shortcutTitleForAction('sources.go-to-source')
)); |
| 931 this.attachInfobars([sourceMapInfobar]); | 931 this.attachInfobars([sourceMapInfobar]); |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 } | 934 } |
| 935 } | 935 } |
| 936 | 936 |
| 937 /** | 937 /** |
| 938 * @override | 938 * @override |
| 939 */ | 939 */ |
| 940 onTextEditorContentSet() { | 940 onTextEditorContentSet() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 964 if (line.startsWith('//#')) // mind source map. | 964 if (line.startsWith('//#')) // mind source map. |
| 965 continue; | 965 continue; |
| 966 if (line.length > 500) { | 966 if (line.length > 500) { |
| 967 minified = true; | 967 minified = true; |
| 968 break; | 968 break; |
| 969 } | 969 } |
| 970 } | 970 } |
| 971 if (!minified) | 971 if (!minified) |
| 972 return; | 972 return; |
| 973 | 973 |
| 974 this._prettyPrintInfobar = WebInspector.Infobar.create( | 974 this._prettyPrintInfobar = UI.Infobar.create( |
| 975 WebInspector.Infobar.Type.Info, WebInspector.UIString('Pretty-print this
minified file?'), | 975 UI.Infobar.Type.Info, Common.UIString('Pretty-print this minified file?'
), |
| 976 WebInspector.settings.createSetting('prettyPrintInfobarDisabled', false)
); | 976 Common.settings.createSetting('prettyPrintInfobarDisabled', false)); |
| 977 if (!this._prettyPrintInfobar) | 977 if (!this._prettyPrintInfobar) |
| 978 return; | 978 return; |
| 979 | 979 |
| 980 this._prettyPrintInfobar.setCloseCallback(() => delete this._prettyPrintInfo
bar); | 980 this._prettyPrintInfobar.setCloseCallback(() => delete this._prettyPrintInfo
bar); |
| 981 var toolbar = new WebInspector.Toolbar(''); | 981 var toolbar = new UI.Toolbar(''); |
| 982 var button = new WebInspector.ToolbarButton('', 'largeicon-pretty-print'); | 982 var button = new UI.ToolbarButton('', 'largeicon-pretty-print'); |
| 983 toolbar.appendToolbarItem(button); | 983 toolbar.appendToolbarItem(button); |
| 984 toolbar.element.style.display = 'inline-block'; | 984 toolbar.element.style.display = 'inline-block'; |
| 985 toolbar.element.style.verticalAlign = 'middle'; | 985 toolbar.element.style.verticalAlign = 'middle'; |
| 986 toolbar.element.style.marginBottom = '3px'; | 986 toolbar.element.style.marginBottom = '3px'; |
| 987 toolbar.element.style.pointerEvents = 'none'; | 987 toolbar.element.style.pointerEvents = 'none'; |
| 988 var element = this._prettyPrintInfobar.createDetailsRowMessage(); | 988 var element = this._prettyPrintInfobar.createDetailsRowMessage(); |
| 989 element.appendChild(WebInspector.formatLocalized( | 989 element.appendChild(UI.formatLocalized( |
| 990 'You can click the %s button on the bottom status bar, and continue debu
gging with the new formatted source.', | 990 'You can click the %s button on the bottom status bar, and continue debu
gging with the new formatted source.', |
| 991 [toolbar.element])); | 991 [toolbar.element])); |
| 992 this.attachInfobars([this._prettyPrintInfobar]); | 992 this.attachInfobars([this._prettyPrintInfobar]); |
| 993 } | 993 } |
| 994 | 994 |
| 995 /** | 995 /** |
| 996 * @param {!WebInspector.Event} event | 996 * @param {!Common.Event} event |
| 997 */ | 997 */ |
| 998 _handleGutterClick(event) { | 998 _handleGutterClick(event) { |
| 999 if (this._muted) | 999 if (this._muted) |
| 1000 return; | 1000 return; |
| 1001 | 1001 |
| 1002 var eventData = /** @type {!WebInspector.SourcesTextEditor.GutterClickEventD
ata} */ (event.data); | 1002 var eventData = /** @type {!SourceFrame.SourcesTextEditor.GutterClickEventDa
ta} */ (event.data); |
| 1003 var lineNumber = eventData.lineNumber; | 1003 var lineNumber = eventData.lineNumber; |
| 1004 var eventObject = eventData.event; | 1004 var eventObject = eventData.event; |
| 1005 | 1005 |
| 1006 if (eventObject.button !== 0 || eventObject.altKey || eventObject.ctrlKey ||
eventObject.metaKey) | 1006 if (eventObject.button !== 0 || eventObject.altKey || eventObject.ctrlKey ||
eventObject.metaKey) |
| 1007 return; | 1007 return; |
| 1008 | 1008 |
| 1009 this._toggleBreakpoint(lineNumber, eventObject.shiftKey); | 1009 this._toggleBreakpoint(lineNumber, eventObject.shiftKey); |
| 1010 eventObject.consume(true); | 1010 eventObject.consume(true); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1029 * @param {number} lineNumber | 1029 * @param {number} lineNumber |
| 1030 * @param {string} condition | 1030 * @param {string} condition |
| 1031 * @param {boolean} enabled | 1031 * @param {boolean} enabled |
| 1032 */ | 1032 */ |
| 1033 _createNewBreakpoint(lineNumber, condition, enabled) { | 1033 _createNewBreakpoint(lineNumber, condition, enabled) { |
| 1034 findPossibleBreakpoints.call(this, lineNumber) | 1034 findPossibleBreakpoints.call(this, lineNumber) |
| 1035 .then(checkNextLineIfNeeded.bind(this, lineNumber, 4)) | 1035 .then(checkNextLineIfNeeded.bind(this, lineNumber, 4)) |
| 1036 .then(setBreakpoint.bind(this)); | 1036 .then(setBreakpoint.bind(this)); |
| 1037 | 1037 |
| 1038 /** | 1038 /** |
| 1039 * @this {!WebInspector.JavaScriptSourceFrame} | 1039 * @this {!Sources.JavaScriptSourceFrame} |
| 1040 * @param {number} lineNumber | 1040 * @param {number} lineNumber |
| 1041 * @return {!Promise<?Array<!WebInspector.UILocation>>} | 1041 * @return {!Promise<?Array<!Workspace.UILocation>>} |
| 1042 */ | 1042 */ |
| 1043 function findPossibleBreakpoints(lineNumber) { | 1043 function findPossibleBreakpoints(lineNumber) { |
| 1044 const maxLengthToCheck = 1024; | 1044 const maxLengthToCheck = 1024; |
| 1045 if (lineNumber >= this._textEditor.linesCount) | 1045 if (lineNumber >= this._textEditor.linesCount) |
| 1046 return Promise.resolve(/** @type {?Array<!WebInspector.UILocation>} */([
])); | 1046 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */([]))
; |
| 1047 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) | 1047 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) |
| 1048 return Promise.resolve(/** @type {?Array<!WebInspector.UILocation>} */([
])); | 1048 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */([]))
; |
| 1049 return this._breakpointManager.possibleBreakpoints(this.uiSourceCode(), ne
w WebInspector.TextRange(lineNumber, 0, lineNumber + 1, 0)) | 1049 return this._breakpointManager.possibleBreakpoints(this.uiSourceCode(), ne
w Common.TextRange(lineNumber, 0, lineNumber + 1, 0)) |
| 1050 .then(locations => locations.length ? locations : null); | 1050 .then(locations => locations.length ? locations : null); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 /** | 1053 /** |
| 1054 * @this {!WebInspector.JavaScriptSourceFrame} | 1054 * @this {!Sources.JavaScriptSourceFrame} |
| 1055 * @param {number} currentLineNumber | 1055 * @param {number} currentLineNumber |
| 1056 * @param {number} linesToCheck | 1056 * @param {number} linesToCheck |
| 1057 * @param {?Array<!WebInspector.UILocation>} locations | 1057 * @param {?Array<!Workspace.UILocation>} locations |
| 1058 * @return {!Promise<?Array<!WebInspector.UILocation>>} | 1058 * @return {!Promise<?Array<!Workspace.UILocation>>} |
| 1059 */ | 1059 */ |
| 1060 function checkNextLineIfNeeded(currentLineNumber, linesToCheck, locations) { | 1060 function checkNextLineIfNeeded(currentLineNumber, linesToCheck, locations) { |
| 1061 if (locations || linesToCheck <= 0) | 1061 if (locations || linesToCheck <= 0) |
| 1062 return Promise.resolve(locations); | 1062 return Promise.resolve(locations); |
| 1063 return findPossibleBreakpoints.call(this, currentLineNumber + 1) | 1063 return findPossibleBreakpoints.call(this, currentLineNumber + 1) |
| 1064 .then(checkNextLineIfNeeded.bind(this, currentLineNumber + 1, linesToC
heck - 1)); | 1064 .then(checkNextLineIfNeeded.bind(this, currentLineNumber + 1, linesToC
heck - 1)); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 /** | 1067 /** |
| 1068 * @this {!WebInspector.JavaScriptSourceFrame} | 1068 * @this {!Sources.JavaScriptSourceFrame} |
| 1069 * @param {?Array<!WebInspector.UILocation>} locations | 1069 * @param {?Array<!Workspace.UILocation>} locations |
| 1070 */ | 1070 */ |
| 1071 function setBreakpoint(locations) { | 1071 function setBreakpoint(locations) { |
| 1072 if (!locations || !locations.length) | 1072 if (!locations || !locations.length) |
| 1073 this._setBreakpoint(lineNumber, 0, condition, enabled); | 1073 this._setBreakpoint(lineNumber, 0, condition, enabled); |
| 1074 else | 1074 else |
| 1075 this._setBreakpoint(locations[0].lineNumber, locations[0].columnNumber,
condition, enabled); | 1075 this._setBreakpoint(locations[0].lineNumber, locations[0].columnNumber,
condition, enabled); |
| 1076 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Scrip
tsBreakpointSet); | 1076 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ScriptsBreakpointSet)
; |
| 1077 } | 1077 } |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 toggleBreakpointOnCurrentLine() { | 1080 toggleBreakpointOnCurrentLine() { |
| 1081 if (this._muted) | 1081 if (this._muted) |
| 1082 return; | 1082 return; |
| 1083 | 1083 |
| 1084 var selection = this.textEditor.selection(); | 1084 var selection = this.textEditor.selection(); |
| 1085 if (!selection) | 1085 if (!selection) |
| 1086 return; | 1086 return; |
| 1087 this._toggleBreakpoint(selection.startLine, false); | 1087 this._toggleBreakpoint(selection.startLine, false); |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 /** | 1090 /** |
| 1091 * @param {number} lineNumber | 1091 * @param {number} lineNumber |
| 1092 * @param {number} columnNumber | 1092 * @param {number} columnNumber |
| 1093 * @param {string} condition | 1093 * @param {string} condition |
| 1094 * @param {boolean} enabled | 1094 * @param {boolean} enabled |
| 1095 */ | 1095 */ |
| 1096 _setBreakpoint(lineNumber, columnNumber, condition, enabled) { | 1096 _setBreakpoint(lineNumber, columnNumber, condition, enabled) { |
| 1097 if (!WebInspector.debuggerWorkspaceBinding.uiLineHasMapping(this.uiSourceCod
e(), lineNumber)) | 1097 if (!Bindings.debuggerWorkspaceBinding.uiLineHasMapping(this.uiSourceCode(),
lineNumber)) |
| 1098 return; | 1098 return; |
| 1099 | 1099 |
| 1100 this._breakpointManager.setBreakpoint(this.uiSourceCode(), lineNumber, colum
nNumber, condition, enabled); | 1100 this._breakpointManager.setBreakpoint(this.uiSourceCode(), lineNumber, colum
nNumber, condition, enabled); |
| 1101 this._breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled); | 1101 this._breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 /** | 1104 /** |
| 1105 * @param {number} lineNumber | 1105 * @param {number} lineNumber |
| 1106 * @param {number} columnNumber | 1106 * @param {number} columnNumber |
| 1107 * @param {string} condition | 1107 * @param {string} condition |
| 1108 * @param {boolean} enabled | 1108 * @param {boolean} enabled |
| 1109 */ | 1109 */ |
| 1110 _breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled) { | 1110 _breakpointWasSetForTest(lineNumber, columnNumber, condition, enabled) { |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 /** | 1113 /** |
| 1114 * @override | 1114 * @override |
| 1115 */ | 1115 */ |
| 1116 dispose() { | 1116 dispose() { |
| 1117 this._breakpointManager.removeEventListener( | 1117 this._breakpointManager.removeEventListener( |
| 1118 WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointA
dded, this); | 1118 Bindings.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded
, this); |
| 1119 this._breakpointManager.removeEventListener( | 1119 this._breakpointManager.removeEventListener( |
| 1120 WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpoin
tRemoved, this); | 1120 Bindings.BreakpointManager.Events.BreakpointRemoved, this._breakpointRem
oved, this); |
| 1121 this.uiSourceCode().removeEventListener( | 1121 this.uiSourceCode().removeEventListener( |
| 1122 WebInspector.UISourceCode.Events.SourceMappingChanged, this._onSourceMap
pingChanged, this); | 1122 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin
gChanged, this); |
| 1123 this.uiSourceCode().removeEventListener( | 1123 this.uiSourceCode().removeEventListener( |
| 1124 WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyCh
anged, this); | 1124 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); |
| 1125 this.uiSourceCode().removeEventListener( | 1125 this.uiSourceCode().removeEventListener( |
| 1126 WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopy
Committed, this); | 1126 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); |
| 1127 this.uiSourceCode().removeEventListener( | 1127 this.uiSourceCode().removeEventListener( |
| 1128 WebInspector.UISourceCode.Events.TitleChanged, this._showBlackboxInfobar
IfNeeded, this); | 1128 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); |
| 1129 WebInspector.moduleSetting('skipStackFramesPattern').removeChangeListener(th
is._showBlackboxInfobarIfNeeded, this); | 1129 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh
owBlackboxInfobarIfNeeded, this); |
| 1130 WebInspector.moduleSetting('skipContentScripts').removeChangeListener(this._
showBlackboxInfobarIfNeeded, this); | 1130 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl
ackboxInfobarIfNeeded, this); |
| 1131 super.dispose(); | 1131 super.dispose(); |
| 1132 } | 1132 } |
| 1133 }; | 1133 }; |
| OLD | NEW |