Fix to ensure 100ms minimum when timeout is less than 100ms for animated images. Checking in for pav. r=saari, sr=me

This commit is contained in:
hyatt%netscape.com 2001-04-14 00:40:47 +00:00
Родитель 52b85e64e9
Коммит 46df562a47
3 изменённых файлов: 12 добавлений и 9 удалений

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

@ -348,7 +348,10 @@ NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
if (!mInitalized)
return NS_ERROR_NOT_INITIALIZED;
*aTimeout = mTimeout;
if (mTimeout == 0)
*aTimeout = 100; // Ensure a minimal time between updates so we don't throttle the UI thread.
else
*aTimeout = mTimeout;
return NS_OK;
}

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

@ -348,7 +348,10 @@ NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
if (!mInitalized)
return NS_ERROR_NOT_INITIALIZED;
*aTimeout = mTimeout;
if (mTimeout == 0)
*aTimeout = 100; // Ensure a minimal time between updates so we don't throttle the UI thread.
else
*aTimeout = mTimeout;
return NS_OK;
}

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

@ -174,8 +174,7 @@ NS_IMETHODIMP imgContainer::AppendFrame(gfxIImageFrame *item)
nsCOMPtr<gfxIImageFrame> currentFrame;
this->GetFrameAt(mCurrentDecodingFrameIndex, getter_AddRefs(currentFrame));
currentFrame->GetTimeout(&timeout);
if (timeout != -1 &&
timeout >= 0) { // -1 means display this frame forever
if (timeout > 0) { // -1 means display this frame forever
if(mAnimating) {
// Since we have more than one frame we need a timer
@ -216,8 +215,7 @@ NS_IMETHODIMP imgContainer::EndFrameDecode(PRUint32 aFrameNum, PRUint32 aTimeout
PRUint32 numFrames;
this->GetNumFrames(&numFrames);
if (numFrames > 1) {
if (aTimeout != -1 &&
aTimeout >= 0) { // -1 means display this frame forever
if (aTimeout > 0) { // -1 means display this frame forever
mAnimating = PR_TRUE;
mTimer = do_CreateInstance("@mozilla.org/timer;1");
@ -269,8 +267,7 @@ NS_IMETHODIMP imgContainer::StartAnimation()
this->GetCurrentFrame(getter_AddRefs(currentFrame));
if (currentFrame) {
currentFrame->GetTimeout(&timeout);
if (timeout != -1 &&
timeout >= 0) { // -1 means display this frame forever
if (timeout > 0) { // -1 means display this frame forever
mAnimating = PR_TRUE;
if(!mTimer) mTimer = do_CreateInstance("@mozilla.org/timer;1");
@ -381,7 +378,7 @@ NS_IMETHODIMP_(void) imgContainer::Notify(nsITimer *timer)
if(!nextFrame) return;
}
if(timeout >= 0)
if(timeout > 0)
mTimer->SetDelay(timeout);
else
this->StopAnimation();