Bug 1078119 - Rename AnimationTimeline/AnimationPlayer GetCurrentTimeDuration; r=bz

This patch performs the following renaming:

  AnimationPlayer::GetCurrentTime -> GetCurrentTimeAsDouble
  AnimationPlayer::GetCurrentTimeDuration -> GetCurrentTime
  AnimationTimeline::GetCurrentTime -> GetCurrentTimeAsDouble
  AnimationTimeline::GetCurrentTimeDuration -> GetCurrentTime
This commit is contained in:
Brian Birtles 2014-10-20 13:55:45 +09:00
parent 2ad3a40b91
commit 95a9a512d3
8 changed files with 46 additions and 42 deletions

View File

@ -28,16 +28,25 @@ AnimationPlayer::GetStartTime() const
return AnimationUtils::TimeDurationToDouble(mStartTime);
}
Nullable<double>
Nullable<TimeDuration>
AnimationPlayer::GetCurrentTime() const
{
return AnimationUtils::TimeDurationToDouble(GetCurrentTimeDuration());
Nullable<TimeDuration> result;
if (!mHoldTime.IsNull()) {
result = mHoldTime;
} else {
Nullable<TimeDuration> timelineTime = mTimeline->GetCurrentTime();
if (!timelineTime.IsNull() && !mStartTime.IsNull()) {
result.SetValue(timelineTime.Value() - mStartTime.Value());
}
}
return result;
}
AnimationPlayState
AnimationPlayer::PlayState() const
{
Nullable<TimeDuration> currentTime = GetCurrentTimeDuration();
Nullable<TimeDuration> currentTime = GetCurrentTime();
if (currentTime.IsNull()) {
return AnimationPlayState::Idle;
}
@ -65,7 +74,7 @@ AnimationPlayer::Play(UpdateFlags aFlags)
}
mIsPaused = false;
Nullable<TimeDuration> timelineTime = mTimeline->GetCurrentTimeDuration();
Nullable<TimeDuration> timelineTime = mTimeline->GetCurrentTime();
if (timelineTime.IsNull()) {
// FIXME: We should just sit in the pending state in this case.
// We will introduce the pending state in Bug 927349.
@ -92,7 +101,7 @@ AnimationPlayer::Pause(UpdateFlags aFlags)
mIsRunningOnCompositor = false;
// Bug 927349 - check for null result here and go to pending state
mHoldTime = GetCurrentTimeDuration();
mHoldTime = GetCurrentTime();
mStartTime.SetNull();
if (aFlags == eUpdateStyle) {
@ -100,6 +109,12 @@ AnimationPlayer::Pause(UpdateFlags aFlags)
}
}
Nullable<double>
AnimationPlayer::GetCurrentTimeAsDouble() const
{
return AnimationUtils::TimeDurationToDouble(GetCurrentTime());
}
AnimationPlayState
AnimationPlayer::PlayStateFromJS() const
{
@ -142,7 +157,7 @@ AnimationPlayer::SetSource(Animation* aSource)
}
mSource = aSource;
if (mSource) {
mSource->SetParentTime(GetCurrentTimeDuration());
mSource->SetParentTime(GetCurrentTime());
}
}
@ -150,7 +165,7 @@ void
AnimationPlayer::Tick()
{
if (mSource) {
mSource->SetParentTime(GetCurrentTimeDuration());
mSource->SetParentTime(GetCurrentTime());
}
}
@ -165,21 +180,6 @@ AnimationPlayer::IsRunning() const
return computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
}
Nullable<TimeDuration>
AnimationPlayer::GetCurrentTimeDuration() const
{
Nullable<TimeDuration> result;
if (!mHoldTime.IsNull()) {
result = mHoldTime;
} else {
Nullable<TimeDuration> timelineTime = mTimeline->GetCurrentTimeDuration();
if (!timelineTime.IsNull() && !mStartTime.IsNull()) {
result.SetValue(timelineTime.Value() - mStartTime.Value());
}
}
return result;
}
void
AnimationPlayer::FlushStyle() const
{

View File

@ -60,14 +60,17 @@ public:
Animation* GetSource() const { return mSource; }
AnimationTimeline* Timeline() const { return mTimeline; }
Nullable<double> GetStartTime() const;
Nullable<double> GetCurrentTime() const;
Nullable<TimeDuration> GetCurrentTime() const;
AnimationPlayState PlayState() const;
virtual void Play(UpdateFlags aUpdateFlags);
virtual void Pause(UpdateFlags aUpdateFlags);
bool IsRunningOnCompositor() const { return mIsRunningOnCompositor; }
// Wrapper functions for performing extra steps such as flushing
// style when calling from JS.
// Wrapper functions for AnimationPlayer DOM methods when called
// from script. We often use the same methods internally and from
// script but when called from script we perform extra steps such
// as flushing style or converting the return type.
Nullable<double> GetCurrentTimeAsDouble() const;
AnimationPlayState PlayStateFromJS() const;
void PlayFromJS();
void PauseFromJS();
@ -90,10 +93,6 @@ public:
return GetSource() && GetSource()->IsInEffect();
}
// Return the duration since the start time of the player, taking into
// account the pause state. May be negative or null.
Nullable<TimeDuration> GetCurrentTimeDuration() const;
// The beginning of the delay period.
Nullable<TimeDuration> mStartTime; // Timeline timescale
bool mIsRunningOnCompositor;

