void PageSerializer::retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclaration* styleDeclaration) { if (!styleDeclaration) return; CSSStyleSheet* cssStyleSheet = styleDeclaration->parentStyleSheet(); ASSERT(cssStyleSheet); // The background-image and list-style-image (for ul or ol) are the CSS properties // that make use of images. We iterate to make sure we include any other // image properties there might be. unsigned propertyCount = styleDeclaration->propertyCount(); for (unsigned i = 0; i < propertyCount; ++i) { RefPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i).value(); if (!cssValue->isImageValue()) continue; CSSImageValue* imageValue = static_cast<CSSImageValue*>(cssValue.get()); StyleImage* styleImage = imageValue->cachedOrPendingImage(); // Non cached-images are just place-holders and do not contain data. if (!styleImage || !styleImage->isCachedImage()) continue; CachedImage* image = static_cast<StyleCachedImage*>(styleImage)->cachedImage(); Document* document = cssStyleSheet->findDocument(); KURL url = document->completeURL(image->url()); addImageToResources(image, 0, url); } }
void CSSStyleSheet::styleSheetChanged() { CSSStyleSheet* rootSheet = this; while (CSSStyleSheet* parent = rootSheet->parentStyleSheet()) rootSheet = parent; /* FIXME: We don't need to do everything updateStyleSelector does, * basically we just need to recreate the document's selector with the * already existing style sheets. */ if (Document* documentToUpdate = rootSheet->findDocument()) documentToUpdate->styleSelectorChanged(DeferRecalcStyle); }
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); } }