Bug 1324691 - Part 2: Move AnimationsWithDestroyedFrame into RestyleManagerBase. r=hiro

Both ServoRestyleManager and RestyleManager need AnimationsWithDestroyedFrame,
so move it to the base class.

MozReview-Commit-ID: BswoDYm0gS1
This commit is contained in:
Boris Chiou
2017-01-26 17:05:53 +08:00
parent 8019f824cb
commit 9a29980c26
5 changed files with 118 additions and 109 deletions

View File

@@ -50,8 +50,6 @@ private:
{
MOZ_ASSERT(!mReframingStyleContexts,
"temporary member should be nulled out before destruction");
MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
"leaving dangling pointers from AnimationsWithDestroyedFrame");
}
public:
@@ -221,62 +219,6 @@ public:
nsStyleContext* aOldStyleContext,
RefPtr<nsStyleContext>* aNewStyleContext /* inout */);
// AnimationsWithDestroyedFrame is used to stop animations and transitions
// on elements that have no frame at the end of the restyling process.
// It only lives during the restyling process.
class MOZ_STACK_CLASS AnimationsWithDestroyedFrame final {
public:
// Construct a AnimationsWithDestroyedFrame object. The caller must
// ensure that aRestyleManager lives at least as long as the
// object. (This is generally easy since the caller is typically a
// method of RestyleManager.)
explicit AnimationsWithDestroyedFrame(RestyleManager* aRestyleManager);
// This method takes the content node for the generated content for
// animation/transition on ::before and ::after, rather than the
// content node for the real element.
void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
MOZ_ASSERT(aContent);
CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
if (pseudoType == CSSPseudoElementType::NotPseudo) {
mContents.AppendElement(aContent);
} else if (pseudoType == CSSPseudoElementType::before) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
mBeforeContents.AppendElement(aContent->GetParent());
} else if (pseudoType == CSSPseudoElementType::after) {
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
mAfterContents.AppendElement(aContent->GetParent());
}
}
void StopAnimationsForElementsWithoutFrames();
private:
void StopAnimationsWithoutFrame(nsTArray<RefPtr<nsIContent>>& aArray,
CSSPseudoElementType aPseudoType);
RestyleManager* mRestyleManager;
AutoRestore<AnimationsWithDestroyedFrame*> mRestorePointer;
// Below three arrays might include elements that have already had their
// animations or transitions stopped.
//
// mBeforeContents and mAfterContents hold the real element rather than
// the content node for the generated content (which might change during
// a reframe)
nsTArray<RefPtr<nsIContent>> mContents;
nsTArray<RefPtr<nsIContent>> mBeforeContents;
nsTArray<RefPtr<nsIContent>> mAfterContents;
};
/**
* Return the current AnimationsWithDestroyedFrame struct, or null if we're
* not currently in a restyling operation.
*/
AnimationsWithDestroyedFrame* GetAnimationsWithDestroyedFrame() {
return mAnimationsWithDestroyedFrame;
}
private:
void RestyleForEmptyChange(Element* aContainer);
@@ -509,7 +451,6 @@ private:
uint64_t mAnimationGeneration;
ReframingStyleContexts* mReframingStyleContexts;
AnimationsWithDestroyedFrame* mAnimationsWithDestroyedFrame;
RestyleTracker mPendingRestyles;