Bug 1419021 - Part 1: Invalidate display items when we get a size for decoded images since this can change the display items we build. r=tnikkel
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 14 Dec 2017 17:37:56 -0600
changeset 396424 5d4f37b2ab23037d29673729855b8bce824bb3a0
parent 396423 3b21a98026b79238649ad459e96263bfba8c7f5f
child 396425 0b56d4134b331a150ae644a58c581a798671dfb4
push id98312
push usermwoodrow@mozilla.com
push dateThu, 14 Dec 2017 23:40:04 +0000
treeherdermozilla-inbound@969f4ef3c4b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1419021
milestone59.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 1419021 - Part 1: Invalidate display items when we get a size for decoded images since this can change the display items we build. r=tnikkel This breaks rendering when we try do a sync decode paint since we might not have created the nsDisplayImage/nsDisplayBackgroundImage yet (or cached the empty size) and so we never get to the actual paint call.
layout/generic/nsImageFrame.cpp
layout/style/ImageLoader.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -578,16 +578,18 @@ nsImageFrame::OnSizeAvailable(imgIReques
 
     // Have to size to 0,0 so that GetDesiredSize recalculates the size.
     mIntrinsicSize.width.SetCoordValue(0);
     mIntrinsicSize.height.SetCoordValue(0);
     mIntrinsicRatio.SizeTo(0, 0);
     intrinsicSizeChanged = true;
   }
 
+  MarkNeedsDisplayItemRebuild();
+
   if (intrinsicSizeChanged && (mState & IMAGE_GOTINITIALREFLOW)) {
     // Now we need to reflow if we have an unconstrained size and have
     // already gotten the initial reflow
     if (!(mState & IMAGE_SIZECONSTRAINED)) {
       nsIPresShell *presShell = presContext->GetPresShell();
       NS_ASSERTION(presShell, "No PresShell.");
       if (presShell) {
         presShell->FrameNeedsReflow(this, nsIPresShell::eStyleChange,
--- a/layout/style/ImageLoader.cpp
+++ b/layout/style/ImageLoader.cpp
@@ -446,16 +446,30 @@ ImageLoader::OnSizeAvailable(imgIRequest
 {
   nsPresContext* presContext = GetPresContext();
   if (!presContext) {
     return NS_OK;
   }
 
   aImage->SetAnimationMode(presContext->ImageAnimationMode());
 
+  FrameSet* frameSet = nullptr;
+  if (!mRequestToFrameMap.Get(aRequest, &frameSet)) {
+    return NS_OK;
+  }
+
+  FrameSet::size_type length = frameSet->Length();
+  for (FrameSet::size_type i = 0; i < length; i++) {
+    nsIFrame* frame = frameSet->ElementAt(i);
+
+    if (frame->StyleVisibility()->IsVisible()) {
+      frame->MarkNeedsDisplayItemRebuild();
+    }
+  }
+
   return NS_OK;
 }
 
 nsresult
 ImageLoader::OnImageIsAnimated(imgIRequest* aRequest)
 {
   if (!mDocument) {
     return NS_OK;