зеркало из https://github.com/mozilla/pjs.git
Bug 653270: Simplify nsSMILAnimationController construction/initialization. r=jwatt
This commit is contained in:
Родитель
9a0a18126a
Коммит
e95eeb5a52
|
@ -5527,7 +5527,7 @@ nsDocument::GetAnimationController()
|
|||
if (!NS_SMILEnabled() || mLoadedAsData || mLoadedAsInteractiveData)
|
||||
return nsnull;
|
||||
|
||||
mAnimationController = NS_NewSMILAnimationController(this);
|
||||
mAnimationController = new nsSMILAnimationController(this);
|
||||
|
||||
// If there's a presContext then check the animation mode and pause if
|
||||
// necessary.
|
||||
|
|
|
@ -71,47 +71,18 @@ GetRefreshDriverForDoc(nsIDocument* aDoc)
|
|||
//----------------------------------------------------------------------
|
||||
// ctors, dtors, factory methods
|
||||
|
||||
nsSMILAnimationController::nsSMILAnimationController()
|
||||
nsSMILAnimationController::nsSMILAnimationController(nsIDocument* aDoc)
|
||||
: mAvgTimeBetweenSamples(0),
|
||||
mResampleNeeded(PR_FALSE),
|
||||
mDeferredStartSampling(PR_FALSE),
|
||||
mRunningSample(PR_FALSE),
|
||||
mDocument(nsnull)
|
||||
mDocument(aDoc)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aDoc, "need a non-null document");
|
||||
|
||||
mAnimationElementTable.Init();
|
||||
mChildContainerTable.Init();
|
||||
}
|
||||
|
||||
nsSMILAnimationController::~nsSMILAnimationController()
|
||||
{
|
||||
StopSampling(GetRefreshDriverForDoc(mDocument));
|
||||
NS_ASSERTION(mAnimationElementTable.Count() == 0,
|
||||
"Animation controller shouldn't be tracking any animation"
|
||||
" elements when it dies");
|
||||
}
|
||||
|
||||
nsSMILAnimationController* NS_NewSMILAnimationController(nsIDocument* aDoc)
|
||||
{
|
||||
nsSMILAnimationController* animationController =
|
||||
new nsSMILAnimationController();
|
||||
NS_ENSURE_TRUE(animationController, nsnull);
|
||||
|
||||
nsresult rv = animationController->Init(aDoc);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete animationController;
|
||||
animationController = nsnull;
|
||||
}
|
||||
|
||||
return animationController;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSMILAnimationController::Init(nsIDocument* aDoc)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDoc);
|
||||
|
||||
// Keep track of document, so we can traverse its set of animation elements
|
||||
mDocument = aDoc;
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriverForDoc(mDocument);
|
||||
if (refreshDriver) {
|
||||
mStartTime = refreshDriver->MostRecentRefresh();
|
||||
|
@ -121,8 +92,14 @@ nsSMILAnimationController::Init(nsIDocument* aDoc)
|
|||
mCurrentSampleTime = mStartTime;
|
||||
|
||||
Begin();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
nsSMILAnimationController::~nsSMILAnimationController()
|
||||
{
|
||||
StopSampling(GetRefreshDriverForDoc(mDocument));
|
||||
NS_ASSERTION(mAnimationElementTable.Count() == 0,
|
||||
"Animation controller shouldn't be tracking any animation"
|
||||
" elements when it dies");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -70,9 +70,8 @@ class nsIDocument;
|
|||
class nsSMILAnimationController : public nsSMILTimeContainer,
|
||||
public nsARefreshObserver
|
||||
{
|
||||
protected:
|
||||
nsSMILAnimationController();
|
||||
public:
|
||||
nsSMILAnimationController(nsIDocument* aDoc);
|
||||
~nsSMILAnimationController();
|
||||
|
||||
// nsSMILContainer
|
||||
|
@ -149,11 +148,6 @@ protected:
|
|||
nsSMILMilestone mMilestone;
|
||||
};
|
||||
|
||||
// Factory methods
|
||||
friend nsSMILAnimationController*
|
||||
NS_NewSMILAnimationController(nsIDocument* aDoc);
|
||||
nsresult Init(nsIDocument* aDoc);
|
||||
|
||||
// Cycle-collection implementation helpers
|
||||
PR_STATIC_CALLBACK(PLDHashOperator) CompositorTableEntryTraverse(
|
||||
nsSMILCompositor* aCompositor, void* aArg);
|
||||
|
@ -243,6 +237,4 @@ protected:
|
|||
nsAutoPtr<nsSMILCompositorTable> mLastCompositorTable;
|
||||
};
|
||||
|
||||
nsSMILAnimationController* NS_NewSMILAnimationController(nsIDocument *doc);
|
||||
|
||||
#endif // NS_SMILANIMATIONCONTROLLER_H_
|
||||
|
|
Загрузка…
Ссылка в новой задаче