Bug 516334: Track image decode notifications to send correct notifications to late-coming consumers (Tp4 orange fix). r=joe

This commit is contained in:
Bobby Holley 2009-12-14 10:35:47 +00:00
Родитель 1f63142174
Коммит e36296240f
2 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -190,11 +190,15 @@ nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus, PRBoo
*/
if (aNotify) {
// The "real" OnStopDecode - fix this with bug 505385.
if (!(mState & stateDecodeStopped)) {
proxy->OnStopContainer(mImage);
}
// make sure that observer gets an OnStopDecode message sent to it
if (!(mState & stateRequestStopped)) {
proxy->OnStopDecode(aStatus, nsnull);
}
}
// make sure that observer gets an OnStopRequest message sent to it
@ -295,8 +299,11 @@ nsresult imgRequest::NotifyProxyListener(imgRequestProxy *proxy)
mImage->ResetAnimation();
}
if (mState & stateRequestStopped) {
// The "real" OnStopDecode - Fix this with bug 505385.
if (mState & stateDecodeStopped)
proxy->OnStopContainer(mImage);
if (mState & stateRequestStopped) {
proxy->OnStopDecode(GetResultFromImageStatus(mImageStatus), nsnull);
proxy->OnStopRequest(nsnull, nsnull,
GetResultFromImageStatus(mImageStatus),
@ -651,6 +658,10 @@ NS_IMETHODIMP imgRequest::OnStopContainer(imgIRequest *request,
{
LOG_SCOPE(gImgLog, "imgRequest::OnStopContainer");
// XXXbholley - This should be moved into OnStopDecode when we fix bug
// 505385.
mState |= stateDecodeStopped;
nsTObserverArray<imgRequestProxy*>::ForwardIterator iter(mObservers);
while (iter.HasMore()) {
iter.GetNext()->OnStopContainer(image);
@ -700,7 +711,7 @@ NS_IMETHODIMP imgRequest::OnStopRequest(imgIRequest *aRequest,
NS_IMETHODIMP imgRequest::OnDiscard(imgIRequest *aRequest)
{
// Clear the state bits we no longer deserve.
PRUint32 stateBitsToClear = stateDecodeStarted;
PRUint32 stateBitsToClear = stateDecodeStarted | stateDecodeStopped;
mState &= ~stateBitsToClear;
// Clear the status bits we no longer deserve.
@ -750,6 +761,7 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
mImageStatus &= ~imgIRequest::STATUS_FRAME_COMPLETE;
mState &= ~stateRequestStarted;
mState &= ~stateDecodeStarted;
mState &= ~stateDecodeStopped;
mState &= ~stateRequestStopped;
}

Просмотреть файл

@ -71,6 +71,7 @@ enum {
stateRequestStarted = PR_BIT(0),
stateHasSize = PR_BIT(1),
stateDecodeStarted = PR_BIT(2),
stateDecodeStopped = PR_BIT(3),
stateRequestStopped = PR_BIT(4)
};