--- a/webengine/osswebengine/WebCore/loader/DocLoader.cpp Fri May 08 08:25:06 2009 +0300
+++ b/webengine/osswebengine/WebCore/loader/DocLoader.cpp Fri Jul 03 15:54:40 2009 +0100
@@ -62,6 +62,7 @@
for (HashMap<String, CachedResource*>::iterator it = m_docResources.begin(); it != end; ++it)
it->second->setDocLoader(0);
m_cache->removeDocLoader(this);
+ m_reloadedURLs.clear();
}
void DocLoader::checkForReload(const KURL& fullURL)
@@ -99,7 +100,7 @@
CachedImage* DocLoader::requestImage(const String& url)
{
- CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, url));
+ CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, url, String()));
if (autoLoadImages() && resource && resource->stillNeedsLoad()) {
resource->setLoading(true);
cache()->loader()->load(this, resource, true);
@@ -107,50 +108,39 @@
return resource;
}
-CachedCSSStyleSheet* DocLoader::requestCSSStyleSheet(const String& url, const String& charset, bool isUserStyleSheet)
+CachedCSSStyleSheet* DocLoader::requestCSSStyleSheet(const String& url, const String& charset)
{
- // FIXME: Passing true for "skipCanLoadCheck" here in the isUserStyleSheet case won't have any effect
- // if this resource is already in the cache. It's theoretically possible that what's in the cache already
- // is a load that failed because of the canLoad check. Probably not an issue in practice.
- CachedCSSStyleSheet *sheet = static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, url, &charset, isUserStyleSheet, !isUserStyleSheet));
-
- // A user style sheet can outlive its DocLoader so don't store any pointers to it
- if (sheet && isUserStyleSheet) {
- sheet->setDocLoader(0);
- m_docResources.remove(sheet->url());
- }
-
- return sheet;
+ return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, url, charset));
}
CachedCSSStyleSheet* DocLoader::requestUserCSSStyleSheet(const String& url, const String& charset)
{
- return requestCSSStyleSheet(url, charset, true);
+ return cache()->requestUserCSSStyleSheet(this, url, charset);
}
CachedScript* DocLoader::requestScript(const String& url, const String& charset)
{
- return static_cast<CachedScript*>(requestResource(CachedResource::Script, url, &charset));
+ return static_cast<CachedScript*>(requestResource(CachedResource::Script, url, charset));
}
#if ENABLE(XSLT)
CachedXSLStyleSheet* DocLoader::requestXSLStyleSheet(const String& url)
{
- return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, url));
+ return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, url, String()));
}
#endif
#if ENABLE(XBL)
CachedXBLDocument* DocLoader::requestXBLDocument(const String& url)
{
- return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XBL, url));
+ return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XBL, url, String()));
}
#endif
#if PRELOAD_SCANNER_ENABLED
-CachedResource* DocLoader::requestResource(CachedResource::Type type, const String& url, const String* charset, bool skipCanLoadCheck, bool sendResourceLoadCallbacks, bool isPreload)
+CachedResource* DocLoader::requestResource(CachedResource::Type type, const String& url, const String& charset, bool isPreload)
#else
-CachedResource* DocLoader::requestResource(CachedResource::Type type, const String& url, const String* charset, bool skipCanLoadCheck, bool sendResourceLoadCallbacks)
+CachedResource* DocLoader::requestResource(CachedResource::Type type, const String& url, const String& charset)
#endif
{
KURL fullURL = m_doc->completeURL(url.deprecatedString());
@@ -170,9 +160,9 @@
checkForReload(fullURL);
#if PRELOAD_SCANNER_ENABLED
- CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, skipCanLoadCheck, sendResourceLoadCallbacks, isPreload);
+ CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload);
#else
- CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, skipCanLoadCheck, sendResourceLoadCallbacks);
+ CachedResource* resource = cache()->requestResource(this, type, fullURL, charset);
#endif
if (resource) {
m_docResources.set(resource->url(), resource);
@@ -276,7 +266,7 @@
void DocLoader::preload(CachedResource::Type type, const String& url)
{
String encoding = (type == CachedResource::Script || type == CachedResource::CSSStyleSheet) ? m_doc->frame()->loader()->encoding() : String();
- CachedResource* resource = requestResource(type, url, &encoding, true);
+ CachedResource* resource = requestResource(type, url, encoding, true);
if (!resource || m_preloads.contains(resource))
return;
resource->increasePreloadCount();
@@ -294,11 +284,17 @@
ListHashSet<CachedResource*>::iterator end = m_preloads.end();
for (ListHashSet<CachedResource*>::iterator it = m_preloads.begin(); it != end; ++it) {
CachedResource* res = *it;
- if (res->canDelete() && !res->inCache())
+ res->decreasePreloadCount();
+ if (res->canDelete())
+ {
+ if(res->inCache())
+ cache()->remove(res);
+ else
delete res;
+ }
else if (res->preloadResult() == CachedResource::PreloadNotReferenced)
cache()->remove(res);
- res->decreasePreloadCount();
+
}
m_preloads.clear();
}