Bug 756367 - Reset animation of image requests when they become the current request instead of when they finish loading. r=bz

This commit is contained in:
Robert Lickenbrock 2012-06-13 21:12:37 -04:00
parent 6105e338ad
commit dede1348c8
2 changed files with 21 additions and 8 deletions

View File

@ -272,14 +272,6 @@ nsImageLoadingContent::OnStopDecode(imgIRequest* aRequest,
NS_ABORT_IF_FALSE(aRequest == mCurrentRequest,
"One way or another, we should be current by now");
if (mCurrentRequestNeedsResetAnimation) {
nsCOMPtr<imgIContainer> container;
mCurrentRequest->GetImage(getter_AddRefs(container));
if (container)
container->ResetAnimation();
mCurrentRequestNeedsResetAnimation = false;
}
// We just loaded all the data we're going to get. If we're visible and
// haven't done an initial paint (*), we want to make sure the image starts
// decoding immediately, for two reasons:
@ -579,6 +571,7 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
getter_AddRefs(req));
if (NS_SUCCEEDED(rv)) {
TrackImage(req);
ResetAnimationIfNeeded();
} else {
// If we don't have a current URI, we might as well store this URI so people
// know what we tried (and failed) to load.
@ -746,6 +739,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
getter_AddRefs(req));
if (NS_SUCCEEDED(rv)) {
TrackImage(req);
ResetAnimationIfNeeded();
// Handle cases when we just ended up with a pending request but it's
// already done. In that situation we have to synchronously switch that
@ -1028,6 +1022,7 @@ nsImageLoadingContent::MakePendingRequestCurrent()
mPendingRequest = nsnull;
mCurrentRequestNeedsResetAnimation = mPendingRequestNeedsResetAnimation;
mPendingRequestNeedsResetAnimation = false;
ResetAnimationIfNeeded();
}
void
@ -1093,6 +1088,18 @@ nsImageLoadingContent::GetRegisteredFlagForRequest(imgIRequest* aRequest)
}
}
void
nsImageLoadingContent::ResetAnimationIfNeeded()
{
if (mCurrentRequest && mCurrentRequestNeedsResetAnimation) {
nsCOMPtr<imgIContainer> container;
mCurrentRequest->GetImage(getter_AddRefs(container));
if (container)
container->ResetAnimation();
mCurrentRequestNeedsResetAnimation = false;
}
}
bool
nsImageLoadingContent::HaveSize(imgIRequest *aImage)
{

View File

@ -285,6 +285,12 @@ protected:
*/
bool* GetRegisteredFlagForRequest(imgIRequest* aRequest);
/**
* Reset animation of the current request if |mNewRequestsWillNeedAnimationReset|
* was true when the request was prepared.
*/
void ResetAnimationIfNeeded();
/**
* Static helper method to tell us if we have the size of a request. The
* image may be null.