Changeset 147024 in webkit


Ignore:
Timestamp:
Mar 27, 2013 5:02:59 PM (11 years ago)
Author:
anilsson@rim.com
Message:

[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):

Location:
trunk/Source/WebKit/blackberry
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r146961 r147024  
    23192319            context.setFlag(Platform::WebContext::IsImage);
    23202320            // FIXME: At the mean time, we only show "Save Image" when the image data is available.
    2321             if (CachedResource* cachedResource = imageElement->cachedImage()) {
    2322                 if (cachedResource->isLoaded() && cachedResource->resourceBuffer()) {
     2321            if (CachedImage* cachedImage = imageElement->cachedImage()) {
     2322                if (cachedImage->isLoaded() && cachedImage->resourceBuffer()) {
    23232323                    String url = stripLeadingAndTrailingHTMLSpaces(imageElement->getAttribute(HTMLNames::srcAttr).string());
    23242324                    context.setSrc(node->document()->completeURL(url).string());
     2325
     2326                    String mimeType = cachedImage->response().mimeType();
     2327                    if (mimeType.isEmpty()) {
     2328                        StringBuilder builder;
     2329                        String extension = cachedImage->image()->filenameExtension();
     2330                        builder.append("image/");
     2331                        if (extension.isEmpty())
     2332                            builder.append("unknown");
     2333                        else if (extension == "jpg")
     2334                            builder.append("jpeg");
     2335                        else
     2336                            builder.append(extension);
     2337                        mimeType = builder.toString();
     2338                    }
     2339                    context.setMimeType(mimeType);
    23252340                }
    23262341            }
     
    51685183    if (!database)
    51695184        return;
    5170    
     5185
    51715186    Vector<String> pluginDirectories = database->pluginDirectories();
    51725187    if (path.empty() || pluginDirectories.contains(String(path)))
  • trunk/Source/WebKit/blackberry/ChangeLog

    r146961 r147024  
     12013-03-27  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [BlackBerry] Populate the mime type of the WebContext for images
     4        https://bugs.webkit.org/show_bug.cgi?id=113272
     5
     6        Reviewed by George Staikos.
     7
     8        PR 278967
     9
     10        Populate the mime type using the file extension reported by the image
     11        decoder. This way we benefit from file type sniffing, instead of
     12        relying on the mime type reported by the resource response.
     13
     14        * Api/WebPage.cpp:
     15        (BlackBerry::WebKit::WebPagePrivate::webContext):
     16
    1172013-03-26  Hayato Ito  <hayato@chromium.org>
    218
Note: See TracChangeset for help on using the changeset viewer.