Bug 1184996 (Part 3) - Replace all remaining references to 'size decodes' with 'metadata decodes'. r=tn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Wed, 22 Jul 2015 22:39:54 -0700
changeset 285944 9c85da36168b81f3113628c1d4fac7d0488084d6
parent 285943 97a30fa80826f06992cd085b12a2f6eee83c1d9e
child 285945 aaf3459a20b5236b81c5d4f243503c9e1eeff3a6
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1184996
milestone42.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 1184996 (Part 3) - Replace all remaining references to 'size decodes' with 'metadata decodes'. r=tn
image/DecodePool.cpp
image/Decoder.cpp
image/Decoder.h
image/DecoderFactory.cpp
image/DecoderFactory.h
image/RasterImage.cpp
image/RasterImage.h
image/decoders/nsBMPDecoder.cpp
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsICODecoder.cpp
image/decoders/nsIconDecoder.cpp
image/decoders/nsJPEGDecoder.cpp
image/decoders/nsPNGDecoder.cpp
image/decoders/nsPNGDecoder.h
--- a/image/DecodePool.cpp
+++ b/image/DecodePool.cpp
@@ -198,34 +198,34 @@ public:
 
     MonitorAutoLock lock(mMonitor);
 
     if (mShuttingDown) {
       // Drop any new work on the floor if we're shutting down.
       return;
     }
 
