mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1109390 part 10 - Add an enum to AnimationPlayer to represent if we are pause-pending or play-pending; r=jwatt
This commit is contained in:
parent
b79fa30ddf
commit
ad1d94152f
@ -160,7 +160,7 @@ AnimationPlayer::SilentlySetPlaybackRate(double aPlaybackRate)
|
||||
AnimationPlayState
|
||||
AnimationPlayer::PlayState() const
|
||||
{
|
||||
if (mIsPending) {
|
||||
if (mPendingState != PendingState::NotPending) {
|
||||
return AnimationPlayState::Pending;
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ AnimationPlayer::Tick()
|
||||
// it's possible that mPendingReadyTime is set to a time in the future.
|
||||
// In that case, we should wait until the next refresh driver tick before
|
||||
// resuming.
|
||||
if (mIsPending &&
|
||||
if (mPendingState != PendingState::NotPending &&
|
||||
!mPendingReadyTime.IsNull() &&
|
||||
mPendingReadyTime.Value() <= mTimeline->GetCurrentTime().Value()) {
|
||||
ResumeAt(mPendingReadyTime.Value());
|
||||
@ -333,7 +333,7 @@ AnimationPlayer::GetCurrentOrPendingStartTime() const
|
||||
void
|
||||
AnimationPlayer::Cancel()
|
||||
{
|
||||
if (mIsPending) {
|
||||
if (mPendingState != PendingState::NotPending) {
|
||||
CancelPendingPlay();
|
||||
if (mReady) {
|
||||
mReady->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||
@ -444,7 +444,7 @@ AnimationPlayer::DoPlay()
|
||||
// Clear the start time until we resolve a new one
|
||||
mStartTime.SetNull();
|
||||
|
||||
mIsPending = true;
|
||||
mPendingState = PendingState::PlayPending;
|
||||
|
||||
nsIDocument* doc = GetRenderedDocument();
|
||||
if (!doc) {
|
||||
@ -463,7 +463,7 @@ AnimationPlayer::DoPlay()
|
||||
void
|
||||
AnimationPlayer::DoPause()
|
||||
{
|
||||
if (mIsPending) {
|
||||
if (mPendingState == PendingState::PlayPending) {
|
||||
CancelPendingPlay();
|
||||
// Resolve the ready promise since we currently only use it for
|
||||
// players that are waiting to play. Later (in bug 1109390), we will
|
||||
@ -490,10 +490,11 @@ AnimationPlayer::ResumeAt(const TimeDuration& aResumeTime)
|
||||
// This method is only expected to be called for a player that is
|
||||
// waiting to play. We can easily adapt it to handle other states
|
||||
// but it's currently not necessary.
|
||||
MOZ_ASSERT(PlayState() == AnimationPlayState::Pending,
|
||||
"Expected to resume a pending player");
|
||||
MOZ_ASSERT(mPendingState == PendingState::PlayPending,
|
||||
"Expected to resume a play-pending player");
|
||||
MOZ_ASSERT(!mHoldTime.IsNull(),
|
||||
"A player in the pending state should have a resolved hold time");
|
||||
"A player in the play-pending state should have a resolved"
|
||||
" hold time");
|
||||
|
||||
if (mPlaybackRate != 0) {
|
||||
mStartTime.SetValue(aResumeTime - (mHoldTime.Value() / mPlaybackRate));
|
||||
@ -501,7 +502,7 @@ AnimationPlayer::ResumeAt(const TimeDuration& aResumeTime)
|
||||
} else {
|
||||
mStartTime.SetValue(aResumeTime);
|
||||
}
|
||||
mIsPending = false;
|
||||
mPendingState = PendingState::NotPending;
|
||||
|
||||
UpdateSourceContent();
|
||||
|
||||
@ -540,7 +541,7 @@ AnimationPlayer::PostUpdate()
|
||||
void
|
||||
AnimationPlayer::CancelPendingPlay()
|
||||
{
|
||||
if (!mIsPending) {
|
||||
if (mPendingState == PendingState::NotPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -552,7 +553,7 @@ AnimationPlayer::CancelPendingPlay()
|
||||
}
|
||||
}
|
||||
|
||||
mIsPending = false;
|
||||
mPendingState = PendingState::NotPending;
|
||||
mPendingReadyTime.SetNull();
|
||||
}
|
||||
|
||||
@ -573,11 +574,11 @@ AnimationPlayer::IsPossiblyOrphanedPendingPlayer() const
|
||||
// when we have been painted.
|
||||
// * When we started playing we couldn't find a PendingPlayerTracker to
|
||||
// register with (perhaps the source content had no document) so we simply
|
||||
// set mIsPending in DoPlay and relied on this method to catch us on the
|
||||
// set mPendingState in DoPlay and relied on this method to catch us on the
|
||||
// next tick.
|
||||
|
||||
// If we're not pending we're ok.
|
||||
if (!mIsPending) {
|
||||
if (mPendingState == PendingState::NotPending) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
explicit AnimationPlayer(AnimationTimeline* aTimeline)
|
||||
: mTimeline(aTimeline)
|
||||
, mPlaybackRate(1.0)
|
||||
, mIsPending(false)
|
||||
, mPendingState(PendingState::NotPending)
|
||||
, mIsRunningOnCompositor(false)
|
||||
, mIsPreviousStateFinished(false)
|
||||
, mIsRelevant(false)
|
||||
@ -235,9 +235,9 @@ protected:
|
||||
void UpdateSourceContent();
|
||||
void FlushStyle() const;
|
||||
void PostUpdate();
|
||||
// Remove this player from the pending player tracker and resets mIsPending
|
||||
// as necessary. The caller is responsible for resolving or aborting the
|
||||
// mReady promise as necessary.
|
||||
// Remove this player from the pending player tracker and reset
|
||||
// mPendingState as necessary. The caller is responsible for resolving or
|
||||
// aborting the mReady promise as necessary.
|
||||
void CancelPendingPlay();
|
||||
|
||||
bool IsPossiblyOrphanedPendingPlayer() const;
|
||||
@ -261,12 +261,15 @@ protected:
|
||||
// This object is lazily created by GetReady.
|
||||
nsRefPtr<Promise> mReady;
|
||||
|
||||
// Indicates if the player is in the pending state. We use this rather
|
||||
// than checking if this player is tracked by a PendingPlayerTracker.
|
||||
// This is because the PendingPlayerTracker is associated with the source
|
||||
// content's document but we need to know if we're pending even if the
|
||||
// source content loses association with its document.
|
||||
bool mIsPending;
|
||||
// Indicates if the player is in the pending state (and what state it is
|
||||
// waiting to enter when it finished pending). We use this rather than
|
||||
// checking if this player is tracked by a PendingPlayerTracker because the
|
||||
// player will continue to be pending even after it has been removed from the
|
||||
// PendingPlayerTracker while it is waiting for the next tick
|
||||
// (see TriggerOnNextTick for details).
|
||||
enum class PendingState { NotPending, PlayPending, PausePending };
|
||||
PendingState mPendingState;
|
||||
|
||||
bool mIsRunningOnCompositor;
|
||||
// Indicates whether we were in the finished state during our
|
||||
// most recent unthrottled sample (our last ComposeStyle call).
|
||||
|
Loading…
Reference in New Issue
Block a user