Bug 919144. Part 4: Create nsLayoutUtils::IsFixedPosFrameInDisplayPort. r=mats

--HG--
extra : rebase_source : a7b7179efd91838ec7205f7109182c78814d33c5
This commit is contained in:
Robert O'Callahan 2013-09-27 18:01:11 +12:00
parent 7676e34f90
commit 65c65dd2ce
2 changed files with 28 additions and 0 deletions

View File

@ -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)

View File

@ -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