Bug 1300864 - Define AutoCurrentActiveScrolledRootSetter::SetCurrentActiveScrolledRoot() out of line. r=mstange
MozReview-Commit-ID: FdtGza5wS6f
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -878,16 +878,56 @@ nsDisplayListBuilder::MergeItems(nsTArra
// of the temporary item.
merged->MergeDisplayListFromItem(this, item);
}
return merged;
}
void
+nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter::SetCurrentActiveScrolledRoot(
+ const ActiveScrolledRoot* aActiveScrolledRoot)
+{
+ MOZ_ASSERT(!mUsed);
+
+ // Set the builder's mCurrentActiveScrolledRoot.
+ mBuilder->mCurrentActiveScrolledRoot = aActiveScrolledRoot;
+
+ // We also need to adjust the builder's mCurrentContainerASR.
+ // mCurrentContainerASR needs to be an ASR that all the container's
+ // contents have finite bounds with respect to. If aActiveScrolledRoot
+ // is an ancestor ASR of mCurrentContainerASR, that means we need to
+ // set mCurrentContainerASR to aActiveScrolledRoot, because otherwise
+ // the items that will be created with aActiveScrolledRoot wouldn't
+ // have finite bounds with respect to mCurrentContainerASR. There's one
+ // exception, in the case where there's a content clip on the builder
+ // that is scrolled by a descendant ASR of aActiveScrolledRoot. This
+ // content clip will clip all items that are created while this
+ // AutoCurrentActiveScrolledRootSetter exists. This means that the items
+ // created during our lifetime will have finite bounds with respect to
+ // the content clip's ASR, even if the items' actual ASR is an ancestor
+ // of that. And it also means that mCurrentContainerASR only needs to be
+ // set to the content clip's ASR and not all the way to aActiveScrolledRoot.
+ // This case is tested by fixed-pos-scrolled-clip-opacity-layerize.html
+ // and fixed-pos-scrolled-clip-opacity-inside-layerize.html.
+
+ // finiteBoundsASR is the leafmost ASR that all items created during
+ // object's lifetime have finite bounds with respect to.
+ const ActiveScrolledRoot* finiteBoundsASR = ActiveScrolledRoot::PickDescendant(
+ mContentClipASR, aActiveScrolledRoot);
+
+ // mCurrentContainerASR is adjusted so that it's still an ancestor of
+ // finiteBoundsASR.
+ mBuilder->mCurrentContainerASR = ActiveScrolledRoot::PickAncestor(
+ mBuilder->mCurrentContainerASR, finiteBoundsASR);
+
+ mUsed = true;
+}
+
+void
nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter::InsertScrollFrame(nsIScrollableFrame* aScrollableFrame)
{
MOZ_ASSERT(!mUsed);
size_t descendantsEndIndex = mBuilder->mActiveScrolledRoots.Length();
const ActiveScrolledRoot* parentASR = mBuilder->mCurrentActiveScrolledRoot;
const ActiveScrolledRoot* asr = mBuilder->AllocateActiveScrolledRoot(parentASR, aScrollableFrame);
mBuilder->mCurrentActiveScrolledRoot = asr;
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -1213,53 +1213,17 @@ public:
{
}
~AutoCurrentActiveScrolledRootSetter()
{
mBuilder->mCurrentActiveScrolledRoot = mSavedActiveScrolledRoot;
}
- void SetCurrentActiveScrolledRoot(const ActiveScrolledRoot* aActiveScrolledRoot)
- {
- MOZ_ASSERT(!mUsed);
-
- // Set the builder's mCurrentActiveScrolledRoot.
- mBuilder->mCurrentActiveScrolledRoot = aActiveScrolledRoot;
-
- // We also need to adjust the builder's mCurrentContainerASR.
- // mCurrentContainerASR needs to be an ASR that all the container's
- // contents have finite bounds with respect to. If aActiveScrolledRoot
- // is an ancestor ASR of mCurrentContainerASR, that means we need to
- // set mCurrentContainerASR to aActiveScrolledRoot, because otherwise
- // the items that will be created with aActiveScrolledRoot wouldn't
- // have finite bounds with respect to mCurrentContainerASR. There's one
- // exception, in the case where there's a content clip on the builder
- // that is scrolled by a descendant ASR of aActiveScrolledRoot. This
- // content clip will clip all items that are created while this
- // AutoCurrentActiveScrolledRootSetter exists. This means that the items
- // created during our lifetime will have finite bounds with respect to
- // the content clip's ASR, even if the items' actual ASR is an ancestor
- // of that. And it also means that mCurrentContainerASR only needs to be
- // set to the content clip's ASR and not all the way to aActiveScrolledRoot.
- // This case is tested by fixed-pos-scrolled-clip-opacity-layerize.html
- // and fixed-pos-scrolled-clip-opacity-inside-layerize.html.
-
- // finiteBoundsASR is the leafmost ASR that all items created during
- // object's lifetime have finite bounds with respect to.
- const ActiveScrolledRoot* finiteBoundsASR = ActiveScrolledRoot::PickDescendant(
- mContentClipASR, aActiveScrolledRoot);
-
- // mCurrentContainerASR is adjusted so that it's still an ancestor of
- // finiteBoundsASR.
- mBuilder->mCurrentContainerASR = ActiveScrolledRoot::PickAncestor(
- mBuilder->mCurrentContainerASR, finiteBoundsASR);
-
- mUsed = true;
- }
+ void SetCurrentActiveScrolledRoot(const ActiveScrolledRoot* aActiveScrolledRoot);
void EnterScrollFrame(nsIScrollableFrame* aScrollableFrame)
{
MOZ_ASSERT(!mUsed);
ActiveScrolledRoot* asr = mBuilder->AllocateActiveScrolledRoot(
mBuilder->mCurrentActiveScrolledRoot, aScrollableFrame);
mBuilder->mCurrentActiveScrolledRoot = asr;
mUsed = true;