2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-04-15 02:48:21 +03:00
|
|
|
/* 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/. */
|
|
|
|
|
2015-10-13 23:17:00 +03:00
|
|
|
#ifndef mozilla_dom_AnimationEffectReadOnly_h
|
|
|
|
#define mozilla_dom_AnimationEffectReadOnly_h
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2016-07-25 13:27:33 +03:00
|
|
|
#include "mozilla/ComputedTiming.h"
|
|
|
|
#include "mozilla/dom/AnimationEffectTimingReadOnly.h"
|
2015-10-13 23:17:00 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2016-07-25 13:27:33 +03:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "mozilla/StickyTimeDuration.h"
|
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "mozilla/TimingParams.h"
|
2015-04-15 02:48:21 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2015-10-13 23:17:00 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2015-04-15 02:48:21 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
2016-07-25 11:56:34 +03:00
|
|
|
|
|
|
|
struct ElementPropertyTransition;
|
|
|
|
|
2015-04-15 02:48:21 +03:00
|
|
|
namespace dom {
|
|
|
|
|
2016-07-25 11:56:34 +03:00
|
|
|
class Animation;
|
2016-01-13 20:37:00 +03:00
|
|
|
class AnimationEffectTimingReadOnly;
|
2016-07-25 11:56:34 +03:00
|
|
|
class KeyframeEffectReadOnly;
|
2015-10-13 23:17:00 +03:00
|
|
|
struct ComputedTimingProperties;
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2015-10-13 23:17:00 +03:00
|
|
|
class AnimationEffectReadOnly : public nsISupports,
|
|
|
|
public nsWrapperCache
|
|
|
|
{
|
2015-04-15 02:48:21 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2015-04-30 16:06:43 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationEffectReadOnly)
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2016-07-25 13:27:33 +03:00
|
|
|
AnimationEffectReadOnly(nsIDocument* aDocument,
|
|
|
|
AnimationEffectTimingReadOnly* aTiming);
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2016-07-25 11:56:34 +03:00
|
|
|
virtual KeyframeEffectReadOnly* AsKeyframeEffect() { return nullptr; }
|
|
|
|
|
|
|
|
virtual ElementPropertyTransition* AsTransition() { return nullptr; }
|
|
|
|
virtual const ElementPropertyTransition* AsTransition() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-13 05:32:01 +03:00
|
|
|
nsISupports* GetParentObject() const { return mDocument; }
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2016-07-25 13:27:33 +03:00
|
|
|
bool IsCurrent() const;
|
|
|
|
bool IsInEffect() const;
|
2016-10-14 13:14:11 +03:00
|
|
|
bool IsActiveDurationZero() const
|
|
|
|
{
|
|
|
|
return SpecifiedTiming().ActiveDuration() == StickyTimeDuration();
|
|
|
|
}
|
2016-07-25 11:56:34 +03:00
|
|
|
|
2016-07-25 13:27:33 +03:00
|
|
|
already_AddRefed<AnimationEffectTimingReadOnly> Timing();
|
|
|
|
const TimingParams& SpecifiedTiming() const
|
|
|
|
{
|
|
|
|
return mTiming->AsTimingParams();
|
|
|
|
}
|
|
|
|
void SetSpecifiedTiming(const TimingParams& aTiming);
|
2016-07-25 11:56:34 +03:00
|
|
|
|
2016-07-25 13:27:33 +03:00
|
|
|
// This function takes as input the timing parameters of an animation and
|
|
|
|
// returns the computed timing at the specified local time.
|
|
|
|
//
|
|
|
|
// The local time may be null in which case only static parameters such as the
|
|
|
|
// active duration are calculated. All other members of the returned object
|
|
|
|
// are given a null/initial value.
|
|
|
|
//
|
|
|
|
// This function returns a null mProgress member of the return value
|
|
|
|
// if the animation should not be run
|
|
|
|
// (because it is not currently active and is not filling at this time).
|
|
|
|
static ComputedTiming
|
|
|
|
GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime,
|
|
|
|
const TimingParams& aTiming,
|
|
|
|
double aPlaybackRate);
|
2016-07-25 11:56:34 +03:00
|
|
|
// Shortcut that gets the computed timing using the current local time as
|
|
|
|
// calculated from the timeline time.
|
2016-07-25 13:27:33 +03:00
|
|
|
ComputedTiming GetComputedTiming(const TimingParams* aTiming = nullptr) const;
|
|
|
|
void GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const;
|
2016-01-13 20:37:00 +03:00
|
|
|
|
2016-07-13 13:44:19 +03:00
|
|
|
virtual void SetAnimation(Animation* aAnimation) = 0;
|
2016-07-25 13:27:33 +03:00
|
|
|
Animation* GetAnimation() const { return mAnimation; };
|
2015-10-13 23:17:00 +03:00
|
|
|
|
|
|
|
protected:
|
2016-07-25 13:27:33 +03:00
|
|
|
virtual ~AnimationEffectReadOnly();
|
|
|
|
|
|
|
|
Nullable<TimeDuration> GetLocalTime() const;
|
2015-10-13 23:17:00 +03:00
|
|
|
|
2015-04-15 02:48:21 +03:00
|
|
|
protected:
|
2016-07-13 05:32:01 +03:00
|
|
|
RefPtr<nsIDocument> mDocument;
|
2016-07-25 13:27:33 +03:00
|
|
|
RefPtr<AnimationEffectTimingReadOnly> mTiming;
|
|
|
|
RefPtr<Animation> mAnimation;
|
2015-04-15 02:48:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-10-13 23:17:00 +03:00
|
|
|
#endif // mozilla_dom_AnimationEffectReadOnly_h
|