From 5a7e4e2124a8c4cdbecaaf51b44dfea5a9004c12 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Wed, 6 Mar 2019 22:51:09 +0000 Subject: [PATCH] Bug 1528743 - Move the top-layer display items inside the async zoom container. r=mstange This maintains the important invariant that layers that carry scroll metadata for the RCD-RSF are inside the async zoom container. Differential Revision: https://phabricator.services.mozilla.com/D22049 --HG-- extra : moz-landing-system : lando --- layout/generic/ViewportFrame.cpp | 12 ------------ layout/generic/nsGfxScrollFrame.cpp | 24 ++++++++++++++++++++++++ layout/generic/nsGfxScrollFrame.h | 12 ++++++++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/layout/generic/ViewportFrame.cpp b/layout/generic/ViewportFrame.cpp index e31624385f39..5c63475bbbbf 100644 --- a/layout/generic/ViewportFrame.cpp +++ b/layout/generic/ViewportFrame.cpp @@ -60,18 +60,6 @@ void ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // below negative z-index elements. BuildDisplayListForChild(aBuilder, kid, aLists); } - - nsDisplayList topLayerList; - BuildDisplayListForTopLayer(aBuilder, &topLayerList); - if (!topLayerList.IsEmpty()) { - // Wrap the whole top layer in a single item with maximum z-index, - // and append it at the very end, so that it stays at the topmost. - nsDisplayWrapList* wrapList = - MakeDisplayItem(aBuilder, this, &topLayerList); - wrapList->SetOverrideZIndex( - std::numeric_limitsZIndex())>::max()); - aLists.PositionedDescendants()->AppendToTop(wrapList); - } } #ifdef DEBUG diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 46e87d70da96..ab61d213c9df 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -68,6 +68,7 @@ #include "UnitTransforms.h" #include "nsPluginFrame.h" #include "nsSliderFrame.h" +#include "ViewportFrame.h" #include "mozilla/layers/APZCCallbackHelper.h" #include "mozilla/layers/AxisPhysicsModel.h" #include "mozilla/layers/AxisPhysicsMSDModel.h" @@ -3378,6 +3379,8 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, mOuter->BuildDisplayListForChild(aBuilder, mScrolledFrame, aLists); } + MaybeAddTopLayerItems(aBuilder, aLists); + if (addScrollBars) { // Add overlay scrollbars. AppendScrollPartsTo(aBuilder, aLists, createLayersForScrollbars, true); @@ -3662,6 +3665,8 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, } } + MaybeAddTopLayerItems(aBuilder, set); + if (willBuildAsyncZoomContainer) { MOZ_ASSERT(mClipAllDescendants); @@ -3735,6 +3740,25 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, scrolledContent.MoveTo(aLists); } +void ScrollFrameHelper::MaybeAddTopLayerItems(nsDisplayListBuilder* aBuilder, + const nsDisplayListSet& aLists) { + if (mIsRoot) { + if (ViewportFrame* viewportFrame = do_QueryFrame(mOuter->GetParent())) { + nsDisplayList topLayerList; + viewportFrame->BuildDisplayListForTopLayer(aBuilder, &topLayerList); + if (!topLayerList.IsEmpty()) { + // Wrap the whole top layer in a single item with maximum z-index, + // and append it at the very end, so that it stays at the topmost. + nsDisplayWrapList* wrapList = MakeDisplayItem( + aBuilder, viewportFrame, &topLayerList); + wrapList->SetOverrideZIndex( + std::numeric_limitsZIndex())>::max()); + aLists.PositionedDescendants()->AppendToTop(wrapList); + } + } + } +} + bool ScrollFrameHelper::DecideScrollableLayer( nsDisplayListBuilder* aBuilder, nsRect* aVisibleRect, nsRect* aDirtyRect, bool aSetBase, bool* aDirtyRectHasBeenOverriden) { diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index c28a2a109ab9..39286ed0278f 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -82,6 +82,18 @@ class ScrollFrameHelper : public nsIReflowCallback { void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists); + // Add display items for the top-layer (which includes things like + // the fullscreen element, its backdrop, and text selection carets) + // to |aLists|. + // This is a no-op for scroll frames other than the viewport's + // root scroll frame. + // This should be called with an nsDisplayListSet that will be + // wrapped in the async zoom container, if we're building one. + // It should not be called with an ASR setter on the stack, as the + // top-layer items handle setting up their own ASRs. + void MaybeAddTopLayerItems(nsDisplayListBuilder* aBuilder, + const nsDisplayListSet& aLists); + void AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists, bool aCreateLayer, bool aPositioned);