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

Unified Diff: Source/devtools/front_end/sdk/ResourceScriptMapping.js

Issue 464963002: DevTools: Make UISourceCode Target-agnostic (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/sdk/ResourceScriptMapping.js
diff --git a/Source/devtools/front_end/sdk/ResourceScriptMapping.js b/Source/devtools/front_end/sdk/ResourceScriptMapping.js
index 675144f7a74c6a51b7fd1926dd61920ce4b4bf19..c525e4bf03c3c931f35207bd4440e9d3b784df3c 100644
--- a/Source/devtools/front_end/sdk/ResourceScriptMapping.js
+++ b/Source/devtools/front_end/sdk/ResourceScriptMapping.js
@@ -40,10 +40,14 @@ WebInspector.ResourceScriptMapping = function(debuggerModel, workspace, debugger
this._target = debuggerModel.target();
this._debuggerModel = debuggerModel;
this._workspace = workspace;
- this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
+ this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
+ this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
this._debuggerWorkspaceBinding = debuggerWorkspaceBinding;
this._boundURLs = new StringSet();
+ /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.ResourceScriptFile>} */
+ this._uiSourceCodeToScriptFile = new Map();
+
debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
}
@@ -59,7 +63,7 @@ WebInspector.ResourceScriptMapping.prototype = {
var uiSourceCode = this._workspaceUISourceCodeForScript(script);
if (!uiSourceCode)
return null;
- var scriptFile = uiSourceCode.scriptFileForTarget(this._target);
+ var scriptFile = this.scriptFile(uiSourceCode);
if (scriptFile && ((scriptFile.hasDivergedFromVM() && !scriptFile.isMergingToVM()) || scriptFile.isDivergingFromVM()))
return null;
return uiSourceCode.uiLocation(debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0);
@@ -112,13 +116,37 @@ WebInspector.ResourceScriptMapping.prototype = {
return true;
},
- _uiSourceCodeAddedToWorkspace: function(event)
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @return {?WebInspector.ResourceScriptFile}
+ */
+ scriptFile: function(uiSourceCode)
+ {
+ return this._uiSourceCodeToScriptFile.get(uiSourceCode) || null;
+ },
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {?WebInspector.ResourceScriptFile} scriptFile
+ */
+ _setScriptFile: function(uiSourceCode, scriptFile)
+ {
+ if (scriptFile)
+ this._uiSourceCodeToScriptFile.put(uiSourceCode, scriptFile);
+ else
+ this._uiSourceCodeToScriptFile.remove(uiSourceCode);
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _uiSourceCodeAdded: function(event)
{
var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
- if (uiSourceCode.project().isServiceProject())
- return;
if (!uiSourceCode.url)
return;
+ if (uiSourceCode.project().isServiceProject())
+ return;
var scripts = this._scriptsForUISourceCode(uiSourceCode);
if (!scripts.length)
@@ -128,6 +156,20 @@ WebInspector.ResourceScriptMapping.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _uiSourceCodeRemoved: function(event)
+ {
+ var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
+ if (!uiSourceCode.url)
+ return;
+ if (uiSourceCode.project().isServiceProject())
+ return;
+
+ this._unbindUISourceCode(uiSourceCode);
+ },
+
+ /**
* @param {!WebInspector.UISourceCode} uiSourceCode
*/
_hasMergedToVM: function(uiSourceCode)
@@ -181,10 +223,10 @@ WebInspector.ResourceScriptMapping.prototype = {
{
console.assert(scripts.length);
var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode, scripts);
- uiSourceCode.setScriptFileForTarget(this._target, scriptFile);
+ this._setScriptFile(uiSourceCode, scriptFile);
for (var i = 0; i < scripts.length; ++i)
this._debuggerWorkspaceBinding.updateLocations(scripts[i]);
- uiSourceCode.setSourceMappingForTarget(this._target, this);
+ this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCode, this);
this._boundURLs.add(uiSourceCode.url);
},
@@ -193,12 +235,12 @@ WebInspector.ResourceScriptMapping.prototype = {
*/
_unbindUISourceCode: function(uiSourceCode)
{
- var scriptFile = /** @type {!WebInspector.ResourceScriptFile} */ (uiSourceCode.scriptFileForTarget(this._target));
+ var scriptFile = this.scriptFile(uiSourceCode);
if (scriptFile) {
scriptFile.dispose();
- uiSourceCode.setScriptFileForTarget(this._target, null);
+ this._setScriptFile(uiSourceCode, null);
}
- uiSourceCode.setSourceMappingForTarget(this._target, null);
+ this._debuggerWorkspaceBinding.setSourceMapping(this._target, uiSourceCode, null);
},
_debuggerReset: function()
@@ -217,7 +259,8 @@ WebInspector.ResourceScriptMapping.prototype = {
dispose: function()
{
this._debuggerReset();
- this._workspace.removeEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
+ this._workspace.removeEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
+ this._workspace.removeEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
}
}
« no previous file with comments | « Source/devtools/front_end/sdk/LiveEditSupport.js ('k') | Source/devtools/front_end/sdk/ScriptSnippetModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698