/**
* @constructor
- * @extends {WebInspector.TargetAwareObject}
+ * @extends {WebInspector.SDKObject}
* @implements {WebInspector.ContentProvider}
* @param {!WebInspector.Target} target
* @param {string} scriptId
*/
WebInspector.Script = function(target, scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
{
- WebInspector.TargetAwareObject.call(this, target);
+ WebInspector.SDKObject.call(this, target);
this.scriptId = scriptId;
this.sourceURL = sourceURL;
this.lineOffset = startLine;
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 = {
ScriptEdited: "ScriptEdited",
+ SourceMapURLAdded: "SourceMapURLAdded",
}
WebInspector.Script.snippetSourceURLPrefix = "snippets:///";
WebInspector.Script._trimSourceURLComment = function(source)
{
return source.replace(WebInspector.Script.sourceURLRegex, "");
-},
+}
WebInspector.Script.prototype = {
if (this.scriptId) {
// Script failed to parse.
this.target().debuggerAgent().searchInContent(this.scriptId, query, caseSensitive, isRegex, innerCallback);
- } else
+ } else {
callback([]);
+ }
},
/**
},
/**
- * @return {boolean}
- */
- isInlineScript: function()
- {
- var startsAtZero = !this.lineOffset && !this.columnOffset;
- return !!this.sourceURL && !startsAtZero;
- },
-
- /**
- * @return {boolean}
- */
- isAnonymousScript: function()
- {
- return !this.sourceURL;
- },
-
- /**
- * @return {boolean}
- */
- isSnippet: function()
- {
- return !!this.sourceURL && this.sourceURL.startsWith(WebInspector.Script.snippetSourceURLPrefix);
- },
-
- /**
- * @return {boolean}
- */
- isFramework: function()
- {
- if (!WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabled())
- return false;
- if (!WebInspector.settings.skipStackFramesSwitch.get())
- return false;
- var regex = WebInspector.settings.skipStackFramesPattern.asRegExp();
- return regex ? regex.test(this.sourceURL) : false;
- },
-
- /**
* @param {number} lineNumber
* @param {number=} columnNumber
- * @return {!WebInspector.UILocation}
+ * @return {!WebInspector.DebuggerModel.Location}
*/
- rawLocationToUILocation: function(lineNumber, columnNumber)
+ rawLocation: 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);
+ return new WebInspector.DebuggerModel.Location(this.target(), this.scriptId, lineNumber, columnNumber || 0);
},
/**
- * @param {!WebInspector.SourceMapping} sourceMapping
+ * @return {boolean}
*/
- pushSourceMapping: function(sourceMapping)
+ isInlineScript: function()
{
- this._sourceMappings.push(sourceMapping);
- this.updateLocations();
+ var startsAtZero = !this.lineOffset && !this.columnOffset;
+ return !!this.sourceURL && !startsAtZero;
},
/**
- * @return {!WebInspector.SourceMapping}
+ * @param {string} sourceMapURL
*/
- popSourceMapping: function()
+ addSourceMapURL: function(sourceMapURL)
{
- 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();
+ if (this.sourceMapURL)
+ return;
+ this.sourceMapURL = sourceMapURL;
+ this.dispatchEventToListeners(WebInspector.Script.Events.SourceMapURLAdded, this.sourceMapURL);
},
/**
- * @param {!WebInspector.DebuggerModel.Location} rawLocation
- * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDelegate
- * @return {!WebInspector.Script.Location}
+ * @return {boolean}
*/
- createLiveLocation: function(rawLocation, updateDelegate)
+ isAnonymousScript: function()
{
- console.assert(rawLocation.scriptId === this.scriptId);
- var location = new WebInspector.Script.Location(this, rawLocation, updateDelegate);
- this._locations.add(location);
- location.update();
- return location;
+ return !this.sourceURL;
},
- __proto__: WebInspector.TargetAwareObject.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}
+ * @return {boolean}
*/
- uiLocation: function()
- {
- var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (this.rawLocation());
- return this._script.rawLocationToUILocation(debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber);
- },
-
- dispose: function()
+ isSnippet: function()
{
- WebInspector.LiveLocation.prototype.dispose.call(this);
- this._script._locations.remove(this);
+ return !!this.sourceURL && this.sourceURL.startsWith(WebInspector.Script.snippetSourceURLPrefix);
},
- __proto__: WebInspector.LiveLocation.prototype
+ __proto__: WebInspector.SDKObject.prototype
}