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

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

Issue 464963002: DevTools: Make UISourceCode Target-agnostic (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/DebuggerWorkspaceBinding.js
diff --git a/Source/devtools/front_end/sdk/DebuggerWorkspaceBinding.js b/Source/devtools/front_end/sdk/DebuggerWorkspaceBinding.js
index 4fddd5caf33acb8098531133980f61e619d8b917..05438661a6ef042e40e08a6e6fbd0878e5eb09bb 100644
--- a/Source/devtools/front_end/sdk/DebuggerWorkspaceBinding.js
+++ b/Source/devtools/front_end/sdk/DebuggerWorkspaceBinding.js
@@ -61,6 +61,18 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {
},
/**
+ * @param {!WebInspector.Target} target
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {?WebInspector.SourceMapping} sourceMapping
+ */
+ setSourceMapping: function(target, uiSourceCode, sourceMapping)
+ {
+ var data = this._targetToData.get(target);
+ if (data)
+ data._setSourceMapping(uiSourceCode, sourceMapping);
+ },
+
+ /**
* @param {!WebInspector.Script} script
*/
updateLocations: function(script)
@@ -114,11 +126,45 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {
* @param {!WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
- * @return {!WebInspector.DebuggerModel.Location}
+ * @return {?WebInspector.DebuggerModel.Location}
*/
uiLocationToRawLocation: function(target, uiSourceCode, lineNumber, columnNumber)
{
- return /** @type {!WebInspector.DebuggerModel.Location} */ (uiSourceCode.uiLocationToRawLocation(target, lineNumber, columnNumber));
+ var targetData = this._targetToData.get(target);
+ return targetData ? /** @type {?WebInspector.DebuggerModel.Location} */ (targetData._uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber)) : null;
+ },
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {number} lineNumber
+ * @param {number} columnNumber
+ * @return {!Array.<!WebInspector.RawLocation>}
+ */
+ uiLocationToRawLocations: function(uiSourceCode, lineNumber, columnNumber)
+ {
+ var result = [];
+ var targetDatas = this._targetToData.values();
+ for (var i = 0; i < targetDatas.length; ++i) {
+ var rawLocation = targetDatas[i]._uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
+ if (rawLocation)
+ result.push(rawLocation);
+ }
+ return result;
+ },
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {number} lineNumber
+ * @return {boolean}
+ */
+ uiLineHasMapping: function(uiSourceCode, lineNumber)
+ {
+ var targetDatas = this._targetToData.values();
+ for (var i = 0; i < targetDatas.length; ++i) {
+ if (!targetDatas[i]._uiLineHasMapping(uiSourceCode, lineNumber))
+ return false;
+ }
+ return true;
},
/**
@@ -132,6 +178,17 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {
},
/**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {!WebInspector.Target} target
+ * @return {?WebInspector.ResourceScriptFile}
+ */
+ scriptFile: function(uiSourceCode, target)
+ {
+ var targetData = this._targetToData.get(target);
+ return targetData ? targetData._resourceMapping.scriptFile(uiSourceCode) : null;
+ },
+
+ /**
* @param {!WebInspector.Event} event
*/
_globalObjectCleared: function(event)
@@ -216,6 +273,8 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {
*/
WebInspector.DebuggerWorkspaceBinding.TargetData = function(target, debuggerWorkspaceBinding)
{
+ this._target = target;
+
/** @type {!StringMap.<!WebInspector.DebuggerWorkspaceBinding.ScriptInfo>} */
this.scriptDataMap = new StringMap();
@@ -233,6 +292,9 @@ WebInspector.DebuggerWorkspaceBinding.TargetData = function(target, debuggerWork
/** @type {!WebInspector.LiveEditSupport} */
this._liveEditSupport = new WebInspector.LiveEditSupport(target, workspace, debuggerWorkspaceBinding);
+ /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.SourceMapping>} */
+ this._uiSourceCodeToSourceMapping = new Map();
vsevik 2014/08/13 07:02:04 This map is never cleared.
apavlov 2014/08/13 07:20:43 Done.
+
debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this);
}
@@ -257,6 +319,46 @@ WebInspector.DebuggerWorkspaceBinding.TargetData.prototype = {
this._compilerMapping.addScript(script);
},
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {?WebInspector.SourceMapping} sourceMapping
+ */
+ _setSourceMapping: function(uiSourceCode, sourceMapping)
+ {
+ if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping)
+ return;
+
+ if (sourceMapping)
+ this._uiSourceCodeToSourceMapping.put(uiSourceCode, sourceMapping);
+ else
+ this._uiSourceCodeToSourceMapping.remove(uiSourceCode);
+
+ uiSourceCode.dispatchEventToListeners(WebInspector.UISourceCode.Events.SourceMappingChanged, {target: this._target, isIdentity: sourceMapping ? sourceMapping.isIdentity() : false});
vsevik 2014/08/13 07:02:04 SourceMappingChanged event is definitely not somet
+ },
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {number} lineNumber
+ * @param {number} columnNumber
+ * @return {?WebInspector.RawLocation}
+ */
+ _uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
+ {
+ var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode);
+ return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) : null;
+ },
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {number} lineNumber
+ * @return {boolean}
+ */
+ _uiLineHasMapping: function(uiSourceCode, lineNumber)
+ {
+ var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode);
+ return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, lineNumber) : true;
+ },
+
_dispose: function()
{
this._compilerMapping.dispose();

Powered by Google App Engine
This is Rietveld 408576698