| 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 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Bindings.DebuggerWorkspaceBinding = class { | 8 Bindings.DebuggerWorkspaceBinding = class { |
| 9 /** | 9 /** |
| 10 * @param {!SDK.TargetManager} targetManager | 10 * @param {!SDK.TargetManager} targetManager |
| 11 * @param {!Workspace.Workspace} workspace | 11 * @param {!Workspace.Workspace} workspace |
| 12 */ | 12 */ |
| 13 constructor(targetManager, workspace) { | 13 constructor(targetManager, workspace) { |
| 14 this._workspace = workspace; | 14 this._workspace = workspace; |
| 15 | 15 |
| 16 // FIXME: Migrate from _targetToData to _debuggerModelToData. | 16 // FIXME: Migrate from _targetToData to _debuggerModelToData. |
| 17 /** @type {!Map.<!SDK.Target, !Bindings.DebuggerWorkspaceBinding.TargetData>
} */ | 17 /** @type {!Map.<!SDK.Target, !Bindings.DebuggerWorkspaceBinding.TargetData>
} */ |
| 18 this._targetToData = new Map(); | 18 this._targetToData = new Map(); |
| 19 targetManager.observeTargets(this); | 19 targetManager.observeTargets(this); |
| 20 | 20 |
| 21 targetManager.addModelListener( | 21 targetManager.addModelListener( |
| 22 SDK.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this._g
lobalObjectCleared, this); | 22 SDK.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this._g
lobalObjectCleared, this); |
| 23 targetManager.addModelListener( | 23 targetManager.addModelListener( |
| 24 SDK.DebuggerModel, SDK.DebuggerModel.Events.BeforeDebuggerPaused, this._
beforeDebuggerPaused, this); |
| 25 targetManager.addModelListener( |
| 24 SDK.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this._debug
gerResumed, this); | 26 SDK.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this._debug
gerResumed, this); |
| 25 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t
his._uiSourceCodeRemoved, this); | 27 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t
his._uiSourceCodeRemoved, this); |
| 26 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._
projectRemoved, this); | 28 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._
projectRemoved, this); |
| 27 } | 29 } |
| 28 | 30 |
| 29 /** | 31 /** |
| 30 * @override | 32 * @override |
| 31 * @param {!SDK.Target} target | 33 * @param {!SDK.Target} target |
| 32 */ | 34 */ |
| 33 targetAdded(target) { | 35 targetAdded(target) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 info._removeLocation(location); | 320 info._removeLocation(location); |
| 319 } | 321 } |
| 320 | 322 |
| 321 /** | 323 /** |
| 322 * @param {!Common.Event} event | 324 * @param {!Common.Event} event |
| 323 */ | 325 */ |
| 324 _debuggerResumed(event) { | 326 _debuggerResumed(event) { |
| 325 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.target); | 327 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.target); |
| 326 this._reset(debuggerModel.target()); | 328 this._reset(debuggerModel.target()); |
| 327 } | 329 } |
| 330 |
| 331 /** |
| 332 * @param {!Common.Event} event |
| 333 */ |
| 334 _beforeDebuggerPaused(event) { |
| 335 var rawLocation = event.data.callFrames[0].location(); |
| 336 var targetData = this._targetToData.get(rawLocation.target()); |
| 337 if (!targetData._compilerMapping.mapsToSourceCode(rawLocation)) { |
| 338 event.stopPropagation(); |
| 339 event.preventDefault(); |
| 340 } |
| 341 } |
| 328 }; | 342 }; |
| 329 | 343 |
| 330 /** | 344 /** |
| 331 * @unrestricted | 345 * @unrestricted |
| 332 */ | 346 */ |
| 333 Bindings.DebuggerWorkspaceBinding.TargetData = class { | 347 Bindings.DebuggerWorkspaceBinding.TargetData = class { |
| 334 /** | 348 /** |
| 335 * @param {!SDK.DebuggerModel} debuggerModel | 349 * @param {!SDK.DebuggerModel} debuggerModel |
| 336 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 350 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 337 */ | 351 */ |
| 338 constructor(debuggerModel, debuggerWorkspaceBinding) { | 352 constructor(debuggerModel, debuggerWorkspaceBinding) { |
| 339 this._debuggerModel = debuggerModel; | 353 this._target = debuggerModel.target(); |
| 340 | 354 |
| 341 /** @type {!Map.<string, !Bindings.DebuggerWorkspaceBinding.ScriptInfo>} */ | 355 /** @type {!Map.<string, !Bindings.DebuggerWorkspaceBinding.ScriptInfo>} */ |
| 342 this.scriptDataMap = new Map(); | 356 this.scriptDataMap = new Map(); |
| 343 | 357 |
| 344 /** @type {!Set.<!Bindings.DebuggerWorkspaceBinding.Location>} */ | 358 /** @type {!Set.<!Bindings.DebuggerWorkspaceBinding.Location>} */ |
| 345 this.callFrameLocations = new Set(); | 359 this.callFrameLocations = new Set(); |
| 346 | 360 |
| 347 var workspace = debuggerWorkspaceBinding._workspace; | 361 var workspace = debuggerWorkspaceBinding._workspace; |
| 348 | 362 |
| 349 this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, work
space, debuggerWorkspaceBinding); | 363 this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, work
space, debuggerWorkspaceBinding); |
| 350 this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, wo
rkspace, debuggerWorkspaceBinding); | 364 this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, wo
rkspace, debuggerWorkspaceBinding); |
| 351 this._compilerMapping = new Bindings.CompilerScriptMapping( | 365 this._compilerMapping = new Bindings.CompilerScriptMapping( |
| 352 debuggerModel, workspace, Bindings.NetworkProject.forTarget(this._debugg
erModel.target()), | 366 debuggerModel, workspace, Bindings.NetworkProject.forTarget(this._target
), debuggerWorkspaceBinding); |
| 353 debuggerWorkspaceBinding); | |
| 354 | 367 |
| 355 /** @type {!Map.<!Workspace.UISourceCode, !Bindings.DebuggerSourceMapping>}
*/ | 368 /** @type {!Map.<!Workspace.UISourceCode, !Bindings.DebuggerSourceMapping>}
*/ |
| 356 this._uiSourceCodeToSourceMapping = new Map(); | 369 this._uiSourceCodeToSourceMapping = new Map(); |
| 357 | 370 |
| 358 debuggerModel.setBeforePausedCallback(this._beforePaused.bind(this)); | |
| 359 this._eventListeners = [ | 371 this._eventListeners = [ |
| 360 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource
, this._parsedScriptSource, this), | 372 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource
, this._parsedScriptSource, this), |
| 361 debuggerModel.addEventListener(SDK.DebuggerModel.Events.FailedToParseScrip
tSource, this._parsedScriptSource, this) | 373 debuggerModel.addEventListener(SDK.DebuggerModel.Events.FailedToParseScrip
tSource, this._parsedScriptSource, this) |
| 362 ]; | 374 ]; |
| 363 } | 375 } |
| 364 | 376 |
| 365 /** | 377 /** |
| 366 * @param {!SDK.DebuggerPausedDetails} debuggerPausedDetails | |
| 367 * @return {boolean} | |
| 368 */ | |
| 369 _beforePaused(debuggerPausedDetails) { | |
| 370 return !!this._compilerMapping.mapsToSourceCode(debuggerPausedDetails.callFr
ames[0].location()); | |
| 371 } | |
| 372 | |
| 373 /** | |
| 374 * @param {!Common.Event} event | 378 * @param {!Common.Event} event |
| 375 */ | 379 */ |
| 376 _parsedScriptSource(event) { | 380 _parsedScriptSource(event) { |
| 377 var script = /** @type {!SDK.Script} */ (event.data); | 381 var script = /** @type {!SDK.Script} */ (event.data); |
| 378 this._defaultMapping.addScript(script); | 382 this._defaultMapping.addScript(script); |
| 379 this._resourceMapping.addScript(script); | 383 this._resourceMapping.addScript(script); |
| 380 | 384 |
| 381 if (Common.moduleSetting('jsSourceMapsEnabled').get()) | 385 if (Common.moduleSetting('jsSourceMapsEnabled').get()) |
| 382 this._compilerMapping.addScript(script); | 386 this._compilerMapping.addScript(script); |
| 383 } | 387 } |
| 384 | 388 |
| 385 /** | 389 /** |
| 386 * @param {!Workspace.UISourceCode} uiSourceCode | 390 * @param {!Workspace.UISourceCode} uiSourceCode |
| 387 * @param {?Bindings.DebuggerSourceMapping} sourceMapping | 391 * @param {?Bindings.DebuggerSourceMapping} sourceMapping |
| 388 */ | 392 */ |
| 389 _setSourceMapping(uiSourceCode, sourceMapping) { | 393 _setSourceMapping(uiSourceCode, sourceMapping) { |
| 390 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping) | 394 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping) |
| 391 return; | 395 return; |
| 392 | 396 |
| 393 if (sourceMapping) | 397 if (sourceMapping) |
| 394 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping); | 398 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping); |
| 395 else | 399 else |
| 396 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 400 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); |
| 397 | 401 |
| 398 uiSourceCode.dispatchEventToListeners( | 402 uiSourceCode.dispatchEventToListeners( |
| 399 Workspace.UISourceCode.Events.SourceMappingChanged, | 403 Workspace.UISourceCode.Events.SourceMappingChanged, |
| 400 {target: this._debuggerModel.target(), isIdentity: sourceMapping ? sourc
eMapping.isIdentity() : false}); | 404 {target: this._target, isIdentity: sourceMapping ? sourceMapping.isIdent
ity() : false}); |
| 401 } | 405 } |
| 402 | 406 |
| 403 /** | 407 /** |
| 404 * @param {!Workspace.UISourceCode} uiSourceCode | 408 * @param {!Workspace.UISourceCode} uiSourceCode |
| 405 * @param {number} lineNumber | 409 * @param {number} lineNumber |
| 406 * @param {number} columnNumber | 410 * @param {number} columnNumber |
| 407 * @return {?SDK.DebuggerModel.Location} | 411 * @return {?SDK.DebuggerModel.Location} |
| 408 */ | 412 */ |
| 409 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { | 413 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
| 410 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); | 414 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 422 } | 426 } |
| 423 | 427 |
| 424 /** | 428 /** |
| 425 * @param {!Workspace.UISourceCode} uiSourceCode | 429 * @param {!Workspace.UISourceCode} uiSourceCode |
| 426 */ | 430 */ |
| 427 _uiSourceCodeRemoved(uiSourceCode) { | 431 _uiSourceCodeRemoved(uiSourceCode) { |
| 428 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 432 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); |
| 429 } | 433 } |
| 430 | 434 |
| 431 _dispose() { | 435 _dispose() { |
| 432 this._debuggerModel.setBeforePausedCallback(null); | |
| 433 Common.EventTarget.removeEventListeners(this._eventListeners); | 436 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 434 this._compilerMapping.dispose(); | 437 this._compilerMapping.dispose(); |
| 435 this._resourceMapping.dispose(); | 438 this._resourceMapping.dispose(); |
| 436 this._defaultMapping.dispose(); | 439 this._defaultMapping.dispose(); |
| 437 this._uiSourceCodeToSourceMapping.clear(); | 440 this._uiSourceCodeToSourceMapping.clear(); |
| 438 } | 441 } |
| 439 }; | 442 }; |
| 440 | 443 |
| 441 /** | 444 /** |
| 442 * @unrestricted | 445 * @unrestricted |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 * @param {number} lineNumber | 648 * @param {number} lineNumber |
| 646 * @return {boolean} | 649 * @return {boolean} |
| 647 */ | 650 */ |
| 648 uiLineHasMapping(uiSourceCode, lineNumber) {} | 651 uiLineHasMapping(uiSourceCode, lineNumber) {} |
| 649 }; | 652 }; |
| 650 | 653 |
| 651 /** | 654 /** |
| 652 * @type {!Bindings.DebuggerWorkspaceBinding} | 655 * @type {!Bindings.DebuggerWorkspaceBinding} |
| 653 */ | 656 */ |
| 654 Bindings.debuggerWorkspaceBinding; | 657 Bindings.debuggerWorkspaceBinding; |
| OLD | NEW |