Bug 1125401 - Replace ProgressTracker::IsLoading() with checks of the correct progress flags. r=tn
authorSeth Fowler <seth@mozilla.com>
Sat, 24 Jan 2015 23:16:46 -0800
changeset 225606 9ad3baed1c70884c60ccfc26b5be18e9a242833e
parent 225605 042523d55ed89d57ecd55a3f67702df963546ac9
child 225607 dcc5393d19501da8e2418a4d03085e12b548818e
push id28170
push userphilringnalda@gmail.com
push dateSun, 25 Jan 2015 19:44:07 +0000
treeherdermozilla-central@fa91879c8428 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1125401
milestone38.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 1125401 - Replace ProgressTracker::IsLoading() with checks of the correct progress flags. r=tn
image/src/ClippedImage.cpp
image/src/ProgressTracker.cpp
image/src/ProgressTracker.h
image/src/imgRequest.cpp
--- a/image/src/ClippedImage.cpp
+++ b/image/src/ClippedImage.cpp
@@ -142,17 +142,18 @@ ClippedImage::ShouldClip()
     } else if (NS_SUCCEEDED(InnerImage()->GetWidth(&width)) && width > 0 &&
                NS_SUCCEEDED(InnerImage()->GetHeight(&height)) && height > 0) {
       // Clamp the clipping region to the size of the underlying image.
       mClip = mClip.Intersect(nsIntRect(0, 0, width, height));
 
       // If the clipping region is the same size as the underlying image we
       // don't have to do anything.
       mShouldClip.emplace(!mClip.IsEqualInterior(nsIntRect(0, 0, width, height)));
-    } else if (progressTracker && progressTracker->IsLoading()) {
+    } else if (progressTracker &&
+               !(progressTracker->GetProgress() & FLAG_LOAD_COMPLETE)) {
       // The image just hasn't finished loading yet. We don't yet know whether
       // clipping with be needed or not for now. Just return without memoizing
       // anything.
       return false;
     } else {
       // We have a fully loaded image without a clearly defined width and
       // height. This can happen with SVG images.
       mShouldClip.emplace(false);
--- a/image/src/ProgressTracker.cpp
+++ b/image/src/ProgressTracker.cpp
@@ -94,25 +94,16 @@ ProgressTracker::SetImage(Image* aImage)
 
 void
 ProgressTracker::ResetImage()
 {
   NS_ABORT_IF_FALSE(mImage, "Resetting image when it's already null!");
   mImage = nullptr;
 }
 
-bool
-ProgressTracker::IsLoading() const
-{
-  // Checking for whether OnStopRequest has fired allows us to say we're
-  // loading before OnStartRequest gets called, letting the request properly
-  // get removed from the cache in certain cases.
-  return !(mProgress & FLAG_LOAD_COMPLETE);
-}
-
 uint32_t
 ProgressTracker::GetImageStatus() const
 {
   uint32_t status = imgIRequest::STATUS_NONE;
 
   // Translate our current state to a set of imgIRequest::STATE_* flags.
   if (mProgress & FLAG_SIZE_AVAILABLE) {
     status |= imgIRequest::STATUS_SIZE_AVAILABLE;
--- a/image/src/ProgressTracker.h
+++ b/image/src/ProgressTracker.h
@@ -83,20 +83,16 @@ public:
 
   bool HasImage() const { return mImage; }
   already_AddRefed<Image> GetImage() const
   {
     nsRefPtr<Image> image = mImage;
     return image.forget();
   }
 
-  // Returns whether we are in the process of loading; that is, whether we have
-  // not received OnStopRequest from Necko.
-  bool IsLoading() const;
-
   // Get the current image status (as in imgIRequest).
   uint32_t GetImageStatus() const;
 
   // Get the current Progress.
   Progress GetProgress() const { return mProgress; }
 
   // Schedule an asynchronous "replaying" of all the notifications that would
   // have to happen to put us in the current state.
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -228,17 +228,18 @@ nsresult imgRequest::RemoveProxy(imgRequ
     }
 #endif
 
     /* If |aStatus| is a failure code, then cancel the load if it is still in progress.
        Otherwise, let the load continue, keeping 'this' in the cache with no observers.
        This way, if a proxy is destroyed without calling cancel on it, it won't leak
        and won't leave a bad pointer in the observer list.
      */
-    if (progressTracker->IsLoading() && NS_FAILED(aStatus)) {
+    if (!(progressTracker->GetProgress() & FLAG_LAST_PART_COMPLETE) &&
+        NS_FAILED(aStatus)) {
       LOG_MSG(GetImgLog(), "imgRequest::RemoveProxy", "load in progress.  canceling");
 
       this->Cancel(NS_BINDING_ABORTED);
     }
 
     /* break the cycle from the cache entry. */
     mCacheEntry = nullptr;
   }
@@ -304,17 +305,17 @@ void imgRequest::ContinueCancel(nsresult
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsRefPtr<ProgressTracker> progressTracker = GetProgressTracker();
   progressTracker->SyncNotifyProgress(FLAG_HAS_ERROR | FLAG_ONLOAD_UNBLOCKED);
 
   RemoveFromCache();
 
-  if (mRequest && progressTracker->IsLoading()) {
+  if (mRequest && !(progressTracker->GetProgress() & FLAG_LAST_PART_COMPLETE)) {
      mRequest->Cancel(aStatus);
   }
 }
 
 class imgRequestMainThreadEvict : public nsRunnable
 {
 public:
   explicit imgRequestMainThreadEvict(imgRequest *aImgRequest)