diff options
Diffstat (limited to 'Source/WebCore/loader/cache')
-rw-r--r-- | Source/WebCore/loader/cache/CachedImage.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/loader/cache/CachedImage.h | 5 | ||||
-rw-r--r-- | Source/WebCore/loader/cache/CachedResource.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/loader/cache/CachedResource.h | 1 | ||||
-rw-r--r-- | Source/WebCore/loader/cache/CachedResourceLoader.cpp | 30 |
5 files changed, 29 insertions, 11 deletions
diff --git a/Source/WebCore/loader/cache/CachedImage.cpp b/Source/WebCore/loader/cache/CachedImage.cpp index ba30860..6867302 100644 --- a/Source/WebCore/loader/cache/CachedImage.cpp +++ b/Source/WebCore/loader/cache/CachedImage.cpp @@ -57,6 +57,7 @@ CachedImage::CachedImage(const String& url) , m_image(0) , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired) , m_shouldPaintBrokenImage(true) + , m_autoLoadWasPreventedBySettings(false) { setStatus(Unknown); } @@ -66,6 +67,7 @@ CachedImage::CachedImage(Image* image) , m_image(image) , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired) , m_shouldPaintBrokenImage(true) + , m_autoLoadWasPreventedBySettings(false) { setStatus(Cached); setLoading(false); diff --git a/Source/WebCore/loader/cache/CachedImage.h b/Source/WebCore/loader/cache/CachedImage.h index 42c7814..79643d7 100644 --- a/Source/WebCore/loader/cache/CachedImage.h +++ b/Source/WebCore/loader/cache/CachedImage.h @@ -75,7 +75,7 @@ public: void clear(); - bool stillNeedsLoad() const { return !errorOccurred() && status() == Unknown && !isLoading(); } + bool stillNeedsLoad() const { return (!errorOccurred() && status() == Unknown && !isLoading()) || (m_autoLoadWasPreventedBySettings && !inCache()); } void load(); // ImageObserver @@ -86,6 +86,8 @@ public: virtual void animationAdvanced(const Image*); virtual void changedInRect(const Image*, const IntRect&); + void setAutoLoadWasPreventedBySettings(bool prevented) { m_autoLoadWasPreventedBySettings = prevented; } + private: void createImage(); size_t maximumDecodedImageSize(); @@ -98,6 +100,7 @@ private: RefPtr<Image> m_image; Timer<CachedImage> m_decodedDataDeletionTimer; bool m_shouldPaintBrokenImage; + bool m_autoLoadWasPreventedBySettings; }; } diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp index 95f5522..e599769 100644 --- a/Source/WebCore/loader/cache/CachedResource.cpp +++ b/Source/WebCore/loader/cache/CachedResource.cpp @@ -261,7 +261,7 @@ void CachedResource::addClient(CachedResourceClient* client) void CachedResource::didAddClient(CachedResourceClient* c) { - if (!isLoading()) + if (!isLoading() && !stillNeedsLoad()) c->notifyFinished(this); } diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h index 72b00e5..2f33ac7 100644 --- a/Source/WebCore/loader/cache/CachedResource.h +++ b/Source/WebCore/loader/cache/CachedResource.h @@ -127,6 +127,7 @@ public: bool isLoading() const { return m_loading; } void setLoading(bool b) { m_loading = b; } + virtual bool stillNeedsLoad() const { return false; } virtual bool isImage() const { return false; } bool isLinkResource() const diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp index 38fcee4..91c0629 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp @@ -138,14 +138,21 @@ CachedImage* CachedResourceLoader::requestImage(const String& url) } } CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, url, String())); - if (autoLoadImages() && resource && resource->stillNeedsLoad()) { + if (resource) { #ifdef ANDROID_BLOCK_NETWORK_IMAGE - if (shouldBlockNetworkImage(url)) { - return resource; - } + resource->setAutoLoadWasPreventedBySettings(!autoLoadImages() || shouldBlockNetworkImage(url)); +#else + resource->setAutoLoadWasPreventedBySettings(!autoLoadImages()); +#endif + if (autoLoadImages() && resource->stillNeedsLoad()) { +#ifdef ANDROID_BLOCK_NETWORK_IMAGE + if (shouldBlockNetworkImage(url)) { + return resource; + } #endif - resource->setLoading(true); - load(resource, true); + resource->setLoading(true); + load(resource, true); + } } return resource; } @@ -520,9 +527,12 @@ void CachedResourceLoader::setAutoLoadImages(bool enable) if (shouldBlockNetworkImage(image->url())) continue; #endif + image->setAutoLoadWasPreventedBySettings(false); - if (image->stillNeedsLoad()) + if (image->stillNeedsLoad()) { + image->setLoading(true); load(image, true); + } } } } @@ -536,7 +546,6 @@ bool CachedResourceLoader::shouldBlockNetworkImage(const String& url) const KURL kurl = m_document->completeURL(url); if (kurl.protocolIs("http") || kurl.protocolIs("https")) return true; - return false; } @@ -555,8 +564,11 @@ void CachedResourceLoader::setBlockNetworkImage(bool block) CachedResource* resource = it->second.get(); if (resource->type() == CachedResource::ImageResource) { CachedImage* image = const_cast<CachedImage*>(static_cast<const CachedImage*>(resource)); - if (image->stillNeedsLoad()) + image->setAutoLoadWasPreventedBySettings(false); + if (image->stillNeedsLoad()) { + image->setLoading(true); load(image, true); + } } } } |