| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include <wtf/CurrentTime.h> | 41 #include <wtf/CurrentTime.h> |
| 42 #include <wtf/MemoryInstrumentationHashMap.h> | 42 #include <wtf/MemoryInstrumentationHashMap.h> |
| 43 #include <wtf/MemoryObjectInfo.h> | 43 #include <wtf/MemoryObjectInfo.h> |
| 44 #include <wtf/StdLibExtras.h> | 44 #include <wtf/StdLibExtras.h> |
| 45 #include <wtf/Vector.h> | 45 #include <wtf/Vector.h> |
| 46 | 46 |
| 47 #if ENABLE(SVG) | 47 #if ENABLE(SVG) |
| 48 #include "SVGImage.h" | 48 #include "SVGImage.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 #if USE(WEBP) |
| 52 #include "RuntimeEnabledFeatures.h" |
| 53 #endif |
| 54 |
| 51 using std::max; | 55 using std::max; |
| 52 | 56 |
| 53 namespace WebCore { | 57 namespace WebCore { |
| 54 | 58 |
| 55 CachedImage::CachedImage(const ResourceRequest& resourceRequest) | 59 CachedImage::CachedImage(const ResourceRequest& resourceRequest) |
| 56 : CachedResource(resourceRequest, ImageResource) | 60 : CachedResource(resourceRequest, ImageResource) |
| 57 , m_image(0) | 61 , m_image(0) |
| 58 , m_shouldPaintBrokenImage(true) | 62 , m_shouldPaintBrokenImage(true) |
| 59 { | 63 { |
| 60 setStatus(Unknown); | 64 setStatus(Unknown); |
| 65 setCustomAcceptHeader(); |
| 61 } | 66 } |
| 62 | 67 |
| 63 CachedImage::CachedImage(Image* image) | 68 CachedImage::CachedImage(Image* image) |
| 64 : CachedResource(ResourceRequest(), ImageResource) | 69 : CachedResource(ResourceRequest(), ImageResource) |
| 65 , m_image(image) | 70 , m_image(image) |
| 66 , m_shouldPaintBrokenImage(true) | 71 , m_shouldPaintBrokenImage(true) |
| 67 { | 72 { |
| 68 setStatus(Cached); | 73 setStatus(Cached); |
| 69 setLoading(false); | 74 setLoading(false); |
| 75 setCustomAcceptHeader(); |
| 70 } | 76 } |
| 71 | 77 |
| 72 CachedImage::~CachedImage() | 78 CachedImage::~CachedImage() |
| 73 { | 79 { |
| 74 clearImage(); | 80 clearImage(); |
| 75 } | 81 } |
| 76 | 82 |
| 77 void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
eLoaderOptions& options) | 83 void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
eLoaderOptions& options) |
| 78 { | 84 { |
| 79 if (!cachedResourceLoader || cachedResourceLoader->autoLoadImages()) | 85 if (!cachedResourceLoader || cachedResourceLoader->autoLoadImages()) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 } | 303 } |
| 298 | 304 |
| 299 void CachedImage::clear() | 305 void CachedImage::clear() |
| 300 { | 306 { |
| 301 destroyDecodedData(); | 307 destroyDecodedData(); |
| 302 clearImage(); | 308 clearImage(); |
| 303 m_pendingContainerSizeRequests.clear(); | 309 m_pendingContainerSizeRequests.clear(); |
| 304 setEncodedSize(0); | 310 setEncodedSize(0); |
| 305 } | 311 } |
| 306 | 312 |
| 313 void CachedImage::setCustomAcceptHeader() |
| 314 { |
| 315 #if USE(WEBP) |
| 316 if (RuntimeEnabledFeatures::webPInAcceptHeaderEnabled()) |
| 317 setAccept("image/webp,*/*;q=0.8"); |
| 318 #endif |
| 319 } |
| 320 |
| 307 inline void CachedImage::createImage() | 321 inline void CachedImage::createImage() |
| 308 { | 322 { |
| 309 // Create the image if it doesn't yet exist. | 323 // Create the image if it doesn't yet exist. |
| 310 if (m_image) | 324 if (m_image) |
| 311 return; | 325 return; |
| 312 #if ENABLE(SVG) | 326 #if ENABLE(SVG) |
| 313 else if (m_response.mimeType() == "image/svg+xml") { | 327 else if (m_response.mimeType() == "image/svg+xml") { |
| 314 RefPtr<SVGImage> svgImage = SVGImage::create(this); | 328 RefPtr<SVGImage> svgImage = SVGImage::create(this); |
| 315 m_svgImageCache = SVGImageCache::create(svgImage.get()); | 329 m_svgImageCache = SVGImageCache::create(svgImage.get()); |
| 316 m_image = svgImage.release(); | 330 m_image = svgImage.release(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 484 |
| 471 bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer) | 485 bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer) |
| 472 { | 486 { |
| 473 Image* image = imageForRenderer(renderer); | 487 Image* image = imageForRenderer(renderer); |
| 474 if (image->isBitmapImage()) | 488 if (image->isBitmapImage()) |
| 475 image->nativeImageForCurrentFrame(); // force decode | 489 image->nativeImageForCurrentFrame(); // force decode |
| 476 return image->currentFrameKnownToBeOpaque(); | 490 return image->currentFrameKnownToBeOpaque(); |
| 477 } | 491 } |
| 478 | 492 |
| 479 } // namespace WebCore | 493 } // namespace WebCore |
| OLD | NEW |