Put the presshell background color underneath as well.
draft
Put the presshell background color underneath as well.
--- 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;
}