Bug 222176 - Animated GIF loops 1 time too many; r=bholly,joe a=joe
authorMax Stepin <newstop@gmail.com>
Fri, 21 Jan 2011 15:18:01 -0500
changeset 61111 8f8108abcff2be98d287d9b934d33cff428bbba3
parent 61110 7699976cd9defa01295252999f9af0a96ea75cca
child 61112 ddd42df9beb7d5ed80180f52cd9ba1507f71e4da
push idunknown
push userunknown
push dateunknown
reviewersbholly, joe, joe
bugs222176
milestone2.0b10pre
Bug 222176 - Animated GIF loops 1 time too many; r=bholly,joe a=joe
modules/libpr0n/decoders/nsGIFDecoder2.cpp
--- a/modules/libpr0n/decoders/nsGIFDecoder2.cpp
+++ b/modules/libpr0n/decoders/nsGIFDecoder2.cpp
@@ -141,17 +141,17 @@ nsGIFDecoder2::FinishInternal()
   // If the GIF got cut off, handle it anyway
   if (!IsSizeDecode() && mGIFOpen) {
     if (mCurrentFrame == mGIFStruct.images_decoded)
       EndImageFrame();
     PostDecodeDone();
     mGIFOpen = PR_FALSE;
   }
 
-  mImage->SetLoopCount(mGIFStruct.loop_count);
+  mImage->SetLoopCount(mGIFStruct.loop_count - 1);
 }
 
 // Push any new rows according to mCurrentPass/mLastFlushedPass and
 // mCurrentRow/mLastFlushedRow.  Note: caller is responsible for
 // updating mlastFlushed{Row,Pass}.
 void
 nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows)
 {
@@ -866,21 +866,16 @@ nsGIFDecoder2::WriteInternal(const char 
 
     /* Parse netscape-specific application extensions */
     case gif_consume_netscape_extension:
       switch (q[0] & 7) {
         case 1:
           /* Loop entire animation specified # of times.  Only read the
              loop count during the first iteration. */
           mGIFStruct.loop_count = GETINT16(q + 1);
-  
-          /* Zero loop count is infinite animation loop request */
-          if (mGIFStruct.loop_count == 0)
-            mGIFStruct.loop_count = -1;
-  
           GETN(1, gif_netscape_extension_block);
           break;
         
         case 2:
           /* Wait for specified # of bytes to enter buffer */
           // Don't do this, this extension doesn't exist (isn't used at all) 
           // and doesn't do anything, as our streaming/buffering takes care of it all...
           // See: http://semmix.pl/color/exgraf/eeg24.htm