Bug 1439285: Hack around bug 1406134. r=bholley
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 22 Feb 2018 20:03:43 +0100
changeset 404883 1218f0cd72df90ec988a8028e04393065201b9bf
parent 404882 90dde2f81fa039d4a3ed63736cde73b8fc7b9b30
child 404884 e912232f4b2b6439c6557ac809a37e7b607fb07d
push id60034
push userecoal95@gmail.com
push dateThu, 22 Feb 2018 19:56:26 +0000
treeherderautoland@1218f0cd72df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1439285, 1406134
milestone60.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 1439285: Hack around bug 1406134. r=bholley MozReview-Commit-ID: Cg2HxB99cGD
layout/style/nsStyleStruct.cpp
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2194,17 +2194,18 @@ nsStyleImageRequest::~nsStyleImageReques
 
   MOZ_ASSERT(!mRequestProxy);
   MOZ_ASSERT(!mImageValue);
   MOZ_ASSERT(!mImageTracker);
 }
 
 bool
 nsStyleImageRequest::Resolve(
-  nsPresContext* aPresContext, const nsStyleImageRequest* aOldImageRequest)
+  nsPresContext* aPresContext,
+  const nsStyleImageRequest* aOldImageRequest)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!IsResolved(), "already resolved");
   MOZ_ASSERT(aPresContext);
 
   mResolved = true;
 
   nsIDocument* doc = aPresContext->Document();
@@ -2214,32 +2215,47 @@ nsStyleImageRequest::Resolve(
     RefPtr<nsIURI> imageURI = GetImageURI();
     imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
     if (isEqualExceptRef) {
       // Prevent loading an internal resource.
       return true;
     }
   }
 
-  mDocGroup = doc->GetDocGroup();
-
-  mImageValue->Initialize(doc);
-
-  nsCSSValue value;
-  value.SetImageValue(mImageValue);
-  mRequestProxy = value.GetPossiblyStaticImageValue(aPresContext->Document(),
-                                                    aPresContext);
+  // TODO(emilio, bug 1440442): This is a hackaround to avoid flickering due the
+  // lack of non-http image caching in imagelib (bug 1406134), which causes
+  // stuff like bug 1439285. Cleanest fix if that doesn't get fixed is bug
+  // 1440305, but that seems too risky, and a lot of work to do before 60.
+  //
+  // Once that's fixed, the "old style" argument to FinishStyle can go away.
+  if (aPresContext->IsChrome() && aOldImageRequest &&
+      aOldImageRequest->IsResolved() && DefinitelyEquals(*aOldImageRequest)) {
+    MOZ_ASSERT(aOldImageRequest->mDocGroup == doc->GetDocGroup());
+    MOZ_ASSERT(mModeFlags == aOldImageRequest->mModeFlags);
+
+    mDocGroup = aOldImageRequest->mDocGroup;
+    mImageValue = aOldImageRequest->mImageValue;
+    mRequestProxy = aOldImageRequest->mRequestProxy;
+  } else {
+    mDocGroup = doc->GetDocGroup();
+    mImageValue->Initialize(doc);
+
+    nsCSSValue value;
+    value.SetImageValue(mImageValue);
+    mRequestProxy = value.GetPossiblyStaticImageValue(aPresContext->Document(),
+                                                      aPresContext);
+  }
 
   if (!mRequestProxy) {
     // The URL resolution or image load failed.
     return false;
   }
 
   if (mModeFlags & Mode::Track) {
-    mImageTracker = aPresContext->Document()->ImageTracker();
+    mImageTracker = doc->ImageTracker();
   }
 
   MaybeTrackAndLock();
   return true;
 }
 
 void
 nsStyleImageRequest::MaybeTrackAndLock()