Bug 716140 - Explicitly record whether an image is animated. r=seth
authorJoe Drew <joe@drew.ca>
Fri, 18 Jan 2013 16:47:17 -0500
changeset 132054 5fbb93a483d615310b3216e8cac820a099d20652
parent 132053 a6078996517b59a7da0868eef9eaba198cbd4244
child 132055 781b89454236fd0c74e8454666a8c9316cab94d3
push idunknown
push userunknown
push dateunknown
reviewersseth
bugs716140
milestone22.0a1
Bug 716140 - Explicitly record whether an image is animated. r=seth
image/src/imgStatusTracker.cpp
image/src/imgStatusTracker.h
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -382,22 +382,18 @@ imgStatusTracker::SyncNotify(imgRequestP
     // least one frame) then send OnFrameUpdate.
     if (!r.IsEmpty())
       proxy->OnFrameUpdate(&r);
 
     if (mState & stateFrameStopped)
       proxy->OnStopFrame();
 
     // OnImageIsAnimated
-    bool isAnimated = false;
-
-    nsresult rv = mImage->GetAnimated(&isAnimated);
-    if (NS_SUCCEEDED(rv) && isAnimated) {
+    if (mState & stateImageIsAnimated)
       proxy->OnImageIsAnimated();
-    }
   }
 
   if (mState & stateDecodeStopped) {
     NS_ABORT_IF_FALSE(mImage, "stopped decoding without ever having an image?");
     proxy->OnStopDecode();
   }
 
   if (mState & stateRequestStopped) {
@@ -563,48 +559,46 @@ imgStatusTracker::RecordDiscard()
   // Clear the status bits we no longer deserve.
   uint32_t statusBitsToClear = imgIRequest::STATUS_DECODE_STARTED |
                                imgIRequest::STATUS_FRAME_COMPLETE |
                                imgIRequest::STATUS_DECODE_COMPLETE;
   mImageStatus &= ~statusBitsToClear;
 }
 
 void
+imgStatusTracker::SendDiscard(imgRequestProxy* aProxy)
+{
+  if (!aProxy->NotificationsDeferred())
+    aProxy->OnDiscard();
+}
+
+
+void
 imgStatusTracker::RecordUnlockedDraw()
 {
   NS_ABORT_IF_FALSE(mImage,
                     "RecordUnlockedDraw called before we have an Image");
 }
 
 void
+imgStatusTracker::RecordImageIsAnimated()
+{
+  NS_ABORT_IF_FALSE(mImage,
+                    "RecordImageIsAnimated called before we have an Image");
+  mImageStatus |= stateImageIsAnimated;
+}
+
+void
 imgStatusTracker::SendImageIsAnimated(imgRequestProxy* aProxy)
 {
   if (!aProxy->NotificationsDeferred())
     aProxy->OnImageIsAnimated();
 }
 
 void
-imgStatusTracker::RecordImageIsAnimated()
-{
-  NS_ABORT_IF_FALSE(mImage,
-                    "RecordImageIsAnimated called before we have an Image");
-  // No bookkeeping necessary here - once decoding is complete, GetAnimated()
-  // will accurately return that this is an animated image. Until that time,
-  // the OnImageIsAnimated notification is the only indication an observer
-  // will have that an image has more than 1 frame.
-}
-
-void
-imgStatusTracker::SendDiscard(imgRequestProxy* aProxy)
-{
-  if (!aProxy->NotificationsDeferred())
-    aProxy->OnDiscard();
-}
-
-void
 imgStatusTracker::SendUnlockedDraw(imgRequestProxy* aProxy)
 {
   if (!aProxy->NotificationsDeferred())
     aProxy->OnUnlockedDraw();
 }
 
 void
 imgStatusTracker::RecordFrameChanged(const nsIntRect* aDirtyRect)
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -30,17 +30,18 @@ class Image;
 
 enum {
   stateRequestStarted    = 1u << 0,
   stateHasSize           = 1u << 1,
   stateDecodeStarted     = 1u << 2,
   stateDecodeStopped     = 1u << 3,
   stateFrameStopped      = 1u << 4,
   stateRequestStopped    = 1u << 5,
-  stateBlockingOnload    = 1u << 6
+  stateBlockingOnload    = 1u << 6,
+  stateImageIsAnimated   = 1u << 7
 };
 
 /*
  * The image status tracker is a class that encapsulates all the loading and
  * decoding status about an Image, and makes it possible to send notifications
  * to imgRequestProxys, both synchronously (i.e., the status now) and
  * asynchronously (the status later).
  *