зеркало из https://github.com/mozilla/gecko-dev.git
Bug 653238 patch 2: Promote nsSMILAnimationController's static helper 'GetRefreshDriverForDoc' to an instance method. r=smaug
This commit is contained in:
Родитель
bfc033911f
Коммит
5980b0a29a
|
@ -55,24 +55,6 @@ using namespace mozilla::dom;
|
|||
//----------------------------------------------------------------------
|
||||
// nsSMILAnimationController implementation
|
||||
|
||||
// Helper method
|
||||
static nsRefreshDriver*
|
||||
GetRefreshDriverForDoc(nsIDocument* aDoc)
|
||||
{
|
||||
if (!aDoc) {
|
||||
NS_ERROR("Requesting refresh driver after document has disconnected!");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIPresShell* shell = aDoc->GetShell();
|
||||
if (!shell) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsPresContext* context = shell->GetPresContext();
|
||||
return context ? context->RefreshDriver() : nsnull;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// ctors, dtors, factory methods
|
||||
|
||||
|
@ -88,7 +70,7 @@ nsSMILAnimationController::nsSMILAnimationController(nsIDocument* aDoc)
|
|||
mAnimationElementTable.Init();
|
||||
mChildContainerTable.Init();
|
||||
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriverForDoc(mDocument);
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
if (refreshDriver) {
|
||||
mStartTime = refreshDriver->MostRecentRefresh();
|
||||
} else {
|
||||
|
@ -113,7 +95,7 @@ nsSMILAnimationController::Disconnect()
|
|||
NS_ABORT_IF_FALSE(mRefCnt.get() == 1,
|
||||
"Expecting to disconnect when doc is sole remaining owner");
|
||||
|
||||
StopSampling(GetRefreshDriverForDoc(mDocument));
|
||||
StopSampling(GetRefreshDriver());
|
||||
|
||||
mDocument = nsnull; // (raw pointer)
|
||||
}
|
||||
|
@ -128,7 +110,7 @@ nsSMILAnimationController::Pause(PRUint32 aType)
|
|||
|
||||
if (mPauseState) {
|
||||
mDeferredStartSampling = PR_FALSE;
|
||||
StopSampling(GetRefreshDriverForDoc(mDocument));
|
||||
StopSampling(GetRefreshDriver());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +126,7 @@ nsSMILAnimationController::Resume(PRUint32 aType)
|
|||
|
||||
if (wasPaused && !mPauseState && mChildContainerTable.Count()) {
|
||||
Sample(); // Run the first sample manually
|
||||
MaybeStartSampling(GetRefreshDriverForDoc(mDocument));
|
||||
MaybeStartSampling(GetRefreshDriver());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +205,7 @@ nsSMILAnimationController::RegisterAnimationElement(
|
|||
NS_ABORT_IF_FALSE(mAnimationElementTable.Count() == 1,
|
||||
"we shouldn't have deferred sampling if we already had "
|
||||
"animations registered");
|
||||
StartSampling(GetRefreshDriverForDoc(mDocument));
|
||||
StartSampling(GetRefreshDriver());
|
||||
} // else, don't sample until a time container is registered (via AddChild)
|
||||
}
|
||||
}
|
||||
|
@ -312,8 +294,8 @@ nsSMILAnimationController::StartSampling(nsRefreshDriver* aRefreshDriver)
|
|||
NS_ASSERTION(!mDeferredStartSampling,
|
||||
"Started sampling but the deferred start flag is still set");
|
||||
if (aRefreshDriver) {
|
||||
NS_ABORT_IF_FALSE(!GetRefreshDriverForDoc(mDocument) ||
|
||||
aRefreshDriver == GetRefreshDriverForDoc(mDocument),
|
||||
NS_ABORT_IF_FALSE(!GetRefreshDriver() ||
|
||||
aRefreshDriver == GetRefreshDriver(),
|
||||
"Starting sampling with wrong refresh driver");
|
||||
// We're effectively resuming from a pause so update our current sample time
|
||||
// or else it will confuse our "average time between samples" calculations.
|
||||
|
@ -328,8 +310,8 @@ nsSMILAnimationController::StopSampling(nsRefreshDriver* aRefreshDriver)
|
|||
if (aRefreshDriver) {
|
||||
// NOTE: The document might already have been detached from its PresContext
|
||||
// (and RefreshDriver), which would make GetRefreshDriverForDoc return null.
|
||||
NS_ABORT_IF_FALSE(!GetRefreshDriverForDoc(mDocument) ||
|
||||
aRefreshDriver == GetRefreshDriverForDoc(mDocument),
|
||||
NS_ABORT_IF_FALSE(!GetRefreshDriver() ||
|
||||
aRefreshDriver == GetRefreshDriver(),
|
||||
"Stopping sampling with wrong refresh driver");
|
||||
aRefreshDriver->RemoveRefreshObserver(this, Flush_Style);
|
||||
}
|
||||
|
@ -834,7 +816,7 @@ nsSMILAnimationController::AddChild(nsSMILTimeContainer& aChild)
|
|||
|
||||
if (!mPauseState && mChildContainerTable.Count() == 1) {
|
||||
Sample(); // Run the first sample manually
|
||||
MaybeStartSampling(GetRefreshDriverForDoc(mDocument));
|
||||
MaybeStartSampling(GetRefreshDriver());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -846,6 +828,24 @@ nsSMILAnimationController::RemoveChild(nsSMILTimeContainer& aChild)
|
|||
mChildContainerTable.RemoveEntry(&aChild);
|
||||
|
||||
if (!mPauseState && mChildContainerTable.Count() == 0) {
|
||||
StopSampling(GetRefreshDriverForDoc(mDocument));
|
||||
StopSampling(GetRefreshDriver());
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method
|
||||
nsRefreshDriver*
|
||||
nsSMILAnimationController::GetRefreshDriver()
|
||||
{
|
||||
if (!mDocument) {
|
||||
NS_ERROR("Requesting refresh driver after document has disconnected!");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIPresShell* shell = mDocument->GetShell();
|
||||
if (!shell) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsPresContext* context = shell->GetPresContext();
|
||||
return context ? context->RefreshDriver() : nsnull;
|
||||
}
|
||||
|
|
|
@ -155,6 +155,9 @@ protected:
|
|||
PR_STATIC_CALLBACK(PLDHashOperator) CompositorTableEntryTraverse(
|
||||
nsSMILCompositor* aCompositor, void* aArg);
|
||||
|
||||
// Returns mDocument's refresh driver, if it's got one.
|
||||
nsRefreshDriver* GetRefreshDriver();
|
||||
|
||||
// Methods for controlling whether we're sampling
|
||||
void StartSampling(nsRefreshDriver* aRefreshDriver);
|
||||
void StopSampling(nsRefreshDriver* aRefreshDriver);
|
||||
|
|
Загрузка…
Ссылка в новой задаче