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 29 matching lines...) Expand all Loading... |
40 #include <wtf/CurrentTime.h> | 40 #include <wtf/CurrentTime.h> |
41 #include <wtf/MemoryInstrumentationHashMap.h> | 41 #include <wtf/MemoryInstrumentationHashMap.h> |
42 #include <wtf/MemoryObjectInfo.h> | 42 #include <wtf/MemoryObjectInfo.h> |
43 #include <wtf/StdLibExtras.h> | 43 #include <wtf/StdLibExtras.h> |
44 #include <wtf/Vector.h> | 44 #include <wtf/Vector.h> |
45 | 45 |
46 #if ENABLE(SVG) | 46 #if ENABLE(SVG) |
47 #include "SVGImage.h" | 47 #include "SVGImage.h" |
48 #endif | 48 #endif |
49 | 49 |
| 50 #if USE(WEBP) |
| 51 #include "RuntimeEnabledFeatures.h" |
| 52 #endif |
| 53 |
50 using std::max; | 54 using std::max; |
51 | 55 |
52 namespace WebCore { | 56 namespace WebCore { |
53 | 57 |
54 CachedImage::CachedImage(const ResourceRequest& resourceRequest) | 58 CachedImage::CachedImage(const ResourceRequest& resourceRequest) |
55 : CachedResource(resourceRequest, ImageResource) | 59 : CachedResource(resourceRequest, ImageResource) |
56 , m_image(0) | 60 , m_image(0) |
57 { | 61 { |
58 setStatus(Unknown); | 62 setStatus(Unknown); |
| 63 setCustomAcceptHeader(); |
59 } | 64 } |
60 | 65 |
61 CachedImage::CachedImage(Image* image) | 66 CachedImage::CachedImage(Image* image) |
62 : CachedResource(ResourceRequest(), ImageResource) | 67 : CachedResource(ResourceRequest(), ImageResource) |
63 , m_image(image) | 68 , m_image(image) |
64 { | 69 { |
65 setStatus(Cached); | 70 setStatus(Cached); |
66 setLoading(false); | 71 setLoading(false); |
| 72 setCustomAcceptHeader(); |
67 } | 73 } |
68 | 74 |
69 CachedImage::~CachedImage() | 75 CachedImage::~CachedImage() |
70 { | 76 { |
71 clearImage(); | 77 clearImage(); |
72 } | 78 } |
73 | 79 |
74 void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
eLoaderOptions& options) | 80 void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
eLoaderOptions& options) |
75 { | 81 { |
76 if (!cachedResourceLoader || cachedResourceLoader->autoLoadImages()) | 82 if (!cachedResourceLoader || cachedResourceLoader->autoLoadImages()) |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 292 } |
287 | 293 |
288 void CachedImage::clear() | 294 void CachedImage::clear() |
289 { | 295 { |
290 destroyDecodedData(); | 296 destroyDecodedData(); |
291 clearImage(); | 297 clearImage(); |
292 m_pendingContainerSizeRequests.clear(); | 298 m_pendingContainerSizeRequests.clear(); |
293 setEncodedSize(0); | 299 setEncodedSize(0); |
294 } | 300 } |
295 | 301 |
| 302 void CachedImage::setCustomAcceptHeader() |
| 303 { |
| 304 #if USE(WEBP) |
| 305 if (RuntimeEnabledFeatures::webPInAcceptHeaderEnabled()) |
| 306 setAccept("image/webp,*/*;q=0.8"); |
| 307 #endif |
| 308 } |
| 309 |
296 inline void CachedImage::createImage() | 310 inline void CachedImage::createImage() |
297 { | 311 { |
298 // Create the image if it doesn't yet exist. | 312 // Create the image if it doesn't yet exist. |
299 if (m_image) | 313 if (m_image) |
300 return; | 314 return; |
301 #if ENABLE(SVG) | 315 #if ENABLE(SVG) |
302 else if (m_response.mimeType() == "image/svg+xml") { | 316 else if (m_response.mimeType() == "image/svg+xml") { |
303 RefPtr<SVGImage> svgImage = SVGImage::create(this); | 317 RefPtr<SVGImage> svgImage = SVGImage::create(this); |
304 m_svgImageCache = SVGImageCache::create(svgImage.get()); | 318 m_svgImageCache = SVGImageCache::create(svgImage.get()); |
305 m_image = svgImage.release(); | 319 m_image = svgImage.release(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 472 |
459 bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer) | 473 bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer) |
460 { | 474 { |
461 Image* image = imageForRenderer(renderer); | 475 Image* image = imageForRenderer(renderer); |
462 if (image->isBitmapImage()) | 476 if (image->isBitmapImage()) |
463 image->nativeImageForCurrentFrame(); // force decode | 477 image->nativeImageForCurrentFrame(); // force decode |
464 return image->currentFrameKnownToBeOpaque(); | 478 return image->currentFrameKnownToBeOpaque(); |
465 } | 479 } |
466 | 480 |
467 } // namespace WebCore | 481 } // namespace WebCore |
OLD | NEW |