本文整理汇总了C++中nsCSSValue::GetURLValue方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCSSValue::GetURLValue方法的具体用法?C++ nsCSSValue::GetURLValue怎么用?C++ nsCSSValue::GetURLValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCSSValue
的用法示例。
在下文中一共展示了nsCSSValue::GetURLValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/**
* Tries to call |nsCSSValue::StartImageLoad()| on an image source.
* Image sources are specified by |url()| or |-moz-image-rect()| function.
*/
static void
TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
nsStyleContext* aContext, nsCSSPropertyID aProperty,
bool aForTokenStream)
{
MOZ_ASSERT(aDocument);
if (aValue.GetUnit() == eCSSUnit_URL) {
#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
// The 'mask-image' property accepts local reference URIs.
// For example,
// mask-image: url(#mask_id); // refer to a SVG mask element, whose id is
// // "mask_id", in the current document.
// For such 'mask-image' values (pointing to an in-document element),
// there is no need to trigger image download.
if (aProperty == eCSSProperty_mask_image) {
// Filter out all fragment URLs.
// Since nsCSSValue::GetURLStructValue runs much faster than
// nsIURI::EqualsExceptRef bellow, we get performance gain by this
// early return.
URLValue* urlValue = aValue.GetURLStructValue();
if (urlValue->GetLocalURLFlag()) {
return;
}
// Even though urlValue is not a fragment URL, it might still refer to
// an internal resource.
// For example, aDocument base URL is "http://foo/index.html" and
// intentionally references a mask-image at
// url(http://foo/index.html#mask) which still refers to a resource in
// aDocument.
nsIURI* imageURI = aValue.GetURLValue();
if (imageURI) {
nsIURI* docURI = aDocument->GetDocumentURI();
bool isEqualExceptRef = false;
nsresult rv = imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
if (NS_SUCCEEDED(rv) && isEqualExceptRef) {
return;
}
}
}
#endif
aValue.StartImageLoad(aDocument);
if (aForTokenStream && aContext) {
CSSVariableImageTable::Add(aContext, aProperty,
aValue.GetImageStructValue());
}
}
else if (aValue.GetUnit() == eCSSUnit_Image) {
// If we already have a request, see if this document needs to clone it.
imgIRequest* request = aValue.GetImageValue(nullptr);
if (request) {
ImageValue* imageValue = aValue.GetImageStructValue();
aDocument->StyleImageLoader()->MaybeRegisterCSSImage(imageValue);
if (aForTokenStream && aContext) {
CSSVariableImageTable::Add(aContext, aProperty, imageValue);
}
}
}
else if (aValue.EqualsFunction(eCSSKeyword__moz_image_rect)) {
nsCSSValue::Array* arguments = aValue.GetArrayValue();
MOZ_ASSERT(arguments->Count() == 6, "unexpected num of arguments");
const nsCSSValue& image = arguments->Item(1);
TryToStartImageLoadOnValue(image, aDocument, aContext, aProperty,
aForTokenStream);
}
}