Bug 1341667 - Part 1. Keep url in nsStyleImage for local-fragment url. r=heycam
MozReview-Commit-ID: KEbO4vZXBJo
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2028,23 +2028,36 @@ nsStyleImageRequest::~nsStyleImageReques
bool
nsStyleImageRequest::Resolve(nsPresContext* aPresContext)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsResolved(), "already resolved");
MOZ_ASSERT(aPresContext);
mResolved = true;
- mDocGroup = aPresContext->Document()->GetDocGroup();
+
+ nsIDocument* doc = aPresContext->Document();
+ nsIURI* docURI = doc->GetDocumentURI();
+ if (GetImageValue()->HasRef()) {
+ bool isEqualExceptRef = false;
+ RefPtr<nsIURI> imageURI = GetImageURI();
+ imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
+ if (isEqualExceptRef) {
+ // Prevent loading an internal resource.
+ return true;
+ }
+ }
+
+ mDocGroup = doc->GetDocGroup();
// For now, just have unique nsCSSValue/ImageValue objects. We should
// really store the ImageValue on the Servo specified value, so that we can
// share imgRequestProxys that come from the same rule in the same
// document.
- mImageValue->Initialize(aPresContext->Document());
+ mImageValue->Initialize(doc);
nsCSSValue value;
value.SetImageValue(mImageValue);
mRequestProxy = value.GetPossiblyStaticImageValue(aPresContext->Document(),
aPresContext);
if (!mRequestProxy) {
// The URL resolution or image load failed.
@@ -2388,17 +2401,17 @@ nsStyleImage::IsOpaque() const
if (!IsComplete()) {
return false;
}
if (mType == eStyleImageType_Gradient) {
return mGradient->IsOpaque();
}
- if (mType == eStyleImageType_Element) {
+ if (mType == eStyleImageType_Element || mType == eStyleImageType_URL) {
return false;
}
MOZ_ASSERT(mType == eStyleImageType_Image, "unexpected image type");
MOZ_ASSERT(GetImageData(), "should've returned earlier above");
nsCOMPtr<imgIContainer> imageContainer;
GetImageData()->GetImage(getter_AddRefs(imageContainer));