diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 772a871d2181..0b9f24f5f130 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -3043,7 +3043,6 @@ void css::ImageValue::Initialize(nsIDocument* aDocument) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(!mInitialized); // NB: If aDocument is not the original document, we may not be able to load // images from aDocument. Instead we do the image load from the original doc @@ -3053,17 +3052,15 @@ css::ImageValue::Initialize(nsIDocument* aDocument) loadingDoc = aDocument; } - loadingDoc->StyleImageLoader()->LoadImage(GetURI(), - mExtraData->GetPrincipal(), - mExtraData->GetReferrer(), this); + if (!mLoadedImage) { + loadingDoc->StyleImageLoader()->LoadImage(GetURI(), + mExtraData->GetPrincipal(), + mExtraData->GetReferrer(), this); - if (loadingDoc != aDocument) { - aDocument->StyleImageLoader()->MaybeRegisterCSSImage(this); + mLoadedImage = true; } -#ifdef DEBUG - mInitialized = true; -#endif + aDocument->StyleImageLoader()->MaybeRegisterCSSImage(this); } css::ImageValue::~ImageValue() diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index f76a47ab2d02..487f1b69e5ca 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -230,9 +230,7 @@ public: nsRefPtrHashtable, imgRequestProxy> mRequests; private: -#ifdef DEBUG - bool mInitialized = false; -#endif + bool mLoadedImage = false; }; struct GridNamedArea {