From 2ac8df004709a717b7902b5fd4eacd0970d6054c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 26 Jan 2011 10:52:42 -0800 Subject: [PATCH] Bug 601723 - Fix gifs not animating on page reload. r=joe a=blocking-final --- modules/libpr0n/src/imgRequestProxy.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/libpr0n/src/imgRequestProxy.cpp b/modules/libpr0n/src/imgRequestProxy.cpp index da8fcd9dec5..948efcb5b95 100644 --- a/modules/libpr0n/src/imgRequestProxy.cpp +++ b/modules/libpr0n/src/imgRequestProxy.cpp @@ -166,12 +166,14 @@ nsresult imgRequestProxy::ChangeOwner(imgRequest *aNewOwner) for (PRUint32 i = 0; i < oldLockCount; i++) LockImage(); - // If we had animation requests, apply them here - for (PRUint32 i = 0; i < oldAnimationConsumers; i++) - IncrementAnimationConsumers(); + if (mCanceled) { + // If we had animation requests, restore them before exiting + // (otherwise we restore them later below) + for (PRUint32 i = 0; i < oldAnimationConsumers; i++) + IncrementAnimationConsumers(); - if (mCanceled) return NS_OK; + } // Were we decoded before? PRBool wasDecoded = PR_FALSE; @@ -185,6 +187,12 @@ nsresult imgRequestProxy::ChangeOwner(imgRequest *aNewOwner) // OnStopRequest, if needed. mOwner->RemoveProxy(this, NS_IMAGELIB_CHANGING_OWNER, PR_FALSE); + // If we had animation requests, restore them here. Note that we + // do this *after* RemoveProxy, which clears out animation consumers + // (see bug 601723). + for (PRUint32 i = 0; i < oldAnimationConsumers; i++) + IncrementAnimationConsumers(); + mOwner = aNewOwner; mOwner->AddProxy(this);