bool CSSCursorImageValue::hasFragmentInURL() const { if (m_imageValue->isImageValue()) { CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); KURL kurl(ParsedURLString, imageValue->url()); return kurl.hasFragmentIdentifier(); } return false; }
StyleImage* CSSCursorImageValue::cacheImage(const Document& document, float deviceScaleFactor) { if (m_imageValue->isImageSetValue()) return toCSSImageSetValue(*m_imageValue) .cacheImage(document, deviceScaleFactor); if (m_isCachePending) { m_isCachePending = false; // For SVG images we need to lazily substitute in the correct URL. Rather // than attempt to change the URL of the CSSImageValue (which would then // change behavior like cssText), we create an alternate CSSImageValue to // use. if (hasFragmentInURL()) { CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get()); // FIXME: This will fail if the <cursor> element is in a shadow DOM // (http://crbug/59827) if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(imageValue->url(), document)) { CSSImageValue* svgImageValue = CSSImageValue::create(document.completeURL( cursorElement->href()->currentValue()->value())); svgImageValue->setReferrer(imageValue->referrer()); m_cachedImage = svgImageValue->cacheImage(document); return m_cachedImage.get(); } } if (m_imageValue->isImageValue()) m_cachedImage = toCSSImageValue(*m_imageValue).cacheImage(document); } if (m_cachedImage && m_cachedImage->isImageResource()) return toStyleFetchedImage(m_cachedImage); return nullptr; }
void CSSImageSetValue::fillImageSet() { size_t length = this->length(); size_t i = 0; while (i < length) { CSSImageValue* imageValue = toCSSImageValue(item(i)); String imageURL = imageValue->url(); ++i; ASSERT_WITH_SECURITY_IMPLICATION(i < length); CSSValue* scaleFactorValue = item(i); float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue(); ImageWithScale image; image.imageURL = imageURL; image.referrer = imageValue->referrer(); image.scaleFactor = scaleFactor; m_imagesInSet.append(image); ++i; } // Sort the images so that they are stored in order from lowest resolution to highest. std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::compareByScaleFactor); }