Bug 716140 - Don't use Gets on mImage from decoders.
authorJoe Drew <joe@drew.ca>
Tue, 18 Dec 2012 11:37:14 -0500
changeset 125512 ecf95d9819f0528d2aec9cb119f244e8756b5495
parent 125511 b682f3b118b1873e4278ba6611691d2e40990bbc
child 125513 0bcb93a716beaf14ecf13f5312541474252c0b5a
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs716140
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 716140 - Don't use Gets on mImage from decoders.
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsPNGDecoder.cpp
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -214,19 +214,17 @@ nsresult nsGIFDecoder2::BeginImageFrame(
   // Tell the superclass we're starting a frame
   PostFrameStart();
 
   if (!mGIFStruct.images_decoded) {
     // Send a onetime invalidation for the first frame if it has a y-axis offset. 
     // Otherwise, the area may never be refreshed and the placeholder will remain
     // on the screen. (Bug 37589)
     if (mGIFStruct.y_offset > 0) {
-      int32_t imgWidth;
-      mImage.GetWidth(&imgWidth);
-      nsIntRect r(0, 0, imgWidth, mGIFStruct.y_offset);
+      nsIntRect r(0, 0, mGIFStruct.screen_width, mGIFStruct.y_offset);
       PostInvalidation(r);
     }
   }
 
   mCurrentFrame = mGIFStruct.images_decoded;
   return NS_OK;
 }
 
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -100,24 +100,24 @@ void nsPNGDecoder::CreateFrame(png_uint_
   if (NS_FAILED(rv))
     longjmp(png_jmpbuf(mPNG), 5); // NS_ERROR_OUT_OF_MEMORY
 
   mFrameRect.x = x_offset;
   mFrameRect.y = y_offset;
   mFrameRect.width = width;
   mFrameRect.height = height;
 
+  // Tell the superclass we're starting a frame
+  PostFrameStart();
+
 #ifdef PNG_APNG_SUPPORTED
   if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL))
     SetAnimFrameInfo();
 #endif
 
-  // Tell the superclass we're starting a frame
-  PostFrameStart();
-
   PR_LOG(GetPNGDecoderAccountingLog(), PR_LOG_DEBUG,
          ("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created "
           "image frame with %dx%d pixels in container %p",
           width, height,
           &mImage));
 
   mFrameHasNoAlpha = true;
 }
@@ -144,17 +144,17 @@ void nsPNGDecoder::SetAnimFrameInfo()
       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<int32_t>
               (static_cast<double>(delay_num) * 1000 / delay_den);
   }
 
-  uint32_t numFrames = mImage.GetNumFrames();
+  uint32_t numFrames = GetFrameCount();
 
   mImage.SetFrameTimeout(numFrames - 1, timeout);
 
   if (dispose_op == PNG_DISPOSE_OP_PREVIOUS)
       mImage.SetFrameDisposalMethod(numFrames - 1,
                                     RasterImage::kDisposeRestorePrevious);
   else if (dispose_op == PNG_DISPOSE_OP_BACKGROUND)
       mImage.SetFrameDisposalMethod(numFrames - 1,
@@ -173,17 +173,17 @@ void nsPNGDecoder::SetAnimFrameInfo()
 // set timeout and frame disposal method for the current frame
 void nsPNGDecoder::EndImageFrame()
 {
   if (mFrameIsHidden)
     return;
 
   uint32_t numFrames = 1;
 #ifdef PNG_APNG_SUPPORTED
-  numFrames = mImage.GetNumFrames();
+  numFrames = GetFrameCount();
 
   // 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)
       mImage.SetFrameHasNoAlpha(numFrames - 1);
 
     // PNG is always non-premult
@@ -785,17 +785,17 @@ nsPNGDecoder::row_callback(png_structp p
       break;
       default:
         longjmp(png_jmpbuf(decoder->mPNG), 1);
     }
 
     if (!rowHasNoAlpha)
       decoder->mFrameHasNoAlpha = false;
 
-    uint32_t numFrames = decoder->mImage.GetNumFrames();
+    uint32_t numFrames = decoder->GetFrameCount();
     if (numFrames <= 1) {
       // Only do incremental image display for the first frame
       // XXXbholley - this check should be handled in the superclass
       nsIntRect r(0, row_num, width, 1);
       decoder->PostInvalidation(r);
     }
   }
 }