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

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

Issue 299443016: DevTools: Decouple debugger model from UI entities (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge DebuggerScriptMapping into DebuggerWorkspaceBinding Created 6 years, 5 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/Script.js
diff --git a/Source/devtools/front_end/sdk/Script.js b/Source/devtools/front_end/sdk/Script.js
index a646a7ded254f3dcc49596e80ce00d95ac4950b6..5a96777c6f404006cafbd3be379db730b4366f70 100644
--- a/Source/devtools/front_end/sdk/Script.js
+++ b/Source/devtools/front_end/sdk/Script.js
@@ -50,10 +50,6 @@ WebInspector.Script = function(target, scriptId, sourceURL, startLine, startColu
this._isContentScript = isContentScript;
this.sourceMapURL = sourceMapURL;
this.hasSourceURL = hasSourceURL;
- /** @type {!Set.<!WebInspector.Script.Location>} */
- this._locations = new Set();
- /** @type {!Array.<!WebInspector.SourceMapping>} */
- this._sourceMappings = [];
}
WebInspector.Script.Events = {
@@ -72,7 +68,7 @@ WebInspector.Script.sourceURLRegex = /\n[\040\t]*\/\/[@#]\ssourceURL=\s*(\S*?)\s
WebInspector.Script._trimSourceURLComment = function(source)
{
return source.replace(WebInspector.Script.sourceURLRegex, "");
-},
+}
WebInspector.Script.prototype = {
@@ -154,8 +150,9 @@ WebInspector.Script.prototype = {
if (this.scriptId) {
// Script failed to parse.
this.target().debuggerAgent().searchInContent(this.scriptId, query, caseSensitive, isRegex, innerCallback);
- } else
+ } else {
callback([]);
+ }
},
/**
@@ -205,6 +202,16 @@ WebInspector.Script.prototype = {
},
/**
+ * @param {number} lineNumber
+ * @param {number=} columnNumber
+ * @return {!WebInspector.DebuggerModel.Location}
+ */
+ rawLocation: function(lineNumber, columnNumber)
+ {
+ return new WebInspector.DebuggerModel.Location(this.target(), this.scriptId, lineNumber, columnNumber || 0);
+ },
+
+ /**
* @return {boolean}
*/
isInlineScript: function()
@@ -251,92 +258,5 @@ WebInspector.Script.prototype = {
return regex ? regex.test(this.sourceURL) : false;
},
- /**
- * @param {number} lineNumber
- * @param {number=} columnNumber
- * @return {!WebInspector.UILocation}
- */
- rawLocationToUILocation: function(lineNumber, columnNumber)
- {
- var uiLocation;
- var rawLocation = new WebInspector.DebuggerModel.Location(this.target(), this.scriptId, lineNumber, columnNumber || 0);
- for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i)
- uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLocation);
- console.assert(uiLocation, "Script raw location can not be mapped to any ui location.");
- return /** @type {!WebInspector.UILocation} */ (uiLocation);
- },
-
- /**
- * @param {!WebInspector.SourceMapping} sourceMapping
- */
- pushSourceMapping: function(sourceMapping)
- {
- this._sourceMappings.push(sourceMapping);
- this.updateLocations();
- },
-
- /**
- * @return {!WebInspector.SourceMapping}
- */
- popSourceMapping: function()
- {
- var sourceMapping = this._sourceMappings.pop();
- this.updateLocations();
- return sourceMapping;
- },
-
- updateLocations: function()
- {
- var items = this._locations.values();
- for (var i = 0; i < items.length; ++i)
- items[i].update();
- },
-
- /**
- * @param {!WebInspector.DebuggerModel.Location} rawLocation
- * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
- * @return {!WebInspector.Script.Location}
- */
- createLiveLocation: function(rawLocation, updateDelegate)
- {
- console.assert(rawLocation.scriptId === this.scriptId);
- var location = new WebInspector.Script.Location(this, rawLocation, updateDelegate);
- this._locations.add(location);
- location.update();
- return location;
- },
-
__proto__: WebInspector.SDKObject.prototype
}
-
-/**
- * @constructor
- * @extends {WebInspector.LiveLocation}
- * @param {!WebInspector.Script} script
- * @param {!WebInspector.DebuggerModel.Location} rawLocation
- * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
- */
-WebInspector.Script.Location = function(script, rawLocation, updateDelegate)
-{
- WebInspector.LiveLocation.call(this, rawLocation, updateDelegate);
- this._script = script;
-}
-
-WebInspector.Script.Location.prototype = {
- /**
- * @return {!WebInspector.UILocation}
- */
- uiLocation: function()
- {
- var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (this.rawLocation());
- return this._script.rawLocationToUILocation(debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber);
- },
-
- dispose: function()
- {
- WebInspector.LiveLocation.prototype.dispose.call(this);
- this._script._locations.remove(this);
- },
-
- __proto__: WebInspector.LiveLocation.prototype
-}

Powered by Google App Engine
This is Rietveld 408576698