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: */
|
2014-08-10 11:06:46 +04: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-15 02:48:21 +03:00
|
|
|
#ifndef mozilla_dom_KeyframeEffect_h
|
|
|
|
#define mozilla_dom_KeyframeEffect_h
|
2014-08-10 11:06:46 +04:00
|
|
|
|
2016-05-24 06:57:42 +03:00
|
|
|
#include "nsChangeHint.h"
|
2016-03-22 10:19:43 +03:00
|
|
|
#include "nsCSSProperty.h"
|
|
|
|
#include "nsCSSValue.h"
|
2014-08-10 11:06:46 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2016-03-22 10:19:43 +03:00
|
|
|
#include "nsTArray.h"
|
2014-08-10 11:06:46 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2016-03-04 11:54:25 +03:00
|
|
|
#include "mozilla/AnimationPerformanceWarning.h"
|
2016-04-28 18:22:43 +03:00
|
|
|
#include "mozilla/AnimationTarget.h"
|
2014-08-10 11:06:46 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-03-22 02:11:05 +03:00
|
|
|
#include "mozilla/ComputedTiming.h"
|
|
|
|
#include "mozilla/ComputedTimingFunction.h"
|
2016-04-28 18:22:43 +03:00
|
|
|
#include "mozilla/EffectCompositor.h"
|
2016-05-05 10:41:03 +03:00
|
|
|
#include "mozilla/KeyframeEffectParams.h"
|
2016-03-22 02:11:05 +03:00
|
|
|
#include "mozilla/LayerAnimationInfo.h" // LayerAnimations::kRecords
|
2016-03-22 10:19:43 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2014-09-25 09:25:50 +04:00
|
|
|
#include "mozilla/StickyTimeDuration.h"
|
2014-08-10 11:06:49 +04:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2014-08-10 11:06:48 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2016-03-07 08:11:11 +03:00
|
|
|
#include "mozilla/TimingParams.h"
|
2015-04-30 16:06:43 +03:00
|
|
|
#include "mozilla/dom/AnimationEffectReadOnly.h"
|
2016-03-07 08:11:11 +03:00
|
|
|
#include "mozilla/dom/AnimationEffectTimingReadOnly.h"
|
2014-10-02 10:14:15 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2014-08-10 11:06:48 +04:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2014-08-10 11:06:46 +04:00
|
|
|
|
|
|
|
struct JSContext;
|
2014-10-20 08:55:46 +04:00
|
|
|
class nsCSSPropertySet;
|
2015-11-06 04:38:00 +03:00
|
|
|
class nsIContent;
|
2015-11-06 04:51:00 +03:00
|
|
|
class nsIDocument;
|
2015-11-06 04:38:00 +03:00
|
|
|
class nsIFrame;
|
2016-05-24 06:57:43 +03:00
|
|
|
class nsIPresShell;
|
2015-11-06 04:51:00 +03:00
|
|
|
class nsPresContext;
|
2014-08-10 11:06:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-07-29 04:57:39 +03:00
|
|
|
|
2014-10-20 08:55:46 +04:00
|
|
|
class AnimValuesStyleRule;
|
2016-02-17 23:37:00 +03:00
|
|
|
enum class CSSPseudoElementType : uint8_t;
|
2014-08-10 11:06:49 +04:00
|
|
|
|
2015-10-23 01:48:00 +03:00
|
|
|
namespace dom {
|
2016-02-05 21:01:00 +03:00
|
|
|
class ElementOrCSSPseudoElement;
|
|
|
|
class OwningElementOrCSSPseudoElement;
|
2016-03-12 16:14:10 +03:00
|
|
|
class UnrestrictedDoubleOrKeyframeAnimationOptions;
|
2015-11-19 21:48:00 +03:00
|
|
|
class UnrestrictedDoubleOrKeyframeEffectOptions;
|
|
|
|
enum class IterationCompositeOperation : uint32_t;
|
|
|
|
enum class CompositeOperation : uint32_t;
|
2016-03-13 14:10:10 +03:00
|
|
|
struct AnimationPropertyDetails;
|
2015-10-23 01:48:00 +03:00
|
|
|
}
|
|
|
|
|
2016-03-22 10:19:43 +03: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-30 02:59:08 +03:00
|
|
|
|
|
|
|
bool operator==(const PropertyValuePair& aOther) const {
|
|
|
|
return mProperty == aOther.mProperty &&
|
|
|
|
mValue == aOther.mValue;
|
|
|
|
}
|
2016-03-22 10:19:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A single keyframe.
|
|
|
|
*
|
|
|
|
* This is the canonical form in which keyframe effects are stored and
|
2016-05-13 03:40:52 +03:00
|
|
|
* corresponds closely to the type of objects returned via the getKeyframes()
|
|
|
|
* API.
|
2016-03-22 10:19:43 +03:00
|
|
|
*
|
|
|
|
* 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 04:39:29 +03:00
|
|
|
Keyframe() = default;
|
2016-03-31 10:26:52 +03:00
|
|
|
Keyframe(const Keyframe& aOther) = default;
|
2016-03-24 04:39:29 +03:00
|
|
|
Keyframe(Keyframe&& aOther)
|
|
|
|
{
|
2016-03-29 05:29:20 +03:00
|
|
|
*this = Move(aOther);
|
|
|
|
}
|
2016-03-31 10:26:52 +03:00
|
|
|
|
|
|
|
Keyframe& operator=(const Keyframe& aOther) = default;
|
2016-03-29 05:29:20 +03:00
|
|
|
Keyframe& operator=(Keyframe&& aOther)
|
|
|
|
{
|
|
|
|
mOffset = aOther.mOffset;
|
|
|
|
mComputedOffset = aOther.mComputedOffset;
|
|
|
|
mTimingFunction = Move(aOther.mTimingFunction);
|
|
|
|
mPropertyValues = Move(aOther.mPropertyValues);
|
|
|
|
return *this;
|
2016-03-24 04:39:29 +03:00
|
|
|
}
|
|
|
|
|
2016-03-22 10:19:43 +03:00
|
|
|
Maybe<double> mOffset;
|
2016-05-12 11:00:47 +03:00
|
|
|
static MOZ_CONSTEXPR_VAR double kComputedOffsetNotSet = -1.0;
|
|
|
|
double mComputedOffset = kComputedOffsetNotSet;
|
2016-03-22 10:19:43 +03:00
|
|
|
Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
|
|
|
|
// "linear"
|
|
|
|
nsTArray<PropertyValuePair> mPropertyValues;
|
|
|
|
};
|
|
|
|
|
2014-08-10 11:06:49 +04:00
|
|
|
struct AnimationPropertySegment
|
|
|
|
{
|
|
|
|
float mFromKey, mToKey;
|
|
|
|
StyleAnimationValue mFromValue, mToValue;
|
2016-01-29 16:44:00 +03:00
|
|
|
Maybe<ComputedTimingFunction> mTimingFunction;
|
2015-03-14 08:34:40 +03:00
|
|
|
|
2016-05-24 06:57:42 +03:00
|
|
|
nsChangeHint mChangeHint;
|
|
|
|
|
2015-03-14 08:34:40 +03: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 11:06:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimationProperty
|
|
|
|
{
|
2015-12-20 16:16:00 +03:00
|
|
|
nsCSSProperty mProperty = eCSSProperty_UNKNOWN;
|
2015-03-20 07:10:00 +03: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-04-01 01:05:54 +03: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 07:38:16 +03:00
|
|
|
//
|
2016-01-06 05:04:05 +03:00
|
|
|
// **NOTE**: This member is not included when comparing AnimationProperty
|
2015-09-10 08:03:46 +03:00
|
|
|
// objects for equality.
|
2016-01-13 07:38:16 +03:00
|
|
|
bool mWinsInCascade = false;
|
2015-12-20 16:16:00 +03: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 07:41:16 +03:00
|
|
|
// between calling RequestRestyle on its EffectCompositor and when the
|
2015-12-20 16:16:00 +03:00
|
|
|
// restyle is performed, this member may temporarily become false even if
|
|
|
|
// the animation remains on the layer after the restyle.
|
2016-01-13 07:38:16 +03:00
|
|
|
//
|
|
|
|
// **NOTE**: This member is not included when comparing AnimationProperty
|
|
|
|
// objects for equality.
|
2015-12-20 16:16:00 +03:00
|
|
|
bool mIsRunningOnCompositor = false;
|
2015-03-20 07:10:00 +03:00
|
|
|
|
2016-03-04 11:54:25 +03:00
|
|
|
Maybe<AnimationPerformanceWarning> mPerformanceWarning;
|
2016-03-04 00:36:36 +03:00
|
|
|
|
2014-08-10 11:06:49 +04:00
|
|
|
InfallibleTArray<AnimationPropertySegment> mSegments;
|
2015-03-14 08:34:40 +03:00
|
|
|
|
2015-12-20 16:16:00 +03:00
|
|
|
// NOTE: This operator does *not* compare the mWinsInCascade member *or* the
|
|
|
|
// mIsRunningOnCompositor member.
|
2015-09-10 08:03:46 +03: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 16:16:00 +03: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 08:34:40 +03: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 11:06:49 +04:00
|
|
|
};
|
|
|
|
|
2014-08-10 11:06:52 +04:00
|
|
|
struct ElementPropertyTransition;
|
|
|
|
|
2014-08-10 11:06:46 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-10-07 08:30:27 +03:00
|
|
|
class Animation;
|
|
|
|
|
2015-04-30 16:06:43 +03:00
|
|
|
class KeyframeEffectReadOnly : public AnimationEffectReadOnly
|
2014-08-10 11:06:46 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-04-30 16:06:43 +03:00
|
|
|
KeyframeEffectReadOnly(nsIDocument* aDocument,
|
2016-04-28 18:22:44 +03:00
|
|
|
const Maybe<OwningAnimationTarget>& aTarget,
|
2016-05-05 10:41:03 +03:00
|
|
|
const TimingParams& aTiming,
|
|
|
|
const KeyframeEffectParams& aOptions);
|
2014-08-10 11:06:46 +04:00
|
|
|
|
2015-04-15 02:48:21 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2015-04-30 16:06:43 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffectReadOnly,
|
|
|
|
AnimationEffectReadOnly)
|
2014-08-10 11:06:46 +04:00
|
|
|
|
2015-04-15 02:48:21 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2014-08-10 11:06:46 +04:00
|
|
|
|
2014-08-10 11:06:52 +04:00
|
|
|
virtual ElementPropertyTransition* AsTransition() { return nullptr; }
|
2015-06-09 05:13:53 +03:00
|
|
|
virtual const ElementPropertyTransition* AsTransition() const
|
|
|
|
{
|
2014-08-10 11:06:52 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-30 16:06:43 +03:00
|
|
|
// KeyframeEffectReadOnly interface
|
2015-10-22 11:22:38 +03:00
|
|
|
static already_AddRefed<KeyframeEffectReadOnly>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
2016-02-05 21:01:00 +03:00
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2015-11-19 21:48:00 +03:00
|
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
2016-03-11 11:27:16 +03:00
|
|
|
ErrorResult& aRv);
|
2016-01-29 04:37:52 +03:00
|
|
|
|
2016-02-05 21:01:00 +03:00
|
|
|
void GetTarget(Nullable<OwningElementOrCSSPseudoElement>& aRv) const;
|
2016-03-21 11:49:50 +03:00
|
|
|
Maybe<NonOwningAnimationTarget> GetTarget() const
|
|
|
|
{
|
|
|
|
Maybe<NonOwningAnimationTarget> result;
|
|
|
|
if (mTarget) {
|
2016-04-28 18:22:43 +03:00
|
|
|
result.emplace(*mTarget);
|
2016-03-21 11:49:50 +03:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2016-05-13 03:40:52 +03:00
|
|
|
void GetKeyframes(JSContext*& aCx,
|
|
|
|
nsTArray<JSObject*>& aResult,
|
|
|
|
ErrorResult& aRv);
|
2016-03-17 07:47:14 +03:00
|
|
|
void GetProperties(nsTArray<AnimationPropertyDetails>& aProperties,
|
|
|
|
ErrorResult& aRv) const;
|
2014-08-22 16:42:47 +04:00
|
|
|
|
2015-11-19 21:48:00 +03:00
|
|
|
IterationCompositeOperation IterationComposite() const;
|
|
|
|
CompositeOperation Composite() const;
|
2016-05-05 10:41:03 +03:00
|
|
|
void GetSpacing(nsString& aRetVal) const
|
|
|
|
{
|
|
|
|
mEffectOptions.GetSpacingAsString(aRetVal);
|
2014-08-10 11:06:50 +04:00
|
|
|
}
|
2015-11-19 21:48:00 +03:00
|
|
|
|
2016-01-13 20:41:00 +03:00
|
|
|
already_AddRefed<AnimationEffectTimingReadOnly> Timing() const override;
|
|
|
|
|
|
|
|
const TimingParams& SpecifiedTiming() const
|
|
|
|
{
|
|
|
|
return mTiming->AsTimingParams();
|
|
|
|
}
|
|
|
|
void SetSpecifiedTiming(const TimingParams& aTiming);
|
2016-01-06 05:04:04 +03:00
|
|
|
void NotifyAnimationTimingUpdated();
|
2015-08-17 21:28:00 +03:00
|
|
|
|
2015-10-07 08:30:28 +03:00
|
|
|
Nullable<TimeDuration> GetLocalTime() const;
|
2014-08-10 11:06:50 +04: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-19 01:38:00 +03:00
|
|
|
// This function returns a null mProgress member of the return value
|
|
|
|
// if the animation should not be run
|
2015-05-13 07:57:35 +03:00
|
|
|
// (because it is not currently active and is not filling at this time).
|
2014-08-10 11:06:50 +04:00
|
|
|
static ComputedTiming
|
|
|
|
GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime,
|
2016-01-13 20:41:00 +03:00
|
|
|
const TimingParams& aTiming);
|
2014-08-10 11:06:50 +04:00
|
|
|
|
|
|
|
// Shortcut for that gets the computed timing using the current local time as
|
|
|
|
// calculated from the timeline time.
|
2015-10-19 01:38:00 +03:00
|
|
|
ComputedTiming
|
2016-01-13 20:41:00 +03:00
|
|
|
GetComputedTiming(const TimingParams* aTiming = nullptr) const
|
2015-10-19 01:38:00 +03:00
|
|
|
{
|
2016-01-13 20:41:00 +03:00
|
|
|
return GetComputedTimingAt(GetLocalTime(),
|
|
|
|
aTiming ? *aTiming : SpecifiedTiming());
|
2014-08-10 11:06:50 +04:00
|
|
|
}
|
|
|
|
|
2015-10-23 01:48:00 +03:00
|
|
|
void
|
|
|
|
GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const override;
|
|
|
|
|
2015-10-07 08:30:27 +03:00
|
|
|
bool IsInPlay() const;
|
|
|
|
bool IsCurrent() const;
|
2014-10-02 10:14:14 +04:00
|
|
|
bool IsInEffect() const;
|
2014-08-10 11:06:50 +04:00
|
|
|
|
2015-10-07 08:30:27 +03:00
|
|
|
void SetAnimation(Animation* aAnimation);
|
2015-11-26 10:53:53 +03:00
|
|
|
Animation* GetAnimation() const { return mAnimation; }
|
2015-10-07 08:30:27 +03:00
|
|
|
|
2016-05-13 03:40:52 +03:00
|
|
|
void SetKeyframes(JSContext* aContext, JS::Handle<JSObject*> aKeyframes,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
void SetKeyframes(nsTArray<Keyframe>&& aKeyframes,
|
|
|
|
nsStyleContext* aStyleContext);
|
2015-03-20 07:10:00 +03:00
|
|
|
const AnimationProperty*
|
|
|
|
GetAnimationOfProperty(nsCSSProperty aProperty) const;
|
|
|
|
bool HasAnimationOfProperty(nsCSSProperty aProperty) const {
|
|
|
|
return GetAnimationOfProperty(aProperty) != nullptr;
|
|
|
|
}
|
2015-04-06 05:53:51 +03:00
|
|
|
bool HasAnimationOfProperties(const nsCSSProperty* aProperties,
|
|
|
|
size_t aPropertyCount) const;
|
2014-08-10 11:06:49 +04:00
|
|
|
const InfallibleTArray<AnimationProperty>& Properties() const {
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
InfallibleTArray<AnimationProperty>& Properties() {
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
|
2016-05-13 03:40:52 +03:00
|
|
|
// Update |mProperties| by recalculating from |mKeyframes| using
|
|
|
|
// |aStyleContext| to resolve specified values.
|
2016-03-30 02:59:08 +03:00
|
|
|
void UpdateProperties(nsStyleContext* aStyleContext);
|
|
|
|
|
2014-10-20 08:55:46 +04:00
|
|
|
// Updates |aStyleRule| with the animation values produced by this
|
2015-10-07 08:30:27 +03:00
|
|
|
// AnimationEffect for the current time except any properties already
|
|
|
|
// contained in |aSetProperties|.
|
2014-10-20 08:55:46 +04:00
|
|
|
// Any updated properties are added to |aSetProperties|.
|
2015-10-18 08:24:48 +03:00
|
|
|
void ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
|
2014-10-20 08:55:46 +04:00
|
|
|
nsCSSPropertySet& aSetProperties);
|
2015-11-06 04:49:00 +03:00
|
|
|
// Returns true if at least one property is being animated on compositor.
|
2015-09-16 17:05:00 +03:00
|
|
|
bool IsRunningOnCompositor() const;
|
|
|
|
void SetIsRunningOnCompositor(nsCSSProperty aProperty, bool aIsRunning);
|
2016-05-16 10:25:46 +03:00
|
|
|
void ResetIsRunningOnCompositor();
|
2014-10-20 08:55:46 +04:00
|
|
|
|
2016-03-14 03:07:48 +03: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-04 02:32:53 +03:00
|
|
|
//
|
|
|
|
// For example, if we have an animation of geometric properties like 'left'
|
2016-03-14 03:07:48 +03: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-04 02:32:53 +03:00
|
|
|
//
|
2016-03-14 03:07:48 +03:00
|
|
|
// When returning true, |aPerformanceWarning| stores the reason why
|
|
|
|
// we shouldn't run the transform animations.
|
|
|
|
bool ShouldBlockAsyncTransformAnimations(
|
2016-03-04 11:54:25 +03:00
|
|
|
const nsIFrame* aFrame,
|
|
|
|
AnimationPerformanceWarning::Type& aPerformanceWarning) const;
|
2015-12-04 02:32:53 +03:00
|
|
|
|
2015-11-06 04:51:00 +03:00
|
|
|
nsIDocument* GetRenderedDocument() const;
|
|
|
|
nsPresContext* GetPresContext() const;
|
2016-05-24 06:57:43 +03:00
|
|
|
nsIPresShell* GetPresShell() const;
|
2015-11-06 04:51:00 +03:00
|
|
|
|
2016-03-04 11:54:25 +03: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-04 00:36:36 +03:00
|
|
|
|
2016-05-24 06:57:42 +03:00
|
|
|
// Cumulative change hint on each segment for each property.
|
|
|
|
// This is used for deciding the animation is paint-only.
|
|
|
|
void CalculateCumulativeChangeHint();
|
|
|
|
|
2016-05-24 06:57:42 +03:00
|
|
|
// Returns true if all of animation properties' change hints
|
|
|
|
// can ignore painting if the animation is not visible.
|
|
|
|
// See nsChangeHint_Hints_CanIgnoreIfNotVisible in nsChangeHint.h
|
|
|
|
// in detail which change hint can be ignored.
|
|
|
|
bool CanIgnoreIfNotVisible() const;
|
|
|
|
|
2014-08-10 11:06:46 +04:00
|
|
|
protected:
|
2016-02-15 03:34:47 +03:00
|
|
|
KeyframeEffectReadOnly(nsIDocument* aDocument,
|
2016-04-28 18:22:44 +03:00
|
|
|
const Maybe<OwningAnimationTarget>& aTarget,
|
2016-05-05 10:41:03 +03:00
|
|
|
AnimationEffectTimingReadOnly* aTiming,
|
|
|
|
const KeyframeEffectParams& aOptions);
|
2016-02-15 03:34:47 +03:00
|
|
|
|
2015-10-07 08:30:27 +03:00
|
|
|
virtual ~KeyframeEffectReadOnly();
|
2016-02-15 03:34:47 +03:00
|
|
|
|
2016-03-11 11:27:16 +03:00
|
|
|
template<class KeyframeEffectType, class OptionsType>
|
|
|
|
static already_AddRefed<KeyframeEffectType>
|
|
|
|
ConstructKeyframeEffect(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2016-03-11 11:27:16 +03:00
|
|
|
const OptionsType& aOptions,
|
|
|
|
ErrorResult& aRv);
|
2016-02-15 03:34:47 +03:00
|
|
|
|
2016-04-28 18:22:43 +03:00
|
|
|
void ResetWinsInCascade();
|
2014-08-10 11:06:46 +04:00
|
|
|
|
2015-11-26 10:53:53 +03: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();
|
|
|
|
|
2016-04-28 18:22:43 +03:00
|
|
|
// Remove the current effect target from its EffectSet.
|
|
|
|
void UnregisterTarget();
|
|
|
|
|
|
|
|
void RequestRestyle(EffectCompositor::RestyleType aRestyleType);
|
|
|
|
|
2016-04-28 18:22:43 +03:00
|
|
|
Maybe<OwningAnimationTarget> mTarget;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Animation> mAnimation;
|
2014-08-10 11:06:49 +04:00
|
|
|
|
2016-04-13 13:20:46 +03:00
|
|
|
RefPtr<AnimationEffectTimingReadOnly> mTiming;
|
2016-05-05 10:41:03 +03:00
|
|
|
KeyframeEffectParams mEffectOptions;
|
2014-08-10 11:06:51 +04:00
|
|
|
|
2016-03-30 02:59:08 +03:00
|
|
|
// The specified keyframes.
|
2016-05-13 03:40:52 +03:00
|
|
|
nsTArray<Keyframe> mKeyframes;
|
2016-03-30 02:59:08 +03:00
|
|
|
|
2016-05-13 03:40:52 +03:00
|
|
|
// A set of per-property value arrays, derived from |mKeyframes|.
|
2016-03-30 02:59:08 +03:00
|
|
|
nsTArray<AnimationProperty> mProperties;
|
2015-09-16 17:05:00 +03:00
|
|
|
|
2016-01-06 05:04:06 +03: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 05:04:05 +03: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 04:42:00 +03:00
|
|
|
private:
|
2016-05-24 06:57:42 +03:00
|
|
|
nsChangeHint mCumulativeChangeHint;
|
|
|
|
|
2015-11-06 04:42:00 +03:00
|
|
|
nsIFrame* GetAnimationFrame() const;
|
2015-11-06 04:53:00 +03:00
|
|
|
|
2016-01-06 05:04:06 +03:00
|
|
|
bool CanThrottle() const;
|
2015-11-06 04:53:00 +03:00
|
|
|
bool CanThrottleTransformChanges(nsIFrame& aFrame) const;
|
|
|
|
|
2015-11-06 04:45:00 +03:00
|
|
|
// Returns true unless Gecko limitations prevent performing transform
|
2016-03-04 09:07:04 +03:00
|
|
|
// animations for |aFrame|. When returning true, the reason for the
|
|
|
|
// limitation is stored in |aOutPerformanceWarning|.
|
2016-03-04 11:54:25 +03:00
|
|
|
static bool CanAnimateTransformOnCompositor(
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
AnimationPerformanceWarning::Type& aPerformanceWarning);
|
2015-11-06 04:45:00 +03:00
|
|
|
static bool IsGeometricProperty(const nsCSSProperty aProperty);
|
2015-11-06 04:55:00 +03:00
|
|
|
|
|
|
|
static const TimeDuration OverflowRegionRefreshInterval();
|
2014-08-10 11:06:46 +04:00
|
|
|
};
|
|
|
|
|
2016-02-15 03:34:47 +03:00
|
|
|
class KeyframeEffect : public KeyframeEffectReadOnly
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyframeEffect(nsIDocument* aDocument,
|
2016-04-28 18:22:44 +03:00
|
|
|
const Maybe<OwningAnimationTarget>& aTarget,
|
2016-05-05 10:41:03 +03:00
|
|
|
const TimingParams& aTiming,
|
|
|
|
const KeyframeEffectParams& aOptions);
|
2016-02-15 03:34:47 +03:00
|
|
|
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2016-02-15 03:34:47 +03:00
|
|
|
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2016-02-15 03:34:47 +03:00
|
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
2016-03-11 11:27:16 +03:00
|
|
|
ErrorResult& aRv);
|
2016-02-15 03:34:47 +03:00
|
|
|
|
2016-03-12 16:14:10 +03:00
|
|
|
// Variant of Constructor that accepts a KeyframeAnimationOptions object
|
|
|
|
// for use with for Animatable.animate.
|
2016-02-15 03:34:47 +03:00
|
|
|
// Not exposed to content.
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
2016-03-11 11:27:16 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2016-03-12 16:14:10 +03:00
|
|
|
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
2016-03-11 11:27:16 +03:00
|
|
|
ErrorResult& aRv);
|
2016-02-27 00:39:30 +03:00
|
|
|
|
2016-02-27 00:39:49 +03:00
|
|
|
void NotifySpecifiedTimingUpdated();
|
|
|
|
|
2016-04-28 18:22:43 +03:00
|
|
|
// This method calls MaybeUpdateProperties which is not safe to use when
|
|
|
|
// we are in the middle of updating style. If we need to use this when
|
|
|
|
// updating style, we should pass the nsStyleContext into this method and use
|
|
|
|
// that to update the properties rather than calling
|
|
|
|
// GetStyleContextForElement.
|
2016-04-28 18:22:43 +03:00
|
|
|
void SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget);
|
|
|
|
|
2016-02-27 00:39:30 +03:00
|
|
|
protected:
|
|
|
|
~KeyframeEffect() override;
|
2016-04-28 18:22:43 +03:00
|
|
|
|
|
|
|
// We need to be careful to *not* call this when we are updating the style
|
|
|
|
// context. That's because calling GetStyleContextForElement when we are in
|
|
|
|
// the process of building a style context may trigger various forms of
|
|
|
|
// infinite recursion.
|
|
|
|
void MaybeUpdateProperties();
|
2016-02-15 03:34:47 +03:00
|
|
|
};
|
|
|
|
|
2014-08-10 11:06:46 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-04-15 02:48:21 +03:00
|
|
|
#endif // mozilla_dom_KeyframeEffect_h
|