Bug 1079627 (Part 5) - Allow recursive notifications in NotifyProgress. r=tn a=lmandel
authorSeth Fowler <seth@mozilla.com>
Thu, 15 Jan 2015 15:11:36 -0800
changeset 249808 5586653fe1255091a0a5a0b41673f990321d1619
parent 249807 10510070c482dafaa4e9a7e957d732864bc1b555
child 249809 3aa609c00599f68a6465e6ced57e8ebe28e551f6
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn, lmandel
bugs1079627
milestone37.0a2
Bug 1079627 (Part 5) - Allow recursive notifications in NotifyProgress. r=tn a=lmandel
image/src/RasterImage.cpp
image/src/RasterImage.h
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -264,18 +264,16 @@ RasterImage::RasterImage(ProgressTracker
   mLockCount(0),
   mDecodeCount(0),
   mRequestedSampleSize(0),
 #ifdef DEBUG
   mFramesNotified(0),
 #endif
   mSourceBuffer(new SourceBuffer()),
   mFrameCount(0),
-  mNotifyProgress(NoProgress),
-  mNotifying(false),
   mHasSize(false),
   mDecodeOnDraw(false),
   mTransient(false),
   mDiscardable(false),
   mHasSourceData(false),
   mHasBeenDecoded(false),
   mPendingAnimation(false),
   mAnimationFinished(false),
@@ -1847,53 +1845,24 @@ RasterImage::NotifyProgress(Progress aPr
                             uint32_t aFlags /* = DECODE_FLAGS_DEFAULT */)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Ensure that we stay alive long enough to finish notifying.
   nsRefPtr<RasterImage> image(this);
 
   bool wasDefaultFlags = aFlags == DECODE_FLAGS_DEFAULT;
-  Progress progress = aProgress;
-  nsIntRect invalidRect = aInvalidRect;
 
-  if (!invalidRect.IsEmpty() && wasDefaultFlags) {
+  if (!aInvalidRect.IsEmpty() && wasDefaultFlags) {
     // Update our image container since we're invalidating.
     UpdateImageContainer();
   }
 
-  if (mNotifying) {
-    // Accumulate the progress changes. We don't permit recursive notifications
-    // because they cause subtle concurrency bugs, so we'll delay sending out
-    // the notifications until we pop back to the lowest invocation of
-    // NotifyProgress on the stack.
-    mNotifyProgress |= progress;
-    mNotifyInvalidRect.Union(invalidRect);
-  } else {
-    MOZ_ASSERT(mNotifyProgress == NoProgress && mNotifyInvalidRect.IsEmpty(),
-               "Shouldn't have an accumulated change at this point");
-
-    progress = image->mProgressTracker->Difference(progress);
-
-    while (progress != NoProgress || !invalidRect.IsEmpty()) {
-      // Tell the observers what happened.
-      mNotifying = true;
-      image->mProgressTracker->SyncNotifyProgress(progress, invalidRect);
-      mNotifying = false;
-
-      // Gather any progress changes that may have occurred as a result of sending
-      // out the previous notifications. If there were any, we'll send out
-      // notifications for them next.
-      progress = image->mProgressTracker->Difference(mNotifyProgress);
-      mNotifyProgress = NoProgress;
-
-      invalidRect = mNotifyInvalidRect;
-      mNotifyInvalidRect = nsIntRect();
-    }
-  }
+  // Tell the observers what happened.
+  image->mProgressTracker->SyncNotifyProgress(aProgress, aInvalidRect);
 }
 
 void
 RasterImage::FinalizeDecoder(Decoder* aDecoder)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aDecoder);
   MOZ_ASSERT(mError || mHasSize || !aDecoder->HasSize(),
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -371,21 +371,16 @@ private: // data
 #endif
 
   // The source data for this image.
   nsRefPtr<SourceBuffer>     mSourceBuffer;
 
   // The number of frames this image has.
   uint32_t                   mFrameCount;
 
-  // Notification state. Used to avoid recursive notifications.
-  Progress                   mNotifyProgress;
-  nsIntRect                  mNotifyInvalidRect;
-  bool                       mNotifying:1;
-
   // Boolean flags (clustered together to conserve space):
   bool                       mHasSize:1;       // Has SetSize() been called?
   bool                       mDecodeOnDraw:1;  // Decoding on draw?
   bool                       mTransient:1;     // Is the image short-lived?
   bool                       mDiscardable:1;   // Is container discardable?
   bool                       mHasSourceData:1; // Do we have source data?
   bool                       mHasBeenDecoded:1; // Decoded at least once?