Bug 529683 - Code cleanup needed in PNG decoder, r=joe
authorGlenn Randers-Pehrson <glennrp+bmo@gmail.com>
Thu, 03 Dec 2009 18:41:00 -0800
changeset 35694 b259db01f88c05a4e91331b6a0f63367ec419fd0
parent 35693 0db0a203473325dc764b6d489cc38d210ca6fdc4
child 35695 10c98bccd40bc6da00b94cd43f722390212743aa
push id10682
push userphilringnalda@gmail.com
push dateMon, 14 Dec 2009 02:11:07 +0000
treeherdermozilla-central@bc0849430750 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs529683
milestone1.9.3a1pre
Bug 529683 - Code cleanup needed in PNG decoder, r=joe
modules/libpr0n/decoders/png/nsPNGDecoder.cpp
modules/libpr0n/decoders/png/nsPNGDecoder.h
--- a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp
+++ b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp
@@ -56,25 +56,29 @@
 
 #include "nspr.h"
 #include "png.h"
 
 #include "gfxPlatform.h"
 
 static void PNGAPI info_callback(png_structp png_ptr, png_infop info_ptr);
 static void PNGAPI row_callback(png_structp png_ptr, png_bytep new_row,
-                           png_uint_32 row_num, int pass);
-static void PNGAPI frame_info_callback(png_structp png_ptr, png_uint_32 frame_num);
+                                png_uint_32 row_num, int pass);
+static void PNGAPI frame_info_callback(png_structp png_ptr,
+                                       png_uint_32 frame_num);
 static void PNGAPI end_callback(png_structp png_ptr, png_infop info_ptr);
-static void PNGAPI error_callback(png_structp png_ptr, png_const_charp error_msg);
-static void PNGAPI warning_callback(png_structp png_ptr, png_const_charp warning_msg);
+static void PNGAPI error_callback(png_structp png_ptr,
+                                  png_const_charp error_msg);
+static void PNGAPI warning_callback(png_structp png_ptr,
+                                    png_const_charp warning_msg);
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo *gPNGLog = PR_NewLogModule("PNGDecoder");
-static PRLogModuleInfo *gPNGDecoderAccountingLog = PR_NewLogModule("PNGDecoderAccounting");
+static PRLogModuleInfo *gPNGDecoderAccountingLog =
+                        PR_NewLogModule("PNGDecoderAccounting");
 #endif
 
 /* limit image dimensions (bug #251381) */
 #define MOZ_PNG_MAX_DIMENSION 1000000L
 
 // For header-only decodes
 #define WIDTH_OFFSET 16
 #define HEIGHT_OFFSET (WIDTH_OFFSET + 4)
@@ -111,17 +115,17 @@ nsPNGDecoder::~nsPNGDecoder()
     if (mTransform)
       qcms_transform_release(mTransform);
   }
   if (mHeaderBuf)
     nsMemory::Free(mHeaderBuf);
 }
 
 // CreateFrame() is used for both simple and animated images
