OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @implements {WebInspector.DebuggerSourceMapping} | 7 * @implements {WebInspector.DebuggerSourceMapping} |
8 * @param {!WebInspector.DebuggerModel} debuggerModel | 8 * @param {!WebInspector.DebuggerModel} debuggerModel |
9 * @param {!WebInspector.ScriptFormatterEditorAction} editorAction | 9 * @param {!WebInspector.ScriptFormatterEditorAction} editorAction |
10 */ | 10 */ |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 return false; | 215 return false; |
216 var supportedProjectTypes = [WebInspector.projectTypes.Network, WebInspe
ctor.projectTypes.Debugger, WebInspector.projectTypes.ContentScripts]; | 216 var supportedProjectTypes = [WebInspector.projectTypes.Network, WebInspe
ctor.projectTypes.Debugger, WebInspector.projectTypes.ContentScripts]; |
217 if (supportedProjectTypes.indexOf(uiSourceCode.project().type()) === -1) | 217 if (supportedProjectTypes.indexOf(uiSourceCode.project().type()) === -1) |
218 return false; | 218 return false; |
219 return uiSourceCode.contentType().hasScripts(); | 219 return uiSourceCode.contentType().hasScripts(); |
220 }, | 220 }, |
221 | 221 |
222 _toggleFormatScriptSource: function() | 222 _toggleFormatScriptSource: function() |
223 { | 223 { |
224 var uiSourceCode = this._sourcesView.currentUISourceCode(); | 224 var uiSourceCode = this._sourcesView.currentUISourceCode(); |
225 if (!this._isFormatableScript(uiSourceCode)) | 225 if (this._isFormatableScript(uiSourceCode)) |
226 return; | 226 this._formatUISourceCodeScript(uiSourceCode); |
227 this._formatUISourceCodeScript(uiSourceCode); | |
228 }, | 227 }, |
229 | 228 |
230 /** | 229 /** |
231 * @param {!WebInspector.UISourceCode} uiSourceCode | 230 * @param {!WebInspector.UISourceCode} uiSourceCode |
232 * @param {!WebInspector.UISourceCode} formattedUISourceCode | 231 * @param {!WebInspector.UISourceCode} formattedUISourceCode |
233 * @param {!WebInspector.FormatterSourceMapping} mapping | 232 * @param {!WebInspector.FormatterSourceMapping} mapping |
234 * @private | 233 * @private |
235 */ | 234 */ |
236 _showIfNeeded: function(uiSourceCode, formattedUISourceCode, mapping) | 235 _showIfNeeded: function(uiSourceCode, formattedUISourceCode, mapping) |
237 { | 236 { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 var formattedPath = this._formattedPaths.get(uiSourceCode.project().id()
+ ":" + uiSourceCode.url()); | 341 var formattedPath = this._formattedPaths.get(uiSourceCode.project().id()
+ ":" + uiSourceCode.url()); |
343 if (formattedPath) { | 342 if (formattedPath) { |
344 var uiSourceCodePath = formattedPath; | 343 var uiSourceCodePath = formattedPath; |
345 var formattedUISourceCode = this._workspace.uiSourceCode(this._proje
ctId, uiSourceCodePath); | 344 var formattedUISourceCode = this._workspace.uiSourceCode(this._proje
ctId, uiSourceCodePath); |
346 var formatData = formattedUISourceCode ? this._formatData.get(format
tedUISourceCode) : null; | 345 var formatData = formattedUISourceCode ? this._formatData.get(format
tedUISourceCode) : null; |
347 if (formatData) | 346 if (formatData) |
348 this._showIfNeeded(uiSourceCode, /** @type {!WebInspector.UISou
rceCode} */ (formattedUISourceCode), formatData.mapping); | 347 this._showIfNeeded(uiSourceCode, /** @type {!WebInspector.UISou
rceCode} */ (formattedUISourceCode), formatData.mapping); |
349 return; | 348 return; |
350 } | 349 } |
351 | 350 |
352 uiSourceCode.requestContent(contentLoaded.bind(this)); | 351 uiSourceCode.requestContent().then(contentLoaded.bind(this)); |
353 | 352 |
354 /** | 353 /** |
355 * @this {WebInspector.ScriptFormatterEditorAction} | 354 * @this {WebInspector.ScriptFormatterEditorAction} |
356 * @param {?string} content | 355 * @param {?string} content |
357 */ | 356 */ |
358 function contentLoaded(content) | 357 function contentLoaded(content) |
359 { | 358 { |
360 var highlighterType = WebInspector.NetworkProject.uiSourceCodeMimeTy
pe(uiSourceCode); | 359 var highlighterType = WebInspector.NetworkProject.uiSourceCodeMimeTy
pe(uiSourceCode); |
361 WebInspector.Formatter.format(uiSourceCode.contentType(), highlighte
rType, content || "", innerCallback.bind(this)); | 360 WebInspector.Formatter.format(uiSourceCode.contentType(), highlighte
rType, content || "", innerCallback.bind(this)); |
362 } | 361 } |
(...skipping 22 matching lines...) Expand all Loading... |
385 | 384 |
386 var targets = WebInspector.targetManager.targets(); | 385 var targets = WebInspector.targetManager.targets(); |
387 for (var i = 0; i < targets.length; ++i) { | 386 for (var i = 0; i < targets.length; ++i) { |
388 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(targets[i])); | 387 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(targets[i])); |
389 WebInspector.debuggerWorkspaceBinding.setSourceMapping(targets[i
], formattedUISourceCode, scriptMapping); | 388 WebInspector.debuggerWorkspaceBinding.setSourceMapping(targets[i
], formattedUISourceCode, scriptMapping); |
390 } | 389 } |
391 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMap
ping); | 390 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMap
ping); |
392 } | 391 } |
393 } | 392 } |
394 } | 393 } |
OLD | NEW |