Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 { | 37 { |
| 38 this._workspace = workspace; | 38 this._workspace = workspace; |
| 39 /** @type {!Object.<string, !WebInspector.UISourceCode>} */ | 39 /** @type {!Object.<string, !WebInspector.UISourceCode>} */ |
| 40 this._uiSourceCodeForScriptId = {}; | 40 this._uiSourceCodeForScriptId = {}; |
| 41 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.Script>} */ | 41 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.Script>} */ |
| 42 this._scriptForUISourceCode = new Map(); | 42 this._scriptForUISourceCode = new Map(); |
| 43 /** @type {!Object.<string, !WebInspector.UISourceCode>} */ | 43 /** @type {!Object.<string, !WebInspector.UISourceCode>} */ |
| 44 this._uiSourceCodeForSnippetId = {}; | 44 this._uiSourceCodeForSnippetId = {}; |
| 45 /** @type {!Map.<!WebInspector.UISourceCode, string>} */ | 45 /** @type {!Map.<!WebInspector.UISourceCode, string>} */ |
| 46 this._snippetIdForUISourceCode = new Map(); | 46 this._snippetIdForUISourceCode = new Map(); |
| 47 | 47 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SnippetScriptFile >} */ |
| 48 this._scriptFiles = new Map(); | |
| 49 | |
| 48 this._snippetStorage = new WebInspector.SnippetStorage("script", "Script sni ppet #"); | 50 this._snippetStorage = new WebInspector.SnippetStorage("script", "Script sni ppet #"); |
| 49 this._lastSnippetEvaluationIndexSetting = WebInspector.settings.createSettin g("lastSnippetEvaluationIndex", 0); | 51 this._lastSnippetEvaluationIndexSetting = WebInspector.settings.createSettin g("lastSnippetEvaluationIndex", 0); |
| 50 this._snippetScriptMapping = new WebInspector.SnippetScriptMapping(this); | 52 this._snippetScriptMapping = new WebInspector.SnippetScriptMapping(this); |
| 51 this._projectDelegate = new WebInspector.SnippetsProjectDelegate(this); | 53 this._projectDelegate = new WebInspector.SnippetsProjectDelegate(this); |
| 52 this._project = this._workspace.addProject(this._projectDelegate); | 54 this._project = this._workspace.addProject(this._projectDelegate); |
| 53 this.reset(); | 55 this.reset(); |
| 54 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event s.GlobalObjectCleared, this._debuggerReset, this); | 56 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Event s.GlobalObjectCleared, this._debuggerReset, this); |
| 55 } | 57 } |
| 56 | 58 |
| 57 WebInspector.ScriptSnippetModel.prototype = { | 59 WebInspector.ScriptSnippetModel.prototype = { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 * @return {string} | 96 * @return {string} |
| 95 */ | 97 */ |
| 96 _addScriptSnippet: function(snippet) | 98 _addScriptSnippet: function(snippet) |
| 97 { | 99 { |
| 98 var path = this._projectDelegate.addSnippet(snippet.name, new WebInspect or.SnippetContentProvider(snippet)); | 100 var path = this._projectDelegate.addSnippet(snippet.name, new WebInspect or.SnippetContentProvider(snippet)); |
| 99 var uiSourceCode = this._workspace.uiSourceCode(this._projectDelegate.id (), path); | 101 var uiSourceCode = this._workspace.uiSourceCode(this._projectDelegate.id (), path); |
| 100 if (!uiSourceCode) { | 102 if (!uiSourceCode) { |
| 101 console.assert(uiSourceCode); | 103 console.assert(uiSourceCode); |
| 102 return ""; | 104 return ""; |
| 103 } | 105 } |
| 104 var scriptFile = new WebInspector.SnippetScriptFile(this, uiSourceCode); | 106 this._scriptFiles.put(uiSourceCode, new WebInspector.SnippetScriptFile(t his, uiSourceCode)); |
| 105 uiSourceCode.setScriptFile(scriptFile); | |
| 106 this._snippetIdForUISourceCode.put(uiSourceCode, snippet.id); | 107 this._snippetIdForUISourceCode.put(uiSourceCode, snippet.id); |
| 107 uiSourceCode.setSourceMapping(this._snippetScriptMapping); | 108 uiSourceCode.setSourceMapping(this._snippetScriptMapping); |
| 108 this._uiSourceCodeForSnippetId[snippet.id] = uiSourceCode; | 109 this._uiSourceCodeForSnippetId[snippet.id] = uiSourceCode; |
| 109 return path; | 110 return path; |
| 110 }, | 111 }, |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * @param {string} path | 114 * @param {string} path |
| 114 */ | 115 */ |
| 115 deleteScriptSnippet: function(path) | 116 deleteScriptSnippet: function(path) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 if (!snippetId) | 322 if (!snippetId) |
| 322 return; | 323 return; |
| 323 var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId]; | 324 var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId]; |
| 324 | 325 |
| 325 if (!uiSourceCode || this._evaluationSourceURL(uiSourceCode) !== script. sourceURL) | 326 if (!uiSourceCode || this._evaluationSourceURL(uiSourceCode) !== script. sourceURL) |
| 326 return; | 327 return; |
| 327 | 328 |
| 328 console.assert(!this._scriptForUISourceCode.get(uiSourceCode)); | 329 console.assert(!this._scriptForUISourceCode.get(uiSourceCode)); |
| 329 this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode; | 330 this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode; |
| 330 this._scriptForUISourceCode.put(uiSourceCode, script); | 331 this._scriptForUISourceCode.put(uiSourceCode, script); |
| 331 uiSourceCode.scriptFile().setHasDivergedFromVM(false); | 332 var scriptFile = /** @type {?WebInspector.SnippetScriptFile} */ (this._s criptFiles.get(uiSourceCode)); |
| 333 scriptFile.setHasDivergedFromVM(false); | |
| 332 script.pushSourceMapping(this._snippetScriptMapping); | 334 script.pushSourceMapping(this._snippetScriptMapping); |
| 333 }, | 335 }, |
| 334 | 336 |
| 335 /** | 337 /** |
| 336 * @param {!WebInspector.UISourceCode} uiSourceCode | 338 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 337 * @return {!Array.<!Object>} | 339 * @return {!Array.<!Object>} |
| 338 */ | 340 */ |
| 339 _removeBreakpoints: function(uiSourceCode) | 341 _removeBreakpoints: function(uiSourceCode) |
| 340 { | 342 { |
| 341 var breakpointLocations = WebInspector.breakpointManager.breakpointLocat ionsForUISourceCode(uiSourceCode); | 343 var breakpointLocations = WebInspector.breakpointManager.breakpointLocat ionsForUISourceCode(uiSourceCode); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 358 }, | 360 }, |
| 359 | 361 |
| 360 /** | 362 /** |
| 361 * @param {!WebInspector.UISourceCode} uiSourceCode | 363 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 362 */ | 364 */ |
| 363 _releaseSnippetScript: function(uiSourceCode) | 365 _releaseSnippetScript: function(uiSourceCode) |
| 364 { | 366 { |
| 365 var script = this._scriptForUISourceCode.get(uiSourceCode); | 367 var script = this._scriptForUISourceCode.get(uiSourceCode); |
| 366 if (!script) | 368 if (!script) |
| 367 return null; | 369 return null; |
| 368 | 370 var scriptFile = /** @type {?WebInspector.SnippetScriptFile} */ (this._s criptFiles.get(uiSourceCode)); |
|
vsevik
2014/04/09 10:39:42
No need to cast, since you don't store anything el
| |
| 369 uiSourceCode.scriptFile().setIsDivergingFromVM(true); | 371 scriptFile.setIsDivergingFromVM(true); |
| 370 uiSourceCode.scriptFile().setHasDivergedFromVM(true); | 372 scriptFile.setHasDivergedFromVM(true); |
| 371 delete this._uiSourceCodeForScriptId[script.scriptId]; | 373 delete this._uiSourceCodeForScriptId[script.scriptId]; |
| 372 this._scriptForUISourceCode.remove(uiSourceCode); | 374 this._scriptForUISourceCode.remove(uiSourceCode); |
| 373 delete uiSourceCode._evaluationIndex; | 375 delete uiSourceCode._evaluationIndex; |
| 374 uiSourceCode.scriptFile().setIsDivergingFromVM(false); | 376 scriptFile.setIsDivergingFromVM(false); |
| 375 }, | 377 }, |
| 376 | 378 |
| 377 _debuggerReset: function() | 379 _debuggerReset: function() |
| 378 { | 380 { |
| 379 for (var snippetId in this._uiSourceCodeForSnippetId) { | 381 for (var snippetId in this._uiSourceCodeForSnippetId) { |
| 380 var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId]; | 382 var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId]; |
| 381 this._releaseSnippetScript(uiSourceCode); | 383 this._releaseSnippetScript(uiSourceCode); |
| 382 } | 384 } |
| 383 }, | 385 }, |
| 384 | 386 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 _workingCopyChanged: function() | 488 _workingCopyChanged: function() |
| 487 { | 489 { |
| 488 this._scriptSnippetModel._scriptSnippetEdited(this._uiSourceCode); | 490 this._scriptSnippetModel._scriptSnippetEdited(this._uiSourceCode); |
| 489 }, | 491 }, |
| 490 | 492 |
| 491 __proto__: WebInspector.Object.prototype | 493 __proto__: WebInspector.Object.prototype |
| 492 } | 494 } |
| 493 | 495 |
| 494 /** | 496 /** |
| 495 * @constructor | 497 * @constructor |
| 496 * @implements {WebInspector.ScriptSourceMapping} | 498 * @extends {WebInspector.SourceMappingWithScriptFile} |
| 499 * @implements {WebInspector.SourceMapping} | |
| 497 * @param {!WebInspector.ScriptSnippetModel} scriptSnippetModel | 500 * @param {!WebInspector.ScriptSnippetModel} scriptSnippetModel |
| 498 */ | 501 */ |
| 499 WebInspector.SnippetScriptMapping = function(scriptSnippetModel) | 502 WebInspector.SnippetScriptMapping = function(scriptSnippetModel) |
| 500 { | 503 { |
| 504 WebInspector.SourceMappingWithScriptFile.call(this); | |
| 501 this._scriptSnippetModel = scriptSnippetModel; | 505 this._scriptSnippetModel = scriptSnippetModel; |
| 502 } | 506 } |
| 503 | 507 |
| 504 WebInspector.SnippetScriptMapping.prototype = { | 508 WebInspector.SnippetScriptMapping.prototype = { |
| 505 /** | 509 /** |
| 506 * @param {!WebInspector.RawLocation} rawLocation | 510 * @param {!WebInspector.RawLocation} rawLocation |
| 507 * @return {?WebInspector.UILocation} | 511 * @return {?WebInspector.UILocation} |
| 508 */ | 512 */ |
| 509 rawLocationToUILocation: function(rawLocation) | 513 rawLocationToUILocation: function(rawLocation) |
| 510 { | 514 { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 540 this._scriptSnippetModel._addScript(script); | 544 this._scriptSnippetModel._addScript(script); |
| 541 }, | 545 }, |
| 542 | 546 |
| 543 /** | 547 /** |
| 544 * @return {boolean} | 548 * @return {boolean} |
| 545 */ | 549 */ |
| 546 isIdentity: function() | 550 isIdentity: function() |
| 547 { | 551 { |
| 548 return false; | 552 return false; |
| 549 }, | 553 }, |
| 554 | |
| 555 /** | |
| 556 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 557 * @return {?WebInspector.SnippetScriptFile} | |
| 558 */ | |
| 559 scriptFile: function(uiSourceCode) | |
| 560 { | |
| 561 return this._scriptSnippetModel._scriptFiles.get(uiSourceCode) || null; | |
| 562 }, | |
| 563 | |
| 564 __proto__: WebInspector.SourceMappingWithScriptFile.prototype | |
| 550 } | 565 } |
| 551 | 566 |
| 552 /** | 567 /** |
| 553 * @constructor | 568 * @constructor |
| 554 * @implements {WebInspector.ContentProvider} | 569 * @implements {WebInspector.ContentProvider} |
| 555 * @param {!WebInspector.Snippet} snippet | 570 * @param {!WebInspector.Snippet} snippet |
| 556 */ | 571 */ |
| 557 WebInspector.SnippetContentProvider = function(snippet) | 572 WebInspector.SnippetContentProvider = function(snippet) |
| 558 { | 573 { |
| 559 this._snippet = snippet; | 574 this._snippet = snippet; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 this._model.deleteScriptSnippet(path); | 708 this._model.deleteScriptSnippet(path); |
| 694 }, | 709 }, |
| 695 | 710 |
| 696 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype | 711 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype |
| 697 } | 712 } |
| 698 | 713 |
| 699 /** | 714 /** |
| 700 * @type {!WebInspector.ScriptSnippetModel} | 715 * @type {!WebInspector.ScriptSnippetModel} |
| 701 */ | 716 */ |
| 702 WebInspector.scriptSnippetModel; | 717 WebInspector.scriptSnippetModel; |
| OLD | NEW |