Commit e02af71e authored by anilsson@rim.com's avatar anilsson@rim.com

[BlackBerry] Populate the mime type of the WebContext for images

https://bugs.webkit.org/show_bug.cgi?id=113272

Reviewed by George Staikos.

PR 278967

Populate the mime type using the file extension reported by the image
decoder. This way we benefit from file type sniffing, instead of
relying on the mime type reported by the resource response.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c2deee04
......@@ -2318,10 +2318,25 @@ Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy
if (imageElement && imageElement->renderer()) {
context.setFlag(Platform::WebContext::IsImage);
// FIXME: At the mean time, we only show "Save Image" when the image data is available.
if (CachedResource* cachedResource = imageElement->cachedImage()) {
if (cachedResource->isLoaded() && cachedResource->resourceBuffer()) {
if (CachedImage* cachedImage = imageElement->cachedImage()) {
if (cachedImage->isLoaded() && cachedImage->resourceBuffer()) {
String url = stripLeadingAndTrailingHTMLSpaces(imageElement->getAttribute(HTMLNames::srcAttr).string());
context.setSrc(node->document()->completeURL(url).string());
String mimeType = cachedImage->response().mimeType();
if (mimeType.isEmpty()) {
StringBuilder builder;
String extension = cachedImage->image()->filenameExtension();
builder.append("image/");
if (extension.isEmpty())
builder.append("unknown");
else if (extension == "jpg")
builder.append("jpeg");
else
builder.append(extension);
mimeType = builder.toString();
}
context.setMimeType(mimeType);
}
}
String alt = imageElement->altText();
......@@ -5167,7 +5182,7 @@ void WebPage::setExtraPluginDirectory(const BlackBerry::Platform::String& path)
PluginDatabase* database = PluginDatabase::installedPlugins(true /* true for loading default directories */);
if (!database)
return;
Vector<String> pluginDirectories = database->pluginDirectories();
if (path.empty() || pluginDirectories.contains(String(path)))
return;
......
2013-03-27 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Populate the mime type of the WebContext for images
https://bugs.webkit.org/show_bug.cgi?id=113272
Reviewed by George Staikos.
PR 278967
Populate the mime type using the file extension reported by the image
decoder. This way we benefit from file type sniffing, instead of
relying on the mime type reported by the resource response.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
2013-03-26 Hayato Ito <hayato@chromium.org>
Allow ShadowContents in HitTests by default.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment