From 9c468fcb6520f98fb00bfd1843ac9942cc6304f4 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Mon, 16 Oct 2017 01:50:35 -0500 Subject: [PATCH] Bug 1408607. Make all uses of mWillBuildScrollableLayer conditional on painting to the window. r=mstange This mostly restores us to the previous behaviour where we would set mWillBuildScrollableLayer to false for event handling display lists. But it's better because we don't keep flipping its value. The real reason we want to do this is that it fixes bugs with event handling. --- layout/generic/nsGfxScrollFrame.cpp | 35 +++++++++++++++------------ layout/generic/nsSubDocumentFrame.cpp | 3 ++- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 3879daa2160f..33f56d7588cc 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -3392,18 +3392,20 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, // area to the dispatch to content layer event regions) necessary to activate // a scroll frame so it creates a scrollable layer. bool couldBuildLayer = false; - if (mWillBuildScrollableLayer) { - couldBuildLayer = true; - } else { - couldBuildLayer = - nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && - WantAsyncScroll() && - // If we are using containers for root frames, and we are the root - // scroll frame for the display root, then we don't need a scroll - // info layer. nsDisplayList::PaintForFrame already calls - // ComputeFrameMetrics for us. - (!(gfxPrefs::LayoutUseContainersForRootFrames() && mIsRoot) || - (aBuilder->RootReferenceFrame()->PresContext() != mOuter->PresContext())); + if (aBuilder->IsPaintingToWindow()) { + if (mWillBuildScrollableLayer) { + couldBuildLayer = true; + } else { + couldBuildLayer = + nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && + WantAsyncScroll() && + // If we are using containers for root frames, and we are the root + // scroll frame for the display root, then we don't need a scroll + // info layer. nsDisplayList::PaintForFrame already calls + // ComputeFrameMetrics for us. + (!(gfxPrefs::LayoutUseContainersForRootFrames() && mIsRoot) || + (aBuilder->RootReferenceFrame()->PresContext() != mOuter->PresContext())); + } } // Now display the scrollbars and scrollcorner. These parts are drawn @@ -3505,7 +3507,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, } nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter asrSetter(aBuilder); - if (mWillBuildScrollableLayer) { + if (mWillBuildScrollableLayer && aBuilder->IsPaintingToWindow()) { asrSetter.EnterScrollFrame(sf); } @@ -3521,7 +3523,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsRect scrolledRectClip = GetUnsnappedScrolledRectInternal(mScrolledFrame->GetScrollableOverflowRect(), mScrollPort.Size()) + mScrolledFrame->GetPosition(); - if (mWillBuildScrollableLayer) { + if (mWillBuildScrollableLayer && aBuilder->IsPaintingToWindow()) { // Clip the contents to the display port. // The dirty rect already acts kind of like a clip, in that // FrameLayerBuilder intersects item bounds and opaque regions with @@ -3569,7 +3571,8 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, // above (where the idSetter variable is created). // // This is not compatible when using containes for root scrollframes. - MOZ_ASSERT(couldBuildLayer && mScrolledFrame->GetContent()); + MOZ_ASSERT(couldBuildLayer && mScrolledFrame->GetContent() && + aBuilder->IsPaintingToWindow()); if (!mWillBuildScrollableLayer) { // Set a displayport so next paint we don't have to force layerization // after the fact. @@ -3591,7 +3594,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, } } - if (mWillBuildScrollableLayer) { + if (mWillBuildScrollableLayer && aBuilder->IsPaintingToWindow()) { aBuilder->ForceLayerForScrollParent(); } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 260e58018fea..71e46aff30b4 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -404,7 +404,8 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, ©OfDirty, /* aSetBase = */ true); - if (!gfxPrefs::LayoutUseContainersForRootFrames()) { + if (!gfxPrefs::LayoutUseContainersForRootFrames() || + !aBuilder->IsPaintingToWindow()) { haveDisplayPort = false; }