2014-08-10 11:06:44 +04:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_AnimationPlayer_h
|
|
|
|
#define mozilla_dom_AnimationPlayer_h
|
|
|
|
|
|
|
|
#include <algorithm> // for std::max
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
|
2014-08-10 11:06:46 +04:00
|
|
|
#include "mozilla/dom/Animation.h" // for Animation
|
2014-08-10 11:06:44 +04:00
|
|
|
#include "mozilla/dom/AnimationTimeline.h" // for AnimationTimeline
|
|
|
|
#include "nsCSSProperty.h" // for nsCSSProperty
|
|
|
|
|
|
|
|
// X11 has a #define for CurrentTime.
|
|
|
|
#ifdef CurrentTime
|
|
|
|
#undef CurrentTime
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-08-10 11:06:52 +04:00
|
|
|
class AnimationPlayer MOZ_FINAL : public nsWrapperCache
|
2014-08-10 11:06:44 +04:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual ~AnimationPlayer() { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AnimationPlayer(AnimationTimeline* aTimeline)
|
2014-08-13 13:21:45 +04:00
|
|
|
: mPlayState(NS_STYLE_ANIMATION_PLAY_STATE_RUNNING)
|
|
|
|
, mIsRunningOnCompositor(false)
|
2014-08-10 11:06:44 +04:00
|
|
|
, mTimeline(aTimeline)
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationPlayer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationPlayer)
|
|
|
|
|
|
|
|
AnimationTimeline* GetParentObject() const { return mTimeline; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
// AnimationPlayer methods
|
2014-08-10 11:06:47 +04:00
|
|
|
Animation* GetSource() const { return mSource; }
|
2014-08-10 11:06:44 +04:00
|
|
|
AnimationTimeline* Timeline() const { return mTimeline; }
|
2014-08-30 10:11:56 +04:00
|
|
|
Nullable<double> GetStartTime() const;
|
|
|
|
Nullable<double> GetCurrentTime() const;
|
2014-08-22 16:42:47 +04:00
|
|
|
bool IsRunningOnCompositor() const { return mIsRunningOnCompositor; }
|
2014-08-10 11:06:44 +04:00
|
|
|
|
2014-08-10 11:06:47 +04:00
|
|
|
void SetSource(Animation* aSource);
|
2014-08-10 11:06:48 +04:00
|
|
|
void Tick();
|
2014-08-10 11:06:47 +04:00
|
|
|
|
2014-08-22 16:42:48 +04:00
|
|
|
const nsString& Name() const {
|
|
|
|
return mSource ? mSource->Name() : EmptyString();
|
|
|
|
}
|
|
|
|
|
2014-08-10 11:06:44 +04:00
|
|
|
bool IsPaused() const {
|
|
|
|
return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsRunning() const;
|
2014-10-02 10:14:13 +04:00
|
|
|
|
|
|
|
bool HasCurrentSource() const {
|
|
|
|
return GetSource() && GetSource()->IsCurrent();
|
|
|
|
}
|
2014-08-10 11:06:44 +04:00
|
|
|
|
2014-08-10 11:06:50 +04:00
|
|
|
// Return the duration since the start time of the player, taking into
|
2014-08-30 10:11:57 +04:00
|
|
|
// account the pause state. May be negative or null.
|
|
|
|
Nullable<TimeDuration> GetCurrentTimeDuration() const;
|
2014-08-10 11:06:44 +04:00
|
|
|
|
|
|
|
// The beginning of the delay period.
|
2014-08-30 10:11:57 +04:00
|
|
|
Nullable<TimeDuration> mStartTime;
|
2014-08-30 10:11:57 +04:00
|
|
|
Nullable<TimeDuration> mHoldTime;
|
2014-08-10 11:06:44 +04:00
|
|
|
uint8_t mPlayState;
|
|
|
|
bool mIsRunningOnCompositor;
|
|
|
|
|
|
|
|
nsRefPtr<AnimationTimeline> mTimeline;
|
2014-08-10 11:06:47 +04:00
|
|
|
nsRefPtr<Animation> mSource;
|
2014-08-10 11:06:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_AnimationPlayer_h
|