Bug 511689 - Ensure we're always on the correct frame when decoding GIF images. r=jrmuizel,alfredkeyser sr=vlad
authorJoe Drew <joe@drew.ca>
Wed, 02 Sep 2009 11:50:14 -0400
changeset 32164 1fa7bd42a36c1aee109a5968af84a6bfc8d155cd
parent 32163 a1c45ec0d5d5859a7c1628016a6aa03d51aa4c60
child 32165 14cf3892b66f47834e877b3f1238b35966967cd6
push id8889
push userjdrew@mozilla.com
push dateWed, 02 Sep 2009 15:51:09 +0000
treeherdermozilla-central@1fa7bd42a36c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, alfredkeyser, vlad
bugs511689
milestone1.9.3a1pre
Bug 511689 - Ensure we're always on the correct frame when decoding GIF images. r=jrmuizel,alfredkeyser sr=vlad
modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp
--- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp
+++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp
@@ -416,19 +416,23 @@ void nsGIFDecoder2::EndImageFrame()
     }
 
     // We actually have the timeout information before we get the lzw encoded 
     // image data, at least according to the spec, but we delay in setting the 
     // timeout for the image until here to help ensure that we have the whole 
     // image frame decoded before we go off and try to display another frame.
     mImageContainer->SetFrameTimeout(mGIFStruct.images_decoded, mGIFStruct.delay_time);
     mImageContainer->EndFrameDecode(mGIFStruct.images_decoded);
+  }
 
-    mGIFStruct.images_decoded++;
-  }
+  // Unconditionally increment images_decoded, because we unconditionally
+  // append frames in BeginImageFrame(). This ensures that images_decoded
+  // always refers to the frame in mImageContainer we're currently decoding,
+  // even if some of them weren't decoded properly and thus are blank.
+  mGIFStruct.images_decoded++;
 
   if (mObserver)
     mObserver->OnStopFrame(nsnull, curframe);
 
   // Reset the transparent pixel
   if (mOldColor) {
     mColormap[mGIFStruct.tpixel] = mOldColor;
     mOldColor = 0;