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); } }
void StyleRuleImport::requestStyleSheet() { if (!m_parentStyleSheet) return; Document* document = m_parentStyleSheet->singleOwnerDocument(); if (!document) return; ResourceFetcher* fetcher = document->fetcher(); if (!fetcher) return; KURL absURL; if (!m_parentStyleSheet->baseURL().isNull()) { // use parent styleheet's URL as the base URL absURL = KURL(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; } FetchRequest request(ResourceRequest(absURL), FetchInitiatorTypeNames::css, m_parentStyleSheet->charset()); m_resource = CSSStyleSheetResource::fetch(request, fetcher); if (m_resource) { // 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_resource->addClient(m_styleSheetClient); } }