LiveEditSupport.js [plain text]
WebInspector.LiveEditSupport = function(workspace)
{
this._workspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace, WebInspector.projectTypes.LiveEdit);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
this._debuggerReset();
}
WebInspector.LiveEditSupport.prototype = {
uiSourceCodeForLiveEdit: function(uiSourceCode)
{
var rawLocation = uiSourceCode.uiLocationToRawLocation(0, 0);
var debuggerModelLocation = (rawLocation);
var script = WebInspector.debuggerModel.scriptForId(debuggerModelLocation.scriptId);
var uiLocation = script.rawLocationToUILocation(0, 0);
if (uiLocation.uiSourceCode !== uiSourceCode)
return uiLocation.uiSourceCode;
if (this._uiSourceCodeForScriptId[script.scriptId])
return this._uiSourceCodeForScriptId[script.scriptId];
console.assert(!script.isInlineScript());
var liveEditUISourceCode = this._workspaceProvider.addUniqueFileForURL(script.sourceURL, script, true, script.isContentScript);
liveEditUISourceCode.setScriptFile(new WebInspector.LiveEditScriptFile(uiSourceCode, liveEditUISourceCode, script.scriptId));
this._uiSourceCodeForScriptId[script.scriptId] = liveEditUISourceCode;
this._scriptIdForUISourceCode.put(liveEditUISourceCode, script.scriptId);
return liveEditUISourceCode;
},
_debuggerReset: function()
{
this._uiSourceCodeForScriptId = {};
this._scriptIdForUISourceCode = new Map();
this._workspaceProvider.reset();
},
}
WebInspector.LiveEditScriptFile = function(uiSourceCode, liveEditUISourceCode, scriptId)
{
WebInspector.ScriptFile.call(this);
this._uiSourceCode = uiSourceCode;
this._liveEditUISourceCode = liveEditUISourceCode;
this._scriptId = scriptId;
this._liveEditUISourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
}
WebInspector.LiveEditScriptFile.prototype = {
_workingCopyCommitted: function(event)
{
function innerCallback(error)
{
if (error) {
WebInspector.showErrorMessage(error);
return;
}
}
var script = WebInspector.debuggerModel.scriptForId(this._scriptId);
WebInspector.debuggerModel.setScriptSource(script.scriptId, this._liveEditUISourceCode.workingCopy(), innerCallback.bind(this));
},
hasDivergedFromVM: function()
{
return true;
},
isDivergingFromVM: function()
{
return false;
},
isMergingToVM: function()
{
return false;
},
checkMapping: function()
{
},
__proto__: WebInspector.Object.prototype
}
WebInspector.liveEditSupport = null;