WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber)
{
this.uiSourceCode = uiSourceCode;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
}
WebInspector.LiveLocation = function()
{
}
WebInspector.LiveLocation.prototype = {
update: function(rawLocation) { },
dispose: function() { }
}
WebInspector.SourceMapping = function()
{
}
WebInspector.SourceMapping.prototype = {
rawLocationToUILocation: function(rawLocation) { },
uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) { }
}
WebInspector.ScriptMapping = function()
{
}
WebInspector.ScriptMapping.Events = {
UISourceCodeListChanged: "ui-source-code-list-changed"
}
WebInspector.ScriptMapping.prototype = {
rawLocationToUILocation: function(rawLocation) {},
uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) {},
uiSourceCodeList: function() {}
}
WebInspector.ScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;
WebInspector.MainScriptMapping = function()
{
this._mappings = [];
this._resourceMapping = new WebInspector.ResourceScriptMapping();
this._mappings.push(this._resourceMapping);
this._compilerMapping = new WebInspector.CompilerScriptMapping();
this._mappings.push(this._compilerMapping);
this._snippetsMapping = new WebInspector.SnippetsScriptMapping();
this._mappings.push(this._snippetsMapping);
for (var i = 0; i < this._mappings.length; ++i)
this._mappings[i].addEventListener(WebInspector.ScriptMapping.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
this._mappingForScriptId = {};
this._mappingForUISourceCode = new Map();
}
WebInspector.MainScriptMapping.Events = {
UISourceCodeListChanged: "ui-source-code-list-changed"
}
WebInspector.MainScriptMapping.prototype = {
rawLocationToUILocation: function(rawLocation)
{
return this._mappingForScriptId[rawLocation.scriptId].rawLocationToUILocation(rawLocation);
},
uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
{
return this._mappingForUISourceCode.get(uiSourceCode).uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
},
uiSourceCodeList: function()
{
var result = [];
for (var i = 0; i < this._mappings.length; ++i) {
var uiSourceCodeList = this._mappings[i].uiSourceCodeList();
for (var j = 0; j < uiSourceCodeList.length; ++j)
result.push(uiSourceCodeList[j]);
}
return result;
},
addScript: function(script)
{
var mapping = this._mappingForScript(script);
this._mappingForScriptId[script.scriptId] = mapping;
mapping.addScript(script);
},
_mappingForScript: function(script)
{
if (WebInspector.experimentsSettings.snippetsSupport.isEnabled()) {
if (WebInspector.snippetsModel.snippetIdForSourceURL(script.sourceURL))
return this._snippetsMapping;
}
if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL) {
if (this._compilerMapping.loadSourceMapForScript(script))
return this._compilerMapping;
}
return this._resourceMapping;
},
_handleUISourceCodeListChanged: function(event)
{
var scriptMapping = event.target;
var removedItems = event.data["removedItems"];
var addedItems = event.data["addedItems"];
for (var i = 0; i < removedItems.length; ++i)
this._mappingForUISourceCode.remove(removedItems[i]);
for (var i = 0; i < addedItems.length; ++i)
this._mappingForUISourceCode.put(addedItems[i], scriptMapping);
this.dispatchEventToListeners(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, event.data);
},
setFormatSource: function(formatSource)
{
this._resourceMapping.setFormatSource(formatSource);
},
forceUpdateSourceMapping: function(rawLocation)
{
if (this._mappingForScriptId[rawLocation.scriptId] === this._resourceMapping)
this._resourceMapping.forceUpdateSourceMapping(rawLocation);
},
reset: function()
{
for (var i = 0; i < this._mappings.length; ++i)
this._mappings[i].reset();
this._mappingForScriptId = {};
this._mappingForUISourceCode = new Map();
}
}
WebInspector.MainScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;