[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
caseq at chromium.org
caseq at chromium.org
Wed Dec 22 14:57:38 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 643fcecb1c789a7ee8021a544c00a8ba65c31480
Author: caseq at chromium.org <caseq at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 26 14:18:57 2010 +0000
2010-10-20 Andrey Kosyakov <caseq at chromium.org>
Reviewed by Yury Semikhatsky.
Inspector needs to use cached resources to display image resources.
https://bugs.webkit.org/show_bug.cgi?id=16395
* inspector/Inspector.idl: Add base64Encode parameter to getContent
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::resourceContent):
* inspector/InspectorResourceAgent.h:
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer.prototype._onGetResourceContent):
* inspector/front-end/ImageView.js:
(WebInspector.ImageView.prototype.contentTabSelected.onResourceContent):
(WebInspector.ImageView.prototype.contentTabSelected):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkDataGridNode.prototype._refreshNameCell.):
(WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
* inspector/front-end/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.prototype.set finished):
(WebInspector.Resource.prototype.getContent):
(WebInspector.Resource.prototype.get contentURL):
(WebInspector.Resource.prototype._requestContent.onResourceContent):
(WebInspector.Resource.prototype._requestContent):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourceSidebarTreeElement.prototype.createIconElement.):
(WebInspector.ResourceSidebarTreeElement.prototype.createIconElement):
* inspector/front-end/Settings.js: Added useDataURLForResourceImageIcons
* inspector/front-end/SourceView.js:
(WebInspector.SourceView.prototype.setupSourceFrameIfNeeded):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70519 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index cb4df10..2527c4b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2010-10-20 Andrey Kosyakov <caseq at chromium.org>
+
+ Reviewed by Yury Semikhatsky.
+
+ Inspector needs to use cached resources to display image resources.
+ https://bugs.webkit.org/show_bug.cgi?id=16395
+
+ * inspector/Inspector.idl: Add base64Encode parameter to getContent
+ * inspector/InspectorResourceAgent.cpp:
+ (WebCore::InspectorResourceAgent::resourceContent):
+ * inspector/InspectorResourceAgent.h:
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer.prototype._onGetResourceContent):
+ * inspector/front-end/ImageView.js:
+ (WebInspector.ImageView.prototype.contentTabSelected.onResourceContent):
+ (WebInspector.ImageView.prototype.contentTabSelected):
+ * inspector/front-end/NetworkPanel.js:
+ (WebInspector.NetworkDataGridNode.prototype._refreshNameCell.):
+ (WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource):
+ (WebInspector.Resource.prototype.set finished):
+ (WebInspector.Resource.prototype.getContent):
+ (WebInspector.Resource.prototype.get contentURL):
+ (WebInspector.Resource.prototype._requestContent.onResourceContent):
+ (WebInspector.Resource.prototype._requestContent):
+ * inspector/front-end/ResourcesPanel.js:
+ (WebInspector.ResourceSidebarTreeElement.prototype.createIconElement.):
+ (WebInspector.ResourceSidebarTreeElement.prototype.createIconElement):
+ * inspector/front-end/Settings.js: Added useDataURLForResourceImageIcons
+ * inspector/front-end/SourceView.js:
+ (WebInspector.SourceView.prototype.setupSourceFrameIfNeeded):
+
2010-10-26 Pavel Feldman <pfeldman at chromium.org>
Reviewed by Timothy Hatcher.
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index 107f156..10965da 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -113,7 +113,7 @@ module core {
[handler=Controller] void stopTimelineProfiler();
[handler=Resource] void cachedResources(out Object resources);
- [handler=Resource] void resourceContent(in unsigned long frameId, in String url, out String content);
+ [handler=Resource] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content);
[notify] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out boolean isMainResource);
[notify] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse);
[notify] void markResourceAsCached(out long identifier);
diff --git a/WebCore/inspector/InspectorResourceAgent.cpp b/WebCore/inspector/InspectorResourceAgent.cpp
index ee7457b..c711974 100644
--- a/WebCore/inspector/InspectorResourceAgent.cpp
+++ b/WebCore/inspector/InspectorResourceAgent.cpp
@@ -432,13 +432,15 @@ void InspectorResourceAgent::cachedResources(RefPtr<InspectorObject>* object)
*object = buildObjectForFrameTree(m_page->mainFrame(), true);
}
-void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, String* content)
+void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, bool base64Encode, String* content)
{
- RefPtr<InspectorArray> frameResources = InspectorArray::create();
for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) {
if (reinterpret_cast<uintptr_t>(frame) != frameId)
continue;
- InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content);
+ if (base64Encode)
+ InspectorResourceAgent::resourceContentBase64(frame, KURL(ParsedURLString, url), content);
+ else
+ InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content);
break;
}
}
diff --git a/WebCore/inspector/InspectorResourceAgent.h b/WebCore/inspector/InspectorResourceAgent.h
index fe52a3a..8a54c89 100644
--- a/WebCore/inspector/InspectorResourceAgent.h
+++ b/WebCore/inspector/InspectorResourceAgent.h
@@ -98,7 +98,7 @@ public:
// Called from frontend
void cachedResources(RefPtr<InspectorObject>*);
- void resourceContent(unsigned long frameID, const String& url, String* content);
+ void resourceContent(unsigned long frameID, const String& url, bool base64Encode, String* content);
private:
InspectorResourceAgent(Page* page, InspectorFrontend* frontend);
diff --git a/WebCore/inspector/front-end/ExtensionServer.js b/WebCore/inspector/front-end/ExtensionServer.js
index 75361a2..ea73c39 100644
--- a/WebCore/inspector/front-end/ExtensionServer.js
+++ b/WebCore/inspector/front-end/ExtensionServer.js
@@ -277,7 +277,7 @@ WebInspector.ExtensionServer.prototype = {
var ids;
var response = [];
- function onContentAvailable(id, encoded, content)
+ function onContentAvailable(id, content, encoded)
{
var resourceContent = {
id: id,
@@ -301,10 +301,8 @@ WebInspector.ExtensionServer.prototype = {
var resource = WebInspector.networkResources[id];
if (!resource)
response.push(this._status.E_NOTFOUND(id));
- else {
- var encode = !WebInspector.Resource.Type.isTextType(resource.type);
- WebInspector.getEncodedResourceContent(id, encode, onContentAvailable.bind(this, id, encode));
- }
+ else
+ resource.getContent(onContentAvailable.bind(this, id));
}
if (response.length === ids.length)
this._dispatchCallback(message.requestId, port, response);
@@ -451,8 +449,3 @@ WebInspector.addExtensions = function(extensions)
}
WebInspector.extensionServer = new WebInspector.ExtensionServer();
-
-WebInspector.getEncodedResourceContent = function(identifier, encode, callback)
-{
- InspectorBackend.getResourceContent(identifier, encode, callback);
-}
diff --git a/WebCore/inspector/front-end/ImageView.js b/WebCore/inspector/front-end/ImageView.js
index 06ca4a4..7cff056 100644
--- a/WebCore/inspector/front-end/ImageView.js
+++ b/WebCore/inspector/front-end/ImageView.js
@@ -49,10 +49,14 @@ WebInspector.ImageView.prototype = {
this.imagePreviewElement = document.createElement("img");
this.imagePreviewElement.addStyleClass("resource-image-view");
- this.imagePreviewElement.setAttribute("src", this.resource.url);
-
this._container.appendChild(this.imagePreviewElement);
+ function onResourceContent(element, content)
+ {
+ this.imagePreviewElement.setAttribute("src", this.resource.contentURL);
+ }
+ this.resource.getContent(onResourceContent.bind(this));
+
this._container = document.createElement("div");
this._container.className = "info";
this.contentElement.appendChild(this._container);
diff --git a/WebCore/inspector/front-end/NetworkPanel.js b/WebCore/inspector/front-end/NetworkPanel.js
index e31ff0d..bec6056 100644
--- a/WebCore/inspector/front-end/NetworkPanel.js
+++ b/WebCore/inspector/front-end/NetworkPanel.js
@@ -1462,7 +1462,15 @@ WebInspector.NetworkDataGridNode.prototype = {
if (this._resource.category === WebInspector.resourceCategories.images) {
var previewImage = document.createElement("img");
previewImage.className = "image-network-icon-preview";
- previewImage.src = this._resource.url;
+
+ function onResourceContent()
+ {
+ previewImage.src = this._resource.contentURL;
+ }
+ if (Preferences.useDataURLForResourceImageIcons)
+ this._resource.getContent(onResourceContent.bind(this));
+ else
+ previewImage.src = this._resource.url;
var iconElement = document.createElement("div");
iconElement.className = "icon";
diff --git a/WebCore/inspector/front-end/Resource.js b/WebCore/inspector/front-end/Resource.js
index 817af0e..c1385a7 100644
--- a/WebCore/inspector/front-end/Resource.js
+++ b/WebCore/inspector/front-end/Resource.js
@@ -34,6 +34,7 @@ WebInspector.Resource = function(identifier, url)
this._endTime = -1;
this._requestMethod = "";
this._category = WebInspector.resourceCategories.other;
+ this._pendingContentCallbacks = [];
}
// Keep these in sync with WebCore::InspectorResource::Type
@@ -254,6 +255,8 @@ WebInspector.Resource.prototype = {
if (x) {
this._checkWarnings();
this.dispatchEventToListeners("finished");
+ if (this._pendingContentCallbacks.length)
+ this._requestContent();
}
},
@@ -597,9 +600,43 @@ WebInspector.Resource.prototype = {
WebInspector.console.addMessage(msg);
},
- getContents: function(callback)
+ getContent: function(callback)
{
- WebInspector.ResourceManager.getContents(this, callback);
+ if (this._content) {
+ callback(this._content, this._contentEncoded);
+ return;
+ }
+ this._pendingContentCallbacks.push(callback);
+ if (this.finished)
+ this._requestContent();
+ },
+
+ get 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 || this._content.length > maxDataUrlSize)
+ return this.url;
+
+ return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content;
+ },
+
+ _requestContent: function()
+ {
+ if (this._contentRequested)
+ return;
+ this._contentRequested = true;
+ this._contentEncoded = !WebInspector.Resource.Type.isTextType(this.type);
+
+ function onResourceContent(data)
+ {
+ this._content = data;
+ var callbacks = this._pendingContentCallbacks.slice();
+ for (var i = 0; i < callbacks.length; ++i)
+ callbacks[i](this._content, this._contentEncoded);
+ this._pendingContentCallbacks.length = 0;
+ }
+ WebInspector.ResourceManager.getContent(this, this._contentEncoded, onResourceContent.bind(this));
}
}
diff --git a/WebCore/inspector/front-end/ResourceManager.js b/WebCore/inspector/front-end/ResourceManager.js
index 8eb7f04..0533ec5 100644
--- a/WebCore/inspector/front-end/ResourceManager.js
+++ b/WebCore/inspector/front-end/ResourceManager.js
@@ -407,7 +407,7 @@ WebInspector.ResourceManager.existingResourceViewForResource = function(resource
return resource._resourcesView;
}
-WebInspector.ResourceManager.getContents = function(resource, callback)
+WebInspector.ResourceManager.getContent = function(resource, base64Encode, callback)
{
if ("overridenContent" in resource) {
callback(resource.overridenContent);
@@ -416,9 +416,9 @@ WebInspector.ResourceManager.getContents = function(resource, callback)
// FIXME: eventually, cached resources will have no identifiers.
if (resource.loader)
- InspectorBackend.resourceContent(resource.loader.frameId, resource.url, callback);
+ InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback);
else
- InspectorBackend.getResourceContent(resource.identifier, false, callback);
+ InspectorBackend.getResourceContent(resource.identifier, base64Encode, callback);
}
WebInspector.ResourceTreeModel = function()
diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js
index cba0cae..48c49dd 100644
--- a/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/WebCore/inspector/front-end/ResourcesPanel.js
@@ -1666,7 +1666,15 @@ WebInspector.ResourceSidebarTreeElement.prototype = {
if (this.resource.category === WebInspector.resourceCategories.images) {
var previewImage = document.createElement("img");
previewImage.className = "image-resource-icon-preview";
- previewImage.src = this.resource.url;
+
+ function onResourceContent()
+ {
+ previewImage.src = this.resource.contentURL;
+ }
+ if (Preferences.useDataURLForResourceImageIcons)
+ this.resource.getContent(onResourceContent.bind(this));
+ else
+ previewImage.src = this.resource.url;
this.iconElement = document.createElement("div");
this.iconElement.className = "icon";
diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js
index c6da14d..c22cf71 100644
--- a/WebCore/inspector/front-end/Settings.js
+++ b/WebCore/inspector/front-end/Settings.js
@@ -45,7 +45,8 @@ var Preferences = {
onlineDetectionEnabled: true,
nativeInstrumentationEnabled: false,
resourceExportEnabled: false,
- networkPanelEnabled: false
+ networkPanelEnabled: false,
+ useDataURLForResourceImageIcons: true
}
WebInspector.Settings = function(sessionScope)
diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js
index 8092505..8f024bc 100644
--- a/WebCore/inspector/front-end/SourceView.js
+++ b/WebCore/inspector/front-end/SourceView.js
@@ -83,7 +83,7 @@ WebInspector.SourceView.prototype = {
this.attach();
delete this._frameNeedsSetup;
- this.resource.getContents(this._contentLoaded.bind(this));
+ this.resource.getContent(this._contentLoaded.bind(this));
},
hasContentTab: function()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list