Bug 418791 - "Don't try to discard image data when the image is animating" (Don't start the timer when image is animating) [p=alfredkayser@gmail.com (Alfred Kayser) r=stuart a=blocking1.9+]

This commit is contained in:
reed@reedloden.com 2008-03-09 12:58:40 -07:00
parent ca72c859b7
commit 6f1799c430

View File

@ -652,6 +652,8 @@ NS_IMETHODIMP imgContainer::RestoreDataDone (void)
/* void notify(in nsITimer timer); */
NS_IMETHODIMP imgContainer::Notify(nsITimer *timer)
{
// Note that as long as the image is animated, it will not be discarded,
// so this should never happen...
nsresult rv = RestoreDiscardedData();
NS_ENSURE_SUCCESS(rv, rv);
@ -661,7 +663,7 @@ NS_IMETHODIMP imgContainer::Notify(nsITimer *timer)
NS_ASSERTION(mAnim->timer == timer,
"imgContainer::Notify() called with incorrect timer");
if (!(mAnim->animating) || !(mAnim->timer))
if (!mAnim->animating || !mAnim->timer)
return NS_OK;
nsCOMPtr<imgIContainerObserver> observer(do_QueryReferent(mObserver));
@ -1305,15 +1307,23 @@ imgContainer::sDiscardTimerCallback(nsITimer *aTimer, void *aClosure)
nsresult
imgContainer::ResetDiscardTimer (void)
{
if (!DiscardingEnabled())
if (!mRestoreDataDone)
return NS_OK;
if (mDiscardTimer) {
/* Cancel current timer */
nsresult rv = mDiscardTimer->Cancel();
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
mDiscardTimer = nsnull;
}
/* Don't activate timer when we are animating... */
if (mAnim && mAnim->animating)
return NS_OK;
if (!mDiscardTimer) {
mDiscardTimer = do_CreateInstance("@mozilla.org/timer;1");
NS_ENSURE_TRUE(mDiscardTimer, NS_ERROR_OUT_OF_MEMORY);
} else {
nsresult rv = mDiscardTimer->Cancel();
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
}
return mDiscardTimer->InitWithFuncCallback(sDiscardTimerCallback,