Bug 590425 part 2 - SVG SMIL: Make nsPresShell's interaction with the animation controller account for deferred sampling; r=dholbert; a=roc

This commit is contained in:
Brian Birtles 2010-10-20 08:53:52 +09:00
parent f3ce784088
commit c1adc2184b
3 changed files with 30 additions and 8 deletions

View File

@ -255,6 +255,27 @@ nsSMILAnimationController::Unlink()
mLastCompositorTable = nsnull;
}
//----------------------------------------------------------------------
// Refresh driver lifecycle related methods
void
nsSMILAnimationController::NotifyRefreshDriverCreated(
nsRefreshDriver* aRefreshDriver)
{
if (!mPauseState && !mDeferredStartSampling) {
StartSampling(aRefreshDriver);
}
}
void
nsSMILAnimationController::NotifyRefreshDriverDestroying(
nsRefreshDriver* aRefreshDriver)
{
if (!mPauseState && !mDeferredStartSampling) {
StopSampling(aRefreshDriver);
}
}
//----------------------------------------------------------------------
// Timer-related implementation helpers

View File

@ -111,10 +111,9 @@ public:
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
void Unlink();
// Methods for controlling whether we're sampling
// (Use to register/unregister us with the given nsRefreshDriver)
void StartSampling(nsRefreshDriver* aRefreshDriver);
void StopSampling(nsRefreshDriver* aRefreshDriver);
// Methods for relaying the availability of the refresh driver
void NotifyRefreshDriverCreated(nsRefreshDriver* aRefreshDriver);
void NotifyRefreshDriverDestroying(nsRefreshDriver* aRefreshDriver);
// Helper to check if we have any animation elements at all
PRBool HasRegisteredAnimations()
@ -154,6 +153,10 @@ protected:
PR_STATIC_CALLBACK(PLDHashOperator) CompositorTableEntryTraverse(
nsSMILCompositor* aCompositor, void* aArg);
// Methods for controlling whether we're sampling
void StartSampling(nsRefreshDriver* aRefreshDriver);
void StopSampling(nsRefreshDriver* aRefreshDriver);
// Sample-related callbacks and implementation helpers
virtual void DoSample();
void DoSample(PRBool aSkipUnchangedContainers);

View File

@ -1867,9 +1867,7 @@ PresShell::Init(nsIDocument* aDocument,
#ifdef MOZ_SMIL
if (mDocument->HasAnimationController()) {
nsSMILAnimationController* animCtrl = mDocument->GetAnimationController();
if (!animCtrl->IsPaused()) {
animCtrl->StartSampling(GetPresContext()->RefreshDriver());
}
animCtrl->NotifyRefreshDriverCreated(GetPresContext()->RefreshDriver());
}
#endif // MOZ_SMIL
@ -2002,7 +2000,7 @@ PresShell::Destroy()
#ifdef MOZ_SMIL
if (mDocument->HasAnimationController()) {
mDocument->GetAnimationController()->StopSampling(rd);
mDocument->GetAnimationController()->NotifyRefreshDriverDestroying(rd);
}
#endif // MOZ_SMIL
}