From 65c65dd2ce8c0140d5f2d6e8dfc51b05f149c108 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 27 Sep 2013 18:01:11 +1200 Subject: [PATCH] Bug 919144. Part 4: Create nsLayoutUtils::IsFixedPosFrameInDisplayPort. r=mats --HG-- extra : rebase_source : a7b7179efd91838ec7205f7109182c78814d33c5 --- layout/base/nsLayoutUtils.cpp | 19 +++++++++++++++++++ layout/base/nsLayoutUtils.h | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 7622f57911e..95b775dfead 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1198,6 +1198,25 @@ nsLayoutUtils::GetScrollableFrameFor(const nsIFrame *aScrolledFrame) return sf; } +bool +nsLayoutUtils::IsFixedPosFrameInDisplayPort(const nsIFrame* aFrame, nsRect* aDisplayPort) +{ + // Fixed-pos frames are parented by the viewport frame or the page content frame. + // We'll assume that printing/print preview don't have displayports for their + // pages! + nsIFrame* parent = aFrame->GetParent(); + if (!parent || parent->GetParent() || + aFrame->StyleDisplay()->mPosition != NS_STYLE_POSITION_FIXED) { + return false; + } + nsIFrame* rootScrollFrame = + aFrame->PresContext()->PresShell()->GetRootScrollFrame(); + // Treat a fixed-pos frame as an animated geometry root if it belongs to + // a viewport which has a scrollframe and a displayport. + return rootScrollFrame && + nsLayoutUtils::GetDisplayPort(rootScrollFrame->GetContent(), aDisplayPort); +} + nsIFrame* nsLayoutUtils::GetAnimatedGeometryRootFor(nsIFrame* aFrame, const nsIFrame* aStopAtAncestor) diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 72362edce76..f5485a782fe 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -361,6 +361,15 @@ public: static bool IsAncestorFrameCrossDoc(const nsIFrame* aAncestorFrame, const nsIFrame* aFrame, const nsIFrame* aCommonAncestor = nullptr); + /** + * Return true if aFrame is a fixed-pos frame and is a child of a viewport + * which has a displayport. These frames get special treatment from the compositor. + * aDisplayPort, if non-null, is set to the display port rectangle (relative to + * the viewport). + */ + static bool IsFixedPosFrameInDisplayPort(const nsIFrame* aFrame, + nsRect* aDisplayPort = nullptr); + /** * Finds the nearest ancestor frame that is considered to have (or will have) * "animated geometry". For example the scrolled frames of scrollframes which