-    if (aDecoder->IsSizeDecode()) {
-      mSizeDecodeQueue.AppendElement(Move(decoder));
+    if (aDecoder->IsMetadataDecode()) {
+      mMetadataDecodeQueue.AppendElement(Move(decoder));
     } else {
       mFullDecodeQueue.AppendElement(Move(decoder));
     }
 
     mMonitor.Notify();
   }
 
   /// Pops a new work item, blocking if necessary.
   Work PopWork()
   {
     MonitorAutoLock lock(mMonitor);
 
     do {
-      // Prioritize size decodes over full decodes.
-      if (!mSizeDecodeQueue.IsEmpty()) {
-        return PopWorkFromQueue(mSizeDecodeQueue);
+      // Prioritize metadata decodes over full decodes.
+      if (!mMetadataDecodeQueue.IsEmpty()) {
+        return PopWorkFromQueue(mMetadataDecodeQueue);
       }
 
       if (!mFullDecodeQueue.IsEmpty()) {
         return PopWorkFromQueue(mFullDecodeQueue);
       }
 
       if (mShuttingDown) {
         Work work;
@@ -248,19 +248,19 @@ private:
     work.mDecoder = aQueue.LastElement();
     aQueue.RemoveElementAt(aQueue.Length() - 1);
 
     return work;
   }
 
   nsThreadPoolNaming mThreadNaming;
 
-  // mMonitor guards mQueue and mShuttingDown.
+  // mMonitor guards the queues and mShuttingDown.
   Monitor mMonitor;
-  nsTArray<nsRefPtr<Decoder>> mSizeDecodeQueue;
+  nsTArray<nsRefPtr<Decoder>> mMetadataDecodeQueue;
   nsTArray<nsRefPtr<Decoder>> mFullDecodeQueue;
   bool mShuttingDown;
 };
 
 class DecodePoolWorker : public nsRunnable
 {
 public:
   explicit DecodePoolWorker(DecodePoolImpl* aImpl) : mImpl(aImpl) { }
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -37,17 +37,17 @@ Decoder::Decoder(RasterImage* aImage)
   , mDataError(false)
   , mDecodeAborted(false)
   , mShouldReportError(false)
   , mImageIsTransient(false)
   , mImageIsLocked(false)
   , mFrameCount(0)
   , mFailCode(NS_OK)
   , mInitialized(false)
-  , mSizeDecode(false)
+  , mMetadataDecode(false)
   , mInFrame(false)
   , mIsAnimated(false)
 { }
 
 Decoder::~Decoder()
 {
   MOZ_ASSERT(mProgress == NoProgress,
              "Destroying Decoder without taking all its progress changes");
@@ -164,17 +164,17 @@ Decoder::Write(const char* aBuffer, uint
   // Keep track of the total number of bytes written.
   mBytesDecoded += aCount;
 
   // If a data error occured, just ignore future data.
   if (HasDataError()) {
     return;
   }
 
-  if (IsSizeDecode() && HasSize()) {
+  if (IsMetadataDecode() && HasSize()) {
     // More data came in since we found the size. We have nothing to do here.
     return;
   }
 
   // Pass the data along to the implementation.
   WriteInternal(aBuffer, aCount);
 
   // Finish telemetry.
@@ -195,17 +195,17 @@ Decoder::CompleteDecode()
   if (mInFrame && !HasError()) {
     PostFrameStop();
   }
 
   // If PostDecodeDone() has not been called, and this decoder wasn't aborted
   // early because of low-memory conditions or losing a race with another
   // decoder, we need to send teardown notifications (and report an error to the
   // console later).
-  if (!IsSizeDecode() && !mDecodeDone && !WasAborted()) {
+  if (!IsMetadataDecode() && !mDecodeDone && !WasAborted()) {
     mShouldReportError = true;
 
     // If we only have a data error, we're usable if we have at least one
     // complete frame.
     if (!HasDecoderError() && GetCompleteFrameCount() > 0) {
       // We're usable, so do exactly what we should have when the decoder
       // completed.
 
@@ -213,17 +213,17 @@ Decoder::CompleteDecode()
       PostHasTransparency();
 
       if (mInFrame) {
         PostFrameStop();
       }
       PostDecodeDone();
     } else {
       // We're not usable. Record some final progress indicating the error.
-      if (!IsSizeDecode()) {
+      if (!IsMetadataDecode()) {
         mProgress |= FLAG_DECODE_COMPLETE;
       }
       mProgress |= FLAG_HAS_ERROR;
     }
   }
 }
 
 void
@@ -264,17 +264,17 @@ Decoder::Finish()
   // Set image metadata before calling DecodingComplete, because
   // DecodingComplete calls Optimize().
   mImageMetadata.SetOnImage(mImage);
 
   if (HasSize()) {
     SetSizeOnImage();
   }
 
-  if (mDecodeDone && !IsSizeDecode()) {
+  if (mDecodeDone && !IsMetadataDecode()) {
     MOZ_ASSERT(HasError() || mCurrentFrame, "Should have an error or a frame");
 
     // If this image wasn't animated and isn't a transient image, mark its frame
     // as optimizable. We don't support optimizing animated images and
     // optimizing transient images isn't worth it.
     if (!mIsAnimated && !mImageIsTransient && mCurrentFrame) {
       mCurrentFrame->SetOptimizable();
     }
@@ -473,17 +473,17 @@ Decoder::PostFrameStart()
 void
 Decoder::PostFrameStop(Opacity aFrameOpacity    /* = Opacity::TRANSPARENT */,
                        DisposalMethod aDisposalMethod
                                                 /* = DisposalMethod::KEEP */,
                        int32_t aTimeout         /* = 0 */,
                        BlendMethod aBlendMethod /* = BlendMethod::OVER */)
 {
   // We should be mid-frame
-  MOZ_ASSERT(!IsSizeDecode(), "Stopping frame during a size decode");
+  MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode");
   MOZ_ASSERT(mInFrame, "Stopping frame when we didn't start one");
   MOZ_ASSERT(mCurrentFrame, "Stopping frame when we don't have one");
 
   // Update our state
   mInFrame = false;
 
   mCurrentFrame->Finish(aFrameOpacity, aDisposalMethod, aTimeout, aBlendMethod);
 
@@ -512,17 +512,17 @@ Decoder::PostInvalidation(const nsIntRec
     mInvalidRect.UnionRect(mInvalidRect, aRect);
     mCurrentFrame->ImageUpdated(aRectAtTargetSize.valueOr(aRect));
   }
 }
 
 void
 Decoder::PostDecodeDone(int32_t aLoopCount /* = 0 */)
 {
-  MOZ_ASSERT(!IsSizeDecode(), "Can't be done with decoding with size decode!");
+  MOZ_ASSERT(!IsMetadataDecode(), "Done with decoding in metadata decode");
   MOZ_ASSERT(!mInFrame, "Can't be done decoding if we're mid-frame!");
   MOZ_ASSERT(!mDecodeDone, "Decode already done!");
   mDecodeDone = true;
 
   mImageMetadata.SetLoopCount(aLoopCount);
 
   mProgress |= FLAG_DECODE_COMPLETE;
 }
--- a/image/Decoder.h
+++ b/image/Decoder.h
@@ -92,25 +92,27 @@ public:
 
   // Implement IResumable.
   virtual void Resume() override;
 
   /*
    * State.
    */
 
-  // If we're doing a "size decode", we more or less pass through the image
-  // data, stopping only to scoop out the image dimensions. A size decode
-  // must be enabled by SetSizeDecode() _before_calling Init().
-  bool IsSizeDecode() { return mSizeDecode; }
-  void SetSizeDecode(bool aSizeDecode)
+  /**
+   * If we're doing a metadata decode, we only decode the image's headers, which
+   * is enough to determine the image's intrinsic size. A metadata decode is
+   * enabled by calling SetMetadataDecode() *before* calling Init().
+   */
+  void SetMetadataDecode(bool aMetadataDecode)
   {
     MOZ_ASSERT(!mInitialized, "Shouldn't be initialized yet");
-    mSizeDecode = aSizeDecode;
+    mMetadataDecode = aMetadataDecode;
   }
+  bool IsMetadataDecode() { return mMetadataDecode; }
 
   /**
    * If this decoder supports downscale-during-decode, sets the target size that
    * this image should be decoded to.
    *
    * If this decoder *doesn't* support downscale-during-decode, returns
    * NS_ERROR_NOT_AVAILABLE. If the provided size is unacceptable, returns
    * another error.
@@ -204,17 +206,18 @@ public:
   bool HasError() const { return HasDataError() || HasDecoderError(); }
   bool HasDataError() const { return mDataError; }
   bool HasDecoderError() const { return NS_FAILED(mFailCode); }
   nsresult GetDecoderError() const { return mFailCode; }
   void PostResizeError() { PostDataError(); }
 
   bool GetDecodeDone() const
   {
-    return mDecodeDone || (mSizeDecode && HasSize()) || HasError() || mDataDone;
+    return mDecodeDone || (mMetadataDecode && HasSize()) ||
+           HasError() || mDataDone;
   }
 
   /**
    * Returns true if this decoder was aborted.
    *
    * This may happen due to a low-memory condition, or because another decoder
    * was racing with this one to decode the same frames with the same flags and
    * this decoder lost the race. Either way, this is not a permanent situation
@@ -418,17 +421,17 @@ protected:
   bool mImageIsLocked;
 
 private:
   uint32_t mFrameCount; // Number of frames, including anything in-progress
 
   nsresult mFailCode;
 
   bool mInitialized;
-  bool mSizeDecode;
+  bool mMetadataDecode;
   bool mInFrame;
   bool mIsAnimated;
 };
 
 } // namespace image
 } // namespace mozilla
 
 #endif // mozilla_image_Decoder_h
--- a/image/DecoderFactory.cpp
+++ b/image/DecoderFactory.cpp
@@ -117,17 +117,17 @@ DecoderFactory::CreateDecoder(DecoderTyp
   if (aType == DecoderType::UNKNOWN) {
     return nullptr;
   }
 
   nsRefPtr<Decoder> decoder = GetDecoder(aType, aImage, aIsRedecode);
   MOZ_ASSERT(decoder, "Should have a decoder now");
 
   // Initialize the decoder.
-  decoder->SetSizeDecode(false);
+  decoder->SetMetadataDecode(false);
   decoder->SetIterator(aSourceBuffer->Iterator());
   decoder->SetFlags(aFlags);
   decoder->SetSendPartialInvalidations(!aIsRedecode);
   decoder->SetImageIsTransient(aImageIsTransient);
 
   if (aImageIsLocked) {
     decoder->SetImageIsLocked();
   }
@@ -157,17 +157,17 @@ DecoderFactory::CreateMetadataDecoder(De
     return nullptr;
   }
 
   nsRefPtr<Decoder> decoder =
     GetDecoder(aType, aImage, /* aIsRedecode = */ false);
   MOZ_ASSERT(decoder, "Should have a decoder now");
 
   // Initialize the decoder.
-  decoder->SetSizeDecode(true);
+  decoder->SetMetadataDecode(true);
   decoder->SetIterator(aSourceBuffer->Iterator());
 
   decoder->Init();
   if (NS_FAILED(decoder->GetDecoderError())) {
     return nullptr;
   }
 
   return decoder.forget();
--- a/image/DecoderFactory.h
+++ b/image/DecoderFactory.h
@@ -73,20 +73,16 @@ public:
                 bool aImageIsLocked);
 
   /**
    * Creates and initializes a metadata decoder of type @aType. This decoder
    * will only decode the image's header, extracting metadata like the size of
    * the image. No actual image data will be decoded and no surfaces will be
    * allocated. The decoder will send notifications to @aImage.
    *
-   * XXX(seth): A metadata decode is called a "size decode" in most of ImageLib,
-   * but we are going to move away from that term, as it's both confusing to
-   * people and increasingly inaccurate.
-   *
    * @param aType Which type of decoder to create - JPEG, PNG, etc.
    * @param aImage The image will own the decoder and which should receive
    *               notifications as decoding progresses.
    * @param aSourceBuffer The SourceBuffer which the decoder will read its data
    *                      from.
    */
   static already_AddRefed<Decoder>
   CreateMetadataDecoder(DecoderType aType,
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -2013,62 +2013,62 @@ RasterImage::FinalizeDecoder(Decoder* aD
   MOZ_ASSERT(mError || mHasSize || !aDecoder->HasSize(),
              "Should have handed off size by now");
 
   // Send out any final notifications.
   NotifyProgress(aDecoder->TakeProgress(),
                  aDecoder->TakeInvalidRect(),
                  aDecoder->GetDecodeFlags());
 
-  bool wasSize = aDecoder->IsSizeDecode();
+  bool wasMetadata = aDecoder->IsMetadataDecode();
   bool done = aDecoder->GetDecodeDone();
 
-  if (!wasSize && aDecoder->ChunkCount()) {
+  if (!wasMetadata && aDecoder->ChunkCount()) {
     Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS,
                           aDecoder->ChunkCount());
   }
 
   if (done) {
-    // Do some telemetry if this isn't a size decode.
-    if (!wasSize) {
+    // Do some telemetry if this isn't a metadata decode.
+    if (!wasMetadata) {
       Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME,
                             int32_t(aDecoder->DecodeTime().ToMicroseconds()));
 
       // We record the speed for only some decoders. The rest have
       // SpeedHistogram return HistogramCount.
       Telemetry::ID id = aDecoder->SpeedHistogram();
       if (id < Telemetry::HistogramCount) {
         int32_t KBps = int32_t(aDecoder->BytesDecoded() /
                                (1024 * aDecoder->DecodeTime().ToSeconds()));
         Telemetry::Accumulate(id, KBps);
       }
     }
 
     // Detect errors.
     if (aDecoder->HasError() && !aDecoder->WasAborted()) {
       DoError();
-    } else if (wasSize && !mHasSize) {
+    } else if (wasMetadata && !mHasSize) {
       DoError();
     }
 
     // If we were waiting to fire the load event, go ahead and fire it now.
-    if (mLoadProgress && wasSize) {
+    if (mLoadProgress && wasMetadata) {
       NotifyForLoadEvent(*mLoadProgress);
       mLoadProgress = Nothing();
       NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
     }
   }
 
   if (aDecoder->ImageIsLocked()) {
     // Unlock the image, balancing the LockImage call we made in CreateDecoder.
     UnlockImage();
   }
 
-  // If we were a size decode and a full decode was requested, now's the time.
-  if (done && wasSize && mWantFullDecode) {
+  // If we were a metadata decode and a full decode was requested, do it.
+  if (done && wasMetadata && mWantFullDecode) {
     mWantFullDecode = false;
     RequestDecode();
   }
 }
 
 already_AddRefed<imgIContainer>
 RasterImage::Unwrap()
 {
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -425,18 +425,18 @@ private: // data
   // but we don't yet have more than one frame, mPendingAnimation is set so that
   // we know to start animation later if/when we have more frames.
   bool                       mPendingAnimation:1;
 
   // Whether the animation can stop, due to running out
   // of frames, or no more owning request
   bool                       mAnimationFinished:1;
 
-  // Whether, once we are done doing a size decode, we should immediately kick
-  // off a full decode.
+  // Whether, once we are done doing a metadata decode, we should immediately
+  // kick off a full decode.
   bool                       mWantFullDecode:1;
 
   TimeStamp mDrawStartTime;
 
 
   //////////////////////////////////////////////////////////////////////////////
   // Scaling.
   //////////////////////////////////////////////////////////////////////////////
--- a/image/decoders/nsBMPDecoder.cpp
+++ b/image/decoders/nsBMPDecoder.cpp
@@ -136,17 +136,17 @@ nsBMPDecoder::FinishInternal()
 {
     // We shouldn't be called in error cases
     MOZ_ASSERT(!HasError(), "Can't call FinishInternal on error!");
 
     // We should never make multiple frames
     MOZ_ASSERT(GetFrameCount() <= 1, "Multiple BMP frames?");
 
     // Send notifications if appropriate
-    if (!IsSizeDecode() && HasSize()) {
+    if (!IsMetadataDecode() && HasSize()) {
 
         // Invalidate
         nsIntRect r(0, 0, mBIH.width, GetHeight());
         PostInvalidation(r);
 
         if (mUseAlphaData) {
           PostFrameStop(Opacity::SOME_TRANSPARENCY);
         } else {
@@ -364,19 +364,18 @@ nsBMPDecoder::WriteInternal(const char* 
 
       // Post our size to the superclass
       PostSize(mBIH.width, real_height);
       if (HasError()) {
         // Setting the size led to an error.
         return;
       }
 
-      // We have the size. If we're doing a size decode, we got what
-      // we came for.
-      if (IsSizeDecode()) {
+      // We have the size. If we're doing a metadata decode, we're done.
+      if (IsMetadataDecode()) {
         return;
       }
 
       // We're doing a real decode.
       mOldLine = mCurLine = real_height;
 
       if (mBIH.bpp <= 8) {
         mNumColors = 1 << mBIH.bpp;
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -98,17 +98,17 @@ nsGIFDecoder2::~nsGIFDecoder2()
 }
 
 void
 nsGIFDecoder2::FinishInternal()
 {
   MOZ_ASSERT(!HasError(), "Shouldn't call FinishInternal after error!");
 
   // If the GIF got cut off, handle it anyway
-  if (!IsSizeDecode() && mGIFOpen) {
+  if (!IsMetadataDecode() && mGIFOpen) {
     if (mCurrentFrameIndex == mGIFStruct.images_decoded) {
       EndImageFrame();
     }
     PostDecodeDone(mGIFStruct.loop_count - 1);
     mGIFOpen = false;
   }
 }
 
@@ -684,17 +684,17 @@ nsGIFDecoder2::WriteInternal(const char*
       // individual images can be smaller than the
       // screen size and located with an origin anywhere
       // within the screen.
 
       mGIFStruct.screen_width = GETINT16(q);
       mGIFStruct.screen_height = GETINT16(q + 2);
       mGIFStruct.global_colormap_depth = (q[4]&0x07) + 1;
 
-      if (IsSizeDecode()) {
+      if (IsMetadataDecode()) {
         MOZ_ASSERT(!mGIFOpen, "Gif should not be open at this point");
         PostSize(mGIFStruct.screen_width, mGIFStruct.screen_height);
         return;
       }
 
       // screen_bgcolor is not used
       //mGIFStruct.screen_bgcolor = q[5];
       // q[6] = Pixel Aspect Ratio
@@ -929,18 +929,18 @@ nsGIFDecoder2::WriteInternal(const char*
         // Create the image container with the right size.
         BeginGIF();
         if (HasError()) {
           // Setting the size led to an error.
           mGIFStruct.state = gif_error;
           return;
         }
 
-        // If we were doing a size decode, we're done
-        if (IsSizeDecode()) {
+        // If we were doing a metadata decode, we're done.
+        if (IsMetadataDecode()) {
           return;
         }
       }
 
       // Work around more broken GIF files that have zero image width or height
       if (!mGIFStruct.height || !mGIFStruct.width) {
         mGIFStruct.height = mGIFStruct.screen_height;
         mGIFStruct.width = mGIFStruct.screen_width;
@@ -1090,17 +1090,18 @@ nsGIFDecoder2::WriteInternal(const char*
       } else {
         // See if there are any more images in this sequence.
         EndImageFrame();
         GETN(1, gif_image_start);
       }
       break;
 
     case gif_done:
-      MOZ_ASSERT(!IsSizeDecode(), "Size decodes shouldn't reach gif_done");
+      MOZ_ASSERT(!IsMetadataDecode(),
+                 "Metadata decodes shouldn't reach gif_done");
       FinishInternal();
       goto done;
 
     case gif_error:
       PostDataError();
       return;
 
     // We shouldn't ever get here.
--- a/image/decoders/nsICODecoder.cpp
+++ b/image/decoders/nsICODecoder.cpp
@@ -353,17 +353,17 @@ nsICODecoder::WriteInternal(const char* 
     mPos += toCopy;
     aCount -= toCopy;
     aBuffer += toCopy;
 
     mIsPNG = !memcmp(mSignature, nsPNGDecoder::pngSignatureBytes,
                      PNGSIGNATURESIZE);
     if (mIsPNG) {
       mContainedDecoder = new nsPNGDecoder(mImage);
-      mContainedDecoder->SetSizeDecode(IsSizeDecode());
+      mContainedDecoder->SetMetadataDecode(IsMetadataDecode());
       mContainedDecoder->SetSendPartialInvalidations(mSendPartialInvalidations);
       mContainedDecoder->Init();
       if (!WriteToContainedDecoder(mSignature, PNGSIGNATURESIZE)) {
         return;
       }
     }
   }
 
@@ -379,17 +379,17 @@ nsICODecoder::WriteInternal(const char* 
     }
 
     mPos += aCount;
     aBuffer += aCount;
     aCount = 0;
 
     // Raymond Chen says that 32bpp only are valid PNG ICOs
     // http://blogs.msdn.com/b/oldnewthing/archive/2010/10/22/10079192.aspx
-    if (!IsSizeDecode() &&
+    if (!IsMetadataDecode() &&
         !static_cast<nsPNGDecoder*>(mContainedDecoder.get())->IsValidICO()) {
       PostDataError();
     }
     return;
   }
 
   // We've processed all of the icon dir entries and are within the
   // bitmap info size
@@ -430,17 +430,17 @@ nsICODecoder::WriteInternal(const char* 
     mBPP = ExtractBPPFromBitmap(reinterpret_cast<int8_t*>(mBIHraw));
 
     // Init the bitmap decoder which will do most of the work for us
     // It will do everything except the AND mask which isn't present in bitmaps
     // bmpDecoder is for local scope ease, it will be freed by mContainedDecoder
     nsBMPDecoder* bmpDecoder = new nsBMPDecoder(mImage);
     mContainedDecoder = bmpDecoder;
     bmpDecoder->SetUseAlphaData(true);
-    mContainedDecoder->SetSizeDecode(IsSizeDecode());
+    mContainedDecoder->SetMetadataDecode(IsMetadataDecode());
     mContainedDecoder->SetSendPartialInvalidations(mSendPartialInvalidations);
     mContainedDecoder->Init();
 
     // The ICO format when containing a BMP does not include the 14 byte
     // bitmap file header. To use the code of the BMP decoder we need to
     // generate this header ourselves and feed it to the BMP decoder.
     int8_t bfhBuffer[BMPFILEHEADERSIZE];
     if (!FillBitmapFileHeaderBuffer(bfhBuffer)) {
@@ -470,19 +470,18 @@ nsICODecoder::WriteInternal(const char* 
     // Write out the BMP's bitmap info header
     if (!WriteToContainedDecoder(mBIHraw, sizeof(mBIHraw))) {
       return;
     }
 
     PostSize(mContainedDecoder->GetImageMetadata().GetWidth(),
              mContainedDecoder->GetImageMetadata().GetHeight());
 
-    // We have the size. If we're doing a size decode, we got what
-    // we came for.
-    if (IsSizeDecode()) {
+    // We have the size. If we're doing a metadata decode, we're done.
+    if (IsMetadataDecode()) {
       return;
     }
 
     // Sometimes the ICO BPP header field is not filled out
     // so we should trust the contained resource over our own
     // information.
     mBPP = bmpDecoder->GetBitsPerPixel();
 
--- a/image/decoders/nsIconDecoder.cpp
+++ b/image/decoders/nsIconDecoder.cpp
@@ -62,18 +62,18 @@ nsIconDecoder::WriteInternal(const char*
         PostHasTransparency();
 
         if (HasError()) {
           // Setting the size led to an error.
           mState = iconStateFinished;
           return;
         }
 
-        // If We're doing a size decode, we're done
-        if (IsSizeDecode()) {
+        // If we're doing a metadata decode, we're done.
+        if (IsMetadataDecode()) {
           mState = iconStateFinished;
           break;
         }
 
         {
           MOZ_ASSERT(!mImageData, "Already have a buffer allocated?");
           nsresult rv = AllocateBasicFrame();
           if (NS_FAILED(rv)) {
--- a/image/decoders/nsJPEGDecoder.cpp
+++ b/image/decoders/nsJPEGDecoder.cpp
@@ -190,17 +190,17 @@ nsJPEGDecoder::InitInternal()
 }
 
 void
 nsJPEGDecoder::FinishInternal()
 {
   // If we're not in any sort of error case, force our state to JPEG_DONE.
   if ((mState != JPEG_DONE && mState != JPEG_SINK_NON_JPEG_TRAILER) &&
       (mState != JPEG_ERROR) &&
-      !IsSizeDecode()) {
+      !IsMetadataDecode()) {
     mState = JPEG_DONE;
   }
 }
 
 void
 nsJPEGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
 {
   mSegment = (const JOCTET*)aBuffer;
@@ -261,18 +261,18 @@ nsJPEGDecoder::WriteInternal(const char*
       PostSize(mInfo.output_width, mInfo.output_height,
                ReadOrientationFromEXIF());
       if (HasError()) {
         // Setting the size led to an error.
         mState = JPEG_ERROR;
         return;
       }
 
-      // If we're doing a size decode, we're done.
-      if (IsSizeDecode()) {
+      // If we're doing a metadata decode, we're done.
+      if (IsMetadataDecode()) {
         return;
       }
 
       // We're doing a full decode.
       if (mCMSMode != eCMSMode_Off &&
           (mInProfile = GetICCProfile(mInfo)) != nullptr) {
         uint32_t profileSpace = qcms_profile_get_color_space(mInProfile);
         bool mismatch = false;
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -42,17 +42,17 @@ GetPNGDecoderAccountingLog()
   return sPNGDecoderAccountingLog;
 }
 
 // Limit image dimensions (bug #251381, #591822, and #967656)
 #ifndef MOZ_PNG_MAX_DIMENSION
 #  define MOZ_PNG_MAX_DIMENSION 32767
 #endif
 
-// For size decodes
+// For metadata decodes.
 #define WIDTH_OFFSET 16
 #define HEIGHT_OFFSET (WIDTH_OFFSET + 4)
 #define BYTES_NEEDED_FOR_DIMENSIONS (HEIGHT_OFFSET + 4)
 
 nsPNGDecoder::AnimFrameInfo::AnimFrameInfo()
  : mDispose(DisposalMethod::KEEP)
  , mBlend(BlendMethod::OVER)
  , mTimeout(0)
@@ -221,18 +221,18 @@ nsPNGDecoder::EndImageFrame()
 
   PostFrameStop(opacity, mAnimInfo.mDispose, mAnimInfo.mTimeout,
                 mAnimInfo.mBlend);
 }
 
 void
 nsPNGDecoder::InitInternal()
 {
-  // For size decodes, we don't need to initialize the png decoder
-  if (IsSizeDecode()) {
+  // For metadata decodes, we don't need to initialize the PNG decoder.
+  if (IsMetadataDecode()) {
     return;
   }
 
   mCMSMode = gfxPlatform::GetCMSMode();
   if (GetDecodeFlags() & imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION) {
     mCMSMode = eCMSMode_Off;
   }
   mDisablePremultipliedAlpha =
@@ -316,18 +316,18 @@ nsPNGDecoder::InitInternal()
 
 }
 
 void
 nsPNGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
 {
   MOZ_ASSERT(!HasError(), "Shouldn't call WriteInternal after error!");
 
-  // If we only want width/height, we don't need to go through libpng
-  if (IsSizeDecode()) {
+  // If we only want width/height, we don't need to go through libpng.
+  if (IsMetadataDecode()) {
 
     // Are we done?
     if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) {
       return;
     }
 
     // Scan the header for the width and height bytes
     uint32_t pos = 0;
--- a/image/decoders/nsPNGDecoder.h
+++ b/image/decoders/nsPNGDecoder.h
@@ -73,17 +73,17 @@ public:
   nsIntRect mFrameRect;
   uint8_t* mCMSLine;
   uint8_t* interlacebuf;
   qcms_profile* mInProfile;
   qcms_transform* mTransform;
 
   gfx::SurfaceFormat format;
 
-  // For size decodes
+  // For metadata decodes.
   uint8_t mSizeBytes[8]; // Space for width and height, both 4 bytes
   uint32_t mHeaderBytesRead;
 
   // whether CMS or premultiplied alpha are forced off
   uint32_t mCMSMode;
 
   uint8_t mChannels;
   bool mFrameIsHidden;