Bug 1159502 - Don't block onload for multipart images. r=tn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Tue, 28 Apr 2015 15:51:32 -0700
changeset 271600 8e4ecd2f7a60c788135128352e3215acc85413f3
parent 271599 dfa398350b4a44bea8cfae8b52a4069d934b9d03
child 271601 a12fdf664207588dc6395b318b90efcfbdb20c71
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1159502
milestone40.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 1159502 - Don't block onload for multipart images. r=tn
image/src/MultipartImage.cpp
--- a/image/src/MultipartImage.cpp
+++ b/image/src/MultipartImage.cpp
@@ -150,32 +150,42 @@ MultipartImage::BeginTransitionToPart(Im
 
   // Start observing the next part; we'll complete the transition when
   // NextPartObserver calls FinishTransition.
   mNextPartObserver->BeginObserving(mNextPart);
   mNextPart->RequestDecode();
   mNextPart->IncrementAnimationConsumers();
 }
 
-void MultipartImage::FinishTransition()
+static Progress
+FilterProgress(Progress aProgress)
+{
+  // Filter out onload blocking notifications, since we don't want to block
+  // onload for multipart images.
+  return aProgress & ~(FLAG_ONLOAD_BLOCKED | FLAG_ONLOAD_UNBLOCKED);
+}
+
+void
+MultipartImage::FinishTransition()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mNextPart, "Should have a next part here");
 
   nsRefPtr<ProgressTracker> newCurrentPartTracker =
     mNextPart->GetProgressTracker();
   if (newCurrentPartTracker->GetProgress() & FLAG_HAS_ERROR) {
     // This frame has an error; drop it.
     mNextPart = nullptr;
 
     // We still need to notify, though.
     mTracker->ResetForNewRequest();
     nsRefPtr<ProgressTracker> currentPartTracker =
       InnerImage()->GetProgressTracker();
-    mTracker->SyncNotifyProgress(currentPartTracker->GetProgress());
+    mTracker
+      ->SyncNotifyProgress(FilterProgress(currentPartTracker->GetProgress()));
 
     return;
   }
 
   // Stop observing the current part.
   {
     nsRefPtr<ProgressTracker> currentPartTracker =
       InnerImage()->GetProgressTracker();
@@ -185,18 +195,19 @@ void MultipartImage::FinishTransition()
   // Make the next part become the current part.
   mTracker->ResetForNewRequest();
   SetInnerImage(mNextPart);
   mNextPart = nullptr;
   newCurrentPartTracker->AddObserver(this);
 
   // Finally, send all the notifications for the new current part and send a
   // FRAME_UPDATE notification so that observers know to redraw.
-  mTracker->SyncNotifyProgress(newCurrentPartTracker->GetProgress(),
-                               GetMaxSizedIntRect());
+  mTracker
+    ->SyncNotifyProgress(FilterProgress(newCurrentPartTracker->GetProgress()),
+                         GetMaxSizedIntRect());
 }
 
 already_AddRefed<imgIContainer>
 MultipartImage::Unwrap()
 {
   // Although we wrap another image, we don't allow callers to unwrap as. As far
   // as external code is concerned, MultipartImage is atomic.
   nsCOMPtr<imgIContainer> image = this;