Ejemplo n.º 1
0
bool StyleSheetContents::loadCompleted() const {
    StyleSheetContents* parentSheet = parentStyleSheet();
    if (parentSheet)
        return parentSheet->loadCompleted();

    StyleSheetContents* root = rootStyleSheet();
    return root->m_loadingClients.isEmpty();
}
Ejemplo n.º 2
0
void StyleRuleImport::requestStyleSheet(CSSStyleSheet* rootSheet, const CSSParserContext& parserContext)
{
    ASSERT(!rootSheet->parentStyleSheet());
    ASSERT(!m_cachedSheet);

    Node* ownerNode = rootSheet->ownerNode();
    if (!ownerNode)
        return;
    Document* document = ownerNode->document();

    KURL resolvedURL;
    if (!parserContext.baseURL.isNull())
        resolvedURL = KURL(parserContext.baseURL, m_strHref);
    else
        resolvedURL = document->completeURL(m_strHref);

    StyleSheetContents* rootSheetContents = rootSheet->contents();
    if (rootSheetContents->hasImportCycle(this, resolvedURL, document->baseURL()))
        return;

    ResourceRequest request(resolvedURL);
    CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader();
    if (rootSheetContents->isUserStyleSheet())
        m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request, parserContext.charset);
    else
        m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request, parserContext.charset);

    if (!m_cachedSheet)
        return;
    // 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 (rootSheetContents->loadCompleted())
        ownerNode->startLoadingDynamicSheet();

    m_loadContext = adoptPtr(new LoadContext(rootSheet, parserContext));
    m_cachedSheet->addClient(this);
}