Beispiel #1
0
PassRefPtr<StyleSheetContents> CachedCSSStyleSheet::restoreParsedStyleSheet(const CSSParserContext& context)
{
    if (!m_parsedStyleSheetCache)
        return 0;
    ASSERT(m_parsedStyleSheetCache->isCacheable());
    ASSERT(m_parsedStyleSheetCache->isInMemoryCache());

    // Contexts must be identical so we know we would get the same exact result if we parsed again.
    if (m_parsedStyleSheetCache->parserContext() != context)
        return 0;

    didAccessDecodedData(currentTime());

    return m_parsedStyleSheetCache;
}
PassRefPtr<StyleSheetInternal> CachedCSSStyleSheet::restoreParsedStyleSheet(const CSSParserContext& context)
{
    if (!m_parsedStyleSheetCache)
        return 0;
    // Cached parsed stylesheet has mutated, kick it out.
    if (!m_parsedStyleSheetCache->isCacheable()) {
        m_parsedStyleSheetCache.clear();
        setDecodedSize(0);
        return 0;
    }
    // Contexts must be identical so we know we would get the same exact result if we parsed again.
    if (m_parsedStyleSheetCache->parserContext() != context)
        return 0;

    didAccessDecodedData(currentTime());
    // FIXME: Implement copy-on-write to avoid copying when not necessary.
    return m_parsedStyleSheetCache->copy();
}
PassRefPtr<StyleSheetContents> CSSStyleSheetResource::restoreParsedStyleSheet(const CSSParserContext& context)
{
    if (!m_parsedStyleSheetCache)
        return 0;
    if (m_parsedStyleSheetCache->hasFailedOrCanceledSubresources()) {
        m_parsedStyleSheetCache->removedFromMemoryCache();
        m_parsedStyleSheetCache.clear();
        return 0;
    }

    ASSERT(m_parsedStyleSheetCache->isCacheable());
    ASSERT(m_parsedStyleSheetCache->isInMemoryCache());

    // Contexts must be identical so we know we would get the same exact result if we parsed again.
    if (m_parsedStyleSheetCache->parserContext() != context)
        return 0;

    didAccessDecodedData(currentTime());

    return m_parsedStyleSheetCache;
}