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/. */
|
|
|
|
|
2018-05-07 05:15:16 +03:00
|
|
|
#ifndef mozilla_dom_AnimationEffect_h
|
|
|
|
#define mozilla_dom_AnimationEffect_h
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2016-07-25 13:27:33 +03:00
|
|
|
#include "mozilla/ComputedTiming.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;
|
2018-05-07 05:08:59 +03:00
|
|
|
class KeyframeEffect;
|
2018-05-07 06:09:54 +03:00
|
|
|
struct ComputedEffectTiming;
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2018-05-07 05:15:16 +03:00
|
|
|
class AnimationEffect : public nsISupports,
|
|
|
|
public nsWrapperCache
|
2015-10-13 23:17:00 +03:00
|
|
|
{
|
2015-04-15 02:48:21 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2018-05-07 05:15:16 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationEffect)
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2018-06-15 06:00:20 +03:00
|
|
|
AnimationEffect(nsIDocument* aDocument, const TimingParams& aTiming);
|
2015-04-15 02:48:21 +03:00
|
|
|
|
2018-05-07 05:08:59 +03:00
|
|
|
virtual KeyframeEffect* AsKeyframeEffect() { return nullptr; }
|
2016-07-25 11:56:34 +03:00
|
|
|
|
|
|
|
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;
|
2018-03-08 12:22:45 +03:00
|
|
|
bool HasFiniteActiveDuration() const
|
|
|
|
{
|
|
|
|
return SpecifiedTiming().ActiveDuration() != TimeDuration::Forever();
|
|
|
|
}
|
2016-07-25 11:56:34 +03:00
|
|
|
|
2018-05-07 06:37:11 +03:00
|
|
|
// AnimationEffect interface
|
2018-05-07 06:32:38 +03:00
|
|
|
void GetTiming(EffectTiming& aRetVal) const;
|
2018-05-07 06:37:11 +03:00
|
|
|
void GetComputedTimingAsDict(ComputedEffectTiming& aRetVal) const;
|
|
|
|
void UpdateTiming(const OptionalEffectTiming& aTiming, ErrorResult& aRv);
|
2018-05-07 06:32:38 +03:00
|
|
|
|
2018-05-07 06:58:37 +03:00
|
|
|
const TimingParams& SpecifiedTiming() const { return mTiming; }
|
2016-07-25 13:27:33 +03:00
|
|
|
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;
|
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
|
|
|
|
2016-12-02 04:04:08 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this effect animates one of the properties we consider
|
|
|
|
* geometric properties, e.g. properties such as 'width' or 'margin-left'
|
|
|
|
* that we try to synchronize with transform animations, on a valid target
|
|
|
|
* element.
|
|
|
|
*/
|
|
|
|
virtual bool AffectsGeometry() const = 0;
|
|
|
|
|
2015-10-13 23:17:00 +03:00
|
|
|
protected:
|
2018-06-15 06:00:20 +03:00
|
|
|
virtual ~AnimationEffect();
|
2016-07-25 13:27:33 +03:00
|
|
|
|
|
|
|
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<Animation> mAnimation;
|
2018-05-07 06:58:37 +03:00
|
|
|
TimingParams mTiming;
|
2015-04-15 02:48:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2018-05-07 05:15:16 +03:00
|
|
|
#endif // mozilla_dom_AnimationEffect_h
|