From dce4536c2f26c4cc172c1398a7d8fb8c5e85b22d Mon Sep 17 00:00:00 2001 From: cku Date: Thu, 4 May 2017 16:49:30 +0800 Subject: [PATCH] Bug 1310885 - Part 4. (gecko) Allow ImageValue::Intialize be called more then once, but only LoadImage in the first call. r=haycam MozReview-Commit-ID: IjL2e2LIy0f --HG-- extra : rebase_source : 7ba6688ca3ca09f30909014ecc45f182b47a3e69 extra : source : 11fbcc3d133ed19e658c297aaf07d9c96280650c --- layout/style/nsCSSValue.cpp | 15 ++++++--------- layout/style/nsCSSValue.h | 4 +--- 2 files changed, 7 insertions(+), 12 deletions(-) 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 {