View File

@ -26,10 +26,16 @@ AnimationTimeline::WrapObject(JSContext* aCx)
return AnimationTimelineBinding::Wrap(aCx, this);
}
Nullable<double>
Nullable<TimeDuration>
AnimationTimeline::GetCurrentTime() const
{
return AnimationUtils::TimeDurationToDouble(GetCurrentTimeDuration());
return ToTimelineTime(GetCurrentTimeStamp());
}
Nullable<double>
AnimationTimeline::GetCurrentTimeAsDouble() const
{
return AnimationUtils::TimeDurationToDouble(GetCurrentTime());
}
TimeStamp
@ -68,12 +74,6 @@ AnimationTimeline::GetCurrentTimeStamp() const
return result;
}
Nullable<TimeDuration>
AnimationTimeline::GetCurrentTimeDuration() const
{
return ToTimelineTime(GetCurrentTimeStamp());
}
Nullable<TimeDuration>
AnimationTimeline::ToTimelineTime(const TimeStamp& aTimeStamp) const
{

View File

@ -32,10 +32,12 @@ public:
nsISupports* GetParentObject() const { return mDocument; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// WebIDL API
Nullable<double> GetCurrentTime() const;
// AnimationTimeline methods
Nullable<TimeDuration> GetCurrentTime() const;
Nullable<TimeDuration> GetCurrentTimeDuration() const;
// Wrapper functions for AnimationTimeline DOM methods when called from
// script.
Nullable<double> GetCurrentTimeAsDouble() const;
Nullable<TimeDuration> ToTimelineTime(const TimeStamp& aTimeStamp) const;
TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const;

View File

@ -21,6 +21,7 @@ interface AnimationPlayer {
readonly attribute AnimationTimeline timeline;
[Pure]
readonly attribute double? startTime;
[BinaryName="currentTimeAsDouble"]
readonly attribute double? currentTime;
/* Not yet implemented

View File

@ -12,7 +12,9 @@
[Pref="dom.animations-api.core.enabled"]
interface AnimationTimeline {
[BinaryName="currentTimeAsDouble"]
readonly attribute double? currentTime;
// Not yet implemented:
// AnimationPlayer play (optional TimedItem? source = null);
// sequence<AnimationPlayer> getAnimationPlayers ();
};

View File

@ -423,7 +423,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
ResolvedStyleCache resolvedStyles;
const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
Nullable<TimeDuration> now = aTimeline->GetCurrentTimeDuration();
Nullable<TimeDuration> now = aTimeline->GetCurrentTime();
for (size_t animIdx = 0, animEnd = disp->mAnimationNameCount;
animIdx != animEnd; ++animIdx) {

View File

@ -533,7 +533,7 @@ nsTransitionManager::ConsiderStartingTransition(
segment.mTimingFunction.Init(tf);
nsRefPtr<dom::AnimationPlayer> player = new dom::AnimationPlayer(timeline);
player->mStartTime = timeline->GetCurrentTimeDuration();
player->mStartTime = timeline->GetCurrentTime();
player->SetSource(pt);
if (!aElementTransitions) {