| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 }, | 150 }, |
| 151 | 151 |
| 152 /** | 152 /** |
| 153 * @param {!WebInspector.Event} event | 153 * @param {!WebInspector.Event} event |
| 154 */ | 154 */ |
| 155 _editorSelected: function(event) | 155 _editorSelected: function(event) |
| 156 { | 156 { |
| 157 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 157 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
| 158 this._updateButton(uiSourceCode); | 158 this._updateButton(uiSourceCode); |
| 159 | 159 |
| 160 var path = uiSourceCode.project().id() + ":" + uiSourceCode.path(); | 160 var path = uiSourceCode.project().id() + ":" + uiSourceCode.url(); |
| 161 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode); | 161 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode); |
| 162 if (this._isFormatableScript(uiSourceCode) && networkURL && this._pathsT
oFormatOnLoad.has(path) && !this._formattedPaths.get(path)) | 162 if (this._isFormatableScript(uiSourceCode) && networkURL && this._pathsT
oFormatOnLoad.has(path) && !this._formattedPaths.get(path)) |
| 163 this._formatUISourceCodeScript(uiSourceCode); | 163 this._formatUISourceCodeScript(uiSourceCode); |
| 164 }, | 164 }, |
| 165 | 165 |
| 166 /** | 166 /** |
| 167 * @param {!WebInspector.Event} event | 167 * @param {!WebInspector.Event} event |
| 168 */ | 168 */ |
| 169 _editorClosed: function(event) | 169 _editorClosed: function(event) |
| 170 { | 170 { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 this._formatData.remove(formattedUISourceCode); | 259 this._formatData.remove(formattedUISourceCode); |
| 260 var path = formatData.projectId + ":" + formatData.path; | 260 var path = formatData.projectId + ":" + formatData.path; |
| 261 this._formattedPaths.remove(path); | 261 this._formattedPaths.remove(path); |
| 262 this._pathsToFormatOnLoad.delete(path); | 262 this._pathsToFormatOnLoad.delete(path); |
| 263 for (var i = 0; i < formatData.scripts.length; ++i) { | 263 for (var i = 0; i < formatData.scripts.length; ++i) { |
| 264 this._uiSourceCodes.remove(formatData.scripts[i]); | 264 this._uiSourceCodes.remove(formatData.scripts[i]); |
| 265 WebInspector.debuggerWorkspaceBinding.popSourceMapping(formatData.sc
ripts[i]); | 265 WebInspector.debuggerWorkspaceBinding.popSourceMapping(formatData.sc
ripts[i]); |
| 266 } | 266 } |
| 267 this._project.removeFile(formattedUISourceCode.path()); | 267 this._project.removeFile(formattedUISourceCode.url()); |
| 268 }, | 268 }, |
| 269 | 269 |
| 270 /** | 270 /** |
| 271 * @param {!WebInspector.Target} target | 271 * @param {!WebInspector.Target} target |
| 272 */ | 272 */ |
| 273 _cleanForTarget: function(target) | 273 _cleanForTarget: function(target) |
| 274 { | 274 { |
| 275 var uiSourceCodes = this._formatData.keysArray(); | 275 var uiSourceCodes = this._formatData.keysArray(); |
| 276 for (var i = 0; i < uiSourceCodes.length; ++i) { | 276 for (var i = 0; i < uiSourceCodes.length; ++i) { |
| 277 WebInspector.debuggerWorkspaceBinding.setSourceMapping(target, uiSou
rceCodes[i], null); | 277 WebInspector.debuggerWorkspaceBinding.setSourceMapping(target, uiSou
rceCodes[i], null); |
| 278 var formatData = this._formatData.get(uiSourceCodes[i]); | 278 var formatData = this._formatData.get(uiSourceCodes[i]); |
| 279 var scripts = []; | 279 var scripts = []; |
| 280 for (var j = 0; j < formatData.scripts.length; ++j) { | 280 for (var j = 0; j < formatData.scripts.length; ++j) { |
| 281 if (formatData.scripts[j].target() === target) | 281 if (formatData.scripts[j].target() === target) |
| 282 this._uiSourceCodes.remove(formatData.scripts[j]); | 282 this._uiSourceCodes.remove(formatData.scripts[j]); |
| 283 else | 283 else |
| 284 scripts.push(formatData.scripts[j]); | 284 scripts.push(formatData.scripts[j]); |
| 285 } | 285 } |
| 286 | 286 |
| 287 if (scripts.length) | 287 if (scripts.length) |
| 288 formatData.scripts = scripts; | 288 formatData.scripts = scripts; |
| 289 else { | 289 else { |
| 290 this._formattedPaths.remove(formatData.projectId + ":" + formatD
ata.path); | 290 this._formattedPaths.remove(formatData.projectId + ":" + formatD
ata.path); |
| 291 this._formatData.remove(uiSourceCodes[i]); | 291 this._formatData.remove(uiSourceCodes[i]); |
| 292 this._project.removeFile(uiSourceCodes[i].path()); | 292 this._project.removeFile(uiSourceCodes[i].url()); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 }, | 295 }, |
| 296 | 296 |
| 297 /** | 297 /** |
| 298 * @param {!WebInspector.Event} event | 298 * @param {!WebInspector.Event} event |
| 299 */ | 299 */ |
| 300 _debuggerReset: function(event) | 300 _debuggerReset: function(event) |
| 301 { | 301 { |
| 302 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta
rget); | 302 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta
rget); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 332 return rawLocations.map(function(rawLocation) { return rawLocation.s
cript(); }); | 332 return rawLocations.map(function(rawLocation) { return rawLocation.s
cript(); }); |
| 333 } | 333 } |
| 334 return []; | 334 return []; |
| 335 }, | 335 }, |
| 336 | 336 |
| 337 /** | 337 /** |
| 338 * @param {!WebInspector.UISourceCode} uiSourceCode | 338 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 339 */ | 339 */ |
| 340 _formatUISourceCodeScript: function(uiSourceCode) | 340 _formatUISourceCodeScript: function(uiSourceCode) |
| 341 { | 341 { |
| 342 var formattedPath = this._formattedPaths.get(uiSourceCode.project().id()
+ ":" + uiSourceCode.path()); | 342 var formattedPath = this._formattedPaths.get(uiSourceCode.project().id()
+ ":" + uiSourceCode.url()); |
| 343 if (formattedPath) { | 343 if (formattedPath) { |
| 344 var uiSourceCodePath = formattedPath; | 344 var uiSourceCodePath = formattedPath; |
| 345 var formattedUISourceCode = this._workspace.uiSourceCode(this._proje
ctId, uiSourceCodePath); | 345 var formattedUISourceCode = this._workspace.uiSourceCode(this._proje
ctId, uiSourceCodePath); |
| 346 var formatData = formattedUISourceCode ? this._formatData.get(format
tedUISourceCode) : null; | 346 var formatData = formattedUISourceCode ? this._formatData.get(format
tedUISourceCode) : null; |
| 347 if (formatData) | 347 if (formatData) |
| 348 this._showIfNeeded(uiSourceCode, /** @type {!WebInspector.UISou
rceCode} */ (formattedUISourceCode), formatData.mapping); | 348 this._showIfNeeded(uiSourceCode, /** @type {!WebInspector.UISou
rceCode} */ (formattedUISourceCode), formatData.mapping); |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 | 351 |
| 352 uiSourceCode.requestContent(contentLoaded.bind(this)); | 352 uiSourceCode.requestContent(contentLoaded.bind(this)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 363 | 363 |
| 364 /** | 364 /** |
| 365 * @this {WebInspector.ScriptFormatterEditorAction} | 365 * @this {WebInspector.ScriptFormatterEditorAction} |
| 366 * @param {string} formattedContent | 366 * @param {string} formattedContent |
| 367 * @param {!WebInspector.FormatterSourceMapping} formatterMapping | 367 * @param {!WebInspector.FormatterSourceMapping} formatterMapping |
| 368 */ | 368 */ |
| 369 function innerCallback(formattedContent, formatterMapping) | 369 function innerCallback(formattedContent, formatterMapping) |
| 370 { | 370 { |
| 371 var scripts = this._scriptsForUISourceCode(uiSourceCode); | 371 var scripts = this._scriptsForUISourceCode(uiSourceCode); |
| 372 var contentProvider = new WebInspector.StaticContentProvider(uiSourc
eCode.contentType(), formattedContent); | 372 var contentProvider = new WebInspector.StaticContentProvider(uiSourc
eCode.contentType(), formattedContent); |
| 373 var formattedUISourceCode = this._project.addContentProvider(uiSourc
eCode.path() + ":formatted", contentProvider); | 373 var formattedUISourceCode = this._project.addContentProvider(uiSourc
eCode.url() + ":formatted", contentProvider); |
| 374 var formattedPath = formattedUISourceCode.path(); | 374 var formattedPath = formattedUISourceCode.url(); |
| 375 var formatData = new WebInspector.FormatterScriptMapping.FormatData(
uiSourceCode.project().id(), uiSourceCode.path(), formatterMapping, scripts); | 375 var formatData = new WebInspector.FormatterScriptMapping.FormatData(
uiSourceCode.project().id(), uiSourceCode.url(), formatterMapping, scripts); |
| 376 this._formatData.set(formattedUISourceCode, formatData); | 376 this._formatData.set(formattedUISourceCode, formatData); |
| 377 var path = uiSourceCode.project().id() + ":" + uiSourceCode.path(); | 377 var path = uiSourceCode.project().id() + ":" + uiSourceCode.url(); |
| 378 this._formattedPaths.set(path, formattedPath); | 378 this._formattedPaths.set(path, formattedPath); |
| 379 this._pathsToFormatOnLoad.add(path); | 379 this._pathsToFormatOnLoad.add(path); |
| 380 for (var i = 0; i < scripts.length; ++i) { | 380 for (var i = 0; i < scripts.length; ++i) { |
| 381 this._uiSourceCodes.set(scripts[i], formattedUISourceCode); | 381 this._uiSourceCodes.set(scripts[i], formattedUISourceCode); |
| 382 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(scripts[i].target())); | 382 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(scripts[i].target())); |
| 383 WebInspector.debuggerWorkspaceBinding.pushSourceMapping(scripts[
i], scriptMapping); | 383 WebInspector.debuggerWorkspaceBinding.pushSourceMapping(scripts[
i], scriptMapping); |
| 384 } | 384 } |
| 385 | 385 |
| 386 var targets = WebInspector.targetManager.targets(); | 386 var targets = WebInspector.targetManager.targets(); |
| 387 for (var i = 0; i < targets.length; ++i) { | 387 for (var i = 0; i < targets.length; ++i) { |
| 388 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(targets[i])); | 388 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(targets[i])); |
| 389 WebInspector.debuggerWorkspaceBinding.setSourceMapping(targets[i
], formattedUISourceCode, scriptMapping); | 389 WebInspector.debuggerWorkspaceBinding.setSourceMapping(targets[i
], formattedUISourceCode, scriptMapping); |
| 390 } | 390 } |
| 391 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMap
ping); | 391 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMap
ping); |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 } | 394 } |
| OLD | NEW |