Bug 1104435 part 4 - Create and resolve new ready promises on play(); r=heycam

Every time we call play() (and in future pause()) we should create a new Promise
object and then fulfill it when we complete the play() operation.

This patch adds that step. This allows us to tweak test cases that currently
expect animations to start immediately so that by waiting on this promise they
will continue to work when we introduce the delayed start behavior in bug
927349.

We should also resolve the ready promise when we are in the pending state and
pause() is called. However, since we currently never enter the pending state we
don't need to add this just yet.
This commit is contained in:
Brian Birtles 2014-12-18 08:42:40 +09:00
parent 9449535feb
commit 99ec18baa2

View File

@ -150,6 +150,10 @@ AnimationPlayer::ResolveStartTime()
MOZ_ASSERT(!readyTime.IsNull(), "Missing or inactive timeline");
mStartTime.SetValue(readyTime.Value() - mHoldTime.Value());
mHoldTime.SetNull();
if (mReady) {
mReady->MaybeResolve(this);
}
}
bool
@ -222,6 +226,13 @@ AnimationPlayer::DoPlay()
return;
}
// Create a new pending ready promise
nsIGlobalObject* global = mTimeline->GetParentObject();
if (global) {
ErrorResult rv;
mReady = Promise::Create(global, rv);
}
ResolveStartTime();
}