зеркало из https://github.com/mozilla/pjs.git
Bug 115994 - improved MNG decoder error handling. r=pavlov, sr=blizzard
This commit is contained in:
Родитель
b1fbe56df9
Коммит
27941b6983
|
@ -116,8 +116,14 @@ imgContainerMNG::GetHeight(nscoord *aHeight)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
imgContainerMNG::GetCurrentFrame(gfxIImageFrame * *aCurrentFrame)
|
imgContainerMNG::GetCurrentFrame(gfxIImageFrame * *aCurrentFrame)
|
||||||
{
|
{
|
||||||
return mFrame->QueryInterface(NS_GET_IID(gfxIImageFrame),
|
if (mFrame) {
|
||||||
(void**)aCurrentFrame);
|
*aCurrentFrame = mFrame;
|
||||||
|
NS_ADDREF(*aCurrentFrame);
|
||||||
|
return NS_OK;
|
||||||
|
} else {
|
||||||
|
*aCurrentFrame = 0;
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
@ -125,7 +131,10 @@ imgContainerMNG::GetCurrentFrame(gfxIImageFrame * *aCurrentFrame)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
imgContainerMNG::GetNumFrames(PRUint32 *aNumFrames)
|
imgContainerMNG::GetNumFrames(PRUint32 *aNumFrames)
|
||||||
{
|
{
|
||||||
*aNumFrames = 1;
|
if (mFrame)
|
||||||
|
*aNumFrames = 1;
|
||||||
|
else
|
||||||
|
*aNumFrames = 0;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,6 +472,10 @@ il_mng_timeout_func(nsITimer *timer, void *data)
|
||||||
int ret = mng_display_resume(handle);
|
int ret = mng_display_resume(handle);
|
||||||
if (ret == MNG_NEEDMOREDATA)
|
if (ret == MNG_NEEDMOREDATA)
|
||||||
container->mResumeNeeded = PR_TRUE;
|
container->mResumeNeeded = PR_TRUE;
|
||||||
|
else if ((ret != MNG_NOERROR) &&
|
||||||
|
(ret != MNG_NEEDTIMERWAIT) &&
|
||||||
|
(ret != MNG_NEEDSECTIONWAIT))
|
||||||
|
container->mErrorPending = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static mng_bool
|
static mng_bool
|
||||||
|
@ -503,6 +516,7 @@ imgContainerMNG::InitMNG(nsMNGDecoder *decoder)
|
||||||
mBufferPtr = mBufferEnd = 0;
|
mBufferPtr = mBufferEnd = 0;
|
||||||
mBuffer = 0;
|
mBuffer = 0;
|
||||||
mResumeNeeded = PR_FALSE;
|
mResumeNeeded = PR_FALSE;
|
||||||
|
mErrorPending = PR_FALSE;
|
||||||
mTimer = 0;
|
mTimer = 0;
|
||||||
|
|
||||||
// pass mng container as user data
|
// pass mng container as user data
|
||||||
|
@ -550,15 +564,20 @@ imgContainerMNG::InitMNG(nsMNGDecoder *decoder)
|
||||||
mng_setcb_memfree(mHandle, il_mng_free);
|
mng_setcb_memfree(mHandle, il_mng_free);
|
||||||
mng_set_suspensionmode(mHandle, MNG_TRUE);
|
mng_set_suspensionmode(mHandle, MNG_TRUE);
|
||||||
|
|
||||||
if (mng_readdisplay(mHandle) == MNG_NEEDMOREDATA)
|
int ret = mng_readdisplay(mHandle);
|
||||||
|
if (ret == MNG_NEEDMOREDATA)
|
||||||
mResumeNeeded = PR_TRUE;
|
mResumeNeeded = PR_TRUE;
|
||||||
|
else if ((ret != MNG_NOERROR) &&
|
||||||
|
(ret != MNG_NEEDTIMERWAIT) &&
|
||||||
|
(ret != MNG_NEEDSECTIONWAIT))
|
||||||
|
mErrorPending = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------
|
/* ----------------------------------------------------------
|
||||||
* Process data arriving from the stream for the MNG decoder.
|
* Process data arriving from the stream for the MNG decoder.
|
||||||
*/
|
*/
|
||||||
void
|
NS_IMETHODIMP
|
||||||
imgContainerMNG::WriteMNG(nsIInputStream *inStr,
|
imgContainerMNG::WriteMNG(nsIInputStream *inStr,
|
||||||
PRInt32 count,
|
PRInt32 count,
|
||||||
PRUint32 *_retval)
|
PRUint32 *_retval)
|
||||||
|
@ -572,5 +591,14 @@ imgContainerMNG::WriteMNG(nsIInputStream *inStr,
|
||||||
int ret = mng_display_resume(mHandle);
|
int ret = mng_display_resume(mHandle);
|
||||||
if (ret == MNG_NEEDMOREDATA)
|
if (ret == MNG_NEEDMOREDATA)
|
||||||
mResumeNeeded = PR_TRUE;
|
mResumeNeeded = PR_TRUE;
|
||||||
|
else if ((ret != MNG_NOERROR) &&
|
||||||
|
(ret != MNG_NEEDTIMERWAIT) &&
|
||||||
|
(ret != MNG_NEEDSECTIONWAIT))
|
||||||
|
mErrorPending = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mErrorPending)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
else
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
imgContainerMNG();
|
imgContainerMNG();
|
||||||
virtual ~imgContainerMNG();
|
virtual ~imgContainerMNG();
|
||||||
|
|
||||||
void WriteMNG(nsIInputStream *inStr, PRInt32 count, PRUint32 *_retval);
|
NS_IMETHODIMP WriteMNG(nsIInputStream *inStr, PRInt32 count, PRUint32 *_retval);
|
||||||
void InitMNG(nsMNGDecoder *decoder);
|
void InitMNG(nsMNGDecoder *decoder);
|
||||||
|
|
||||||
nsWeakPtr mObserver;
|
nsWeakPtr mObserver;
|
||||||
|
@ -81,6 +81,7 @@ public:
|
||||||
|
|
||||||
PRPackedBool mResumeNeeded; // display_resume call needed?
|
PRPackedBool mResumeNeeded; // display_resume call needed?
|
||||||
PRPackedBool mFrozen; // animation frozen?
|
PRPackedBool mFrozen; // animation frozen?
|
||||||
|
PRPackedBool mErrorPending; // decode error to report?
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -87,7 +87,5 @@ nsMNGDecoder::WriteFrom(nsIInputStream *inStr,
|
||||||
PRUint32 count,
|
PRUint32 count,
|
||||||
PRUint32 *_retval)
|
PRUint32 *_retval)
|
||||||
{
|
{
|
||||||
NS_REINTERPRET_CAST(imgContainerMNG*, mImageContainer.get())->WriteMNG(inStr, count, _retval);
|
return NS_REINTERPRET_CAST(imgContainerMNG*, mImageContainer.get())->WriteMNG(inStr, count, _retval);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче