Put the presshell background color underneath as well. draft
authorMarkus Stange <mstange@themasta.com>
Wed, 28 Sep 2016 16:43:32 -0400
changeset 419130 aa821458371cebb53c07834e3a73d157086fba30
parent 419129 906ddf64d001f8fe5afc742a9ac8218523df8814
child 419131 c2e3b3142732640c69d761f42cec4805e32a43d6
push id30851
push userbmo:mstange@themasta.com
push dateThu, 29 Sep 2016 18:23:13 +0000
milestone52.0a1
Put the presshell background color underneath as well.
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5228,30 +5228,39 @@ PresShell::AddCanvasBackgroundColorItem(
   nscolor bgcolor = NS_ComposeColors(aBackstopColor, mCanvasBackgroundColor);
   if (NS_GET_A(bgcolor) == 0)
     return;
 
   // To make layers work better, we want to avoid having a big non-scrolled
   // color background behind a scrolled transparent background. Instead,
   // we'll try to move the color background into the scrolled content
   // by making nsDisplayCanvasBackground paint it.
+  bool addedScrollingBackgroundColor = false;
   if (!aFrame->GetParent()) {
     nsIScrollableFrame* sf =
       aFrame->PresContext()->PresShell()->GetRootScrollFrameAsScrollable();
     if (sf) {
       nsCanvasFrame* canvasFrame = do_QueryFrame(sf->GetScrolledFrame());
       if (canvasFrame && canvasFrame->IsVisibleForPainting(&aBuilder)) {
-        if (AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor))
-          return;
-      }
-    }
-  }
-
-  aList.AppendNewToBottom(
-    new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor));
+        addedScrollingBackgroundColor =
+          AddCanvasBackgroundColor(aList, canvasFrame, bgcolor, mHasCSSBackgroundColor);
+      }
+    }
+  }
+
+  if (!addedScrollingBackgroundColor ||
+      (nsLayoutUtils::UsesAsyncScrolling(aFrame) && NS_GET_A(bgcolor) == 255)) {
+    // With async scrolling, we'd like to have two instances of the background
+    // color: one that scrolls with the content (for the reasons stated above),
+    // and one underneath which does not scroll with the content, but which can
+    // be shown during checkerboarding and overscroll.
+    // We can only do that if the color is opaque.
+    aList.AppendNewToBottom(
+      new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor));
+  }
 }
 
 static bool IsTransparentContainerElement(nsPresContext* aPresContext)
 {
   nsCOMPtr<nsIDocShell> docShell = aPresContext->GetDocShell();
   if (!docShell) {
     return false;
   }