Bug 514033 - Error recovery for imagelib - part 7 - Move mIsHidden check inside nsPNGDecoder::EndImageFrame.r=joe,a=blocker
authorBobby Holley <bobbyholley@gmail.com>
Sun, 12 Sep 2010 08:22:30 -0700
changeset 53667 fb21557442d39a5aa898c9d6a33df7667d9a934d
parent 53666 c2686243b32e5f430dee8fd219acdce93c602132
child 53668 f5b73f397fed5d871ddf613917fbfbe08b7aa4f1
push idunknown
push userunknown
push dateunknown
reviewersjoe, blocker
bugs514033
milestone2.0b6pre
Bug 514033 - Error recovery for imagelib - part 7 - Move mIsHidden check inside nsPNGDecoder::EndImageFrame.r=joe,a=blocker
modules/libpr0n/decoders/nsPNGDecoder.cpp
--- a/modules/libpr0n/decoders/nsPNGDecoder.cpp
+++ b/modules/libpr0n/decoders/nsPNGDecoder.cpp
@@ -189,16 +189,19 @@ void nsPNGDecoder::SetAnimFrameInfo()
   /*else // 'over' is the default
       mImage->SetFrameBlendMethod(numFrames - 1, RasterImage::kBlendOver); */
 }
 #endif
 
 // set timeout and frame disposal method for the current frame
 void nsPNGDecoder::EndImageFrame()
 {
+  if (mFrameIsHidden)
+    return;
+
   PRUint32 numFrames = 1;
 #ifdef PNG_APNG_SUPPORTED
   numFrames = mImage->GetNumFrames();
 
   // We can't use mPNG->num_frames_read as it may be one ahead.
   if (numFrames > 1) {
     // Tell the image renderer that the frame is complete
     if (mFrameHasNoAlpha)
@@ -367,18 +370,17 @@ nsPNGDecoder::WriteInternal(const char *
 
 void
 nsPNGDecoder::NotifyDone(PRBool aSuccess)
 {
   // We should only be called once
   NS_ABORT_IF_FALSE(!mNotifiedDone, "Calling NotifyDone twice!");
 
   // Notify
-  if (!mFrameIsHidden)
-    EndImageFrame();
+  EndImageFrame();
   if (aSuccess)
     mImage->DecodingComplete();
   if (mObserver) {
     mObserver->OnStopContainer(nsnull, mImage);
     mObserver->OnStopDecode(nsnull, aSuccess ? NS_OK : NS_ERROR_FAILURE,
                             nsnull);
   }
 
@@ -813,19 +815,19 @@ nsPNGDecoder::frame_info_callback(png_st
 #ifdef PNG_APNG_SUPPORTED
   png_uint_32 x_offset, y_offset;
   PRInt32 width, height;
 
   nsPNGDecoder *decoder =
                static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
 
   // old frame is done
-  if (!decoder->mFrameIsHidden)
-    decoder->EndImageFrame();
+  decoder->EndImageFrame();
 
+  // Only the first frame can be hidden, so unhide unconditionally here.
   decoder->mFrameIsHidden = PR_FALSE;
 
   x_offset = png_get_next_frame_x_offset(png_ptr, decoder->mInfo);
   y_offset = png_get_next_frame_y_offset(png_ptr, decoder->mInfo);
   width = png_get_next_frame_width(png_ptr, decoder->mInfo);
   height = png_get_next_frame_height(png_ptr, decoder->mInfo);
 
   decoder->CreateFrame(x_offset, y_offset, width, height, decoder->format);