Ejemplo n.º 1
0
void
Animation::UpdateTiming()
{
  // We call UpdateFinishedState before UpdateEffect because the former
  // can change the current time, which is used by the latter.
  UpdateFinishedState();
  UpdateEffect();
}
Ejemplo n.º 2
0
void
Animation::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
{
  // We call UpdateFinishedState before UpdateEffect because the former
  // can change the current time, which is used by the latter.
  UpdateFinishedState(aSeekFlag, aSyncNotifyFlag);
  UpdateEffect();

  if (mTimeline) {
    mTimeline->NotifyAnimationUpdated(*this);
  }
}
Ejemplo n.º 3
0
void
Animation::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
{
  // Update the sequence number each time we transition in or out of the
  // idle state
  if (!IsUsingCustomCompositeOrder()) {
    if (PlayState() == AnimationPlayState::Idle) {
      mSequenceNum = kUnsequenced;
    } else if (mSequenceNum == kUnsequenced) {
      mSequenceNum = sNextSequenceNum++;
    }
  }

  // We call UpdateFinishedState before UpdateEffect because the former
  // can change the current time, which is used by the latter.
  UpdateFinishedState(aSeekFlag, aSyncNotifyFlag);
  UpdateEffect();

  // Unconditionally Add/Remove from the timeline. This is ok because if the
  // animation has already been added/removed (which will be true more often
  // than not) the work done by AnimationTimeline/DocumentTimeline is still
  // negligible and its easier than trying to detect whenever we are switching
  // to/from being relevant.
  //
  // We need to do this after calling UpdateEffect since it updates some
  // cached state used by IsRelevant.
  //
  // Note that we only store relevant animations on the timeline since they
  // are the only ones that need ticks and are the only ones returned from
  // AnimationTimeline::GetAnimations. Storing any more than that would mean
  // that we fail to garbage collect irrelevant animations since the timeline
  // keeps a strong reference to each animation.
  //
  // Once we tick animations from the their timeline, and once we expect
  // timelines to go in and out of being inactive, we will also need to store
  // non-idle animations that are waiting for their timeline to become active
  // on their timeline (as otherwise once the timeline becomes active it will
  // have no way of notifying its animations). For now, however, we can
  // simply store just the relevant animations.
  if (mTimeline) {
    // FIXME: Once we expect animations to go back and forth betweeen being
    // inactive and active, we will need to store more than just relevant
    // animations on the timeline. This is because an animation might be
    // deemed irrelevant because its timeline is inactive. If it is removed
    // from the timeline at that point the timeline will have no way of
    // getting the animation to add itself again once it becomes active.
    if (IsRelevant()) {
      mTimeline->AddAnimation(*this);
    } else {
      mTimeline->RemoveAnimation(*this);
    }
  }
}
Ejemplo n.º 4
0
// Implements http://w3c.github.io/web-animations/#set-the-current-time
void
Animation::SetCurrentTime(const TimeDuration& aSeekTime)
{
  SilentlySetCurrentTime(aSeekTime);

  if (mPendingState == PendingState::PausePending) {
    CancelPendingTasks();
    if (mReady) {
      mReady->MaybeResolve(this);
    }
  }

  UpdateFinishedState(true);
  UpdateEffect();
  PostUpdate();
}
Ejemplo n.º 5
0
// https://w3c.github.io/web-animations/#finish-an-animation
void
Animation::Finish(ErrorResult& aRv)
{
  if (mPlaybackRate == 0 ||
      (mPlaybackRate > 0 && EffectEnd() == TimeDuration::Forever())) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }

  TimeDuration limit =
    mPlaybackRate > 0 ? TimeDuration(EffectEnd()) : TimeDuration(0);

  SetCurrentTime(limit);

  if (mPendingState == PendingState::PlayPending) {
    CancelPendingTasks();
    if (mReady) {
      mReady->MaybeResolve(this);
    }
  }
  UpdateFinishedState(true);
  PostUpdate();
}
Ejemplo n.º 6
0
// http://w3c.github.io/web-animations/#pause-an-animation
void
Animation::DoPause()
{
  if (IsPausedOrPausing()) {
    return;
  }

  bool reuseReadyPromise = false;
  if (mPendingState == PendingState::PlayPending) {
    CancelPendingTasks();
    reuseReadyPromise = true;
  }

  // Mark this as no longer running on the compositor so that next time
  // we update animations we won't throttle them and will have a chance
  // to remove the animation from any layer it might be on.
  mIsRunningOnCompositor = false;

  if (!reuseReadyPromise) {
    // Clear ready promise. We'll create a new one lazily.
    mReady = nullptr;
  }

  mPendingState = PendingState::PausePending;

  nsIDocument* doc = GetRenderedDocument();
  if (!doc) {
    TriggerOnNextTick(Nullable<TimeDuration>());
    return;
  }

  PendingAnimationTracker* tracker = doc->GetOrCreatePendingAnimationTracker();
  tracker->AddPausePending(*this);

  UpdateFinishedState();
}