Bug 1291283 - Use URLValueData::GetLocalURLFlag() to identify local-ref URI.
MozReview-Commit-ID: 2tXEGMhPCkn
--- a/layout/style/nsCSSDataBlock.cpp
+++ b/layout/style/nsCSSDataBlock.cpp
@@ -64,19 +64,34 @@ TryToStartImageLoadOnValue(const nsCSSVa
#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) {
- nsIURI* docURI = aDocument->GetDocumentURI();
+ // 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