void CachedResourceLoader::reloadImagesIfNotDeferred() { DocumentResourceMap::iterator end = m_documentResources.end(); for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) { CachedResource* resource = it->value.get(); if (resource->type() == CachedResource::ImageResource && resource->stillNeedsLoad() && !clientDefersImage(resource->url())) const_cast<CachedResource*>(resource)->load(this, defaultCachedResourceOptions()); } }
CachedImage* CachedResourceLoader::requestImage(ResourceRequest& request) { if (Frame* f = frame()) { if (f->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoDismissal) { KURL requestURL = request.url(); if (requestURL.isValid() && canRequest(CachedResource::ImageResource, requestURL)) PingLoader::loadImage(f, requestURL); return 0; } } CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, request, String(), defaultCachedResourceOptions())); if (autoLoadImages() && resource && resource->stillNeedsLoad()) resource->load(this, defaultCachedResourceOptions()); return resource; }
void CachedResourceLoader::requestPreload(CachedResource::Type type, ResourceRequest& request, const String& charset) { String encoding; if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet) encoding = charset.isEmpty() ? m_document->charset() : charset; CachedResource* resource = requestResource(type, request, encoding, defaultCachedResourceOptions(), ResourceLoadPriorityUnresolved, true); if (!resource || (m_preloads && m_preloads->contains(resource))) return; resource->increasePreloadCount(); if (!m_preloads) m_preloads = adoptPtr(new ListHashSet<CachedResource*>); m_preloads->add(resource); #if PRELOAD_DEBUG printf("PRELOADING %s\n", resource->url().latin1().data()); #endif }
void CachedResourceLoader::setAutoLoadImages(bool enable) { if (enable == m_autoLoadImages) return; m_autoLoadImages = enable; if (!m_autoLoadImages) return; DocumentResourceMap::iterator end = m_documentResources.end(); for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) { CachedResource* resource = it->second.get(); if (resource->type() == CachedResource::ImageResource) { CachedImage* image = const_cast<CachedImage*>(static_cast<const CachedImage*>(resource)); if (image->stillNeedsLoad()) image->load(this, defaultCachedResourceOptions()); } } }
CachedResource* CachedResourceLoader::requestLinkResource(CachedResource::Type type, ResourceRequest& request, ResourceLoadPriority priority) { ASSERT(frame()); ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkPrerender || type == CachedResource::LinkSubresource); return requestResource(type, request, String(), defaultCachedResourceOptions(), priority); }
CachedXSLStyleSheet* CachedResourceLoader::requestXSLStyleSheet(ResourceRequest& request) { return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, request, String(), defaultCachedResourceOptions())); }
CachedScript* CachedResourceLoader::requestScript(ResourceRequest& request, const String& charset) { return static_cast<CachedScript*>(requestResource(CachedResource::Script, request, charset, defaultCachedResourceOptions())); }
CachedCSSStyleSheet* CachedResourceLoader::requestCSSStyleSheet(ResourceRequest& request, const String& charset, ResourceLoadPriority priority) { return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, request, charset, defaultCachedResourceOptions(), priority)); }
CachedShader* CachedResourceLoader::requestShader(ResourceRequest& request) { return static_cast<CachedShader*>(requestResource(CachedResource::ShaderResource, request, String(), defaultCachedResourceOptions())); }
CachedTextTrack* CachedResourceLoader::requestTextTrack(ResourceRequest& request) { return static_cast<CachedTextTrack*>(requestResource(CachedResource::TextTrackResource, request, String(), defaultCachedResourceOptions())); }
CachedFont* CachedResourceLoader::requestFont(ResourceRequest& request) { return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, request, String(), defaultCachedResourceOptions())); }