Bug 1040543 part 4 - Create Animation objects and set on AnimationPlayer; r=bz

This commit is contained in:
Brian Birtles 2014-08-10 17:06:47 +10:00
Родитель 30c27e5573
Коммит 8f9311bf63
4 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -56,7 +56,7 @@ const double ComputedTiming::kNullTimeFraction = PositiveInfinity<double>();
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline, mSource)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationPlayer, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationPlayer, Release)
@ -101,6 +101,12 @@ AnimationPlayer::CurrentTime() const
return currentTime.Value().ToMilliseconds();
}
void
AnimationPlayer::SetSource(Animation* aSource)
{
mSource = aSource;
}
bool
AnimationPlayer::IsRunning() const
{

Просмотреть файл

@ -146,11 +146,13 @@ public:
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// AnimationPlayer methods
Animation* GetSource() const { return nullptr; }
Animation* GetSource() const { return mSource; }
AnimationTimeline* Timeline() const { return mTimeline; }
double StartTime() const;
double CurrentTime() const;
void SetSource(Animation* aSource);
// FIXME: If we succeed in moving transition-specific code to a type of
// AnimationEffect (as per the Web Animations API) we should remove these
// virtual methods.
@ -253,6 +255,7 @@ public:
InfallibleTArray<AnimationProperty> mProperties;
nsRefPtr<AnimationTimeline> mTimeline;
nsRefPtr<Animation> mSource;
};
} // namespace dom

Просмотреть файл

@ -24,6 +24,7 @@
using namespace mozilla;
using namespace mozilla::css;
using mozilla::dom::Animation;
using mozilla::dom::AnimationPlayer;
void
@ -443,6 +444,10 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
dest->mTiming.mDirection = src.GetDirection();
dest->mTiming.mFillMode = src.GetFillMode();
nsRefPtr<Animation> destAnim =
new Animation(mPresContext->Document());
dest->SetSource(destAnim);
dest->mStartTime = now;
dest->mPlayState = src.GetPlayState();
if (dest->IsPaused()) {

Просмотреть файл

@ -489,6 +489,9 @@ nsTransitionManager::ConsiderStartingTransition(
pt->mReversePortion = valuePortion;
}
nsRefPtr<dom::Animation> anim = new dom::Animation(aElement->OwnerDoc());
pt->SetSource(anim);
AnimationProperty& prop = *pt->mProperties.AppendElement();
prop.mProperty = aProperty;