本文整理汇总了C++中CachedResourceLoader类的典型用法代码示例。如果您正苦于以下问题:C++ CachedResourceLoader类的具体用法?C++ CachedResourceLoader怎么用?C++ CachedResourceLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CachedResourceLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openFunc
static void* openFunc(const char* uri)
{
ASSERT(XMLDocumentParserScope::currentCachedResourceLoader);
ASSERT(currentThread() == libxmlLoaderThread);
KURL url(KURL(), uri);
if (!shouldAllowExternalLoad(url))
return &globalDescriptor;
ResourceError error;
ResourceResponse response;
Vector<char> data;
{
CachedResourceLoader* cachedResourceLoader = XMLDocumentParserScope::currentCachedResourceLoader;
XMLDocumentParserScope scope(0);
// FIXME: We should restore the original global error handler as well.
if (cachedResourceLoader->frame())
cachedResourceLoader->frame()->loader()->loadResourceSynchronously(url, AllowStoredCredentials, error, response, data);
}
// We have to check the URL again after the load to catch redirects.
// See <https://bugs.webkit.org/show_bug.cgi?id=21963>.
if (!shouldAllowExternalLoad(response.url()))
return &globalDescriptor;
return new OffsetBuffer(data);
}
示例2: cancelLoad
bool TextTrackLoader::load(const KURL& url, const String& crossOriginMode)
{
cancelLoad();
if (!m_client->shouldLoadCues(this))
return false;
ASSERT(m_scriptExecutionContext->isDocument());
Document* document = static_cast<Document*>(m_scriptExecutionContext);
ResourceRequest cueRequest(document->completeURL(url));
if (!crossOriginMode.isNull()) {
m_crossOriginMode = crossOriginMode;
StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
updateRequestForAccessControl(cueRequest, document->securityOrigin(), allowCredentials);
} else {
// Cross-origin resources that are not suitably CORS-enabled may not load.
if (!document->securityOrigin()->canRequest(url)) {
corsPolicyPreventedLoad();
return false;
}
}
CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
m_cachedCueData = cachedResourceLoader->requestTextTrack(cueRequest);
if (m_cachedCueData)
m_cachedCueData->addClient(this);
m_client->cueLoadingStarted(this);
return true;
}
示例3: garbageCollectDocumentResources
void Internals::garbageCollectDocumentResources(Document* document, ExceptionCode& ec) const
{
if (!document) {
ec = INVALID_ACCESS_ERR;
return;
}
CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
if (!cachedResourceLoader)
return;
cachedResourceLoader->garbageCollectDocumentResources();
}
示例4:
std::pair<CachedImage*, float> CSSCursorImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
{
if (is<CSSImageSetValue>(m_imageValue.get()))
return downcast<CSSImageSetValue>(m_imageValue.get()).loadBestFitImage(loader, options);
if (auto* cursorElement = updateCursorElement(*loader.document())) {
if (cursorElement->href() != downcast<CSSImageValue>(m_imageValue.get()).url())
m_imageValue = CSSImageValue::create(loader.document()->completeURL(cursorElement->href()));
}
return { downcast<CSSImageValue>(m_imageValue.get()).loadImage(loader, options), 1 };
}
示例5: beginLoadTimerFired
void CSSFontSelector::beginLoadTimerFired(Timer<WebCore::CSSFontSelector>*)
{
Vector<CachedResourceHandle<CachedFont> > fontsToBeginLoading;
fontsToBeginLoading.swap(m_fontsToBeginLoading);
CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader();
for (size_t i = 0; i < fontsToBeginLoading.size(); ++i) {
fontsToBeginLoading[i]->beginLoadIfNeeded(cachedResourceLoader);
// Balances incrementRequestCount() in beginLoadingFontSoon().
cachedResourceLoader->decrementRequestCount(fontsToBeginLoading[i].get());
}
// Ensure that if the request count reaches zero, the frame loader will know about it.
cachedResourceLoader->loadDone();
}
示例6: load
void CachedImage::load(CachedResourceLoader& cachedResourceLoader, const ResourceLoaderOptions& options)
{
if (cachedResourceLoader.shouldPerformImageLoad(url()))
CachedResource::load(cachedResourceLoader, options);
else
setLoading(false);
}
示例7: requestStyleSheet
void StyleRuleImport::requestStyleSheet()
{
if (!m_parentStyleSheet)
return;
Document* document = m_parentStyleSheet->singleOwnerDocument();
if (!document)
return;
CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
if (!cachedResourceLoader)
return;
URL absURL;
if (!m_parentStyleSheet->baseURL().isNull())
// use parent styleheet's URL as the base URL
absURL = URL(m_parentStyleSheet->baseURL(), m_strHref);
else
absURL = document->completeURL(m_strHref);
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
StyleSheetContents* rootSheet = m_parentStyleSheet;
for (StyleSheetContents* sheet = m_parentStyleSheet; sheet; sheet = sheet->parentStyleSheet()) {
if (equalIgnoringFragmentIdentifier(absURL, sheet->baseURL())
|| equalIgnoringFragmentIdentifier(absURL, document->completeURL(sheet->originalURL())))
return;
rootSheet = sheet;
}
CachedResourceRequest request(ResourceRequest(absURL), m_parentStyleSheet->charset());
request.setInitiator(cachedResourceRequestInitiators().css);
if (m_cachedSheet)
m_cachedSheet->removeClient(&m_styleSheetClient);
if (m_parentStyleSheet->isUserStyleSheet())
m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request);
else
m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request);
if (m_cachedSheet) {
// if the import rule is issued dynamically, the sheet may be
// removed from the pending sheet count, so let the doc know
// the sheet being imported is pending.
if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet)
m_parentStyleSheet->startLoadingDynamicSheet();
m_loading = true;
m_cachedSheet->addClient(&m_styleSheetClient);
}
}
示例8: getAttribute
void SVGFontFaceUriElement::loadFont()
{
if (m_cachedFont)
m_cachedFont->removeClient(this);
const AtomicString& href = getAttribute(XLinkNames::hrefAttr);
if (!href.isNull()) {
CachedResourceLoader* cachedResourceLoader = document()->cachedResourceLoader();
ResourceRequest request(document()->completeURL(href));
m_cachedFont = cachedResourceLoader->requestFont(request);
if (m_cachedFont) {
m_cachedFont->addClient(this);
m_cachedFont->beginLoadIfNeeded(cachedResourceLoader);
}
} else
m_cachedFont = 0;
}
示例9: getAttribute
void SVGFontFaceUriElement::loadFont()
{
if (m_cachedFont)
m_cachedFont->removeClient(this);
String href = getAttribute(XLinkNames::hrefAttr);
if (!href.isNull()) {
CachedResourceLoader* cachedResourceLoader = document()->cachedResourceLoader();
m_cachedFont = cachedResourceLoader->requestFont(href);
if (m_cachedFont) {
m_cachedFont->setSVGFont(true);
m_cachedFont->addClient(this);
m_cachedFont->beginLoadIfNeeded(cachedResourceLoader);
}
} else
m_cachedFont = 0;
}
示例10: preload
void preload(Document* document, const KURL& baseURL)
{
if (m_urlToLoad.isEmpty())
return;
CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
CachedResourceRequest request(ResourceRequest(document->completeURL(m_urlToLoad, baseURL)));
request.setInitiator(tagName());
if (m_tagName == scriptTag) {
request.mutableResourceRequest().setAllowCookies(crossOriginModeAllowsCookies());
cachedResourceLoader->preload(CachedResource::Script, request, m_charset);
}
else if (m_tagName == imgTag || (m_tagName == inputTag && m_inputIsImage))
cachedResourceLoader->preload(CachedResource::ImageResource, request, String());
else if (m_tagName == linkTag && m_linkIsStyleSheet && m_linkMediaAttributeIsScreen)
cachedResourceLoader->preload(CachedResource::CSSStyleSheet, request, m_charset);
}
示例11: load
void CachedSVGDocumentReference::load(CachedResourceLoader& loader)
{
if (m_loadRequested)
return;
CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url)));
request.setInitiator(cachedResourceRequestInitiators().css);
m_document = loader.requestSVGDocument(request);
if (m_document) {
m_document->setCanReuse(m_canReuseResource);
m_document->addClient(this);
if (m_additionalDocumentClient)
m_document->addClient(m_additionalDocumentClient);
}
m_loadRequested = true;
}
示例12: loadSheet
void XSLImportRule::loadSheet()
{
CachedResourceLoader* cachedResourceLoader = 0;
XSLStyleSheet* rootSheet = parentStyleSheet();
if (rootSheet) {
while (XSLStyleSheet* parentSheet = rootSheet->parentStyleSheet())
rootSheet = parentSheet;
}
if (rootSheet)
cachedResourceLoader = rootSheet->cachedResourceLoader();
String absHref = m_strHref;
XSLStyleSheet* parentSheet = parentStyleSheet();
if (!parentSheet->baseURL().isNull())
// use parent styleheet's URL as the base URL
absHref = KURL(parentSheet->baseURL(), m_strHref).string();
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentSheet = parentSheet->parentStyleSheet()) {
if (absHref == parentSheet->baseURL().string())
return;
}
CachedResourceRequest request(ResourceRequest(cachedResourceLoader->document()->completeURL(absHref)));
if (m_cachedSheet)
m_cachedSheet->removeClient(this);
m_cachedSheet = cachedResourceLoader->requestXSLStyleSheet(request);
if (m_cachedSheet) {
m_cachedSheet->addClient(this);
// If the imported sheet is in the cache, then setXSLStyleSheet gets called,
// and the sheet even gets parsed (via parseString). In this case we have
// loaded (even if our subresources haven't), so if we have a stylesheet after
// checking the cache, then we've clearly loaded.
if (!m_styleSheet)
m_loading = true;
}
}
示例13: parentStyleSheet
void CSSImportRule::requestStyleSheet()
{
CSSStyleSheet* parentSheet = parentStyleSheet();
if (!parentSheet)
return;
Document* document = parentSheet->findDocument();
if (!document)
return;
CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
if (!cachedResourceLoader)
return;
String absHref = m_strHref;
if (!parentSheet->finalURL().isNull())
// use parent styleheet's URL as the base URL
absHref = KURL(parentSheet->finalURL(), m_strHref).string();
// Check for a cycle in our import chain. If we encounter a stylesheet
// in our parent chain with the same URL, then just bail.
CSSStyleSheet* rootSheet = parentSheet;
for (CSSStyleSheet* sheet = parentSheet; sheet; sheet = sheet->parentStyleSheet()) {
// FIXME: This is wrong if the finalURL was updated via document::updateBaseURL.
if (absHref == sheet->finalURL().string())
return;
rootSheet = sheet;
}
ResourceRequest request(document->completeURL(absHref));
if (parentSheet->isUserStyleSheet())
m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, parentSheet->charset());
else
m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, parentSheet->charset());
if (m_cachedSheet) {
// if the import rule is issued dynamically, the sheet may be
// removed from the pending sheet count, so let the doc know
// the sheet being imported is pending.
if (parentSheet && parentSheet->loadCompleted() && rootSheet == parentSheet)
parentSheet->startLoadingDynamicSheet();
m_loading = true;
m_cachedSheet->addClient(&m_styleSheetClient);
}
}
示例14: ASSERT
void CSSFontSelector::clearDocument()
{
if (!m_document) {
ASSERT(!m_beginLoadingTimer.isActive());
ASSERT(m_fontsToBeginLoading.isEmpty());
return;
}
m_beginLoadingTimer.stop();
CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader();
for (size_t i = 0; i < m_fontsToBeginLoading.size(); ++i) {
// Balances incrementRequestCount() in beginLoadingFontSoon().
cachedResourceLoader->decrementRequestCount(m_fontsToBeginLoading[i].get());
}
m_fontsToBeginLoading.clear();
m_document = 0;
}
示例15: protect
void CSSFontSelector::beginLoadTimerFired(Timer<WebCore::CSSFontSelector>*)
{
Vector<CachedResourceHandle<CachedFont> > fontsToBeginLoading;
fontsToBeginLoading.swap(m_fontsToBeginLoading);
// CSSFontSelector could get deleted via beginLoadIfNeeded() or loadDone() unless protected.
RefPtr<CSSFontSelector> protect(this);
CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader();
for (size_t i = 0; i < fontsToBeginLoading.size(); ++i) {
fontsToBeginLoading[i]->beginLoadIfNeeded(cachedResourceLoader);
// Balances incrementRequestCount() in beginLoadingFontSoon().
cachedResourceLoader->decrementRequestCount(fontsToBeginLoading[i].get());
}
// Ensure that if the request count reaches zero, the frame loader will know about it.
cachedResourceLoader->loadDone();
// New font loads may be triggered by layout after the document load is complete but before we have dispatched
// didFinishLoading for the frame. Make sure the delegate is always dispatched by checking explicitly.
if (m_document && m_document->frame())
m_document->frame()->loader()->checkLoadComplete();
}