Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/DebuggerWorkspaceBinding.js

Issue 2553043003: [DevTools] Remove methods on Common.Event. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(
26 SDK.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this._debug gerResumed, this); 24 SDK.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this._debug gerResumed, this);
27 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t his._uiSourceCodeRemoved, this); 25 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t his._uiSourceCodeRemoved, this);
28 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._ projectRemoved, this); 26 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._ projectRemoved, this);
29 } 27 }
30 28
31 /** 29 /**
32 * @override 30 * @override
33 * @param {!SDK.Target} target 31 * @param {!SDK.Target} target
34 */ 32 */
35 targetAdded(target) { 33 targetAdded(target) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 info._removeLocation(location); 318 info._removeLocation(location);
321 } 319 }
322 320
323 /** 321 /**
324 * @param {!Common.Event} event 322 * @param {!Common.Event} event
325 */ 323 */
326 _debuggerResumed(event) { 324 _debuggerResumed(event) {
327 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.target); 325 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.target);
328 this._reset(debuggerModel.target()); 326 this._reset(debuggerModel.target());
329 } 327 }
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 }
342 }; 328 };
343 329
344 /** 330 /**
345 * @unrestricted 331 * @unrestricted
346 */ 332 */
347 Bindings.DebuggerWorkspaceBinding.TargetData = class { 333 Bindings.DebuggerWorkspaceBinding.TargetData = class {
348 /** 334 /**
349 * @param {!SDK.DebuggerModel} debuggerModel 335 * @param {!SDK.DebuggerModel} debuggerModel
350 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding 336 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
351 */ 337 */
352 constructor(debuggerModel, debuggerWorkspaceBinding) { 338 constructor(debuggerModel, debuggerWorkspaceBinding) {
353 this._target = debuggerModel.target(); 339 this._debuggerModel = debuggerModel;
354 340
355 /** @type {!Map.<string, !Bindings.DebuggerWorkspaceBinding.ScriptInfo>} */ 341 /** @type {!Map.<string, !Bindings.DebuggerWorkspaceBinding.ScriptInfo>} */
356 this.scriptDataMap = new Map(); 342 this.scriptDataMap = new Map();
357 343
358 /** @type {!Set.<!Bindings.DebuggerWorkspaceBinding.Location>} */ 344 /** @type {!Set.<!Bindings.DebuggerWorkspaceBinding.Location>} */
359 this.callFrameLocations = new Set(); 345 this.callFrameLocations = new Set();
360 346
361 var workspace = debuggerWorkspaceBinding._workspace; 347 var workspace = debuggerWorkspaceBinding._workspace;
362 348
363 this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, work space, debuggerWorkspaceBinding); 349 this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, work space, debuggerWorkspaceBinding);
364 this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, wo rkspace, debuggerWorkspaceBinding); 350 this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, wo rkspace, debuggerWorkspaceBinding);
365 this._compilerMapping = new Bindings.CompilerScriptMapping( 351 this._compilerMapping = new Bindings.CompilerScriptMapping(
366 debuggerModel, workspace, Bindings.NetworkProject.forTarget(this._target ), debuggerWorkspaceBinding); 352 debuggerModel, workspace, Bindings.NetworkProject.forTarget(this._debugg erModel.target()),
353 debuggerWorkspaceBinding);
367 354
368 /** @type {!Map.<!Workspace.UISourceCode, !Bindings.DebuggerSourceMapping>} */ 355 /** @type {!Map.<!Workspace.UISourceCode, !Bindings.DebuggerSourceMapping>} */
369 this._uiSourceCodeToSourceMapping = new Map(); 356 this._uiSourceCodeToSourceMapping = new Map();
370 357
358 debuggerModel.setBeforePausedCallback(this._beforePaused.bind(this));
371 this._eventListeners = [ 359 this._eventListeners = [
372 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource , this._parsedScriptSource, this), 360 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource , this._parsedScriptSource, this),
373 debuggerModel.addEventListener(SDK.DebuggerModel.Events.FailedToParseScrip tSource, this._parsedScriptSource, this) 361 debuggerModel.addEventListener(SDK.DebuggerModel.Events.FailedToParseScrip tSource, this._parsedScriptSource, this)
374 ]; 362 ];
375 } 363 }
376 364
377 /** 365 /**
366 * @param {!SDK.DebuggerPausedDetails} debuggerPausedDetails
lushnikov 2016/12/06 20:21:51 jsdoc: @return is missing
dgozman 2016/12/06 21:36:16 Done.
367 */
368 _beforePaused(debuggerPausedDetails) {
369 return !!this._compilerMapping.mapsToSourceCode(debuggerPausedDetails.callFr ames[0].location());
370 }
371
372 /**
378 * @param {!Common.Event} event 373 * @param {!Common.Event} event
379 */ 374 */
380 _parsedScriptSource(event) { 375 _parsedScriptSource(event) {
381 var script = /** @type {!SDK.Script} */ (event.data); 376 var script = /** @type {!SDK.Script} */ (event.data);
382 this._defaultMapping.addScript(script); 377 this._defaultMapping.addScript(script);
383 this._resourceMapping.addScript(script); 378 this._resourceMapping.addScript(script);
384 379
385 if (Common.moduleSetting('jsSourceMapsEnabled').get()) 380 if (Common.moduleSetting('jsSourceMapsEnabled').get())
386 this._compilerMapping.addScript(script); 381 this._compilerMapping.addScript(script);
387 } 382 }
388 383
389 /** 384 /**
390 * @param {!Workspace.UISourceCode} uiSourceCode 385 * @param {!Workspace.UISourceCode} uiSourceCode
391 * @param {?Bindings.DebuggerSourceMapping} sourceMapping 386 * @param {?Bindings.DebuggerSourceMapping} sourceMapping
392 */ 387 */
393 _setSourceMapping(uiSourceCode, sourceMapping) { 388 _setSourceMapping(uiSourceCode, sourceMapping) {
394 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping) 389 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping)
395 return; 390 return;
396 391
397 if (sourceMapping) 392 if (sourceMapping)
398 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping); 393 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping);
399 else 394 else
400 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); 395 this._uiSourceCodeToSourceMapping.remove(uiSourceCode);
401 396
402 uiSourceCode.dispatchEventToListeners( 397 uiSourceCode.dispatchEventToListeners(
403 Workspace.UISourceCode.Events.SourceMappingChanged, 398 Workspace.UISourceCode.Events.SourceMappingChanged,
404 {target: this._target, isIdentity: sourceMapping ? sourceMapping.isIdent ity() : false}); 399 {target: this._debuggerModel.target(), isIdentity: sourceMapping ? sourc eMapping.isIdentity() : false});
405 } 400 }
406 401
407 /** 402 /**
408 * @param {!Workspace.UISourceCode} uiSourceCode 403 * @param {!Workspace.UISourceCode} uiSourceCode
409 * @param {number} lineNumber 404 * @param {number} lineNumber
410 * @param {number} columnNumber 405 * @param {number} columnNumber
411 * @return {?SDK.DebuggerModel.Location} 406 * @return {?SDK.DebuggerModel.Location}
412 */ 407 */
413 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { 408 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
414 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); 409 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode);
(...skipping 11 matching lines...) Expand all
426 } 421 }
427 422
428 /** 423 /**
429 * @param {!Workspace.UISourceCode} uiSourceCode 424 * @param {!Workspace.UISourceCode} uiSourceCode
430 */ 425 */
431 _uiSourceCodeRemoved(uiSourceCode) { 426 _uiSourceCodeRemoved(uiSourceCode) {
432 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); 427 this._uiSourceCodeToSourceMapping.remove(uiSourceCode);
433 } 428 }
434 429
435 _dispose() { 430 _dispose() {
431 this._debuggerModel.setBeforePausedCallback(null);
436 Common.EventTarget.removeEventListeners(this._eventListeners); 432 Common.EventTarget.removeEventListeners(this._eventListeners);
437 this._compilerMapping.dispose(); 433 this._compilerMapping.dispose();
438 this._resourceMapping.dispose(); 434 this._resourceMapping.dispose();
439 this._defaultMapping.dispose(); 435 this._defaultMapping.dispose();
440 this._uiSourceCodeToSourceMapping.clear(); 436 this._uiSourceCodeToSourceMapping.clear();
441 } 437 }
442 }; 438 };
443 439
444 /** 440 /**
445 * @unrestricted 441 * @unrestricted
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 * @param {number} lineNumber 644 * @param {number} lineNumber
649 * @return {boolean} 645 * @return {boolean}
650 */ 646 */
651 uiLineHasMapping(uiSourceCode, lineNumber) {} 647 uiLineHasMapping(uiSourceCode, lineNumber) {}
652 }; 648 };
653 649
654 /** 650 /**
655 * @type {!Bindings.DebuggerWorkspaceBinding} 651 * @type {!Bindings.DebuggerWorkspaceBinding}
656 */ 652 */
657 Bindings.debuggerWorkspaceBinding; 653 Bindings.debuggerWorkspaceBinding;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698