本文整理汇总了C++中StyleSheetContents::notifyLoadedSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ StyleSheetContents::notifyLoadedSheet方法的具体用法?C++ StyleSheetContents::notifyLoadedSheet怎么用?C++ StyleSheetContents::notifyLoadedSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StyleSheetContents
的用法示例。
在下文中一共展示了StyleSheetContents::notifyLoadedSheet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCSSStyleSheet
void LinkStyle::setCSSStyleSheet(
const String& href,
const KURL& baseURL,
const String& charset,
const CSSStyleSheetResource* cachedStyleSheet) {
if (!m_owner->isConnected()) {
// While the stylesheet is asynchronously loading, the owner can be
// disconnected from a document.
// In that case, cancel any processing on the loaded content.
m_loading = false;
removePendingSheet();
if (m_sheet)
clearSheet();
return;
}
// See the comment in PendingScript.cpp about why this check is necessary
// here, instead of in the resource fetcher. https://crbug.com/500701.
if (!cachedStyleSheet->errorOccurred() &&
!m_owner->fastGetAttribute(HTMLNames::integrityAttr).isEmpty() &&
!cachedStyleSheet->integrityMetadata().isEmpty()) {
ResourceIntegrityDisposition disposition =
cachedStyleSheet->integrityDisposition();
if (disposition == ResourceIntegrityDisposition::NotChecked &&
!cachedStyleSheet->loadFailedOrCanceled()) {
bool checkResult;
// cachedStyleSheet->resourceBuffer() can be nullptr on load success.
// If response size == 0.
const char* data = nullptr;
size_t size = 0;
if (cachedStyleSheet->resourceBuffer()) {
data = cachedStyleSheet->resourceBuffer()->data();
size = cachedStyleSheet->resourceBuffer()->size();
}
checkResult = SubresourceIntegrity::CheckSubresourceIntegrity(
*m_owner, data, size, KURL(baseURL, href), *cachedStyleSheet);
disposition = checkResult ? ResourceIntegrityDisposition::Passed
: ResourceIntegrityDisposition::Failed;
// TODO(kouhei): Remove this const_cast crbug.com/653502
const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
->setIntegrityDisposition(disposition);
}
if (disposition == ResourceIntegrityDisposition::Failed) {
m_loading = false;
removePendingSheet();
notifyLoadedSheetAndAllCriticalSubresources(
Node::ErrorOccurredLoadingSubresource);
return;
}
}
CSSParserContext parserContext(m_owner->document(), nullptr, baseURL,
charset);
DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram,
("Blink.RestoredCachedStyleSheet", 2));
DEFINE_STATIC_LOCAL(
EnumerationHistogram, restoredCachedStyleSheet2Histogram,
("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount));
if (StyleSheetContents* restoredSheet =
const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
->restoreParsedStyleSheet(parserContext)) {
DCHECK(restoredSheet->isCacheableForResource());
DCHECK(!restoredSheet->isLoading());
if (m_sheet)
clearSheet();
m_sheet = CSSStyleSheet::create(restoredSheet, *m_owner);
m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
if (m_owner->isInDocumentTree())
setSheetTitle(m_owner->title());
setCrossOriginStylesheetStatus(m_sheet.get());
m_loading = false;
restoredSheet->checkLoaded();
restoredCachedStyleSheetHistogram.count(true);
restoredCachedStyleSheet2Histogram.count(StyleSheetInMemoryCache);
return;
}
restoredCachedStyleSheetHistogram.count(false);
StyleSheetCacheStatus cacheStatus = cachedStyleSheet->response().wasCached()
? StyleSheetInDiskCache
: StyleSheetNewEntry;
restoredCachedStyleSheet2Histogram.count(cacheStatus);
StyleSheetContents* styleSheet =
StyleSheetContents::create(href, parserContext);
if (m_sheet)
clearSheet();
m_sheet = CSSStyleSheet::create(styleSheet, *m_owner);
m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
if (m_owner->isInDocumentTree())
//.........这里部分代码省略.........