Bug 1238564 - Get rid of cross stacking context parent scroll clip. r?mattwoodrow
MozReview-Commit-ID: JthSGAb5Kp3
--- a/layout/base/DisplayItemScrollClip.cpp
+++ b/layout/base/DisplayItemScrollClip.cpp
@@ -13,17 +13,17 @@ namespace mozilla {
DisplayItemScrollClip::IsAncestor(const DisplayItemScrollClip* aAncestor,
const DisplayItemScrollClip* aDescendant)
{
if (!aAncestor) {
// null means root.
return true;
}
- for (const DisplayItemScrollClip* sc = aDescendant; sc; sc = sc->mCrossStackingContextParent) {
+ for (const DisplayItemScrollClip* sc = aDescendant; sc; sc = sc->mParent) {
if (sc == aAncestor) {
return true;
}
}
return false;
}
--- a/layout/base/DisplayItemScrollClip.h
+++ b/layout/base/DisplayItemScrollClip.h
@@ -24,38 +24,34 @@ class DisplayItemClip;
* composition time, after any async scroll offsets have been applied.
* Scroll clips are created during display list construction when
* async-scrollable scroll frames are entered. At that point, the current
* regular clip is cleared on the display list clip state. They are also
* created for scroll frames that are inactivate and not async scrollable;
* in that case, mIsAsyncScrollable on the scroll clip will be false.
* When async-scrollable scroll frames are nested, the inner display items
* can walk the whole chain of scroll clips via the DisplayItemScrollClip's
- * mParent pointer, or its mCrossStackingContextParent pointer if they need
- * access to the complete chain.
+ * mParent pointer.
* Storing scroll clips on display items allows easy access of all scroll
* frames that affect a certain display item, and it allows some display list
* operations to compute more accurate clips, for example when computing the
* bounds of a container item for a frame that contains an async-scrollable
* scroll frame.
*/
class DisplayItemScrollClip {
public:
DisplayItemScrollClip(const DisplayItemScrollClip* aParent,
- const DisplayItemScrollClip* aCrossStackingContextParent,
nsIScrollableFrame* aScrollableFrame,
const DisplayItemClip* aClip,
bool aIsAsyncScrollable)
: mParent(aParent)
, mScrollableFrame(aScrollableFrame)
, mClip(aClip)
, mIsAsyncScrollable(aIsAsyncScrollable)
- , mCrossStackingContextParent(aCrossStackingContextParent)
- , mCrossStackingContextDepth(aCrossStackingContextParent ?
- aCrossStackingContextParent->mCrossStackingContextDepth + 1 : 1)
+ , mDepth(aParent ? aParent->mDepth + 1 : 1)
{
MOZ_ASSERT(mScrollableFrame);
}
/**
* "Pick descendant" is analogous to the intersection operation on regular
* clips: In some cases, there are multiple candidate clips that can apply to
* an item, one of them being the ancestor of the other. This method picks
@@ -113,21 +109,16 @@ public:
/**
* Whether this scroll clip is for an async-scrollable scroll frame.
* Can change during display list construction.
*/
bool mIsAsyncScrollable;
private:
static uint32_t Depth(const DisplayItemScrollClip* aSC)
- { return aSC ? aSC->mCrossStackingContextDepth : 0; }
+ { return aSC ? aSC->mDepth : 0; }
- /**
- * The previous (outer) scroll clip, across stacking contexts, or null.
- */
- const DisplayItemScrollClip* mCrossStackingContextParent;
-
- const uint32_t mCrossStackingContextDepth;
+ const uint32_t mDepth;
};
} // namespace mozilla
#endif /* DISPLAYITEMSCROLLCLIP_H_ */
--- a/layout/base/DisplayListClipState.cpp
+++ b/layout/base/DisplayListClipState.cpp
@@ -115,38 +115,30 @@ DisplayListClipState::GetCurrentInnermos
mScrollClipContentDescendants, mScrollClipContainingBlockDescendants);
}
void
DisplayListClipState::TurnClipIntoScrollClipForContentDescendants(
nsDisplayListBuilder* aBuilder, nsIScrollableFrame* aScrollableFrame)
{
const DisplayItemScrollClip* parent = GetCurrentInnermostScrollClip();
- const DisplayItemScrollClip* crossStackingContextParent = parent;
- if (!crossStackingContextParent) {
- crossStackingContextParent = mCrossStackingContextParentScrollClip;
- }
mScrollClipContentDescendants =
- aBuilder->AllocateDisplayItemScrollClip(parent, crossStackingContextParent,
+ aBuilder->AllocateDisplayItemScrollClip(parent,
aScrollableFrame,
GetCurrentCombinedClip(aBuilder), true);
Clear();
}
void
DisplayListClipState::TurnClipIntoScrollClipForContainingBlockDescendants(
nsDisplayListBuilder* aBuilder, nsIScrollableFrame* aScrollableFrame)
{
const DisplayItemScrollClip* parent = GetCurrentInnermostScrollClip();
- const DisplayItemScrollClip* crossStackingContextParent = parent;
- if (!crossStackingContextParent) {
- crossStackingContextParent = mCrossStackingContextParentScrollClip;
- }
mScrollClipContainingBlockDescendants =
- aBuilder->AllocateDisplayItemScrollClip(parent, crossStackingContextParent,
+ aBuilder->AllocateDisplayItemScrollClip(parent,
aScrollableFrame,
GetCurrentCombinedClip(aBuilder), true);
Clear();
}
const DisplayItemClip*
WithoutRoundedCorners(nsDisplayListBuilder* aBuilder, const DisplayItemClip* aClip)
{
@@ -165,22 +157,18 @@ DisplayListClipState::CreateInactiveScro
// We ignore the rounded corners on the current clip because we don't want
// them to be double-applied (as scroll clip and as regular clip).
// Double-applying rectangle clips doesn't make a visual difference so it's
// fine.
const DisplayItemClip* rectClip =
WithoutRoundedCorners(aBuilder, GetCurrentCombinedClip(aBuilder));
const DisplayItemScrollClip* parent = GetCurrentInnermostScrollClip();
- const DisplayItemScrollClip* crossStackingContextParent = parent;
- if (!crossStackingContextParent) {
- crossStackingContextParent = mCrossStackingContextParentScrollClip;
- }
DisplayItemScrollClip* scrollClip =
- aBuilder->AllocateDisplayItemScrollClip(parent, crossStackingContextParent,
+ aBuilder->AllocateDisplayItemScrollClip(parent,
aScrollableFrame,
rectClip, false);
return scrollClip;
}
DisplayItemScrollClip*
DisplayListClipState::InsertInactiveScrollClipForContentDescendants(
nsDisplayListBuilder* aBuilder, nsIScrollableFrame* aScrollableFrame)
--- a/layout/base/DisplayListClipState.h
+++ b/layout/base/DisplayListClipState.h
@@ -24,17 +24,16 @@ namespace mozilla {
class DisplayListClipState {
public:
DisplayListClipState()
: mClipContentDescendants(nullptr)
, mClipContainingBlockDescendants(nullptr)
, mCurrentCombinedClip(nullptr)
, mScrollClipContentDescendants(nullptr)
, mScrollClipContainingBlockDescendants(nullptr)
- , mCrossStackingContextParentScrollClip(nullptr)
, mStackingContextAncestorSC(nullptr)
{}
/**
* Returns intersection of mClipContainingBlockDescendants and
* mClipContentDescendants, allocated on aBuilder's arena.
*/
const DisplayItemClip* GetCurrentCombinedClip(nsDisplayListBuilder* aBuilder);
@@ -90,17 +89,16 @@ private:
}
void EnterStackingContextContents(bool aClear)
{
if (aClear) {
mClipContentDescendants = nullptr;
mClipContainingBlockDescendants = nullptr;
mCurrentCombinedClip = nullptr;
- mCrossStackingContextParentScrollClip = GetCurrentInnermostScrollClip();
mScrollClipContentDescendants = nullptr;
mScrollClipContainingBlockDescendants = nullptr;
mStackingContextAncestorSC = nullptr;
} else {
mStackingContextAncestorSC = GetCurrentInnermostScrollClip();
}
}
@@ -179,17 +177,16 @@ private:
*/
const DisplayItemClip* mCurrentCombinedClip;
/**
* The same for scroll clips.
*/
const DisplayItemScrollClip* mScrollClipContentDescendants;
const DisplayItemScrollClip* mScrollClipContainingBlockDescendants;
- const DisplayItemScrollClip* mCrossStackingContextParentScrollClip;
/**
* A scroll clip that is an ancestor of all the scroll clips that were
* "current" on this clip state since EnterStackingContextContents was
* called.
*/
const DisplayItemScrollClip* mStackingContextAncestorSC;
};
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1009,24 +1009,23 @@ nsDisplayListBuilder::AllocateDisplayIte
DisplayItemClip* c = new (p) DisplayItemClip(aOriginal);
mDisplayItemClipsToDestroy.AppendElement(c);
return c;
}
DisplayItemScrollClip*
nsDisplayListBuilder::AllocateDisplayItemScrollClip(const DisplayItemScrollClip* aParent,
- const DisplayItemScrollClip* aCrossStackingContextParent,
nsIScrollableFrame* aScrollableFrame,
const DisplayItemClip* aClip,
bool aIsAsyncScrollable)
{
void* p = Allocate(sizeof(DisplayItemScrollClip));
DisplayItemScrollClip* c =
- new (p) DisplayItemScrollClip(aParent, aCrossStackingContextParent, aScrollableFrame, aClip, aIsAsyncScrollable);
+ new (p) DisplayItemScrollClip(aParent, aScrollableFrame, aClip, aIsAsyncScrollable);
mScrollClipsToDestroy.AppendElement(c);
return c;
}
const nsIFrame*
nsDisplayListBuilder::FindReferenceFrameFor(const nsIFrame *aFrame,
nsPoint* aOffset)
{
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -636,17 +636,16 @@ public:
*/
const DisplayItemClip* AllocateDisplayItemClip(const DisplayItemClip& aOriginal);
/**
* Allocate a new DisplayItemScrollClip in the arena. Will be cleaned up
* automatically when the arena goes away.
*/
DisplayItemScrollClip* AllocateDisplayItemScrollClip(const DisplayItemScrollClip* aParent,
- const DisplayItemScrollClip* aCrossStackingContextParent,
nsIScrollableFrame* aScrollableFrame,
const DisplayItemClip* aClip,
bool aIsAsyncScrollable);
/**
* Transfer off main thread animations to the layer. May be called
* with aBuilder and aItem both null, but only if the caller has
* already checked that off main thread animations should be sent to