diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 92bf7c80516..72c0efc5d35 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -723,10 +723,24 @@ nsHTMLImageElement::SetSrc(const nsAString& aSrc) } } + nsCOMPtr oldCurrentRequest = mCurrentRequest; + // Call ImageURIChanged first so that our image load will kick off // before the SetAttr triggers a reflow ImageURIChanged(aSrc); + if (mCurrentRequest && !mPendingRequest && + oldCurrentRequest != mCurrentRequest) { + // We have a current request, and it's not the same one as we used + // to have, and we have no pending request. So imglib already had + // that image. Reset the animation on it -- see bug 210001 + nsCOMPtr container; + mCurrentRequest->GetImage(getter_AddRefs(container)); + if (container) { + container->ResetAnimation(); + } + } + return nsGenericHTMLLeafElement::SetAttr(kNameSpaceID_None, nsHTMLAtoms::src, aSrc, PR_TRUE); } diff --git a/mozilla/layout/base/nsImageLoader.cpp b/mozilla/layout/base/nsImageLoader.cpp index 743b8bf52bf..b14979c542a 100644 --- a/mozilla/layout/base/nsImageLoader.cpp +++ b/mozilla/layout/base/nsImageLoader.cpp @@ -141,6 +141,8 @@ NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest, * one loop = 2 */ aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + aImage->StartAnimation(); } return NS_OK; } diff --git a/mozilla/layout/base/src/nsImageLoader.cpp b/mozilla/layout/base/src/nsImageLoader.cpp index 743b8bf52bf..b14979c542a 100644 --- a/mozilla/layout/base/src/nsImageLoader.cpp +++ b/mozilla/layout/base/src/nsImageLoader.cpp @@ -141,6 +141,8 @@ NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest, * one loop = 2 */ aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + aImage->StartAnimation(); } return NS_OK; } diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp index 9e22f338e59..c02c078e9dd 100644 --- a/mozilla/layout/generic/nsBulletFrame.cpp +++ b/mozilla/layout/generic/nsBulletFrame.cpp @@ -1711,6 +1711,12 @@ NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, } } + // Handle animations + aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + aImage->StartAnimation(); + + return NS_OK; } diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index fcdd1d5e30f..c9f33bef293 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -329,11 +329,14 @@ nsImageFrame::Init(nsIPresContext* aPresContext, } // If we already have an image container, OnStartContainer won't be called // Set the animation mode here - nsCOMPtr image; if (currentRequest) { + nsCOMPtr image; currentRequest->GetImage(getter_AddRefs(image)); - if (image) + if (image) { image->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + image->StartAnimation(); + } } return rv; @@ -538,6 +541,8 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) * one loop = 2 */ aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + aImage->StartAnimation(); if (IsPendingLoad(aRequest)) { // We don't care diff --git a/mozilla/layout/html/base/src/nsBulletFrame.cpp b/mozilla/layout/html/base/src/nsBulletFrame.cpp index 9e22f338e59..c02c078e9dd 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.cpp +++ b/mozilla/layout/html/base/src/nsBulletFrame.cpp @@ -1711,6 +1711,12 @@ NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, } } + // Handle animations + aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + aImage->StartAnimation(); + + return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index fcdd1d5e30f..c9f33bef293 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -329,11 +329,14 @@ nsImageFrame::Init(nsIPresContext* aPresContext, } // If we already have an image container, OnStartContainer won't be called // Set the animation mode here - nsCOMPtr image; if (currentRequest) { + nsCOMPtr image; currentRequest->GetImage(getter_AddRefs(image)); - if (image) + if (image) { image->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + image->StartAnimation(); + } } return rv; @@ -538,6 +541,8 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) * one loop = 2 */ aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); + // Ensure the animation (if any) is started. + aImage->StartAnimation(); if (IsPendingLoad(aRequest)) { // We don't care diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index ce924c818aa..ab6d4a219fc 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -724,6 +724,9 @@ NS_IMETHODIMP nsImageBoxFrame::OnStartContainer(imgIRequest *request, // If we have no prescontext, what's going on? NS_ENSURE_TRUE(mPresContext, NS_ERROR_UNEXPECTED); + // Ensure the animation (if any) is started + image->StartAnimation(); + mHasImage = PR_TRUE; mSizeFrozen = PR_FALSE; diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index b08bb6e2e4f..d238bd034d1 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -3904,6 +3904,8 @@ NS_IMETHODIMP nsTreeImageListener::OnStartDecode(imgIRequest *aRequest) NS_IMETHODIMP nsTreeImageListener::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) { + // Ensure the animation (if any) is started + aImage->StartAnimation(); return NS_OK; } diff --git a/mozilla/modules/libpr0n/src/imgRequest.cpp b/mozilla/modules/libpr0n/src/imgRequest.cpp index 55b8f5fa8b3..9313255fa00 100644 --- a/mozilla/modules/libpr0n/src/imgRequest.cpp +++ b/mozilla/modules/libpr0n/src/imgRequest.cpp @@ -223,10 +223,9 @@ nsresult imgRequest::NotifyProxyListener(imgRequestProxy *proxy) proxy->OnStopDecode(GetResultFromImageStatus(mImageStatus), nsnull); if (mImage && (mObservers.Count() == 1)) { - LOG_MSG(gImgLog, "imgRequest::AddProxy", "starting animation"); + LOG_MSG(gImgLog, "imgRequest::AddProxy", "resetting animation"); mImage->ResetAnimation(); - mImage->StartAnimation(); } if (mState & onStopRequest) {