https://bugs.webkit.org/show_bug.cgi?id=83922
Reviewed by Yury Semikhatsky.
Source/WebCore:
We have two different types of requestContent methods: one on the source mapping level and one on the resource level.
There are also adapters between the two. I'm aligning it all to a single requestContent method declared in ContentProvider.
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/BreakpointsSidebarPane.js:
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint.didRequestContent):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint):
* inspector/front-end/ContentProvider.js: Added.
(WebInspector.ContentProvider):
(WebInspector.ContentProvider.prototype.contentURL):
(WebInspector.ContentProvider.prototype.requestContent):
(WebInspector.ContentProvider.prototype.searchInContent):
(WebInspector.ContentProvider.SearchMatch):
* inspector/front-end/ContentProviders.js:
(WebInspector.ScriptContentProvider.prototype.contentURL):
(WebInspector.ScriptContentProvider.prototype.requestContent):
(WebInspector.ConcatenatedScriptsContentProvider.prototype.contentURL):
(WebInspector.ConcatenatedScriptsContentProvider.prototype.requestContent):
(WebInspector.CompilerSourceMappingContentProvider.prototype.contentURL):
(WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent):
(WebInspector.StaticContentProvider.prototype.contentURL):
(WebInspector.StaticContentProvider.prototype.requestContent):
* inspector/front-end/DebuggerPresentationModel.js:
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._getResourceContent):
* inspector/front-end/JavaScriptSourceFrame.js:
(WebInspector.JavaScriptSourceFrame.prototype.requestContent):
* inspector/front-end/NetworkItemView.js:
(WebInspector.RequestContentView.prototype._ensureInnerViewShown.callback):
(WebInspector.RequestContentView.prototype._ensureInnerViewShown):
* inspector/front-end/NetworkRequest.js:
(WebInspector.NetworkRequest.prototype.contentURL):
(WebInspector.NetworkRequest.prototype.requestContent):
(WebInspector.NetworkRequest.prototype.searchInContent):
(WebInspector.NetworkRequest.prototype.populateImageSource):
(WebInspector.NetworkRequest.prototype._innerRequestContent.onResourceContent):
(WebInspector.NetworkRequest.prototype._innerRequestContent):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype._createContentProvider):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype.contentURL):
(WebInspector.Resource.prototype.requestContent):
(WebInspector.Resource.prototype._innerRequestContent.callback):
(WebInspector.Resource.prototype._innerRequestContent):
(WebInspector.ResourceRevision.prototype.contentURL):
(WebInspector.ResourceRevision.prototype.requestContent.callbackWrapper):
(WebInspector.ResourceRevision.prototype.requestContent):
(WebInspector.ResourceRevision.prototype.searchInContent):
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceSourceFrame.prototype.requestContent):
(WebInspector.ResourceSourceFrame.prototype._contentChanged):
(WebInspector.ResourceRevisionSourceFrame.prototype.requestContent):
* inspector/front-end/ScriptFormatter.js:
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.requestVisibleScriptOutline):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.setContent):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.requestContent):
(WebInspector.UISourceCode.prototype._didRequestContent):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
LayoutTests:
* http/tests/inspector/compiler-script-mapping.html:
* inspector/debugger/content-providers-expected.txt:
* inspector/debugger/content-providers.html:
* inspector/debugger/raw-source-code.html:
* inspector/debugger/ui-source-code.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114241
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-13 Pavel Feldman <pfeldman@chromium.org>
+
+ Web Inspector: extract ContentProvider into its own file, make NetworkRequest, Resoruce and others implement it.
+ https://bugs.webkit.org/show_bug.cgi?id=83922
+
+ Reviewed by Yury Semikhatsky.
+
+ * http/tests/inspector/compiler-script-mapping.html:
+ * inspector/debugger/content-providers-expected.txt:
+ * inspector/debugger/content-providers.html:
+ * inspector/debugger/raw-source-code.html:
+ * inspector/debugger/ui-source-code.html:
+
2012-04-16 Takashi Toyoshima <toyoshim@chromium.org>
Unreviewed, fix a wrong expected.txt
uiSourceCodeList[0].requestContent(didRequestContent1);
- function didRequestContent1(mimeType, content)
+ function didRequestContent1(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals(0, content.indexOf("window.addEventListener"));
uiSourceCodeList[1].requestContent(didRequestContent2);
}
- function didRequestContent2(mimeType, content)
+ function didRequestContent2(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals(0, content.indexOf("function ClickHandler()"));
next();
uiSourceCodeList[0].requestContent(didRequestContent);
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("<source content>", content);
next();
}
</script>
-Running: testResourceContentProvider
-Request resource content.
-
var mockScriptSource = "function foo() { return 0; }";
var mockScript = createMockScript("foo.js", mockScriptSource);
var contentProvider = new WebInspector.ScriptContentProvider(mockScript);
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("text/javascript", mimeType);
InspectorTest.assertEquals(mockScriptSource, content);
scripts.push(createMockScript("3", "function bar() { return 0; }", [1, 70, 1, 98]));
scripts.push(createMockScript("4", "this should not appear in displayed content", [0, 20, 0, 63]));
var contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(scripts);
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("text/html", mimeType);
InspectorTest.addResult(content);
next();
}
contentProvider.requestContent(didRequestContent);
- },
-
- function testResourceContentProvider(next)
- {
- var mockResourceContent = "<script>var x = 0;</" + "script>";
- var mockResource = {
- requestContent: function(callback)
- {
- InspectorTest.addResult("Request resource content.");
- callback(mockResourceContent);
- }
- };
- var contentProvider = new WebInspector.ResourceContentProvider(mockResource);
- function didRequestContent(mimeType, content)
- {
- InspectorTest.assertEquals("text/html", mimeType);
- InspectorTest.assertEquals(mockResourceContent, content);
- next();
- }
- contentProvider.requestContent(didRequestContent);
}
]);
};
WebInspector.resourceTreeModel._addFrame(new WebInspector.ResourceTreeFrame(WebInspector.resourceTreeModel, null, {id: "frame-id"}));
var request = new WebInspector.NetworkRequest(requestId, url, "http://fake.url", "frame-id", "loader-id");
request.type = type === "document" ? WebInspector.resourceTypes.Document : WebInspector.resourceTypes.Script;
+ request.mimeType = type === "document" ? "text/html" : "text/javascript";
WebInspector.networkManager._dispatcher._startNetworkRequest(request);
if (finished)
InspectorTest.checkRawLocation(script, 10, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 10, 0));
uiSourceCode.requestContent(didRequestContent);
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("text/javascript", mimeType);
InspectorTest.assertEquals("<script source>", content);
uiSourceCode.requestContent(didRequestContent);
}
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
- InspectorTest.assertEquals(mimeType, "text/html");
+ InspectorTest.assertEquals("text/html", mimeType);
InspectorTest.assertEquals("<resource content>", content);
rawSourceCode.addScript(script2);
InspectorTest.assertEquals(false, uiSourceCode.isContentScript);
uiSourceCode.requestContent(didRequestContent);
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
- InspectorTest.assertEquals(mimeType, "text/html");
+ InspectorTest.assertEquals("text/html", mimeType);
InspectorTest.assertEquals("<resource content>", content);
rawSourceCode.addScript(script2);
uiSourceCode.requestContent(didRequestContentOneScript);
}
- function didRequestContentOneScript(mimeType, content)
+ function didRequestContentOneScript(content, contentEncoded, mimeType)
{
- InspectorTest.assertEquals(mimeType, "text/html");
+ InspectorTest.assertEquals("text/html", mimeType);
InspectorTest.assertEquals(" <script><script source 1></" + "script>", content);
rawSourceCode.forceUpdateSourceMapping();
uiSourceCode.requestContent(didRequestContentTwoScripts);
}
- function didRequestContentTwoScripts(mimeType, content)
+ function didRequestContentTwoScripts(content, contentEncoded, mimeType)
{
- InspectorTest.assertEquals(mimeType, "text/html");
+ InspectorTest.assertEquals("text/html", mimeType);
InspectorTest.assertEquals(" <script><script source 1></" + "script> <script><script source 2></" + "script>", content);
rawSourceCode.forceUpdateSourceMapping();
uiSourceCode.requestContent(didRequestContentRequest);
}
- function didRequestContentRequest(mimeType, content)
+ function didRequestContentRequest(content, contentEncoded, mimeType)
{
- InspectorTest.assertEquals(mimeType, "text/html");
+ InspectorTest.assertEquals("text/html", mimeType);
InspectorTest.assertEquals("<resource content>", content);
rawSourceCode.addScript(script3);
InspectorTest.checkRawLocation(script, 2, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 2, 0));
uiSourceCode.requestContent(didRequestContent);
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("text/javascript", mimeType);
InspectorTest.assertEquals("<resource content>", content);
uiSourceCode.requestContent(didRequestFormattedContent);
}
- function didRequestFormattedContent(mimeType, content)
+ function didRequestFormattedContent(content, contentEncoded, mimeType)
{
- InspectorTest.assertEquals(mimeType, "text/javascript");
+ InspectorTest.assertEquals("text/javascript", mimeType);
InspectorTest.assertEquals("<formatted> <resource content>", content);
waitForUISourceCodeChangedEvent(rawSourceCode, requestNotFormattedContent);
uiSourceCode.requestContent(didRequestNotFormattedContent);
}
- function didRequestNotFormattedContent(mimeType, content)
+ function didRequestNotFormattedContent(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("text/javascript", mimeType);
InspectorTest.assertEquals("<resource content>", content);
requestContent: function(callback)
{
InspectorTest.addResult("Content is requested from SourceCodeProvider.");
- setTimeout(callback.bind(null, "text/javascript", "var x = 0;"), 0);
+ setTimeout(callback.bind(null, "var x = 0;", false, "text/javascript"), 0);
}
};
function testUISourceCode(next)
{
var uiSourceCode = new WebInspector.UISourceCode("id", "url", contentProvider);
- function didRequestContent(callNumber, mimeType, content)
+ function didRequestContent(callNumber, content, contentEncoded, mimeType)
{
InspectorTest.addResult("Callback " + callNumber + " is invoked.");
InspectorTest.assertEquals("text/javascript", mimeType);
if (callNumber === 3) {
// Check that sourceCodeProvider.requestContent won't be called anymore.
- uiSourceCode.requestContent(function(mimeType, content)
+ uiSourceCode.requestContent(function(content, contentEncoded, mimeType)
{
InspectorTest.assertEquals("text/javascript", mimeType);
InspectorTest.assertEquals("var x = 0;", content);
+2012-04-13 Pavel Feldman <pfeldman@chromium.org>
+
+ Web Inspector: extract ContentProvider into its own file, make NetworkRequest, Resoruce and others implement it.
+ https://bugs.webkit.org/show_bug.cgi?id=83922
+
+ Reviewed by Yury Semikhatsky.
+
+ We have two different types of requestContent methods: one on the source mapping level and one on the resource level.
+ There are also adapters between the two. I'm aligning it all to a single requestContent method declared in ContentProvider.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/compile-front-end.py:
+ * inspector/front-end/BreakpointsSidebarPane.js:
+ (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint.didRequestContent):
+ (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint):
+ * inspector/front-end/ContentProvider.js: Added.
+ (WebInspector.ContentProvider):
+ (WebInspector.ContentProvider.prototype.contentURL):
+ (WebInspector.ContentProvider.prototype.requestContent):
+ (WebInspector.ContentProvider.prototype.searchInContent):
+ (WebInspector.ContentProvider.SearchMatch):
+ * inspector/front-end/ContentProviders.js:
+ (WebInspector.ScriptContentProvider.prototype.contentURL):
+ (WebInspector.ScriptContentProvider.prototype.requestContent):
+ (WebInspector.ConcatenatedScriptsContentProvider.prototype.contentURL):
+ (WebInspector.ConcatenatedScriptsContentProvider.prototype.requestContent):
+ (WebInspector.CompilerSourceMappingContentProvider.prototype.contentURL):
+ (WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent):
+ (WebInspector.StaticContentProvider.prototype.contentURL):
+ (WebInspector.StaticContentProvider.prototype.requestContent):
+ * inspector/front-end/DebuggerPresentationModel.js:
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer.prototype._getResourceContent):
+ * inspector/front-end/JavaScriptSourceFrame.js:
+ (WebInspector.JavaScriptSourceFrame.prototype.requestContent):
+ * inspector/front-end/NetworkItemView.js:
+ (WebInspector.RequestContentView.prototype._ensureInnerViewShown.callback):
+ (WebInspector.RequestContentView.prototype._ensureInnerViewShown):
+ * inspector/front-end/NetworkRequest.js:
+ (WebInspector.NetworkRequest.prototype.contentURL):
+ (WebInspector.NetworkRequest.prototype.requestContent):
+ (WebInspector.NetworkRequest.prototype.searchInContent):
+ (WebInspector.NetworkRequest.prototype.populateImageSource):
+ (WebInspector.NetworkRequest.prototype._innerRequestContent.onResourceContent):
+ (WebInspector.NetworkRequest.prototype._innerRequestContent):
+ * inspector/front-end/RawSourceCode.js:
+ (WebInspector.RawSourceCode.prototype._createContentProvider):
+ (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
+ (WebInspector.RawSourceCode.prototype._createSourceMapping):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource.prototype.contentURL):
+ (WebInspector.Resource.prototype.requestContent):
+ (WebInspector.Resource.prototype._innerRequestContent.callback):
+ (WebInspector.Resource.prototype._innerRequestContent):
+ (WebInspector.ResourceRevision.prototype.contentURL):
+ (WebInspector.ResourceRevision.prototype.requestContent.callbackWrapper):
+ (WebInspector.ResourceRevision.prototype.requestContent):
+ (WebInspector.ResourceRevision.prototype.searchInContent):
+ * inspector/front-end/ResourceView.js:
+ (WebInspector.ResourceSourceFrame.prototype.requestContent):
+ (WebInspector.ResourceSourceFrame.prototype._contentChanged):
+ (WebInspector.ResourceRevisionSourceFrame.prototype.requestContent):
+ * inspector/front-end/ScriptFormatter.js:
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.requestVisibleScriptOutline):
+ * inspector/front-end/SourceFrame.js:
+ (WebInspector.SourceFrame.prototype.setContent):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode):
+ (WebInspector.UISourceCode.prototype.requestContent):
+ (WebInspector.UISourceCode.prototype._didRequestContent):
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+
2012-04-16 Jason Liu <jason.liu@torchmobile.com.cn>
[BlackBerry] Missing readyState 2 when a XMLHttpRequest calls xmlhttp.open("HEAD","notExist.html",true).
'inspector/front-end/ConsoleModel.js',
'inspector/front-end/ConsolePanel.js',
'inspector/front-end/ConsoleView.js',
+ 'inspector/front-end/ContentProvider.js',
'inspector/front-end/ContentProviders.js',
'inspector/front-end/ContextMenu.js',
'inspector/front-end/CookieItemsView.js',
>
</File>
<File
+ RelativePath="..\inspector\front-end\ContentProvider.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\ContentProviders.js"
>
</File>
"Color.js",
"CompilerScriptMapping.js",
"ConsoleModel.js",
+ "ContentProvider.js",
"ContentProviders.js",
"CookieParser.js",
"CSSCompletions.js",
var snippetElement = document.createElement("div");
snippetElement.className = "source-text monospace";
element.appendChild(snippetElement);
- function didRequestContent(mimeType, content)
+
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function didRequestContent(content, contentEncoded, mimeType)
{
var lineEndings = content.lineEndings();
if (breakpoint.lineNumber < lineEndings.length)
--- /dev/null
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @interface
+ */
+WebInspector.ContentProvider = function() { }
+
+WebInspector.ContentProvider.prototype = {
+ /**
+ * @return {?string}
+ */
+ contentURL: function() { },
+
+ /**
+ * @param {function(?string,boolean,string)} callback
+ */
+ requestContent: function(callback) { },
+
+ /**
+ * @param {string} query
+ * @param {boolean} caseSensitive
+ * @param {boolean} isRegex
+ * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
+ */
+ searchInContent: function(query, caseSensitive, isRegex, callback) { }
+}
+
+/**
+ * @constructor
+ * @param {number} lineNumber
+ * @param {string} lineContent
+ */
+WebInspector.ContentProvider.SearchMatch = function(lineNumber, lineContent) {
+ this.lineNumber = lineNumber;
+ this.lineContent = lineContent;
+}
/**
* @constructor
* @implements {WebInspector.ContentProvider}
+ * @param {WebInspector.Script} script
*/
WebInspector.ScriptContentProvider = function(script)
{
WebInspector.ScriptContentProvider.prototype = {
/**
- * @param {function(string,string)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return this._script.sourceURL;
+ },
+
+ /**
+ * @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)
{
function didRequestSource(source)
{
- callback(this._mimeType, source);
+ callback(source, false, this._mimeType);
}
this._script.requestSource(didRequestSource.bind(this));
},
/**
* @constructor
* @implements {WebInspector.ContentProvider}
+ * @param {Array.<WebInspector.Script>} scripts
*/
WebInspector.ConcatenatedScriptsContentProvider = function(scripts)
{
},
/**
- * @param {function(string,string)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return null;
+ },
+
+ /**
+ * @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)
{
{
sources.push(source);
if (sources.length == scripts.length)
- callback(this._mimeType, this._concatenateScriptsContent(scripts, sources));
+ callback(this._concatenateScriptsContent(scripts, sources), false, this._mimeType);
}
for (var i = 0; i < scripts.length; ++i)
scripts[i].requestSource(didRequestSource.bind(this));
/**
* @constructor
* @implements {WebInspector.ContentProvider}
- * @param {WebInspector.Resource} resource
- */
-WebInspector.ResourceContentProvider = function(resource)
-{
- this._mimeType = resource.type === WebInspector.resourceTypes.Script ? "text/javascript" : "text/html";
- this._resource = resource;
-};
-
-WebInspector.ResourceContentProvider.prototype = {
- /**
- * @param {function(string,string)} callback
- */
- requestContent: function(callback)
- {
- function didRequestContent(content)
- {
- callback(this._mimeType, content);
- }
- this._resource.requestContent(didRequestContent.bind(this));
- },
-
- /**
- * @param {string} query
- * @param {boolean} caseSensitive
- * @param {boolean} isRegex
- * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
- */
- searchInContent: function(query, caseSensitive, isRegex, callback)
- {
- this._resource.searchInContent(query, caseSensitive, isRegex, callback);
- }
-}
-
-WebInspector.ResourceContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
-
-/**
- * @constructor
- * @implements {WebInspector.ContentProvider}
*/
WebInspector.CompilerSourceMappingContentProvider = function(sourceURL)
{
WebInspector.CompilerSourceMappingContentProvider.prototype = {
/**
- * @param {function(string,string)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return this._sourceURL;
+ },
+
+ /**
+ * @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)
{
} catch(e) {
console.error(e.message);
}
- callback(this._mimeType, sourceCode);
+ callback(sourceCode, false, this._mimeType);
},
/**
WebInspector.StaticContentProvider.prototype = {
/**
- * @param {function(string,string)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return null;
+ },
+
+ /**
+ * @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)
{
- callback(this._mimeType, this._content);
+ callback(this._content, false, this._mimeType);
},
/**
* @param {function(?string)} userCallback
* @param {?string} oldContent
* @param {boolean} oldContentEncoded
+ * @param {string} mimeType
*/
- _setContentWithInitialContent: function(uiSourceCode, content, userCallback, oldContent, oldContentEncoded)
+ _setContentWithInitialContent: function(uiSourceCode, content, userCallback, oldContent, oldContentEncoded, mimeType)
{
/**
* @this {WebInspector.DebuggerPresentationModelResourceBinding}
_getResourceContent: function(resource, message, port)
{
- function onContentAvailable(content, encoded)
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function onContentAvailable(content, contentEncoded, mimeType)
{
var response = {
- encoding: encoded ? "base64" : "",
+ encoding: contentEncoded ? "base64" : "",
content: content
};
this._dispatchCallback(message.requestId, port, response);
this._popoverHelper.hidePopover();
},
- // SourceFrame overrides
+ /**
+ * @param {function(?string, boolean, string)} callback
+ */
requestContent: function(callback)
{
- function mycallback(mimeType, content)
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function mycallback(content, contentEncoded, mimeType)
{
this._originalContent = content;
- callback(mimeType, content);
+ callback(content, contentEncoded, mimeType);
}
this._uiSourceCode.requestContent(mycallback.bind(this));
},
return;
this._innerViewShowRequested = true;
- function callback()
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function callback(content, contentEncoded, mimeType)
{
this._innerViewShowRequested = false;
this.contentLoaded();
/**
* @constructor
* @extends {WebInspector.Object}
- *
+ * @implements {WebInspector.ContentProvider}
* @param {NetworkAgent.RequestId} requestId
* @param {string} url
* @param {string} documentURL
},
/**
- * @param {function(?string, boolean)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return this._url;
+ },
+
+ /**
+ * @param {function(?string, boolean, string)} callback
*/
requestContent: function(callback)
{
// Since WebSockets are potentially long-living, fail requests immediately
// to prevent caller blocking until resource is marked as finished.
if (this.type === WebInspector.resourceTypes.WebSocket) {
- callback(null, false);
+ callback(null, false, this._mimeType);
return;
}
if (typeof this._content !== "undefined") {
- callback(this.content, this._contentEncoded);
+ callback(this.content, this._contentEncoded, this._mimeType);
return;
}
this._pendingContentCallbacks.push(callback);
},
/**
+ * @param {string} query
+ * @param {boolean} caseSensitive
+ * @param {boolean} isRegex
+ * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
+ */
+ searchInContent: function(query, caseSensitive, isRegex, callback)
+ {
+ callback([]);
+ },
+
+ /**
* @return {boolean}
*/
isHttpFamily: function()
*/
populateImageSource: function(image)
{
- function onResourceContent()
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function onResourceContent(content, contentEncoded, mimeType)
{
- image.src = this._contentURL();
+ const maxDataUrlSize = 1024 * 1024;
+ // If resource content is not available or won't fit a data URL, fall back to using original URL.
+ if (this._content == null || this._content.length > maxDataUrlSize)
+ return this.url;
+ image.src = "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content;
}
this.requestContent(onResourceContent.bind(this));
},
- /**
- * @return {string}
- */
- _contentURL: function()
- {
- const maxDataUrlSize = 1024 * 1024;
- // If resource content is not available or won't fit a data URL, fall back to using original URL.
- if (this._content == null || this._content.length > maxDataUrlSize)
- return this.url;
-
- return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content;
- },
-
_innerRequestContent: function()
{
if (this._contentRequested)
this._contentEncoded = contentEncoded;
var callbacks = this._pendingContentCallbacks.slice();
for (var i = 0; i < callbacks.length; ++i)
- callbacks[i](this._content, this._contentEncoded);
+ callbacks[i](this._content, this._contentEncoded, this._mimeType);
this._pendingContentCallbacks.length = 0;
delete this._contentRequested;
}
_createContentProvider: function()
{
if (this._resource)
- return new WebInspector.ResourceContentProvider(this._resource);
+ return this._resource;
if (this._scripts.length === 1 && !this._scripts[0].lineOffset && !this._scripts[0].columnOffset)
return new WebInspector.ScriptContentProvider(this._scripts[0]);
return new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
/**
* @this {WebInspector.RawSourceCode}
+ * @param {?string} content
+ * @param {boolean} contentEncoded
* @param {string} mimeType
- * @param {string} content
*/
- function didRequestContent(mimeType, content)
+ function didRequestContent(content, contentEncoded, mimeType)
{
/**
* @this {WebInspector.RawSourceCode}
var sourceMapping = new WebInspector.RawSourceCode.FormattedSourceMapping(this, uiSourceCode, mapping);
callback(sourceMapping);
}
- this._formatter.formatContent(mimeType, content, didFormatContent.bind(this));
+ this._formatter.formatContent(mimeType, content || "", didFormatContent.bind(this));
}
originalContentProvider.requestContent(didRequestContent.bind(this));
},
/**
* @constructor
* @extends {WebInspector.Object}
- *
+ * @implements {WebInspector.ContentProvider}
* @param {?WebInspector.NetworkRequest} request
* @param {string} url
* @param {string} documentURL
},
/**
- * @param {function(?string, boolean)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return this._url;
+ },
+
+ /**
+ * @param {function(?string, boolean, string)} callback
*/
requestContent: function(callback)
{
if (typeof this._content !== "undefined") {
- callback(this._content, !!this._contentEncoded);
+ callback(this._content, !!this._contentEncoded, this.mimeType);
return;
}
* @param {string} query
* @param {boolean} caseSensitive
* @param {boolean} isRegex
- * @param {function(Array.<PageAgent.SearchMatch>)} callback
+ * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
*/
searchInContent: function(query, caseSensitive, isRegex, callback)
{
this._originalContent = content;
var callbacks = this._pendingContentCallbacks.slice();
for (var i = 0; i < callbacks.length; ++i)
- callbacks[i](this._content, this._contentEncoded);
+ callbacks[i](this._content, this._contentEncoded, this.mimeType);
this._pendingContentCallbacks.length = 0;
delete this._contentRequested;
}
/**
* @constructor
+ * @implements {WebInspector.ContentProvider}
* @param {WebInspector.Resource} resource
* @param {string|undefined} content
* @param {number} timestamp
},
/**
- * @param {function(?string)} callback
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return this._resource.url;
+ },
+
+ /**
+ * @param {function(?string, boolean, string)} callback
*/
requestContent: function(callback)
{
if (typeof this._content === "string") {
- callback(this._content);
+ callback(this._content, false, this.resource.mimeType);
return;
}
// If we are here, this is initial revision. First, look up content fetched over the wire.
if (typeof this.resource._originalContent === "string") {
this._content = this._resource._originalContent;
- callback(this._content);
+ callback(this._content, false, this.resource.mimeType);
return;
}
*/
function callbackWrapper(error, content, contentEncoded)
{
- callback(error ? null : content);
+ callback(error ? null : content, contentEncoded, this.resource.mimeType);
}
- PageAgent.getResourceContent(this._resource.frameId, this._resource.url, callbackWrapper);
+ PageAgent.getResourceContent(this._resource.frameId, this._resource.url, callbackWrapper.bind(this));
+ },
+
+ /**
+ * @param {string} query
+ * @param {boolean} caseSensitive
+ * @param {boolean} isRegex
+ * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
+ */
+ searchInContent: function(query, caseSensitive, isRegex, callback)
+ {
+ callback([]);
}
}
return this._resource;
},
+ /**
+ * @param {function(?string,boolean,string)} callback
+ */
requestContent: function(callback)
{
- function contentLoaded(text)
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function callbackWrapper(content, contentEncoded, mimeType)
{
- var mimeType = WebInspector.ResourceSourceFrame._mimeTypeForResource(this._resource);
- callback(mimeType, text);
+ // Canonicalize mimeType.
+ callback(content, contentEncoded, WebInspector.ResourceSourceFrame._mimeTypeForResource(this._resource));
}
-
- this.resource.requestContent(contentLoaded.bind(this));
+ this.resource.requestContent(callbackWrapper.bind(this));
},
_contentChanged: function(event)
{
- this.setContent(WebInspector.ResourceSourceFrame._mimeTypeForResource[this._resource], this._resource.content);
+ this.setContent(this._resource.content, false, WebInspector.ResourceSourceFrame._mimeTypeForResource(this._resource));
}
}
return this._revision.resource;
},
+ /**
+ * @param {function(?string,boolean,string)} callback
+ */
requestContent: function(callback)
{
- function contentLoaded(text)
- {
- var mimeType = WebInspector.ResourceSourceFrame._mimeTypeForResource(this.resource);
- callback(mimeType, text);
- }
-
- this._revision.requestContent(contentLoaded.bind(this));
+ this._revision.requestContent(callback);
},
}
WebInspector.ScriptFormatter.prototype = {
/**
* @param {string} mimeType
- * @param {string} content
+ * @param {?string} content
* @param {function(string, WebInspector.FormattedSourceMapping)} callback
*/
formatContent: function(mimeType, content, callback)
requestVisibleScriptOutline: function()
{
- function contentCallback(mimeType, content)
+
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function contentCallback(content, contentEncoded, mimeType)
{
if (this._outlineWorker)
this._outlineWorker.terminate();
}
},
+ /**
+ * @param {function(?string, boolean, string)} callback
+ */
requestContent: function(callback)
{
},
{
},
- setContent: function(mimeType, content)
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ setContent: function(content, contentEncoded, mimeType)
{
this._textViewer.mimeType = mimeType;
this._loaded = true;
- this._textModel.setText(content);
+ this._textModel.setText(content || "");
this._textViewer.beginUpdates();
this.isContentScript = false;
this.isEditable = false;
/**
- * @type Array.<function(string,string)>
+ * @type Array.<function(?string,boolean,string)>
*/
this._requestContentCallbacks = [];
}
},
/**
- * @param {function(string,string)} callback
+ * @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)
{
if (this._contentLoaded) {
- callback(this._mimeType, this._content);
+ callback(this._content, false, this._mimeType);
return;
}
},
/**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
* @param {string} mimeType
- * @param {string} content
*/
- _didRequestContent: function(mimeType, content)
+ _didRequestContent: function(content, contentEncoded, mimeType)
{
this._contentLoaded = true;
this._mimeType = mimeType;
this._content = content;
for (var i = 0; i < this._requestContentCallbacks.length; ++i)
- this._requestContentCallbacks[i](mimeType, content);
+ this._requestContentCallbacks[i](content, contentEncoded, mimeType);
this._requestContentCallbacks = [];
},
}
WebInspector.UISourceCode.prototype.__proto__ = WebInspector.Object.prototype;
-
-/**
- * @interface
- */
-WebInspector.ContentProvider = function() { }
-WebInspector.ContentProvider.prototype = {
- /**
- * @param {function(string,string)} callback
- */
- requestContent: function(callback) { },
-
- /**
- * @param {string} query
- * @param {boolean} caseSensitive
- * @param {boolean} isRegex
- * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callback
- */
- searchInContent: function(query, caseSensitive, isRegex, callback) { }
-}
-
-/**
- * @constructor
- * @param {number} lineNumber
- * @param {string} lineContent
- */
-WebInspector.ContentProvider.SearchMatch = function(lineNumber, lineContent) {
- this.lineNumber = lineNumber;
- this.lineContent = lineContent;
-}
<file>ConsoleModel.js</file>
<file>ConsolePanel.js</file>
<file>ConsoleView.js</file>
+ <file>ContentProvider.js</file>
<file>ContentProviders.js</file>
<file>ContextMenu.js</file>
<file>CookieItemsView.js</file>
<script type="text/javascript" src="InspectorView.js"></script>
<script type="text/javascript" src="AdvancedSearchController.js"></script>
<script type="text/javascript" src="TimelineGrid.js"></script>
+ <script type="text/javascript" src="ContentProvider.js"></script>
<script type="text/javascript" src="Resource.js"></script>
<script type="text/javascript" src="NetworkRequest.js"></script>
<script type="text/javascript" src="CSSStyleModel.js"></script>