-void nsPNGDecoder::CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset, 
+void nsPNGDecoder::CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
                                PRInt32 width, PRInt32 height,
                                gfxASurface::gfxImageFormat format)
 {
   PRUint32 imageDataLength;
   nsresult rv = mImage->AppendFrame(x_offset, y_offset, width, height, format,
                                     &mImageData, &imageDataLength);
   if (NS_FAILED(rv))
     longjmp(mPNG->jmpbuf, 5); // NS_ERROR_OUT_OF_MEMORY
@@ -136,61 +140,65 @@ void nsPNGDecoder::CreateFrame(png_uint_
 
   PRUint32 numFrames = 0;
   mImage->GetNumFrames(&numFrames);
 
   if (mObserver)
     mObserver->OnStartFrame(nsnull, numFrames - 1);
 
   PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG,
-         ("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created image frame with %dx%d pixels in container %p",
+         ("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created image"
+          " frame with %dx%d pixels in container %p",
           width, height,
           mImage.get ()));
 
   mFrameHasNoAlpha = PR_TRUE;
 }
 
 // set timeout and frame disposal method for the current frame
 void nsPNGDecoder::SetAnimFrameInfo()
 {
   png_uint_16 delay_num, delay_den;
   /* delay, in seconds is delay_num/delay_den */
   png_byte dispose_op;
   png_byte blend_op;
   PRInt32 timeout; /* in milliseconds */
-  
+
   delay_num = png_get_next_frame_delay_num(mPNG, mInfo);
   delay_den = png_get_next_frame_delay_den(mPNG, mInfo);
   dispose_op = png_get_next_frame_dispose_op(mPNG, mInfo);
   blend_op = png_get_next_frame_blend_op(mPNG, mInfo);
 
   if (delay_num == 0) {
     timeout = 0; // SetFrameTimeout() will set to a minimum
   } else {
     if (delay_den == 0)
       delay_den = 100; // so says the APNG spec
-    
+
     // Need to cast delay_num to float to have a proper division and
     // the result to int to avoid compiler warning
     timeout = static_cast<PRInt32>
-                         (static_cast<PRFloat64>(delay_num) * 1000 / delay_den);
+              (static_cast<PRFloat64>(delay_num) * 1000 / delay_den);
   }
 
   PRUint32 numFrames = 0;
   mImage->GetNumFrames(&numFrames);
 
   mImage->SetFrameTimeout(numFrames - 1, timeout);
-  
+
   if (dispose_op == PNG_DISPOSE_OP_PREVIOUS)
-      mImage->SetFrameDisposalMethod(numFrames - 1, imgIContainer::kDisposeRestorePrevious);
+      mImage->SetFrameDisposalMethod(numFrames - 1,
+                                     imgIContainer::kDisposeRestorePrevious);
   else if (dispose_op == PNG_DISPOSE_OP_BACKGROUND)
-      mImage->SetFrameDisposalMethod(numFrames - 1, imgIContainer::kDisposeClear);
+      mImage->SetFrameDisposalMethod(numFrames - 1,
+                                     imgIContainer::kDisposeClear);
   else
-      mImage->SetFrameDisposalMethod(numFrames - 1, imgIContainer::kDisposeKeep);
-  
+      mImage->SetFrameDisposalMethod(numFrames - 1,
+                                     imgIContainer::kDisposeKeep);
+
   if (blend_op == PNG_BLEND_OP_SOURCE)
       mImage->SetFrameBlendMethod(numFrames - 1, imgIContainer::kBlendSource);
   /*else // 'over' is the default
       mImage->SetFrameBlendMethod(numFrames - 1, imgIContainer::kBlendOver); */
 }
 
 // set timeout and frame disposal method for the current frame
 void nsPNGDecoder::EndImageFrame()
@@ -206,28 +214,29 @@ void nsPNGDecoder::EndImageFrame()
 
     if (NS_FAILED(mImage->FrameUpdated(numFrames - 1, mFrameRect))) {
       mError = PR_TRUE;
       // allow the call out to the observers.
     }
     PRUint32 curFrame;
     mImage->GetCurrentFrameIndex(&curFrame);
     if (mObserver)
-      mObserver->OnDataAvailable(nsnull, curFrame == numFrames - 1, &mFrameRect);
+      mObserver->OnDataAvailable(nsnull, curFrame == numFrames - 1,
+                                 &mFrameRect);
   }
 
   mImage->EndFrameDecode(numFrames - 1);
   if (mObserver)
     mObserver->OnStopFrame(nsnull, numFrames - 1);
 }
 
 
 /** imgIDecoder methods **/
 
