Index: Source/devtools/front_end/ScriptSnippetModel.js |
diff --git a/Source/devtools/front_end/ScriptSnippetModel.js b/Source/devtools/front_end/ScriptSnippetModel.js |
index deabc34a026066f36fc7f0970360e9617a54039f..4b0aba18babc0844fa074d88fe29f515170b46ec 100644 |
--- a/Source/devtools/front_end/ScriptSnippetModel.js |
+++ b/Source/devtools/front_end/ScriptSnippetModel.js |
@@ -44,7 +44,9 @@ WebInspector.ScriptSnippetModel = function(workspace) |
this._uiSourceCodeForSnippetId = {}; |
/** @type {!Map.<!WebInspector.UISourceCode, string>} */ |
this._snippetIdForUISourceCode = new Map(); |
- |
+ /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SnippetScriptFile>} */ |
+ this._scriptFiles = new Map(); |
+ |
this._snippetStorage = new WebInspector.SnippetStorage("script", "Script snippet #"); |
this._lastSnippetEvaluationIndexSetting = WebInspector.settings.createSetting("lastSnippetEvaluationIndex", 0); |
this._snippetScriptMapping = new WebInspector.SnippetScriptMapping(this); |
@@ -101,8 +103,7 @@ WebInspector.ScriptSnippetModel.prototype = { |
console.assert(uiSourceCode); |
return ""; |
} |
- var scriptFile = new WebInspector.SnippetScriptFile(this, uiSourceCode); |
- uiSourceCode.setScriptFile(scriptFile); |
+ this._scriptFiles.put(uiSourceCode, new WebInspector.SnippetScriptFile(this, uiSourceCode)); |
this._snippetIdForUISourceCode.put(uiSourceCode, snippet.id); |
uiSourceCode.setSourceMapping(this._snippetScriptMapping); |
this._uiSourceCodeForSnippetId[snippet.id] = uiSourceCode; |
@@ -328,7 +329,8 @@ WebInspector.ScriptSnippetModel.prototype = { |
console.assert(!this._scriptForUISourceCode.get(uiSourceCode)); |
this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode; |
this._scriptForUISourceCode.put(uiSourceCode, script); |
- uiSourceCode.scriptFile().setHasDivergedFromVM(false); |
+ var scriptFile = /** @type {?WebInspector.SnippetScriptFile} */ (this._scriptFiles.get(uiSourceCode)); |
+ scriptFile.setHasDivergedFromVM(false); |
script.pushSourceMapping(this._snippetScriptMapping); |
}, |
@@ -365,13 +367,13 @@ WebInspector.ScriptSnippetModel.prototype = { |
var script = this._scriptForUISourceCode.get(uiSourceCode); |
if (!script) |
return null; |
- |
- uiSourceCode.scriptFile().setIsDivergingFromVM(true); |
- uiSourceCode.scriptFile().setHasDivergedFromVM(true); |
+ var scriptFile = /** @type {?WebInspector.SnippetScriptFile} */ (this._scriptFiles.get(uiSourceCode)); |
vsevik
2014/04/09 10:39:42
No need to cast, since you don't store anything el
|
+ scriptFile.setIsDivergingFromVM(true); |
+ scriptFile.setHasDivergedFromVM(true); |
delete this._uiSourceCodeForScriptId[script.scriptId]; |
this._scriptForUISourceCode.remove(uiSourceCode); |
delete uiSourceCode._evaluationIndex; |
- uiSourceCode.scriptFile().setIsDivergingFromVM(false); |
+ scriptFile.setIsDivergingFromVM(false); |
}, |
_debuggerReset: function() |
@@ -493,11 +495,13 @@ WebInspector.SnippetScriptFile.prototype = { |
/** |
* @constructor |
- * @implements {WebInspector.ScriptSourceMapping} |
+ * @extends {WebInspector.SourceMappingWithScriptFile} |
+ * @implements {WebInspector.SourceMapping} |
* @param {!WebInspector.ScriptSnippetModel} scriptSnippetModel |
*/ |
WebInspector.SnippetScriptMapping = function(scriptSnippetModel) |
{ |
+ WebInspector.SourceMappingWithScriptFile.call(this); |
this._scriptSnippetModel = scriptSnippetModel; |
} |
@@ -547,6 +551,17 @@ WebInspector.SnippetScriptMapping.prototype = { |
{ |
return false; |
}, |
+ |
+ /** |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @return {?WebInspector.SnippetScriptFile} |
+ */ |
+ scriptFile: function(uiSourceCode) |
+ { |
+ return this._scriptSnippetModel._scriptFiles.get(uiSourceCode) || null; |
+ }, |
+ |
+ __proto__: WebInspector.SourceMappingWithScriptFile.prototype |
} |
/** |