Diff
Modified: trunk/LayoutTests/ChangeLog (94570 => 94571)
--- trunk/LayoutTests/ChangeLog 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/LayoutTests/ChangeLog 2011-09-06 15:25:28 UTC (rev 94571)
@@ -1,3 +1,15 @@
+2011-09-05 Pavel Podivilov <[email protected]>
+
+ Web Inspector: re-implement RawSourceCode.
+ https://bugs.webkit.org/show_bug.cgi?id=67609
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/debugger/content-providers-expected.txt:
+ * inspector/debugger/content-providers.html:
+ * inspector/debugger/scripts-panel.html:
+ * inspector/debugger/source-frame-count.html:
+
2011-09-06 Csaba Osztrogonác <[email protected]>
[Qt][Mac] Unreviewed gardening.
Modified: trunk/LayoutTests/inspector/debugger/content-providers-expected.txt (94570 => 94571)
--- trunk/LayoutTests/inspector/debugger/content-providers-expected.txt 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/LayoutTests/inspector/debugger/content-providers-expected.txt 2011-09-06 15:25:28 UTC (rev 94571)
@@ -21,5 +21,3 @@
Running: testResourceContentProvider
Request resource content.
-Running: testFormattedContentProvider
-
Modified: trunk/LayoutTests/inspector/debugger/content-providers.html (94570 => 94571)
--- trunk/LayoutTests/inspector/debugger/content-providers.html 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/LayoutTests/inspector/debugger/content-providers.html 2011-09-06 15:25:28 UTC (rev 94571)
@@ -69,28 +69,6 @@
next();
}
contentProvider.requestContent(didRequestContent);
- },
-
- function testFormattedContentProvider(next)
- {
- var mapping = {};
- var formatter = {
- formatContent: function(mimeType, content, callback)
- {
- setTimeout(callback.bind(null, "<formatted> " + content, mapping), 0);
- }
- };
- var resource = { type: WebInspector.Resource.Type.Document, requestContent: function(callback) { callback("<resource content>"); } };
- var contentProvider = new WebInspector.ResourceContentProvider(resource);
- var formattedContentProvider = new WebInspector.FormattedContentProvider(contentProvider, formatter);
- function didRequestContent(mimeType, content)
- {
- InspectorTest.assertEquals("text/html", mimeType);
- InspectorTest.assertEquals("<formatted> <resource content>", content);
- InspectorTest.assertEquals(mapping, formattedContentProvider.mapping);
- next();
- }
- formattedContentProvider.requestContent(didRequestContent);
}
]);
};
Modified: trunk/LayoutTests/inspector/debugger/script-formatter.html (94570 => 94571)
--- trunk/LayoutTests/inspector/debugger/script-formatter.html 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/LayoutTests/inspector/debugger/script-formatter.html 2011-09-06 15:25:28 UTC (rev 94571)
@@ -185,10 +185,16 @@
function didEvaluate()
{
dumpConsoleMessageURLs();
- InspectorTest.addSniffer(WebInspector, "formatLinkText", InspectorTest.runAfterPendingDispatches.bind(InspectorTest, didFormatLinkText));
+ panel._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCodeReplaced);
panel._toggleFormatSource();
}
+ function uiSourceCodeReplaced(event)
+ {
+ if (event.data.uiSourceCode.url.indexOf("script-formatter.html") !== -1)
+ InspectorTest.runAfterPendingDispatches(didFormatLinkText);
+ }
+
function didFormatLinkText()
{
dumpConsoleMessageURLs();
Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (94570 => 94571)
--- trunk/LayoutTests/inspector/debugger/scripts-panel.html 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html 2011-09-06 15:25:28 UTC (rev 94571)
@@ -10,6 +10,7 @@
{
var model = new WebInspector.Object();
model.breakpointsForUISourceCode = function() { return []; };
+ model.messagesForUISourceCode = function() { return []; };
return model;
}
function addUISouceCode(model, url)
@@ -161,7 +162,7 @@
addUISouceCode(model, "foo.js");
var uiSourceCode = addUISouceCode(model, "bar.js");
- panel._uiSourceCodeReplaced({ data: { oldSourceCode: uiSourceCode, sourceCode: uiSourceCode }});
+ panel._uiSourceCodeReplaced({ data: { oldUISourceCode: uiSourceCode, uiSourceCode: uiSourceCode }});
showSourceFrame(panel, "bar.js");
next();
}
Modified: trunk/LayoutTests/inspector/debugger/source-frame-count.html (94570 => 94571)
--- trunk/LayoutTests/inspector/debugger/source-frame-count.html 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/LayoutTests/inspector/debugger/source-frame-count.html 2011-09-06 15:25:28 UTC (rev 94571)
@@ -31,8 +31,13 @@
function didReload()
{
+ InspectorTest.showScriptSource("source-frame-count.html", didShowScriptSourceAgain);
+ }
+
+ function didShowScriptSourceAgain()
+ {
InspectorTest.assertTrue(select[select.selectedIndex].text.indexOf("source-frame-count.html") !== -1);
- // There should be maximum 2 source frames: first one is the first shown, second one is the last viewed ("scripts-panel.html").
+ // There should be maximum 2 source frames: first one is the first shown, second one is the last viewed ("source-frame-count.html").
InspectorTest.assertEquals(true, sourceFrameCount <= 2, "too many source frames created after page reload");
next();
}
Modified: trunk/Source/WebCore/ChangeLog (94570 => 94571)
--- trunk/Source/WebCore/ChangeLog 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/Source/WebCore/ChangeLog 2011-09-06 15:25:28 UTC (rev 94571)
@@ -1,3 +1,53 @@
+2011-09-05 Pavel Podivilov <[email protected]>
+
+ Web Inspector: re-implement RawSourceCode.
+ https://bugs.webkit.org/show_bug.cgi?id=67609
+
+ RawSourceCode content and source mapping loading logic is too complex, re-implement it using simpler semantics:
+ 1) Initially, RawSourceCode doesn't have any content or mapping because content loading and
+ formatting operations are asynchronous, it only has scripts metadata. We don't update UI right
+ after RawSourceCode creation until full RawSourceCode representation is ready (content + mapping).
+ 2) When RawSourceCode representation is ready (e.g. resource is finished, or content is formatted
+ if in pretty-print mode) we dispatch SourceMappingUpdated event to notify the listeners that
+ source code should be shown to user and raw locations should be converted to ui locations
+ (to show breakpoins, messages, call frames etc in UI). At this moment, all source file's content
+ is ready for loading and source mapping is available.
+ 3) Later, RawSourceCode representation may change again, e.g. if pretty-print mode is toggled, or
+ blocked resource is finished etc., in that case SourceMappingUpdated is dispatched again to update
+ source code, links and decorations in UI.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/front-end/DebuggerPresentationModel.js:
+ (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
+ (WebInspector.DebuggerPresentationModel.prototype._addScript):
+ (WebInspector.DebuggerPresentationModel.prototype._sourceMappingUpdated):
+ (WebInspector.DebuggerPresentationModel.prototype._restoreBreakpoints):
+ (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage.didGetUILocation):
+ (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage):
+ (WebInspector.DebuggerPresentationModel.prototype.messagesForUISourceCode):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._uiSourceCodeReplaced):
+ (WebInspector.ScriptsPanel.prototype._sourceFrameLoaded):
+ * inspector/front-end/SourceFile.js:
+ (WebInspector.RawSourceCode):
+ (WebInspector.RawSourceCode.prototype.addScript):
+ (WebInspector.RawSourceCode.prototype.contentEdited):
+ (WebInspector.RawSourceCode.prototype._resourceFinished):
+ (WebInspector.RawSourceCode.prototype.requestContent):
+ (WebInspector.RawSourceCode.prototype.createSourceMappingIfNeeded.sourceMappingUpdated):
+ (WebInspector.RawSourceCode.prototype.createSourceMappingIfNeeded):
+ (WebInspector.RawSourceCode.prototype.forceLoadContent):
+ (WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping):
+ (WebInspector.RawSourceCode.prototype._updateSourceMapping):
+ (WebInspector.RawSourceCode.prototype._createContentProvider):
+ (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
+ (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
+ (WebInspector.RawSourceCode.prototype._createSourceMapping):
+ (WebInspector.RawSourceCode.prototype._saveSourceMapping):
+ (WebInspector.StaticContentProvider):
+ (WebInspector.StaticContentProvider.prototype.requestContent):
+
2011-09-06 Csaba Osztrogonác <[email protected]>
Unreviewed, rolling out r94564.
Modified: trunk/Source/WebCore/inspector/front-end/BreakpointManager.js (94570 => 94571)
--- trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2011-09-06 15:25:28 UTC (rev 94571)
@@ -214,7 +214,6 @@
{
function resetBreakpoint(breakpoint)
{
- delete breakpoint.uiSourceCode;
this._removeBreakpointFromDebugger(breakpoint);
}
this._forEachBreakpoint(resetBreakpoint.bind(this));
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (94570 => 94571)
--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2011-09-06 15:25:28 UTC (rev 94571)
@@ -157,27 +157,39 @@
rawSourceCode = new WebInspector.RawSourceCode(rawSourceCodeId, script, this._formatter, this._formatSource);
this._rawSourceCode[rawSourceCodeId] = rawSourceCode;
- rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this);
+ rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, this._sourceMappingUpdated, this);
+ },
- function didCreateSourceMapping()
- {
- this._breakpointManager.uiSourceCodeAdded(rawSourceCode.uiSourceCode);
- var breakpoints = this._breakpointManager.breakpointsForUISourceCode(rawSourceCode.uiSourceCode);
- for (var lineNumber in breakpoints)
- this._breakpointAdded(breakpoints[lineNumber]);
- }
- // FIXME: force source formatting if needed. This will go away once formatting
- // is fully encapsulated in RawSourceCode class.
- rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping.bind(this));
+ _sourceMappingUpdated: function(event)
+ {
+ for (var i = 0; i < this._sourceMappingListeners.length; ++i)
+ this._sourceMappingListeners[i]();
+ var rawSourceCode = event.target;
+ var oldUISourceCode = event.data.oldUISourceCode;
var uiSourceCode = rawSourceCode.uiSourceCode;
- this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCode);
+
+ if (!oldUISourceCode)
+ this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCode);
+ else {
+ var breakpoints = this._breakpointManager.breakpointsForUISourceCode(oldUISourceCode);
+ for (var lineNumber in breakpoints) {
+ var breakpoint = breakpoints[lineNumber];
+ this._breakpointRemoved(breakpoint);
+ delete breakpoint.uiSourceCode;
+ }
+ var eventData = { uiSourceCode: uiSourceCode, oldUISourceCode: oldUISourceCode };
+ this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced, eventData);
+ }
+ this._restoreBreakpoints(uiSourceCode);
},
- _uiSourceCodeReplaced: function(event)
+ _restoreBreakpoints: function(uiSourceCode)
{
- // FIXME: restore breakpoints in new source code (currently we just recreate everything when switching to pretty-print mode).
- this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced, event.data);
+ this._breakpointManager.uiSourceCodeAdded(uiSourceCode);
+ var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
+ for (var lineNumber in breakpoints)
+ this._breakpointAdded(breakpoints[lineNumber]);
},
canEditScriptSource: function(uiSourceCode)
@@ -250,6 +262,8 @@
this._formatSource = formatSource;
this._breakpointManager.reset();
+ for (var id in this._rawSourceCode)
+ this._rawSourceCode[id].removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, this._sourceMappingUpdated, this);
this._rawSourceCode = {};
var messages = this._messages;
this._messages = [];
@@ -290,7 +304,7 @@
presentationMessage.uiSourceCode = uiSourceCode;
presentationMessage.lineNumber = lineNumber;
presentationMessage.originalMessage = message;
- uiSourceCode.messages.push(presentationMessage);
+ rawSourceCode.messages.push(presentationMessage);
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage);
}
// FIXME(62725): stack trace line/column numbers are one-based.
@@ -325,6 +339,12 @@
return breakpointsList;
},
+ messagesForUISourceCode: function(uiSourceCode)
+ {
+ var rawSourceCode = uiSourceCode.rawSourceCode;
+ return rawSourceCode.messages;
+ },
+
setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled)
{
this._breakpointManager.setBreakpoint(uiSourceCode, lineNumber, condition, enabled);
@@ -377,7 +397,7 @@
var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId);
if (script)
rawSourceCode = this._rawSourceCodeForScript(script.sourceURL, script.scriptId);
- this._presentationCallFrames.push(new WebInspector.PresenationCallFrame(callFrame, i, this, rawSourceCode));
+ this._presentationCallFrames.push(new WebInspector.PresentationCallFrame(callFrame, i, this, rawSourceCode));
}
var details = WebInspector.debuggerModel.debuggerPausedDetails;
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerPaused, { callFrames: this._presentationCallFrames, details: details });
@@ -446,16 +466,16 @@
/**
* @constructor
*/
-WebInspector.PresenationCallFrame = function(callFrame, index, model, uiSourceCode)
+WebInspector.PresentationCallFrame = function(callFrame, index, model, rawSourceCode)
{
this._callFrame = callFrame;
this._index = index;
this._model = model;
- this._uiSourceCode = uiSourceCode;
+ this._rawSourceCode = rawSourceCode;
this._script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId);
}
-WebInspector.PresenationCallFrame.prototype = {
+WebInspector.PresentationCallFrame.prototype = {
get functionName()
{
return this._callFrame.functionName;
@@ -473,8 +493,8 @@
get url()
{
- if (this._uiSourceCode)
- return this._uiSourceCode.url;
+ if (this._rawSourceCode && this._rawSourceCode.uiSourceCode)
+ return this._rawSourceCode.uiSourceCode.url;
},
get scopeChain()
@@ -494,8 +514,8 @@
select: function()
{
- if (this._uiSourceCode)
- this._uiSourceCode.forceLoadContent(this._script);
+ if (this._rawSourceCode)
+ this._rawSourceCode.forceUpdateSourceMapping();
},
evaluate: function(code, objectGroup, includeCommandLineAPI, returnByValue, callback)
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (94570 => 94571)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-09-06 15:25:28 UTC (rev 94571)
@@ -671,11 +671,13 @@
_uiSourceCodeReplaced: function(event)
{
- var oldUISourceCode = event.data.oldSourceCode;
- var uiSourceCode = event.data.sourceCode;
+ var oldUISourceCode = event.data.oldUISourceCode;
+ var uiSourceCode = event.data.uiSourceCode;
// Re-bind file select option from old source file to new one.
var option = oldUISourceCode._option;
+ if (!option)
+ return;
delete oldUISourceCode._option;
option._uiSourceCode = uiSourceCode;
uiSourceCode._option = option;
@@ -691,7 +693,7 @@
var sourceFrame = event.target;
var uiSourceCode = sourceFrame._uiSourceCode;
- var messages = uiSourceCode.messages;
+ var messages = this._presentationModel.messagesForUISourceCode(uiSourceCode);
for (var i = 0; i < messages.length; ++i) {
var message = messages[i];
sourceFrame.addMessageToSource(message.lineNumber, message.originalMessage);
Modified: trunk/Source/WebCore/inspector/front-end/SourceFile.js (94570 => 94571)
--- trunk/Source/WebCore/inspector/front-end/SourceFile.js 2011-09-06 15:23:43 UTC (rev 94570)
+++ trunk/Source/WebCore/inspector/front-end/SourceFile.js 2011-09-06 15:25:28 UTC (rev 94571)
@@ -43,25 +43,29 @@
if (script.sourceURL)
this._resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
- this._requestContentCallbacks = [];
this.id = id;
this.url = ""
this.isContentScript = script.isContentScript;
this.messages = [];
- if (this._hasPendingResource())
- this._resource.addEventListener("finished", this._reload.bind(this));
+ this._useTemporaryContent = this._resource && !this._resource.finished;
+ this._hasNewScripts = true;
+ if (!this._useTemporaryContent)
+ this._updateSourceMapping();
+ else if (this._resource)
+ this._resource.addEventListener("finished", this._resourceFinished.bind(this));
}
WebInspector.RawSourceCode.Events = {
- UISourceCodeReplaced: "ui-source-code-replaced"
+ SourceMappingUpdated: "source-mapping-updated"
}
WebInspector.RawSourceCode.prototype = {
addScript: function(script)
{
this._scripts.push(script);
+ this._hasNewScripts = true;
},
get uiSourceCode()
@@ -78,9 +82,15 @@
contentEdited: function()
{
- this._reload();
+ this._updateSourceMapping();
},
+ _resourceFinished: function()
+ {
+ this._useTemporaryContent = false;
+ this._updateSourceMapping();
+ },
+
rawLocationToUILocation: function(rawLocation)
{
var location = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation;
@@ -112,126 +122,93 @@
requestContent: function(callback)
{
- if (this._contentLoaded) {
- callback(this._mimeType, this._content);
- return;
- }
-
- this._requestContentCallbacks.push(callback);
- this._requestContent();
+ // FIXME: remove this.
+ this._uiSourceCode.requestContent(callback);
},
createSourceMappingIfNeeded: function(callback)
{
- if (!this._formatted) {
+ // FIXME: remove createSourceMappingIfNeeded, client should listen to SourceMappingUpdated event instead.
+ if (this._uiSourceCode && !this._updatingSourceMapping) {
callback();
return;
}
- function didRequestContent()
+ function sourceMappingUpdated()
{
+ this.removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this);
callback();
}
- // Force content formatting to obtain the mapping.
- this.requestContent(didRequestContent.bind(this));
+ this.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, sourceMappingUpdated, this);
},
- _setContentProvider: function(contentProvider)
+ forceUpdateSourceMapping: function(script)
{
- if (this._formatted)
- this._contentProvider = new WebInspector.FormattedContentProvider(contentProvider, this._formatter);
- else
- this._contentProvider = contentProvider;
+ if (!this._useTemporaryContent || !this._hasNewScripts)
+ return;
+ this._hasNewScripts = false;
+ this._updateSourceMapping();
},
- forceLoadContent: function(script)
+ _updateSourceMapping: function()
{
- if (!this._hasPendingResource())
+ if (this._updatingSourceMapping) {
+ this._updateNeeded = true;
return;
+ }
+ this._updatingSourceMapping = true;
+ this._updateNeeded = false;
- if (!this._concatenatedScripts)
- this._concatenatedScripts = {};
- if (this._concatenatedScripts[script.scriptId])
- return;
- for (var i = 0; i < this._scripts.length; ++i)
- this._concatenatedScripts[this._scripts[i].scriptId] = true;
+ var originalContentProvider = this._createContentProvider();
+ this._createSourceMapping(originalContentProvider, didCreateSourceMapping.bind(this));
- this._reload();
-
- if (!this._contentRequested) {
- this._contentRequested = true;
- this._loadAndConcatenateScriptsContent();
+ function didCreateSourceMapping(contentProvider, mapping)
+ {
+ this._updatingSourceMapping = false;
+ if (!this._updateNeeded)
+ this._saveSourceMapping(contentProvider, mapping);
+ else
+ this._updateSourceMapping();
}
},
- _reload: function()
+ _createContentProvider: function()
{
- if (this._contentLoaded) {
- this._contentLoaded = false;
- // FIXME: create another UISourceCode instance here, UISourceCode should be immutable.
- this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, { oldSourceCode: this, sourceCode: this });
- } else if (this._contentRequested)
- this._reloadContent = true;
- else if (this._requestContentCallbacks.length)
- this._requestContent();
- },
-
- _requestContent: function()
- {
- if (this._contentRequested)
- return;
-
- this._contentRequested = true;
if (this._resource && this._resource.finished)
- this._loadResourceContent(this._resource);
- else if (!this._resource)
- this._loadScriptContent();
- else if (this._concatenatedScripts)
- this._loadAndConcatenateScriptsContent();
- else
- this._contentRequested = false;
- },
-
- _loadResourceContent: function(resource)
- {
- this._setContentProvider(new WebInspector.ResourceContentProvider(resource));
- this._contentProvider.requestContent(this._didRequestContent.bind(this));
- },
-
- _loadScriptContent: function()
- {
- this._setContentProvider(new WebInspector.ScriptContentProvider(this._scripts[0]));
- this._contentProvider.requestContent(this._didRequestContent.bind(this));
- },
-
- _loadAndConcatenateScriptsContent: function()
- {
+ return new WebInspector.ResourceContentProvider(this._resource);
if (this._scripts.length === 1 && !this._scripts[0].lineOffset && !this._scripts[0].columnOffset)
- this._setContentProvider(new WebInspector.ScriptContentProvider(this._scripts[0]));
- else
- this._setContentProvider(new WebInspector.ConcatenatedScriptsContentProvider(this._scripts));
- this._contentProvider.requestContent(this._didRequestContent.bind(this));
+ return new WebInspector.ScriptContentProvider(this._scripts[0]);
+ return new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
},
- _didRequestContent: function(mimeType, content)
+ _createSourceMapping: function(originalContentProvider, callback)
{
- this._contentLoaded = true;
- this._contentRequested = false;
- this._mimeType = mimeType;
- this._content = content;
- this._mapping = this._contentProvider.mapping;
+ if (!this._formatted) {
+ setTimeout(callback.bind(null, originalContentProvider, null), 0);
+ return;
+ }
- for (var i = 0; i < this._requestContentCallbacks.length; ++i)
- this._requestContentCallbacks[i](mimeType, content);
- this._requestContentCallbacks = [];
-
- if (this._reloadContent)
- this._reload();
+ function didRequestContent(mimeType, content)
+ {
+ function didFormatContent(formattedContent, mapping)
+ {
+ var contentProvider = new WebInspector.StaticContentProvider(mimeType, formattedContent)
+ callback(contentProvider, mapping);
+ }
+ this._formatter.formatContent(mimeType, content, didFormatContent.bind(this));
+ }
+ originalContentProvider.requestContent(didRequestContent.bind(this));
},
- _hasPendingResource: function()
+ _saveSourceMapping: function(contentProvider, mapping)
{
- return this._resource && !this._resource.finished;
+ var oldUISourceCode;
+ if (this._uiSourceCode)
+ oldUISourceCode = this;
+ var uiSourceCodeId = (this._formatted ? "deobfuscated:" : "") + (this._scripts[0].sourceURL || this._scripts[0].scriptId);
+ this._uiSourceCode = new WebInspector.UISourceCode(uiSourceCodeId, this.url, this.isContentScript, this, contentProvider);
+ this._mapping = mapping;
+ this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.SourceMappingUpdated, { oldUISourceCode: oldUISourceCode });
}
}
@@ -364,26 +341,17 @@
WebInspector.ResourceContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
-WebInspector.FormattedContentProvider = function(contentProvider, formatter)
+WebInspector.StaticContentProvider = function(mimeType, content)
{
- this._contentProvider = contentProvider;
- this._formatter = formatter;
+ this._mimeType = mimeType;
+ this._content = content;
};
-WebInspector.FormattedContentProvider.prototype = {
+WebInspector.StaticContentProvider.prototype = {
requestContent: function(callback)
{
- function didRequestContent(mimeType, content)
- {
- function didFormatContent(formattedContent, mapping)
- {
- this.mapping = mapping;
- callback(mimeType, formattedContent);
- }
- this._formatter.formatContent(mimeType, content, didFormatContent.bind(this));
- }
- this._contentProvider.requestContent(didRequestContent.bind(this));
+ callback(this._mimeType, this._content);
}
}
-WebInspector.FormattedContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
+WebInspector.StaticContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;