| 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.TargetManager.Observer} | 7 * @implements {WebInspector.TargetManager.Observer} |
| 8 * @param {!WebInspector.TargetManager} targetManager | 8 * @param {!WebInspector.TargetManager} targetManager |
| 9 * @param {!WebInspector.Workspace} workspace | 9 * @param {!WebInspector.Workspace} workspace |
| 10 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding | 10 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 _uiSourceCodeRemoved: function(event) | 46 _uiSourceCodeRemoved: function(event) |
| 47 { | 47 { |
| 48 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 48 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
| 49 var targetDatas = this._targetToData.values(); | 49 var targetDatas = this._targetToData.values(); |
| 50 for (var i = 0; i < targetDatas.length; ++i) | 50 for (var i = 0; i < targetDatas.length; ++i) |
| 51 targetDatas[i]._uiSourceCodeRemoved(uiSourceCode); | 51 targetDatas[i]._uiSourceCodeRemoved(uiSourceCode); |
| 52 }, | 52 }, |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * @param {!WebInspector.Script} script | 55 * @param {!WebInspector.Script} script |
| 56 * @param {!WebInspector.SourceMapping} sourceMapping | 56 * @param {!WebInspector.DebuggerSourceMapping} sourceMapping |
| 57 */ | 57 */ |
| 58 pushSourceMapping: function(script, sourceMapping) | 58 pushSourceMapping: function(script, sourceMapping) |
| 59 { | 59 { |
| 60 var info = this._ensureInfoForScript(script); | 60 var info = this._ensureInfoForScript(script); |
| 61 info._pushSourceMapping(sourceMapping); | 61 info._pushSourceMapping(sourceMapping); |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {!WebInspector.Script} script | 65 * @param {!WebInspector.Script} script |
| 66 * @return {!WebInspector.SourceMapping} | 66 * @return {!WebInspector.DebuggerSourceMapping} |
| 67 */ | 67 */ |
| 68 popSourceMapping: function(script) | 68 popSourceMapping: function(script) |
| 69 { | 69 { |
| 70 var info = this._infoForScript(script.target(), script.scriptId); | 70 var info = this._infoForScript(script.target(), script.scriptId); |
| 71 console.assert(info); | 71 console.assert(info); |
| 72 return info._popSourceMapping(); | 72 return info._popSourceMapping(); |
| 73 }, | 73 }, |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * @param {!WebInspector.Target} target | 76 * @param {!WebInspector.Target} target |
| 77 * @param {!WebInspector.UISourceCode} uiSourceCode | 77 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 78 * @param {?WebInspector.SourceMapping} sourceMapping | 78 * @param {?WebInspector.DebuggerSourceMapping} sourceMapping |
| 79 */ | 79 */ |
| 80 setSourceMapping: function(target, uiSourceCode, sourceMapping) | 80 setSourceMapping: function(target, uiSourceCode, sourceMapping) |
| 81 { | 81 { |
| 82 var data = this._targetToData.get(target); | 82 var data = this._targetToData.get(target); |
| 83 if (data) | 83 if (data) |
| 84 data._setSourceMapping(uiSourceCode, sourceMapping); | 84 data._setSourceMapping(uiSourceCode, sourceMapping); |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @param {!WebInspector.Script} script | 88 * @param {!WebInspector.Script} script |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 uiLocationToRawLocation: function(target, uiSourceCode, lineNumber, columnNu
mber) | 143 uiLocationToRawLocation: function(target, uiSourceCode, lineNumber, columnNu
mber) |
| 144 { | 144 { |
| 145 var targetData = this._targetToData.get(target); | 145 var targetData = this._targetToData.get(target); |
| 146 return targetData ? /** @type {?WebInspector.DebuggerModel.Location} */
(targetData._uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber)) :
null; | 146 return targetData ? /** @type {?WebInspector.DebuggerModel.Location} */
(targetData._uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber)) :
null; |
| 147 }, | 147 }, |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * @param {!WebInspector.UISourceCode} uiSourceCode | 150 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 151 * @param {number} lineNumber | 151 * @param {number} lineNumber |
| 152 * @param {number} columnNumber | 152 * @param {number} columnNumber |
| 153 * @return {!Array.<!WebInspector.RawLocation>} | 153 * @return {!Array.<!WebInspector.DebuggerModel.Location>} |
| 154 */ | 154 */ |
| 155 uiLocationToRawLocations: function(uiSourceCode, lineNumber, columnNumber) | 155 uiLocationToRawLocations: function(uiSourceCode, lineNumber, columnNumber) |
| 156 { | 156 { |
| 157 var result = []; | 157 var result = []; |
| 158 var targetDatas = this._targetToData.values(); | 158 var targetDatas = this._targetToData.values(); |
| 159 for (var i = 0; i < targetDatas.length; ++i) { | 159 for (var i = 0; i < targetDatas.length; ++i) { |
| 160 var rawLocation = targetDatas[i]._uiLocationToRawLocation(uiSourceCo
de, lineNumber, columnNumber); | 160 var rawLocation = targetDatas[i]._uiLocationToRawLocation(uiSourceCo
de, lineNumber, columnNumber); |
| 161 if (rawLocation) | 161 if (rawLocation) |
| 162 result.push(rawLocation); | 162 result.push(rawLocation); |
| 163 } | 163 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 var workspace = debuggerWorkspaceBinding._workspace; | 297 var workspace = debuggerWorkspaceBinding._workspace; |
| 298 | 298 |
| 299 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace,
debuggerWorkspaceBinding); | 299 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace,
debuggerWorkspaceBinding); |
| 300 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel,
workspace, debuggerWorkspaceBinding); | 300 this._defaultMapping = new WebInspector.DefaultScriptMapping(debuggerModel,
workspace, debuggerWorkspaceBinding); |
| 301 this._resourceMapping = new WebInspector.ResourceScriptMapping(debuggerModel
, workspace, debuggerWorkspaceBinding); | 301 this._resourceMapping = new WebInspector.ResourceScriptMapping(debuggerModel
, workspace, debuggerWorkspaceBinding); |
| 302 this._compilerMapping = new WebInspector.CompilerScriptMapping(debuggerModel
, workspace, debuggerWorkspaceBinding._networkWorkspaceBinding, debuggerWorkspac
eBinding); | 302 this._compilerMapping = new WebInspector.CompilerScriptMapping(debuggerModel
, workspace, debuggerWorkspaceBinding._networkWorkspaceBinding, debuggerWorkspac
eBinding); |
| 303 | 303 |
| 304 /** @type {!WebInspector.LiveEditSupport} */ | 304 /** @type {!WebInspector.LiveEditSupport} */ |
| 305 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace,
debuggerWorkspaceBinding); | 305 this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace,
debuggerWorkspaceBinding); |
| 306 | 306 |
| 307 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceMapping>} *
/ | 307 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.DebuggerSourceMap
ping>} */ |
| 308 this._uiSourceCodeToSourceMapping = new Map(); | 308 this._uiSourceCodeToSourceMapping = new Map(); |
| 309 | 309 |
| 310 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScrip
tSource, this._parsedScriptSource, this); | 310 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScrip
tSource, this._parsedScriptSource, this); |
| 311 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToPar
seScriptSource, this._parsedScriptSource, this); | 311 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToPar
seScriptSource, this._parsedScriptSource, this); |
| 312 } | 312 } |
| 313 | 313 |
| 314 WebInspector.DebuggerWorkspaceBinding.TargetData.prototype = { | 314 WebInspector.DebuggerWorkspaceBinding.TargetData.prototype = { |
| 315 /** | 315 /** |
| 316 * @param {!WebInspector.Event} event | 316 * @param {!WebInspector.Event} event |
| 317 */ | 317 */ |
| 318 _parsedScriptSource: function(event) | 318 _parsedScriptSource: function(event) |
| 319 { | 319 { |
| 320 var script = /** @type {!WebInspector.Script} */ (event.data); | 320 var script = /** @type {!WebInspector.Script} */ (event.data); |
| 321 this._defaultMapping.addScript(script); | 321 this._defaultMapping.addScript(script); |
| 322 | 322 |
| 323 if (script.isSnippet()) { | 323 if (script.isSnippet()) { |
| 324 WebInspector.scriptSnippetModel.addScript(script); | 324 WebInspector.scriptSnippetModel.addScript(script); |
| 325 return; | 325 return; |
| 326 } | 326 } |
| 327 | 327 |
| 328 this._resourceMapping.addScript(script); | 328 this._resourceMapping.addScript(script); |
| 329 | 329 |
| 330 if (WebInspector.settings.jsSourceMapsEnabled.get()) | 330 if (WebInspector.settings.jsSourceMapsEnabled.get()) |
| 331 this._compilerMapping.addScript(script); | 331 this._compilerMapping.addScript(script); |
| 332 }, | 332 }, |
| 333 | 333 |
| 334 /** | 334 /** |
| 335 * @param {!WebInspector.UISourceCode} uiSourceCode | 335 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 336 * @param {?WebInspector.SourceMapping} sourceMapping | 336 * @param {?WebInspector.DebuggerSourceMapping} sourceMapping |
| 337 */ | 337 */ |
| 338 _setSourceMapping: function(uiSourceCode, sourceMapping) | 338 _setSourceMapping: function(uiSourceCode, sourceMapping) |
| 339 { | 339 { |
| 340 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMappin
g) | 340 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMappin
g) |
| 341 return; | 341 return; |
| 342 | 342 |
| 343 if (sourceMapping) | 343 if (sourceMapping) |
| 344 this._uiSourceCodeToSourceMapping.put(uiSourceCode, sourceMapping); | 344 this._uiSourceCodeToSourceMapping.put(uiSourceCode, sourceMapping); |
| 345 else | 345 else |
| 346 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 346 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); |
| 347 | 347 |
| 348 uiSourceCode.dispatchEventToListeners(WebInspector.UISourceCode.Events.S
ourceMappingChanged, {target: this._target, isIdentity: sourceMapping ? sourceMa
pping.isIdentity() : false}); | 348 uiSourceCode.dispatchEventToListeners(WebInspector.UISourceCode.Events.S
ourceMappingChanged, {target: this._target, isIdentity: sourceMapping ? sourceMa
pping.isIdentity() : false}); |
| 349 }, | 349 }, |
| 350 | 350 |
| 351 /** | 351 /** |
| 352 * @param {!WebInspector.UISourceCode} uiSourceCode | 352 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 353 * @param {number} lineNumber | 353 * @param {number} lineNumber |
| 354 * @param {number} columnNumber | 354 * @param {number} columnNumber |
| 355 * @return {?WebInspector.RawLocation} | 355 * @return {?WebInspector.DebuggerModel.Location} |
| 356 */ | 356 */ |
| 357 _uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) | 357 _uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) |
| 358 { | 358 { |
| 359 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); | 359 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); |
| 360 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCod
e, lineNumber, columnNumber) : null; | 360 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCod
e, lineNumber, columnNumber) : null; |
| 361 }, | 361 }, |
| 362 | 362 |
| 363 /** | 363 /** |
| 364 * @param {!WebInspector.UISourceCode} uiSourceCode | 364 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 365 * @param {number} lineNumber | 365 * @param {number} lineNumber |
| (...skipping 23 matching lines...) Expand all Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 /** | 391 /** |
| 392 * @constructor | 392 * @constructor |
| 393 * @param {!WebInspector.Script} script | 393 * @param {!WebInspector.Script} script |
| 394 */ | 394 */ |
| 395 WebInspector.DebuggerWorkspaceBinding.ScriptInfo = function(script) | 395 WebInspector.DebuggerWorkspaceBinding.ScriptInfo = function(script) |
| 396 { | 396 { |
| 397 this._script = script; | 397 this._script = script; |
| 398 | 398 |
| 399 /** @type {!Array.<!WebInspector.SourceMapping>} */ | 399 /** @type {!Array.<!WebInspector.DebuggerSourceMapping>} */ |
| 400 this._sourceMappings = []; | 400 this._sourceMappings = []; |
| 401 | 401 |
| 402 /** @type {!Set.<!WebInspector.LiveLocation>} */ | 402 /** @type {!Set.<!WebInspector.LiveLocation>} */ |
| 403 this._locations = new Set(); | 403 this._locations = new Set(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { | 406 WebInspector.DebuggerWorkspaceBinding.ScriptInfo.prototype = { |
| 407 /** | 407 /** |
| 408 * @param {!WebInspector.SourceMapping} sourceMapping | 408 * @param {!WebInspector.DebuggerSourceMapping} sourceMapping |
| 409 */ | 409 */ |
| 410 _pushSourceMapping: function(sourceMapping) | 410 _pushSourceMapping: function(sourceMapping) |
| 411 { | 411 { |
| 412 this._sourceMappings.push(sourceMapping); | 412 this._sourceMappings.push(sourceMapping); |
| 413 this._updateLocations(); | 413 this._updateLocations(); |
| 414 }, | 414 }, |
| 415 | 415 |
| 416 /** | 416 /** |
| 417 * @return {!WebInspector.SourceMapping} | 417 * @return {!WebInspector.DebuggerSourceMapping} |
| 418 */ | 418 */ |
| 419 _popSourceMapping: function() | 419 _popSourceMapping: function() |
| 420 { | 420 { |
| 421 var sourceMapping = this._sourceMappings.pop(); | 421 var sourceMapping = this._sourceMappings.pop(); |
| 422 this._updateLocations(); | 422 this._updateLocations(); |
| 423 return sourceMapping; | 423 return sourceMapping; |
| 424 }, | 424 }, |
| 425 | 425 |
| 426 /** | 426 /** |
| 427 * @param {!WebInspector.LiveLocation} location | 427 * @param {!WebInspector.LiveLocation} location |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 /** | 465 /** |
| 466 * @constructor | 466 * @constructor |
| 467 * @extends {WebInspector.LiveLocation} | 467 * @extends {WebInspector.LiveLocation} |
| 468 * @param {!WebInspector.Script} script | 468 * @param {!WebInspector.Script} script |
| 469 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 469 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 470 * @param {!WebInspector.DebuggerWorkspaceBinding} binding | 470 * @param {!WebInspector.DebuggerWorkspaceBinding} binding |
| 471 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegat
e | 471 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegat
e |
| 472 */ | 472 */ |
| 473 WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, b
inding, updateDelegate) | 473 WebInspector.DebuggerWorkspaceBinding.Location = function(script, rawLocation, b
inding, updateDelegate) |
| 474 { | 474 { |
| 475 WebInspector.LiveLocation.call(this, rawLocation, updateDelegate); | 475 WebInspector.LiveLocation.call(this, updateDelegate); |
| 476 this._script = script; | 476 this._script = script; |
| 477 this._rawLocation = rawLocation; |
| 477 this._binding = binding; | 478 this._binding = binding; |
| 478 } | 479 } |
| 479 | 480 |
| 480 WebInspector.DebuggerWorkspaceBinding.Location.prototype = { | 481 WebInspector.DebuggerWorkspaceBinding.Location.prototype = { |
| 481 /** | 482 /** |
| 482 * @return {!WebInspector.UILocation} | 483 * @return {!WebInspector.UILocation} |
| 483 */ | 484 */ |
| 484 uiLocation: function() | 485 uiLocation: function() |
| 485 { | 486 { |
| 486 var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Locat
ion} */ (this.rawLocation()); | 487 var debuggerModelLocation = this._rawLocation; |
| 487 return this._binding.rawLocationToUILocation(debuggerModelLocation); | 488 return this._binding.rawLocationToUILocation(debuggerModelLocation); |
| 488 }, | 489 }, |
| 489 | 490 |
| 490 dispose: function() | 491 dispose: function() |
| 491 { | 492 { |
| 492 WebInspector.LiveLocation.prototype.dispose.call(this); | 493 WebInspector.LiveLocation.prototype.dispose.call(this); |
| 493 this._binding._removeLiveLocation(this); | 494 this._binding._removeLiveLocation(this); |
| 494 }, | 495 }, |
| 495 | 496 |
| 496 __proto__: WebInspector.LiveLocation.prototype | 497 __proto__: WebInspector.LiveLocation.prototype |
| 497 } | 498 } |
| 498 | 499 |
| 499 /** | 500 /** |
| 501 * @interface |
| 502 */ |
| 503 WebInspector.DebuggerSourceMapping = function() |
| 504 { |
| 505 } |
| 506 |
| 507 WebInspector.DebuggerSourceMapping.prototype = { |
| 508 /** |
| 509 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 510 * @return {?WebInspector.UILocation} |
| 511 */ |
| 512 rawLocationToUILocation: function(rawLocation) { }, |
| 513 |
| 514 /** |
| 515 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 516 * @param {number} lineNumber |
| 517 * @param {number} columnNumber |
| 518 * @return {?WebInspector.DebuggerModel.Location} |
| 519 */ |
| 520 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) {
}, |
| 521 |
| 522 /** |
| 523 * @return {boolean} |
| 524 */ |
| 525 isIdentity: function() { }, |
| 526 |
| 527 /** |
| 528 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 529 * @param {number} lineNumber |
| 530 * @return {boolean} |
| 531 */ |
| 532 uiLineHasMapping: function(uiSourceCode, lineNumber) { } |
| 533 } |
| 534 |
| 535 /** |
| 500 * @type {!WebInspector.DebuggerWorkspaceBinding} | 536 * @type {!WebInspector.DebuggerWorkspaceBinding} |
| 501 */ | 537 */ |
| 502 WebInspector.debuggerWorkspaceBinding; | 538 WebInspector.debuggerWorkspaceBinding; |
| OLD | NEW |