Bug 1000185 - Part 2: Add a bool to keep track of whether nsSMILAnimationController instances are registered with a refresh driver. r=birtles

This commit is contained in:
Daniel Holbert 2014-05-20 08:34:26 -04:00
Родитель 1e71d4b25b
Коммит 30825d9afd
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -29,6 +29,7 @@ nsSMILAnimationController::nsSMILAnimationController(nsIDocument* aDoc)
mResampleNeeded(false),
mDeferredStartSampling(false),
mRunningSample(false),
mRegisteredWithRefreshDriver(false),
mDocument(aDoc)
{
NS_ABORT_IF_FALSE(aDoc, "need a non-null document");
@ -49,6 +50,8 @@ nsSMILAnimationController::~nsSMILAnimationController()
NS_ASSERTION(mAnimationElementTable.Count() == 0,
"Animation controller shouldn't be tracking any animation"
" elements when it dies");
NS_ASSERTION(!mRegisteredWithRefreshDriver,
"Leaving stale entry in refresh driver's observer list");
}
void
@ -260,6 +263,8 @@ nsSMILAnimationController::StartSampling(nsRefreshDriver* aRefreshDriver)
NS_ASSERTION(!mDeferredStartSampling,
"Started sampling but the deferred start flag is still set");
if (aRefreshDriver) {
MOZ_ASSERT(!mRegisteredWithRefreshDriver,
"Redundantly registering with refresh driver");
NS_ABORT_IF_FALSE(!GetRefreshDriver() ||
aRefreshDriver == GetRefreshDriver(),
"Starting sampling with wrong refresh driver");
@ -267,19 +272,21 @@ nsSMILAnimationController::StartSampling(nsRefreshDriver* aRefreshDriver)
// or else it will confuse our "average time between samples" calculations.
mCurrentSampleTime = mozilla::TimeStamp::Now();
aRefreshDriver->AddRefreshObserver(this, Flush_Style);
mRegisteredWithRefreshDriver = true;
}
}
void
nsSMILAnimationController::StopSampling(nsRefreshDriver* aRefreshDriver)
{
if (aRefreshDriver) {
if (aRefreshDriver && mRegisteredWithRefreshDriver) {
// NOTE: The document might already have been detached from its PresContext
// (and RefreshDriver), which would make GetRefreshDriverForDoc return null.
// (and RefreshDriver), which would make GetRefreshDriver() return null.
NS_ABORT_IF_FALSE(!GetRefreshDriver() ||
aRefreshDriver == GetRefreshDriver(),
"Stopping sampling with wrong refresh driver");
aRefreshDriver->RemoveRefreshObserver(this, Flush_Style);
mRegisteredWithRefreshDriver = false;
}
}

Просмотреть файл

@ -214,6 +214,9 @@ protected:
bool mDeferredStartSampling;
bool mRunningSample;
// Are we registered with our document's refresh driver?
bool mRegisteredWithRefreshDriver;
// Store raw ptr to mDocument. It owns the controller, so controller
// shouldn't outlive it
nsIDocument* mDocument;