-/* void init (in imgIContainer aImage, 
+/* void init (in imgIContainer aImage,
               imgIDecoderObserver aObserver,
               unsigned long aFlags); */
 NS_IMETHODIMP nsPNGDecoder::Init(imgIContainer *aImage,
                                  imgIDecoderObserver *aObserver,
                                  PRUint32 aFlags)
 {
 #if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
   static png_byte color_chunks[]=
@@ -264,17 +273,17 @@ NS_IMETHODIMP nsPNGDecoder::Init(imgICon
     return NS_OK;
   }
 
   /* For full decodes, do png init stuff */
 
   /* Initialize the container's source image header. */
   /* Always decode to 24 bit pixdepth */
 
-  mPNG = png_create_read_struct(PNG_LIBPNG_VER_STRING, 
+  mPNG = png_create_read_struct(PNG_LIBPNG_VER_STRING,
                                 NULL, error_callback, warning_callback);
   if (!mPNG) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   mInfo = png_create_info_struct(mPNG);
   if (!mInfo) {
     png_destroy_read_struct(&mPNG, NULL, NULL);
@@ -282,17 +291,17 @@ NS_IMETHODIMP nsPNGDecoder::Init(imgICon
   }
 
 #if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
   /* Ignore unused chunks */
   if (gfxPlatform::GetCMSMode() == eCMSMode_Off) {
     png_set_keep_unknown_chunks(mPNG, 1, color_chunks, 2);
   }
   png_set_keep_unknown_chunks(mPNG, 1, unused_chunks,
-     (int)sizeof(unused_chunks)/5);   
+     (int)sizeof(unused_chunks)/5);
 #endif
 
   /* use this as libpng "progressive pointer" (retrieve in callbacks) */
   png_set_progressive_read_fn(mPNG, static_cast<png_voidp>(this),
                               info_callback, row_callback, end_callback);
 
 
   return NS_OK;
@@ -336,17 +345,18 @@ nsPNGDecoder::Write(const char *aBuffer,
   // If we only want width/height, we don't need to go through libpng
   if (mFlags & imgIDecoder::DECODER_FLAG_HEADERONLY) {
 
     // Are we done?
     if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS)
       return NS_OK;
 
     // Read data into our header buffer
-    PRUint32 bytesToRead = PR_MIN(aCount, BYTES_NEEDED_FOR_DIMENSIONS - mHeaderBytesRead);
+    PRUint32 bytesToRead = PR_MIN(aCount, BYTES_NEEDED_FOR_DIMENSIONS -
+                                  mHeaderBytesRead);
     memcpy(mHeaderBuf + mHeaderBytesRead, aBuffer, bytesToRead);
     mHeaderBytesRead += bytesToRead;
 
     // If we're done now, verify the data and set up the container
     if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) {
 
       // Check that the signature bytes are right
       if (memcmp(mHeaderBuf, pngSignatureBytes, sizeof(pngSignatureBytes)))
@@ -409,17 +419,17 @@ nsPNGDecoder::NotifyDone(PRBool aSuccess
     mObserver->OnStopDecode(nsnull, aSuccess ? NS_OK : NS_ERROR_FAILURE,
                             nsnull);
   }
 
   // Mark that we've been called
   mNotifiedDone = PR_TRUE;
 }
 
-// Sets up gamma pre-correction in libpng before our callback gets called. 
+// Sets up gamma pre-correction in libpng before our callback gets called.
 // We need to do this if we don't end up with a CMS profile.
 static void
 PNGDoGammaCorrection(png_structp png_ptr, png_infop info_ptr)
 {
   double aGamma;
 
   if (png_get_gAMA(png_ptr, info_ptr, &aGamma)) {
     if ((aGamma <= 0.0) || (aGamma > 21474.83)) {
@@ -475,26 +485,28 @@ PNGGetColorProfile(png_structp png_ptr, 
   }
 
   // Check sRGB chunk
   if (!profile && png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB)) {
     profile = qcms_profile_sRGB();
 
     if (profile) {
       int fileIntent;
-      png_set_gray_to_rgb(png_ptr); 
+      png_set_gray_to_rgb(png_ptr);
       png_get_sRGB(png_ptr, info_ptr, &fileIntent);
-      PRUint32 map[] = { QCMS_INTENT_PERCEPTUAL, QCMS_INTENT_RELATIVE_COLORIMETRIC,
-                         QCMS_INTENT_SATURATION, QCMS_INTENT_ABSOLUTE_COLORIMETRIC };
+      PRUint32 map[] = { QCMS_INTENT_PERCEPTUAL,
+                         QCMS_INTENT_RELATIVE_COLORIMETRIC,
+                         QCMS_INTENT_SATURATION,
+                         QCMS_INTENT_ABSOLUTE_COLORIMETRIC };
       *intent = map[fileIntent];
     }
   }
 
   // Check gAMA/cHRM chunks
-  if (!profile && 
+  if (!profile &&
        png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) &&
        png_get_valid(png_ptr, info_ptr, PNG_INFO_cHRM)) {
     qcms_CIE_xyYTRIPLE primaries;
     qcms_CIE_xyY whitePoint;
 
     png_get_cHRM(png_ptr, info_ptr,
                  &whitePoint.x, &whitePoint.y,
                  &primaries.red.x,   &primaries.red.y,
@@ -502,17 +514,18 @@ PNGGetColorProfile(png_structp png_ptr, 
                  &primaries.blue.x,  &primaries.blue.y);
     whitePoint.Y =
       primaries.red.Y = primaries.green.Y = primaries.blue.Y = 1.0;
 
     double gammaOfFile;
 
     png_get_gAMA(png_ptr, info_ptr, &gammaOfFile);
 
-    profile = qcms_profile_create_rgb_with_gamma(whitePoint, primaries, 1/gammaOfFile);
+    profile = qcms_profile_create_rgb_with_gamma(whitePoint, primaries,
+                                                 1.0/gammaOfFile);
 
     if (profile)
       png_set_gray_to_rgb(png_ptr);
   }
 
   if (profile) {
     PRUint32 profileSpace = qcms_profile_get_color_space(profile);
     if (profileSpace == icSigGrayData) {
@@ -538,23 +551,24 @@ info_callback(png_structp png_ptr, png_i
 /*  int number_passes;   NOT USED  */
   png_uint_32 width, height;
   int bit_depth, color_type, interlace_type, compression_type, filter_type;
   unsigned int channels;
 
   png_bytep trans = NULL;
   int num_trans = 0;
 
-  nsPNGDecoder *decoder = static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
+  nsPNGDecoder *decoder =
+               static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
   nsresult rv;
 
   /* always decode to 24-bit RGB or 32-bit RGBA  */
   png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
                &interlace_type, &compression_type, &filter_type);
-  
+
   /* Are we too big? */
   if (width > MOZ_PNG_MAX_DIMENSION || height > MOZ_PNG_MAX_DIMENSION)
     longjmp(decoder->mPNG->jmpbuf, 1);
 
   // Set the size and notify that the container is set up
   rv = decoder->mImage->SetSize(width, height);
   if (NS_FAILED(rv)) {
     longjmp(decoder->mPNG->jmpbuf, 5); // NS_ERROR_UNEXPECTED
@@ -589,17 +603,18 @@ info_callback(png_structp png_ptr, png_i
     else
        png_set_expand(png_ptr);
   }
 
   if (bit_depth == 16)
     png_set_strip_16(png_ptr);
 
   qcms_data_type inType;
-  PRUint32 intent, pIntent;
+  PRUint32 intent = -1;
+  PRUint32 pIntent;
   if (gfxPlatform::GetCMSMode() != eCMSMode_Off) {
     intent = gfxPlatform::GetRenderingIntent();
     decoder->mInProfile = PNGGetColorProfile(png_ptr, info_ptr,
                                              color_type, &inType, &pIntent);
     /* If we're not mandating an intent, use the one from the image. */
     if (intent == PRUint32(-1))
       intent = pIntent;
   }
@@ -607,20 +622,20 @@ info_callback(png_structp png_ptr, png_i
     qcms_data_type outType;
 
     if (color_type & PNG_COLOR_MASK_ALPHA || num_trans)
       outType = QCMS_DATA_RGBA_8;
     else
       outType = QCMS_DATA_RGB_8;
 
     decoder->mTransform = qcms_transform_create(decoder->mInProfile,
-                                             inType,
-                                             gfxPlatform::GetCMSOutputProfile(),
-                                             outType,
-                                             (qcms_intent)intent);
+                                           inType,
+                                           gfxPlatform::GetCMSOutputProfile(),
+                                           outType,
+                                           (qcms_intent)intent);
   } else {
     png_set_gray_to_rgb(png_ptr);
     PNGDoGammaCorrection(png_ptr, info_ptr);
 
     if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
       if (color_type & PNG_COLOR_MASK_ALPHA || num_trans)
         decoder->mTransform = gfxPlatform::GetCMSRGBATransform();
       else
@@ -664,48 +679,49 @@ info_callback(png_structp png_ptr, png_i
 
   if (channels == 1 || channels == 3)
     decoder->format = gfxASurface::ImageFormatRGB24;
   else if (channels == 2 || channels == 4)
     decoder->format = gfxASurface::ImageFormatARGB32;
 
   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL))
     png_set_progressive_frame_fn(png_ptr, frame_info_callback, NULL);
-  
+
   if (png_get_first_frame_is_hidden(png_ptr, info_ptr)) {
     decoder->mFrameIsHidden = PR_TRUE;
   } else {
     decoder->CreateFrame(0, 0, width, height, decoder->format);
   }
-  
+
   if (decoder->mTransform &&
       (channels <= 2 || interlace_type == PNG_INTERLACE_ADAM7)) {
     PRUint32 bpp[] = { 0, 3, 4, 3, 4 };
     decoder->mCMSLine =
       (PRUint8 *)nsMemory::Alloc(bpp[channels] * width);
     if (!decoder->mCMSLine) {
       longjmp(decoder->mPNG->jmpbuf, 5); // NS_ERROR_OUT_OF_MEMORY
     }
   }
 
   if (interlace_type == PNG_INTERLACE_ADAM7) {
     if (height < PR_INT32_MAX / (width * channels))
-      decoder->interlacebuf = (PRUint8 *)nsMemory::Alloc(channels * width * height);
+      decoder->interlacebuf = (PRUint8 *)nsMemory::Alloc(channels *
+                                                         width * height);
     if (!decoder->interlacebuf) {
       longjmp(decoder->mPNG->jmpbuf, 5); // NS_ERROR_OUT_OF_MEMORY
     }
   }
-  
+
   /* Reject any ancillary chunk after IDAT with a bad CRC (bug #397593).
    * It would be better to show the default frame (if one has already been
    * successfully decoded) before bailing, but it's simpler to just bail
    * out with an error message.
    */
   png_set_crc_action(png_ptr, NULL, PNG_CRC_ERROR_QUIT);
-  
+
   return;
 }
 
 void
 row_callback(png_structp png_ptr, png_bytep new_row,
              png_uint_32 row_num, int pass)
 {
   /* libpng comments:
@@ -730,18 +746,19 @@ row_callback(png_structp png_ptr, png_by
    *
    * where old_row is what was displayed for previous rows.  Note
    * that the first pass (pass == 0 really) will completely cover
    * the old row, so the rows do not have to be initialized.  After
    * the first pass (and only for interlaced images), you will have
    * to pass the current row, and the function will combine the
    * old row and the new row.
    */
-  nsPNGDecoder *decoder = static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
-  
+  nsPNGDecoder *decoder =
+               static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
+
   // skip this frame
   if (decoder->mFrameIsHidden)
     return;
 
   if (new_row) {
     PRInt32 width = decoder->mFrameRect.width;
     PRUint32 iwidth = decoder->mFrameRect.width;
 
@@ -752,17 +769,18 @@ row_callback(png_structp png_ptr, png_by
     }
 
     PRUint32 bpr = width * sizeof(PRUint32);
     PRUint32 *cptr32 = (PRUint32*)(decoder->mImageData + (row_num*bpr));
     PRBool rowHasNoAlpha = PR_TRUE;
 
     if (decoder->mTransform) {
       if (decoder->mCMSLine) {
-        qcms_transform_data(decoder->mTransform, line, decoder->mCMSLine, iwidth);
+        qcms_transform_data(decoder->mTransform, line, decoder->mCMSLine,
+                            iwidth);
         /* copy alpha over */
         PRUint32 channels = decoder->mChannels;
         if (channels == 2 || channels == 4) {
           for (PRUint32 i = 0; i < iwidth; i++)
             decoder->mCMSLine[4 * i + 3] = line[channels * i + channels - 1];
         }
         line = decoder->mCMSLine;
       } else {
@@ -774,17 +792,17 @@ row_callback(png_structp png_ptr, png_by
       case gfxASurface::ImageFormatRGB24:
       {
         // counter for while() loops below
         PRUint32 idx = iwidth;
 
         // copy as bytes until source pointer is 32-bit-aligned
         for (; (NS_PTR_TO_UINT32(line) & 0x3) && idx; --idx) {
           *cptr32++ = GFX_PACKED_PIXEL(0xFF, line[0], line[1], line[2]);
-          line += 3; 
+          line += 3;
         }
 
         // copy pixels in blocks of 4
         while (idx >= 4) {
           GFX_BLOCK_RGB_TO_FRGB(line, cptr32);
           idx    -=  4;
           line   += 12;
           cptr32 +=  4;
@@ -824,41 +842,43 @@ row_callback(png_structp png_ptr, png_by
       nsIntRect r(0, row_num, width, 1);
       if (NS_FAILED(decoder->mImage->FrameUpdated(numFrames - 1, r))) {
         decoder->mError = PR_TRUE;  /* bail */
         return;
       }
       PRUint32 curFrame;
       decoder->mImage->GetCurrentFrameIndex(&curFrame);
       if (decoder->mObserver)
-        decoder->mObserver->OnDataAvailable(nsnull, curFrame == numFrames - 1, &r);
+        decoder->mObserver->OnDataAvailable(nsnull,
+                                            curFrame == numFrames - 1, &r);
     }
   }
 }
 
 // got the header of a new frame that's coming
 void
 frame_info_callback(png_structp png_ptr, png_uint_32 frame_num)
 {
   png_uint_32 x_offset, y_offset;
   PRInt32 width, height;
-  
-  nsPNGDecoder *decoder = static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
-  
+
+  nsPNGDecoder *decoder =
+               static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
+
   // old frame is done
   if (!decoder->mFrameIsHidden)
     decoder->EndImageFrame();
-  
+
   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);
 }
 
 void
 end_callback(png_structp png_ptr, png_infop info_ptr)
 {
   /* libpng comments:
    *
@@ -867,21 +887,22 @@ end_callback(png_structp png_ptr, png_in
    * the IEND).  You will usually have the same info chunk as you
    * had in the header, although some data may have been added
    * to the comments and time fields.
    *
    * Most people won't do much here, perhaps setting a flag that
    * marks the image as finished.
    */
 
-  nsPNGDecoder *decoder = static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
+  nsPNGDecoder *decoder =
+               static_cast<nsPNGDecoder*>(png_get_progressive_ptr(png_ptr));
 
   // We shouldn't get here if we've hit an error
   NS_ABORT_IF_FALSE(!decoder->mError, "Finishing up PNG but hit error!");
-  
+
   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL)) {
     PRInt32 num_plays = png_get_num_plays(png_ptr, info_ptr);
     decoder->mImage->SetLoopCount(num_plays - 1);
   }
 
   // Send final notifications
   decoder->NotifyDone(/* aSuccess = */ PR_TRUE);
 }
--- a/modules/libpr0n/decoders/png/nsPNGDecoder.h
+++ b/modules/libpr0n/decoders/png/nsPNGDecoder.h
@@ -65,21 +65,21 @@ class nsPNGDecoder : public imgIDecoder
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_IMGIDECODER
 
   nsPNGDecoder();
   virtual ~nsPNGDecoder();
 
-  void CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset, 
-                   PRInt32 width, PRInt32 height, 
+  void CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
+                   PRInt32 width, PRInt32 height,
                    gfxASurface::gfxImageFormat format);
   void SetAnimFrameInfo();
-  
+
   void EndImageFrame();
   void NotifyDone(PRBool aSuccess);
 
 public:
   nsCOMPtr<imgIContainer> mImage;
   nsCOMPtr<imgIDecoderObserver> mObserver;
   PRUint32 mFlags;