mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
ada14c3498
This patch introduces the basic implementation of play() and pause(). There are a lot of gaps still because we don't yet: * Support the pending state (to be covered in bug 927349) * Support finishing behavior (to be covered in bug 1074630) * Have a good way of updating animation state outside of style resolution (bug 1073336) Also, we don't call these methods from CSS yet because the interaction between play()/pause() and animation-play-state requires storing some extra state which we introduce in subsequent patches in this series. This patch introduces, temporarily, an update flag to indicate whether play()/pause() operations need to post a restyle event. When these methods are triggered by processing restyles we don't want to post another (unnecessary) restyle event. In bug 1073336 we will remove the need for this.
107 lines
3.0 KiB
C++
107 lines
3.0 KiB
C++
/* 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 "nsWrapperCache.h"
|
|
#include "nsCycleCollectionParticipant.h"
|
|
#include "mozilla/Attributes.h"
|
|
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
|
|
#include "mozilla/dom/Animation.h" // for Animation
|
|
#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 {
|
|
|
|
class AnimationPlayer MOZ_FINAL : public nsWrapperCache
|
|
{
|
|
protected:
|
|
virtual ~AnimationPlayer() { }
|
|
|
|
public:
|
|
explicit AnimationPlayer(AnimationTimeline* aTimeline)
|
|
: mIsPaused(false)
|
|
, mIsRunningOnCompositor(false)
|
|
, mTimeline(aTimeline)
|
|
{
|
|
}
|
|
|
|
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;
|
|
|
|
// Temporary flags to control restyle behavior until bug 1073336
|
|
// provides a better solution.
|
|
enum UpdateFlags {
|
|
eNoUpdate,
|
|
eUpdateStyle
|
|
};
|
|
|
|
// AnimationPlayer methods
|
|
Animation* GetSource() const { return mSource; }
|
|
AnimationTimeline* Timeline() const { return mTimeline; }
|
|
Nullable<double> GetStartTime() const;
|
|
Nullable<double> GetCurrentTime() const;
|
|
void Play(UpdateFlags aUpdateFlags);
|
|
void Pause(UpdateFlags aUpdateFlags);
|
|
bool IsRunningOnCompositor() const { return mIsRunningOnCompositor; }
|
|
|
|
// Wrapper functions for performing extra steps such as flushing
|
|
// style when calling from JS.
|
|
void PlayFromJS();
|
|
void PauseFromJS();
|
|
|
|
void SetSource(Animation* aSource);
|
|
void Tick();
|
|
|
|
const nsString& Name() const {
|
|
return mSource ? mSource->Name() : EmptyString();
|
|
}
|
|
|
|
bool IsPaused() const { return mIsPaused; }
|
|
|
|
bool IsRunning() const;
|
|
|
|
bool HasCurrentSource() const {
|
|
return GetSource() && GetSource()->IsCurrent();
|
|
}
|
|
bool HasInEffectSource() const {
|
|
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
|
|
Nullable<TimeDuration> mHoldTime; // Player timescale
|
|
bool mIsPaused;
|
|
bool mIsRunningOnCompositor;
|
|
|
|
nsRefPtr<AnimationTimeline> mTimeline;
|
|
nsRefPtr<Animation> mSource;
|
|
|
|
protected:
|
|
void FlushStyle() const;
|
|
void MaybePostRestyle() const;
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_dom_AnimationPlayer_h
|