diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 526ac1c107c1..3a2a16269bb8 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3019,6 +3019,25 @@ nsLayoutUtils::CalculateAndSetDisplayPortMargins(nsIScrollableFrame* aScrollFram content, presShell, displayportMargins, 0, aRepaintMode); } +bool +nsLayoutUtils::WantDisplayPort(const nsDisplayListBuilder* aBuilder, + nsIFrame* aScrollFrame) +{ + nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollFrame); + if (!scrollableFrame) { + return false; + } + + // We perform an optimization where we ensure that at least one + // async-scrollable frame (i.e. one that WantAsyncScroll()) has a displayport. + // If that's not the case yet, and we are async-scrollable, we will get a + // displayport. + return aBuilder->IsPaintingToWindow() && + nsLayoutUtils::AsyncPanZoomEnabled(aScrollFrame) && + !aBuilder->HaveScrollableDisplayPort() && + scrollableFrame->WantAsyncScroll(); +} + bool nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder, nsIFrame* aScrollFrame, @@ -3037,17 +3056,7 @@ nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder, bool haveDisplayPort = GetDisplayPort(content, aOutDisplayport); - // We perform an optimization where we ensure that at least one - // async-scrollable frame (i.e. one that WantsAsyncScroll()) has a displayport. - // If that's not the case yet, and we are async-scrollable, we will get a - // displayport. - // Note: we only do this in processes where we do subframe scrolling to - // begin with (i.e., not in the parent process on B2G). - if (aBuilder.IsPaintingToWindow() && - nsLayoutUtils::AsyncPanZoomEnabled(aScrollFrame) && - !aBuilder.HaveScrollableDisplayPort() && - scrollableFrame->WantAsyncScroll()) { - + if (WantDisplayPort(&aBuilder, aScrollFrame)) { // If we don't already have a displayport, calculate and set one. if (!haveDisplayPort) { CalculateAndSetDisplayPortMargins(scrollableFrame, nsLayoutUtils::RepaintMode::DoNotRepaint); diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 9f04f45c894a..75fa6d36f8c8 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -2654,6 +2654,12 @@ public: static bool CalculateAndSetDisplayPortMargins(nsIScrollableFrame* aScrollFrame, RepaintMode aRepaintMode); + /** + * Return true if GetOrMaybeCreateDisplayPort would create a displayport. + */ + static bool WantDisplayPort(const nsDisplayListBuilder* aBuilder, + nsIFrame* aScrollFrame); + /** * Get the display port for |aScrollFrame|'s content. If |aScrollFrame| * WantsAsyncScroll() and we don't have a scrollable displayport yet (as diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index bd3cb523fc80..dc078c6a3950 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2778,6 +2778,13 @@ ClipListsExceptCaret(nsDisplayListCollection* aLists, ClipItemsExceptCaret(aLists->Content(), aBuilder, aClipFrame, clip, aUsingDisplayPort); } +bool +ScrollFrameHelper::IsUsingDisplayPort(const nsDisplayListBuilder* aBuilder) const +{ + return aBuilder->IsPaintingToWindow() && + nsLayoutUtils::GetDisplayPort(mOuter->GetContent()); +} + void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, @@ -2818,8 +2825,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, bool createLayersForScrollbars = mIsRoot && mOuter->PresContext()->IsRootContentDocument(); - bool usingDisplayPort = aBuilder->IsPaintingToWindow() && - nsLayoutUtils::GetDisplayPort(mOuter->GetContent()); + bool usingDisplayPort = IsUsingDisplayPort(aBuilder); if (aBuilder->GetIgnoreScrollFrame() == mOuter || IsIgnoringViewportClipping()) { // Root scrollframes have FrameMetrics and clipping on their container diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 48d518a7ea7a..df596eea757e 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -81,6 +81,8 @@ public: bool aCreateLayer, bool aPositioned); + bool IsUsingDisplayPort(const nsDisplayListBuilder* aBuilder) const; + bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea, Sides aSkipSides, nscoord aRadii[8]) const;