2015-05-03 19:32:37 +00: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: */
|
2014-08-10 07:06:46 +00: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-04-14 23:48:21 +00:00
|
|
|
#ifndef mozilla_dom_KeyframeEffect_h
|
|
|
|
#define mozilla_dom_KeyframeEffect_h
|
2014-08-10 07:06:46 +00:00
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
2016-03-22 07:19:43 +00:00
|
|
|
#include "nsCSSProperty.h"
|
|
|
|
#include "nsCSSValue.h"
|
2014-08-10 07:06:46 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2016-03-22 07:19:43 +00:00
|
|
|
#include "nsTArray.h"
|
2014-08-10 07:06:46 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2016-03-04 08:54:25 +00:00
|
|
|
#include "mozilla/AnimationPerformanceWarning.h"
|
2014-08-10 07:06:46 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-03-21 23:11:05 +00:00
|
|
|
#include "mozilla/ComputedTiming.h"
|
|
|
|
#include "mozilla/ComputedTimingFunction.h"
|
|
|
|
#include "mozilla/LayerAnimationInfo.h" // LayerAnimations::kRecords
|
2016-03-22 07:19:43 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
2016-03-21 08:49:50 +00:00
|
|
|
#include "mozilla/NonOwningAnimationTarget.h"
|
2016-03-21 23:11:05 +00:00
|
|
|
#include "mozilla/OwningNonNull.h" // OwningNonNull<...>
|
2014-09-25 05:25:50 +00:00
|
|
|
#include "mozilla/StickyTimeDuration.h"
|
2014-08-10 07:06:49 +00:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2014-08-10 07:06:48 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2016-03-07 05:11:11 +00:00
|
|
|
#include "mozilla/TimingParams.h"
|
2015-04-30 13:06:43 +00:00
|
|
|
#include "mozilla/dom/AnimationEffectReadOnly.h"
|
2016-03-07 05:11:11 +00:00
|
|
|
#include "mozilla/dom/AnimationEffectTimingReadOnly.h"
|
2014-10-02 06:14:15 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2014-08-10 07:06:48 +00:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2014-08-10 07:06:46 +00:00
|
|
|
|
|
|
|
struct JSContext;
|
2014-10-20 04:55:46 +00:00
|
|
|
class nsCSSPropertySet;
|
2015-11-06 01:38:00 +00:00
|
|
|
class nsIContent;
|
2015-11-06 01:51:00 +00:00
|
|
|
class nsIDocument;
|
2015-11-06 01:38:00 +00:00
|
|
|
class nsIFrame;
|
2015-11-06 01:51:00 +00:00
|
|
|
class nsPresContext;
|
2014-08-10 07:06:46 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-07-29 01:57:39 +00:00
|
|
|
|
2014-10-20 04:55:46 +00:00
|
|
|
class AnimValuesStyleRule;
|
2016-02-17 20:37:00 +00:00
|
|
|
enum class CSSPseudoElementType : uint8_t;
|
2014-08-10 07:06:49 +00:00
|
|
|
|
2015-10-22 22:48:00 +00:00
|
|
|
namespace dom {
|
2016-02-05 18:01:00 +00:00
|
|
|
class ElementOrCSSPseudoElement;
|
|
|
|
class OwningElementOrCSSPseudoElement;
|
2016-03-12 13:14:10 +00:00
|
|
|
class UnrestrictedDoubleOrKeyframeAnimationOptions;
|
2015-11-19 18:48:00 +00:00
|
|
|
class UnrestrictedDoubleOrKeyframeEffectOptions;
|
|
|
|
enum class IterationCompositeOperation : uint32_t;
|
|
|
|
enum class CompositeOperation : uint32_t;
|
2016-03-13 11:10:10 +00:00
|
|
|
struct AnimationPropertyDetails;
|
2015-10-22 22:48:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-22 07:19:43 +00:00
|
|
|
/**
|
|
|
|
* A property-value pair specified on a keyframe.
|
|
|
|
*/
|
|
|
|
struct PropertyValuePair
|
|
|
|
{
|
|
|
|
nsCSSProperty mProperty;
|
|
|
|
// The specified value for the property. For shorthand properties or invalid
|
|
|
|
// property values, we store the specified property value as a token stream
|
|
|
|
// (string).
|
|
|
|
nsCSSValue mValue;
|
2016-03-29 23:59:08 +00:00
|
|
|
|
|
|
|
bool operator==(const PropertyValuePair& aOther) const {
|
|
|
|
return mProperty == aOther.mProperty &&
|
|
|
|
mValue == aOther.mValue;
|
|
|
|
}
|
2016-03-22 07:19:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A single keyframe.
|
|
|
|
*
|
|
|
|
* This is the canonical form in which keyframe effects are stored and
|
|
|
|
* corresponds closely to the type of objects returned via the getFrames() API.
|
|
|
|
*
|
|
|
|
* Before computing an output animation value, however, we flatten these frames
|
|
|
|
* down to a series of per-property value arrays where we also resolve any
|
|
|
|
* overlapping shorthands/longhands, convert specified CSS values to computed
|
|
|
|
* values, etc.
|
|
|
|
*
|
|
|
|
* When the target element or style context changes, however, we rebuild these
|
|
|
|
* per-property arrays from the original list of keyframes objects. As a result,
|
|
|
|
* these objects represent the master definition of the effect's values.
|
|
|
|
*/
|
|
|
|
struct Keyframe
|
|
|
|
{
|
2016-03-24 01:39:29 +00:00
|
|
|
Keyframe() = default;
|
2016-03-31 07:26:52 +00:00
|
|
|
Keyframe(const Keyframe& aOther) = default;
|
2016-03-24 01:39:29 +00:00
|
|
|
Keyframe(Keyframe&& aOther)
|
|
|
|
{
|
2016-03-29 02:29:20 +00:00
|
|
|
*this = Move(aOther);
|
|
|
|
}
|
2016-03-31 07:26:52 +00:00
|
|
|
|
|
|
|
Keyframe& operator=(const Keyframe& aOther) = default;
|
2016-03-29 02:29:20 +00:00
|
|
|
Keyframe& operator=(Keyframe&& aOther)
|
|
|
|
{
|
|
|
|
mOffset = aOther.mOffset;
|
|
|
|
mComputedOffset = aOther.mComputedOffset;
|
|
|
|
mTimingFunction = Move(aOther.mTimingFunction);
|
|
|
|
mPropertyValues = Move(aOther.mPropertyValues);
|
|
|
|
return *this;
|
2016-03-24 01:39:29 +00:00
|
|
|
}
|
|
|
|
|
2016-03-22 07:19:43 +00:00
|
|
|
Maybe<double> mOffset;
|
|
|
|
double mComputedOffset = 0.0;
|
|
|
|
Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
|
|
|
|
// "linear"
|
|
|
|
nsTArray<PropertyValuePair> mPropertyValues;
|
|
|
|
};
|
|
|
|
|
2014-08-10 07:06:49 +00:00
|
|
|
struct AnimationPropertySegment
|
|
|
|
{
|
|
|
|
float mFromKey, mToKey;
|
|
|
|
StyleAnimationValue mFromValue, mToValue;
|
2016-01-29 13:44:00 +00:00
|
|
|
Maybe<ComputedTimingFunction> mTimingFunction;
|
2015-03-14 05:34:40 +00:00
|
|
|
|
|
|
|
bool operator==(const AnimationPropertySegment& aOther) const {
|
|
|
|
return mFromKey == aOther.mFromKey &&
|
|
|
|
mToKey == aOther.mToKey &&
|
|
|
|
mFromValue == aOther.mFromValue &&
|
|
|
|
mToValue == aOther.mToValue &&
|
|
|
|
mTimingFunction == aOther.mTimingFunction;
|
|
|
|
}
|
|
|
|
bool operator!=(const AnimationPropertySegment& aOther) const {
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2014-08-10 07:06:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimationProperty
|
|
|
|
{
|
2015-12-20 13:16:00 +00:00
|
|
|
nsCSSProperty mProperty = eCSSProperty_UNKNOWN;
|
2015-03-20 04:10:00 +00:00
|
|
|
|
|
|
|
// Does this property win in the CSS Cascade?
|
|
|
|
//
|
|
|
|
// For CSS transitions, this is true as long as a CSS animation on the
|
|
|
|
// same property and element is not running, in which case we set this
|
|
|
|
// to false so that the animation (lower in the cascade) can win. We
|
|
|
|
// then use this to decide whether to apply the style both in the CSS
|
|
|
|
// cascade and for OMTA.
|
|
|
|
//
|
2015-03-31 22:05:54 +00:00
|
|
|
// For CSS Animations, which are overridden by !important rules in the
|
|
|
|
// cascade, we actually determine this from the CSS cascade
|
|
|
|
// computations, and then use it for OMTA.
|
2016-01-13 04:38:16 +00:00
|
|
|
//
|
2016-01-06 02:04:05 +00:00
|
|
|
// **NOTE**: This member is not included when comparing AnimationProperty
|
2015-09-10 05:03:46 +00:00
|
|
|
// objects for equality.
|
2016-01-13 04:38:16 +00:00
|
|
|
bool mWinsInCascade = false;
|
2015-12-20 13:16:00 +00:00
|
|
|
|
|
|
|
// If true, the propery is currently being animated on the compositor.
|
|
|
|
//
|
|
|
|
// Note that when the owning Animation requests a non-throttled restyle, in
|
2016-02-24 04:41:16 +00:00
|
|
|
// between calling RequestRestyle on its EffectCompositor and when the
|
2015-12-20 13:16:00 +00:00
|
|
|
// restyle is performed, this member may temporarily become false even if
|
|
|
|
// the animation remains on the layer after the restyle.
|
2016-01-13 04:38:16 +00:00
|
|
|
//
|
|
|
|
// **NOTE**: This member is not included when comparing AnimationProperty
|
|
|
|
// objects for equality.
|
2015-12-20 13:16:00 +00:00
|
|
|
bool mIsRunningOnCompositor = false;
|
2015-03-20 04:10:00 +00:00
|
|
|
|
2016-03-04 08:54:25 +00:00
|
|
|
Maybe<AnimationPerformanceWarning> mPerformanceWarning;
|
2016-03-03 21:36:36 +00:00
|
|
|
|
2014-08-10 07:06:49 +00:00
|
|
|
InfallibleTArray<AnimationPropertySegment> mSegments;
|
2015-03-14 05:34:40 +00:00
|
|
|
|
2015-12-20 13:16:00 +00:00
|
|
|
// NOTE: This operator does *not* compare the mWinsInCascade member *or* the
|
|
|
|
// mIsRunningOnCompositor member.
|
2015-09-10 05:03:46 +00:00
|
|
|
// This is because AnimationProperty objects are compared when recreating
|
|
|
|
// CSS animations to determine if mutation observer change records need to
|
|
|
|
// be created or not. However, at the point when these objects are compared
|
2015-12-20 13:16:00 +00:00
|
|
|
// neither the mWinsInCascade nor the mIsRunningOnCompositor will have been
|
|
|
|
// set on the new objects so we ignore these members to avoid generating
|
|
|
|
// spurious change records.
|
2015-03-14 05:34:40 +00:00
|
|
|
bool operator==(const AnimationProperty& aOther) const {
|
|
|
|
return mProperty == aOther.mProperty &&
|
|
|
|
mSegments == aOther.mSegments;
|
|
|
|
}
|
|
|
|
bool operator!=(const AnimationProperty& aOther) const {
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2014-08-10 07:06:49 +00:00
|
|
|
};
|
|
|
|
|
2014-08-10 07:06:52 +00:00
|
|
|
struct ElementPropertyTransition;
|
|
|
|
|
2014-08-10 07:06:46 +00:00
|
|
|
namespace dom {
|
|
|
|
|
2015-10-07 05:30:27 +00:00
|
|
|
class Animation;
|
|
|
|
|
2015-04-30 13:06:43 +00:00
|
|
|
class KeyframeEffectReadOnly : public AnimationEffectReadOnly
|
2014-08-10 07:06:46 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-04-30 13:06:43 +00:00
|
|
|
KeyframeEffectReadOnly(nsIDocument* aDocument,
|
2015-04-14 23:48:21 +00:00
|
|
|
Element* aTarget,
|
2016-02-17 20:37:00 +00:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2016-01-13 17:41:00 +00:00
|
|
|
const TimingParams& aTiming);
|
2014-08-10 07:06:46 +00:00
|
|
|
|
2015-04-14 23:48:21 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2015-04-30 13:06:43 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffectReadOnly,
|
|
|
|
AnimationEffectReadOnly)
|
2014-08-10 07:06:46 +00:00
|
|
|
|
2015-04-14 23:48:21 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2014-08-10 07:06:46 +00:00
|
|
|
|
2014-08-10 07:06:52 +00:00
|
|
|
virtual ElementPropertyTransition* AsTransition() { return nullptr; }
|
2015-06-09 02:13:53 +00:00
|
|
|
virtual const ElementPropertyTransition* AsTransition() const
|
|
|
|
{
|
2014-08-10 07:06:52 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-30 13:06:43 +00:00
|
|
|
// KeyframeEffectReadOnly interface
|
2015-10-22 08:22:38 +00:00
|
|
|
static already_AddRefed<KeyframeEffectReadOnly>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
2016-02-05 18:01:00 +00:00
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-01-29 01:37:52 +00:00
|
|
|
JS::Handle<JSObject*> aFrames,
|
2015-11-19 18:48:00 +00:00
|
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
2016-03-11 08:27:16 +00:00
|
|
|
ErrorResult& aRv);
|
2016-01-29 01:37:52 +00:00
|
|
|
|
2016-02-05 18:01:00 +00:00
|
|
|
void GetTarget(Nullable<OwningElementOrCSSPseudoElement>& aRv) const;
|
2016-03-21 08:49:50 +00:00
|
|
|
Maybe<NonOwningAnimationTarget> GetTarget() const
|
|
|
|
{
|
|
|
|
Maybe<NonOwningAnimationTarget> result;
|
|
|
|
if (mTarget) {
|
|
|
|
result.emplace(mTarget, mPseudoType);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2015-09-29 02:20:14 +00:00
|
|
|
void GetFrames(JSContext*& aCx,
|
|
|
|
nsTArray<JSObject*>& aResult,
|
|
|
|
ErrorResult& aRv);
|
2016-03-17 04:47:14 +00:00
|
|
|
void GetProperties(nsTArray<AnimationPropertyDetails>& aProperties,
|
|
|
|
ErrorResult& aRv) const;
|
2014-08-22 12:42:47 +00:00
|
|
|
|
2015-11-19 18:48:00 +00:00
|
|
|
IterationCompositeOperation IterationComposite() const;
|
|
|
|
CompositeOperation Composite() const;
|
|
|
|
void GetSpacing(nsString& aRetVal) const {
|
|
|
|
aRetVal.AssignLiteral("distribute");
|
2014-08-10 07:06:50 +00:00
|
|
|
}
|
2015-11-19 18:48:00 +00:00
|
|
|
|
2016-01-13 17:41:00 +00:00
|
|
|
already_AddRefed<AnimationEffectTimingReadOnly> Timing() const override;
|
|
|
|
|
|
|
|
const TimingParams& SpecifiedTiming() const
|
|
|
|
{
|
|
|
|
return mTiming->AsTimingParams();
|
|
|
|
}
|
|
|
|
void SetSpecifiedTiming(const TimingParams& aTiming);
|
2016-01-06 02:04:04 +00:00
|
|
|
void NotifyAnimationTimingUpdated();
|
2015-08-17 18:28:00 +00:00
|
|
|
|
2015-10-07 05:30:28 +00:00
|
|
|
Nullable<TimeDuration> GetLocalTime() const;
|
2014-08-10 07:06:50 +00: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.
|
|
|
|
//
|
2015-10-18 22:38:00 +00:00
|
|
|
// This function returns a null mProgress member of the return value
|
|
|
|
// if the animation should not be run
|
2015-05-13 04:57:35 +00:00
|
|
|
// (because it is not currently active and is not filling at this time).
|
2014-08-10 07:06:50 +00:00
|
|
|
static ComputedTiming
|
|
|
|
GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime,
|
2016-01-13 17:41:00 +00:00
|
|
|
const TimingParams& aTiming);
|
2014-08-10 07:06:50 +00:00
|
|
|
|
|
|
|
// Shortcut for that gets the computed timing using the current local time as
|
|
|
|
// calculated from the timeline time.
|
2015-10-18 22:38:00 +00:00
|
|
|
ComputedTiming
|
2016-01-13 17:41:00 +00:00
|
|
|
GetComputedTiming(const TimingParams* aTiming = nullptr) const
|
2015-10-18 22:38:00 +00:00
|
|
|
{
|
2016-01-13 17:41:00 +00:00
|
|
|
return GetComputedTimingAt(GetLocalTime(),
|
|
|
|
aTiming ? *aTiming : SpecifiedTiming());
|
2014-08-10 07:06:50 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 22:48:00 +00:00
|
|
|
void
|
|
|
|
GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const override;
|
|
|
|
|
2015-10-07 05:30:27 +00:00
|
|
|
bool IsInPlay() const;
|
|
|
|
bool IsCurrent() const;
|
2014-10-02 06:14:14 +00:00
|
|
|
bool IsInEffect() const;
|
2014-08-10 07:06:50 +00:00
|
|
|
|
2015-10-07 05:30:27 +00:00
|
|
|
void SetAnimation(Animation* aAnimation);
|
2015-11-26 07:53:53 +00:00
|
|
|
Animation* GetAnimation() const { return mAnimation; }
|
2015-10-07 05:30:27 +00:00
|
|
|
|
2016-04-09 06:33:34 +00:00
|
|
|
void SetFrames(JSContext* aContext, JS::Handle<JSObject*> aFrames,
|
|
|
|
ErrorResult& aRv);
|
2016-03-29 23:59:08 +00:00
|
|
|
void SetFrames(nsTArray<Keyframe>&& aFrames, nsStyleContext* aStyleContext);
|
2015-03-20 04:10:00 +00:00
|
|
|
const AnimationProperty*
|
|
|
|
GetAnimationOfProperty(nsCSSProperty aProperty) const;
|
|
|
|
bool HasAnimationOfProperty(nsCSSProperty aProperty) const {
|
|
|
|
return GetAnimationOfProperty(aProperty) != nullptr;
|
|
|
|
}
|
2015-04-06 02:53:51 +00:00
|
|
|
bool HasAnimationOfProperties(const nsCSSProperty* aProperties,
|
|
|
|
size_t aPropertyCount) const;
|
2014-08-10 07:06:49 +00:00
|
|
|
const InfallibleTArray<AnimationProperty>& Properties() const {
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
InfallibleTArray<AnimationProperty>& Properties() {
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
|
2016-03-29 23:59:08 +00:00
|
|
|
// Update |mProperties| by recalculating from |mFrames| using |aStyleContext|
|
|
|
|
// to resolve specified values.
|
|
|
|
void UpdateProperties(nsStyleContext* aStyleContext);
|
|
|
|
|
2014-10-20 04:55:46 +00:00
|
|
|
// Updates |aStyleRule| with the animation values produced by this
|
2015-10-07 05:30:27 +00:00
|
|
|
// AnimationEffect for the current time except any properties already
|
|
|
|
// contained in |aSetProperties|.
|
2014-10-20 04:55:46 +00:00
|
|
|
// Any updated properties are added to |aSetProperties|.
|
2015-10-18 05:24:48 +00:00
|
|
|
void ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
|
2014-10-20 04:55:46 +00:00
|
|
|
nsCSSPropertySet& aSetProperties);
|
2015-11-06 01:49:00 +00:00
|
|
|
// Returns true if at least one property is being animated on compositor.
|
2015-09-16 14:05:00 +00:00
|
|
|
bool IsRunningOnCompositor() const;
|
|
|
|
void SetIsRunningOnCompositor(nsCSSProperty aProperty, bool aIsRunning);
|
2014-10-20 04:55:46 +00:00
|
|
|
|
2016-03-14 00:07:48 +00:00
|
|
|
// Returns true if this effect, applied to |aFrame|, contains properties
|
|
|
|
// that mean we shouldn't run transform compositor animations on this element.
|
2015-12-03 23:32:53 +00:00
|
|
|
//
|
|
|
|
// For example, if we have an animation of geometric properties like 'left'
|
2016-03-14 00:07:48 +00:00
|
|
|
// and 'top' on an element, we force all 'transform' animations running at
|
|
|
|
// the same time on the same element to run on the main thread.
|
2015-12-03 23:32:53 +00:00
|
|
|
//
|
2016-03-14 00:07:48 +00:00
|
|
|
// When returning true, |aPerformanceWarning| stores the reason why
|
|
|
|
// we shouldn't run the transform animations.
|
|
|
|
bool ShouldBlockAsyncTransformAnimations(
|
2016-03-04 08:54:25 +00:00
|
|
|
const nsIFrame* aFrame,
|
|
|
|
AnimationPerformanceWarning::Type& aPerformanceWarning) const;
|
2015-12-03 23:32:53 +00:00
|
|
|
|
2015-11-06 01:51:00 +00:00
|
|
|
nsIDocument* GetRenderedDocument() const;
|
|
|
|
nsPresContext* GetPresContext() const;
|
|
|
|
|
2016-03-04 08:54:25 +00:00
|
|
|
// Associates a warning with the animated property on the specified frame
|
|
|
|
// indicating why, for example, the property could not be animated on the
|
|
|
|
// compositor. |aParams| and |aParamsLength| are optional parameters which
|
|
|
|
// will be used to generate a localized message for devtools.
|
|
|
|
void SetPerformanceWarning(
|
|
|
|
nsCSSProperty aProperty,
|
|
|
|
const AnimationPerformanceWarning& aWarning);
|
2016-03-03 21:36:36 +00:00
|
|
|
|
2014-08-10 07:06:46 +00:00
|
|
|
protected:
|
2016-02-15 00:34:47 +00:00
|
|
|
KeyframeEffectReadOnly(nsIDocument* aDocument,
|
|
|
|
Element* aTarget,
|
2016-02-17 20:37:00 +00:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2016-02-15 00:34:47 +00:00
|
|
|
AnimationEffectTimingReadOnly* aTiming);
|
|
|
|
|
2015-10-07 05:30:27 +00:00
|
|
|
virtual ~KeyframeEffectReadOnly();
|
2016-02-15 00:34:47 +00:00
|
|
|
|
2016-03-11 08:27:16 +00:00
|
|
|
template<class KeyframeEffectType, class OptionsType>
|
|
|
|
static already_AddRefed<KeyframeEffectType>
|
|
|
|
ConstructKeyframeEffect(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
|
|
JS::Handle<JSObject*> aFrames,
|
|
|
|
const OptionsType& aOptions,
|
|
|
|
ErrorResult& aRv);
|
2016-02-15 00:34:47 +00:00
|
|
|
|
2015-09-16 14:05:00 +00:00
|
|
|
void ResetIsRunningOnCompositor();
|
2014-08-10 07:06:46 +00:00
|
|
|
|
2015-11-26 07:53:53 +00:00
|
|
|
// This effect is registered with its target element so long as:
|
|
|
|
//
|
|
|
|
// (a) It has a target element, and
|
|
|
|
// (b) It is "relevant" (i.e. yet to finish but not idle, or finished but
|
|
|
|
// filling forwards)
|
|
|
|
//
|
|
|
|
// As a result, we need to make sure this gets called whenever anything
|
|
|
|
// changes with regards to this effects's timing including changes to the
|
|
|
|
// owning Animation's timing.
|
|
|
|
void UpdateTargetRegistration();
|
|
|
|
|
2014-10-02 06:14:15 +00:00
|
|
|
nsCOMPtr<Element> mTarget;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<Animation> mAnimation;
|
2014-08-10 07:06:49 +00:00
|
|
|
|
2016-04-13 10:20:46 +00:00
|
|
|
RefPtr<AnimationEffectTimingReadOnly> mTiming;
|
2016-02-17 20:37:00 +00:00
|
|
|
CSSPseudoElementType mPseudoType;
|
2014-08-10 07:06:51 +00:00
|
|
|
|
2016-03-29 23:59:08 +00:00
|
|
|
// The specified keyframes.
|
|
|
|
nsTArray<Keyframe> mFrames;
|
|
|
|
|
|
|
|
// A set of per-property value arrays, derived from |mFrames|.
|
|
|
|
nsTArray<AnimationProperty> mProperties;
|
2015-09-16 14:05:00 +00:00
|
|
|
|
2016-01-06 02:04:06 +00:00
|
|
|
// The computed progress last time we composed the style rule. This is
|
|
|
|
// used to detect when the progress is not changing (e.g. due to a step
|
|
|
|
// timing function) so we can avoid unnecessary style updates.
|
|
|
|
Nullable<double> mProgressOnLastCompose;
|
|
|
|
|
2016-01-06 02:04:05 +00:00
|
|
|
// We need to track when we go to or from being "in effect" since
|
|
|
|
// we need to re-evaluate the cascade of animations when that changes.
|
|
|
|
bool mInEffectOnLastAnimationTimingUpdate;
|
|
|
|
|
2015-11-06 01:42:00 +00:00
|
|
|
private:
|
|
|
|
nsIFrame* GetAnimationFrame() const;
|
2015-11-06 01:53:00 +00:00
|
|
|
|
2016-01-06 02:04:06 +00:00
|
|
|
bool CanThrottle() const;
|
2015-11-06 01:53:00 +00:00
|
|
|
bool CanThrottleTransformChanges(nsIFrame& aFrame) const;
|
|
|
|
|
2015-11-06 01:45:00 +00:00
|
|
|
// Returns true unless Gecko limitations prevent performing transform
|
2016-03-04 06:07:04 +00:00
|
|
|
// animations for |aFrame|. When returning true, the reason for the
|
|
|
|
// limitation is stored in |aOutPerformanceWarning|.
|
2016-03-04 08:54:25 +00:00
|
|
|
static bool CanAnimateTransformOnCompositor(
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
AnimationPerformanceWarning::Type& aPerformanceWarning);
|
2015-11-06 01:45:00 +00:00
|
|
|
static bool IsGeometricProperty(const nsCSSProperty aProperty);
|
2015-11-06 01:55:00 +00:00
|
|
|
|
|
|
|
static const TimeDuration OverflowRegionRefreshInterval();
|
2014-08-10 07:06:46 +00:00
|
|
|
};
|
|
|
|
|
2016-02-15 00:34:47 +00:00
|
|
|
class KeyframeEffect : public KeyframeEffectReadOnly
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyframeEffect(nsIDocument* aDocument,
|
|
|
|
Element* aTarget,
|
2016-02-17 20:37:00 +00:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2016-02-15 00:34:47 +00:00
|
|
|
const TimingParams& aTiming);
|
2016-02-15 00:34:47 +00:00
|
|
|
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2016-02-15 00:34:47 +00:00
|
|
|
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
|
|
JS::Handle<JSObject*> aFrames,
|
|
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
2016-03-11 08:27:16 +00:00
|
|
|
ErrorResult& aRv);
|
2016-02-15 00:34:47 +00:00
|
|
|
|
2016-03-12 13:14:10 +00:00
|
|
|
// Variant of Constructor that accepts a KeyframeAnimationOptions object
|
|
|
|
// for use with for Animatable.animate.
|
2016-02-15 00:34:47 +00:00
|
|
|
// Not exposed to content.
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
2016-03-11 08:27:16 +00:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
|
|
JS::Handle<JSObject*> aFrames,
|
2016-03-12 13:14:10 +00:00
|
|
|
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
2016-03-11 08:27:16 +00:00
|
|
|
ErrorResult& aRv);
|
2016-02-26 21:39:30 +00:00
|
|
|
|
2016-02-26 21:39:49 +00:00
|
|
|
void NotifySpecifiedTimingUpdated();
|
|
|
|
|
2016-04-28 15:22:43 +00:00
|
|
|
void SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget);
|
|
|
|
|
2016-02-26 21:39:30 +00:00
|
|
|
protected:
|
|
|
|
~KeyframeEffect() override;
|
2016-02-15 00:34:47 +00:00
|
|
|
};
|
|
|
|
|
2014-08-10 07:06:46 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-04-14 23:48:21 +00:00
|
|
|
#endif // mozilla_dom_KeyframeEffect_h
|