Bug 1395964 - Don't clear the previously painted image on intrinsic size changes. r=tnikkel
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 18 Mar 2019 16:19:56 +0100
changeset 464822 fdc7b66d76a4ded62d0292bef4de0ffb090d9587
parent 464821 3f1e9dae2467e54c783215189e6cb9617cee7dcd
child 464823 b651bbce8a992c4716098f49fdc4169a0fb7de7b
push id35727
push userdvarga@mozilla.com
push dateTue, 19 Mar 2019 09:48:59 +0000
treeherdermozilla-central@70baa37ae1eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1395964
milestone68.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 1395964 - Don't clear the previously painted image on intrinsic size changes. r=tnikkel This is needed if we want to handle cases like the reporter's example or Google Images. Rendering the old image upscaled is much better than not rendering anything while it's loading. I added a test for the reframing bit, but I don't know how to add a test for the second bit. Differential Revision: https://phabricator.services.mozilla.com/D23127
layout/generic/nsImageFrame.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -686,18 +686,16 @@ nsresult nsImageFrame::OnSizeAvailable(i
     if (!(mState & IMAGE_SIZECONSTRAINED)) {
       PresShell()->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                                     NS_FRAME_IS_DIRTY);
     } else {
       // We've already gotten the initial reflow, and our size hasn't changed,
       // so we're ready to request a decode.
       MaybeDecodeForPredictedSize();
     }
-
-    mPrevImage = nullptr;
   }
 
   return NS_OK;
 }
 
 nsresult nsImageFrame::OnFrameUpdate(imgIRequest* aRequest,
                                      const nsIntRect* aRect) {
   NS_ENSURE_ARG_POINTER(aRect);
@@ -802,18 +800,16 @@ void nsImageFrame::NotifyNewCurrentReque
       if (!(mState & IMAGE_SIZECONSTRAINED)) {
         PresShell()->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
                                       NS_FRAME_IS_DIRTY);
       } else {
         // We've already gotten the initial reflow, and our size hasn't changed,
         // so we're ready to request a decode.
         MaybeDecodeForPredictedSize();
       }
-
-      mPrevImage = nullptr;
     }
     // Update border+content to account for image change
     InvalidateFrame();
   }
 }
 
 void nsImageFrame::MaybeDecodeForPredictedSize() {
   // Check that we're ready to decode.