2016-09-04 10:34:21 +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: */
|
|
|
|
/* 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:07:06 +03:00
|
|
|
#ifndef mozilla_dom_KeyframeEffect_h
|
|
|
|
#define mozilla_dom_KeyframeEffect_h
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
#include "nsChangeHint.h"
|
|
|
|
#include "nsCSSPropertyID.h"
|
2016-12-04 02:07:40 +03:00
|
|
|
#include "nsCSSPropertyIDSet.h"
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "nsCSSValue.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2017-04-06 04:34:50 +03:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/AnimationPerformanceWarning.h"
|
2017-04-06 04:34:50 +03:00
|
|
|
#include "mozilla/AnimationPropertySegment.h"
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "mozilla/AnimationTarget.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ComputedTimingFunction.h"
|
|
|
|
#include "mozilla/EffectCompositor.h"
|
2017-01-29 06:58:23 +03:00
|
|
|
#include "mozilla/Keyframe.h"
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "mozilla/KeyframeEffectParams.h"
|
2016-12-01 04:34:54 +03:00
|
|
|
// RawServoDeclarationBlock and associated RefPtrTraits
|
|
|
|
#include "mozilla/ServoBindingTypes.h"
|
2017-03-31 12:46:37 +03:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2018-05-07 05:15:16 +03:00
|
|
|
#include "mozilla/dom/AnimationEffect.h"
|
2016-12-07 12:47:23 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
class JSObject;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIPresShell;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class AnimValuesStyleRule;
|
|
|
|
enum class CSSPseudoElementType : uint8_t;
|
|
|
|
class ErrorResult;
|
2017-01-24 10:19:18 +03:00
|
|
|
struct AnimationRule;
|
2016-09-04 10:34:21 +03:00
|
|
|
struct TimingParams;
|
2017-05-16 14:11:04 +03:00
|
|
|
class EffectSet;
|
2018-03-22 21:20:41 +03:00
|
|
|
class ComputedStyle;
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class ElementOrCSSPseudoElement;
|
|
|
|
class GlobalObject;
|
|
|
|
class OwningElementOrCSSPseudoElement;
|
|
|
|
class UnrestrictedDoubleOrKeyframeAnimationOptions;
|
|
|
|
class UnrestrictedDoubleOrKeyframeEffectOptions;
|
2017-01-12 04:23:37 +03:00
|
|
|
enum class IterationCompositeOperation : uint8_t;
|
|
|
|
enum class CompositeOperation : uint8_t;
|
2016-09-04 10:34:21 +03:00
|
|
|
struct AnimationPropertyDetails;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct AnimationProperty
|
|
|
|
{
|
|
|
|
nsCSSPropertyID mProperty = eCSSProperty_UNKNOWN;
|
|
|
|
|
|
|
|
// If true, the propery is currently being animated on the compositor.
|
|
|
|
//
|
|
|
|
// Note that when the owning Animation requests a non-throttled restyle, in
|
|
|
|
// between calling RequestRestyle on its EffectCompositor and when the
|
|
|
|
// restyle is performed, this member may temporarily become false even if
|
|
|
|
// the animation remains on the layer after the restyle.
|
|
|
|
//
|
|
|
|
// **NOTE**: This member is not included when comparing AnimationProperty
|
|
|
|
// objects for equality.
|
|
|
|
bool mIsRunningOnCompositor = false;
|
|
|
|
|
|
|
|
Maybe<AnimationPerformanceWarning> mPerformanceWarning;
|
|
|
|
|
|
|
|
InfallibleTArray<AnimationPropertySegment> mSegments;
|
|
|
|
|
2016-11-03 06:36:28 +03:00
|
|
|
// The copy constructor/assignment doesn't copy mIsRunningOnCompositor and
|
|
|
|
// mPerformanceWarning.
|
|
|
|
AnimationProperty() = default;
|
|
|
|
AnimationProperty(const AnimationProperty& aOther)
|
|
|
|
: mProperty(aOther.mProperty), mSegments(aOther.mSegments) { }
|
|
|
|
AnimationProperty& operator=(const AnimationProperty& aOther)
|
|
|
|
{
|
|
|
|
mProperty = aOther.mProperty;
|
|
|
|
mSegments = aOther.mSegments;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-10-05 08:48:05 +03:00
|
|
|
// NOTE: This operator does *not* compare the mIsRunningOnCompositor member.
|
2016-09-04 10:34:21 +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
|
2016-10-05 08:48:05 +03:00
|
|
|
// the mIsRunningOnCompositor will not have been set on the new objects so
|
|
|
|
// we ignore this member to avoid generating spurious change records.
|
2016-11-03 06:36:28 +03:00
|
|
|
bool operator==(const AnimationProperty& aOther) const
|
|
|
|
{
|
2016-09-04 10:34:21 +03:00
|
|
|
return mProperty == aOther.mProperty &&
|
|
|
|
mSegments == aOther.mSegments;
|
|
|
|
}
|
2016-11-03 06:36:28 +03:00
|
|
|
bool operator!=(const AnimationProperty& aOther) const
|
|
|
|
{
|
2016-09-04 10:34:21 +03:00
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ElementPropertyTransition;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Animation;
|
|
|
|
|
2018-05-07 05:15:16 +03:00
|
|
|
class KeyframeEffect : public AnimationEffect
|
2016-09-04 10:34:21 +03:00
|
|
|
{
|
|
|
|
public:
|
2018-05-07 05:08:59 +03:00
|
|
|
KeyframeEffect(nsIDocument* aDocument,
|
|
|
|
const Maybe<OwningAnimationTarget>& aTarget,
|
|
|
|
const TimingParams& aTiming,
|
|
|
|
const KeyframeEffectParams& aOptions);
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2018-05-07 05:08:59 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffect,
|
2018-05-07 05:15:16 +03:00
|
|
|
AnimationEffect)
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2018-05-07 05:08:59 +03:00
|
|
|
KeyframeEffect* AsKeyframeEffect() override { return this; }
|
2016-09-04 10:34:21 +03:00
|
|
|
|
2018-05-07 05:08:59 +03:00
|
|
|
// KeyframeEffect interface
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
2016-09-04 10:34:21 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
|
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2018-05-07 05:08:59 +03:00
|
|
|
static already_AddRefed<KeyframeEffect>
|
2016-10-28 10:41:08 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
2018-05-07 05:08:59 +03:00
|
|
|
KeyframeEffect& aSource,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
// Variant of Constructor that accepts a KeyframeAnimationOptions object
|
|
|
|
// for use with for Animatable.animate.
|
|
|
|
// Not exposed to content.
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
|
|
|
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
2016-10-28 10:41:08 +03:00
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
void GetTarget(Nullable<OwningElementOrCSSPseudoElement>& aRv) const;
|
|
|
|
Maybe<NonOwningAnimationTarget> GetTarget() const
|
|
|
|
{
|
|
|
|
Maybe<NonOwningAnimationTarget> result;
|
|
|
|
if (mTarget) {
|
|
|
|
result.emplace(*mTarget);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2018-05-07 04:48:48 +03:00
|
|
|
// This method calls GetTargetComputedStyle 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 ComputedStyle into this method and use
|
|
|
|
// that to update the properties rather than calling
|
|
|
|
// GetComputedStyle.
|
|
|
|
void SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget);
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
void GetKeyframes(JSContext*& aCx,
|
|
|
|
nsTArray<JSObject*>& aResult,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
void GetProperties(nsTArray<AnimationPropertyDetails>& aProperties,
|
|
|
|
ErrorResult& aRv) const;
|
|
|
|
|
2018-07-14 03:23:03 +03:00
|
|
|
IterationCompositeOperation IterationComposite() const;
|
2018-05-07 04:48:48 +03:00
|
|
|
void SetIterationComposite(
|
2018-07-14 03:23:03 +03:00
|
|
|
const IterationCompositeOperation& aIterationComposite);
|
2018-05-07 04:48:48 +03:00
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
CompositeOperation Composite() const;
|
2018-05-07 04:48:48 +03:00
|
|
|
void SetComposite(const CompositeOperation& aComposite);
|
|
|
|
|
2018-05-07 05:02:12 +03:00
|
|
|
void NotifySpecifiedTimingUpdated();
|
2016-09-04 10:34:21 +03:00
|
|
|
void NotifyAnimationTimingUpdated();
|
2017-03-14 19:33:22 +03:00
|
|
|
void RequestRestyle(EffectCompositor::RestyleType aRestyleType);
|
2016-09-04 10:34:21 +03:00
|
|
|
void SetAnimation(Animation* aAnimation) override;
|
|
|
|
void SetKeyframes(JSContext* aContext, JS::Handle<JSObject*> aKeyframes,
|
|
|
|
ErrorResult& aRv);
|
2017-02-23 03:52:44 +03:00
|
|
|
void SetKeyframes(nsTArray<Keyframe>&& aKeyframes,
|
2018-04-06 15:49:45 +03:00
|
|
|
const ComputedStyle* aStyle);
|
2016-10-13 10:54:25 +03:00
|
|
|
|
|
|
|
// Returns true if the effect includes |aProperty| regardless of whether the
|
|
|
|
// property is overridden by !important rule.
|
|
|
|
bool HasAnimationOfProperty(nsCSSPropertyID aProperty) const;
|
|
|
|
|
|
|
|
// GetEffectiveAnimationOfProperty returns AnimationProperty corresponding
|
|
|
|
// to a given CSS property if the effect includes the property and the
|
|
|
|
// property is not overridden by !important rules.
|
|
|
|
// Also EffectiveAnimationOfProperty returns true under the same condition.
|
|
|
|
//
|
|
|
|
// NOTE: We don't currently check for !important rules for properties that
|
|
|
|
// can't run on the compositor.
|
|
|
|
bool HasEffectiveAnimationOfProperty(nsCSSPropertyID aProperty) const
|
2016-09-04 10:34:21 +03:00
|
|
|
{
|
2016-10-13 10:54:25 +03:00
|
|
|
return GetEffectiveAnimationOfProperty(aProperty) != nullptr;
|
2016-09-04 10:34:21 +03:00
|
|
|
}
|
2016-10-13 10:54:25 +03:00
|
|
|
const AnimationProperty* GetEffectiveAnimationOfProperty(
|
|
|
|
nsCSSPropertyID aProperty) const;
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
const InfallibleTArray<AnimationProperty>& Properties() const
|
|
|
|
{
|
|
|
|
return mProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update |mProperties| by recalculating from |mKeyframes| using
|
2018-03-22 21:20:41 +03:00
|
|
|
// |aComputedStyle| to resolve specified values.
|
|
|
|
void UpdateProperties(const ComputedStyle* aComputedValues);
|
2016-09-04 10:34:21 +03:00
|
|
|
|
2017-03-08 23:20:17 +03:00
|
|
|
// Update various bits of state related to running ComposeStyle().
|
|
|
|
// We need to update this outside ComposeStyle() because we should avoid
|
|
|
|
// mutating any state in ComposeStyle() since it might be called during
|
|
|
|
// parallel traversal.
|
|
|
|
void WillComposeStyle();
|
|
|
|
|
2017-03-17 07:22:13 +03:00
|
|
|
// Updates |aComposeResult| with the animation values produced by this
|
2016-10-05 08:42:56 +03:00
|
|
|
// AnimationEffect for the current time except any properties contained
|
|
|
|
// in |aPropertiesToSkip|.
|
2018-04-09 14:15:59 +03:00
|
|
|
void ComposeStyle(RawServoAnimationValueMap& aComposeResult,
|
2016-10-05 08:42:56 +03:00
|
|
|
const nsCSSPropertyIDSet& aPropertiesToSkip);
|
2016-12-04 02:07:40 +03:00
|
|
|
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
// Returns true if at least one property is being animated on compositor.
|
|
|
|
bool IsRunningOnCompositor() const;
|
|
|
|
void SetIsRunningOnCompositor(nsCSSPropertyID aProperty, bool aIsRunning);
|
|
|
|
void ResetIsRunningOnCompositor();
|
|
|
|
|
|
|
|
// Returns true if this effect, applied to |aFrame|, contains properties
|
|
|
|
// that mean we shouldn't run transform compositor animations on this element.
|
|
|
|
//
|
|
|
|
// For example, if we have an animation of geometric properties like 'left'
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// When returning true, |aPerformanceWarning| stores the reason why
|
|
|
|
// we shouldn't run the transform animations.
|
|
|
|
bool ShouldBlockAsyncTransformAnimations(
|
2017-06-02 03:38:54 +03:00
|
|
|
const nsIFrame* aFrame, AnimationPerformanceWarning::Type& aPerformanceWarning) const;
|
2016-12-02 04:04:08 +03:00
|
|
|
bool HasGeometricProperties() const;
|
|
|
|
bool AffectsGeometry() const override
|
|
|
|
{
|
|
|
|
return GetTarget() && HasGeometricProperties();
|
|
|
|
}
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
nsIDocument* GetRenderedDocument() const;
|
|
|
|
nsIPresShell* GetPresShell() const;
|
|
|
|
|
|
|
|
// 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(
|
|
|
|
nsCSSPropertyID aProperty,
|
|
|
|
const AnimationPerformanceWarning& aWarning);
|
|
|
|
|
|
|
|
// Cumulative change hint on each segment for each property.
|
|
|
|
// This is used for deciding the animation is paint-only.
|
2018-04-06 15:49:45 +03:00
|
|
|
void CalculateCumulativeChangeHint(const ComputedStyle* aStyle);
|
2016-09-04 10:34:21 +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;
|
|
|
|
|
2017-02-09 05:28:47 +03:00
|
|
|
// Returns true if the effect is current state and has scale animation.
|
|
|
|
// |aFrame| is used for calculation of scale values.
|
|
|
|
bool ContainsAnimatedScale(const nsIFrame* aFrame) const;
|
|
|
|
|
2017-05-10 06:06:19 +03:00
|
|
|
AnimationValue BaseStyle(nsCSSPropertyID aProperty) const
|
2017-02-11 13:11:45 +03:00
|
|
|
{
|
2017-05-10 06:06:19 +03:00
|
|
|
AnimationValue result;
|
|
|
|
bool hasProperty = false;
|
2018-03-25 20:42:10 +03:00
|
|
|
// We cannot use getters_AddRefs on RawServoAnimationValue because it is
|
|
|
|
// an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
|
|
|
|
// then assign the raw pointer to a RefPtr.
|
|
|
|
result.mServo = mBaseStyleValuesForServo.GetWeak(aProperty, &hasProperty);
|
2017-02-11 13:11:45 +03:00
|
|
|
MOZ_ASSERT(hasProperty || result.IsNull());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-04-24 03:27:54 +03:00
|
|
|
static bool HasComputedTimingChanged(
|
|
|
|
const ComputedTiming& aComputedTiming,
|
|
|
|
IterationCompositeOperation aIterationComposite,
|
|
|
|
const Nullable<double>& aProgressOnLastCompose,
|
|
|
|
uint64_t aCurrentIterationOnLastCompose);
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
protected:
|
2018-05-07 05:08:59 +03:00
|
|
|
~KeyframeEffect() override = default;
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
static Maybe<OwningAnimationTarget>
|
|
|
|
ConvertTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget);
|
|
|
|
|
2018-07-11 04:27:01 +03:00
|
|
|
template<class OptionsType>
|
|
|
|
static already_AddRefed<KeyframeEffect>
|
2016-09-04 10:34:21 +03:00
|
|
|
ConstructKeyframeEffect(const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
|
|
|
const OptionsType& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
// Build properties by recalculating from |mKeyframes| using |aComputedStyle|
|
2016-11-07 12:01:39 +03:00
|
|
|
// to resolve specified values. This function also applies paced spacing if
|
|
|
|
// needed.
|
2018-04-09 14:15:59 +03:00
|
|
|
nsTArray<AnimationProperty> BuildProperties(const ComputedStyle* aStyle);
|
2016-11-07 12:01:39 +03:00
|
|
|
|
2016-09-04 10:34:21 +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();
|
|
|
|
|
|
|
|
// Remove the current effect target from its EffectSet.
|
|
|
|
void UnregisterTarget();
|
|
|
|
|
|
|
|
// Update the associated frame state bits so that, if necessary, a stacking
|
|
|
|
// context will be created and the effect sent to the compositor. We
|
|
|
|
// typically need to do this when the properties referenced by the keyframe
|
|
|
|
// have changed, or when the target frame might have changed.
|
|
|
|
void MaybeUpdateFrameForCompositor();
|
|
|
|
|
2018-03-23 16:49:21 +03:00
|
|
|
// Looks up the ComputedStyle associated with the target element, if any.
|
2016-09-04 10:34:21 +03:00
|
|
|
// We need to be careful to *not* call this when we are updating the style
|
2018-03-22 21:20:41 +03:00
|
|
|
// context. That's because calling GetComputedStyle when we are in the process
|
2018-03-23 16:49:21 +03:00
|
|
|
// of building a ComputedStyle may trigger various forms of infinite
|
2017-04-05 08:39:23 +03:00
|
|
|
// recursion.
|
2018-03-22 21:20:41 +03:00
|
|
|
already_AddRefed<ComputedStyle> GetTargetComputedStyle();
|
2017-01-16 11:41:24 +03:00
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
// A wrapper for marking cascade update according to the current
|
|
|
|
// target and its effectSet.
|
|
|
|
void MarkCascadeNeedsUpdate();
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
void EnsureBaseStyles(const ComputedStyle* aComputedValues,
|
2017-04-06 04:34:50 +03:00
|
|
|
const nsTArray<AnimationProperty>& aProperties);
|
2016-12-21 07:52:21 +03:00
|
|
|
|
2017-04-06 04:34:50 +03:00
|
|
|
// Stylo version of the above function that also first checks for an additive
|
|
|
|
// value in |aProperty|'s list of segments.
|
|
|
|
void EnsureBaseStyle(const AnimationProperty& aProperty,
|
|
|
|
nsPresContext* aPresContext,
|
2018-03-22 21:20:41 +03:00
|
|
|
const ComputedStyle* aComputedValues,
|
|
|
|
RefPtr<ComputedStyle>& aBaseComputedValues);
|
2017-02-11 13:11:45 +03:00
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
Maybe<OwningAnimationTarget> mTarget;
|
|
|
|
|
|
|
|
KeyframeEffectParams mEffectOptions;
|
|
|
|
|
|
|
|
// The specified keyframes.
|
|
|
|
nsTArray<Keyframe> mKeyframes;
|
|
|
|
|
|
|
|
// A set of per-property value arrays, derived from |mKeyframes|.
|
|
|
|
nsTArray<AnimationProperty> mProperties;
|
|
|
|
|
|
|
|
// 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-09-13 05:48:45 +03:00
|
|
|
// The purpose of this value is the same as mProgressOnLastCompose but
|
|
|
|
// this is used to detect when the current iteration is not changing
|
|
|
|
// in the case when iterationComposite is accumulate.
|
|
|
|
uint64_t mCurrentIterationOnLastCompose = 0;
|
|
|
|
|
2016-09-04 10:34:21 +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;
|
|
|
|
|
2017-02-11 13:11:45 +03:00
|
|
|
// The non-animated values for properties in this effect that contain at
|
|
|
|
// least one animation value that is composited with the underlying value
|
|
|
|
// (i.e. it uses the additive or accumulate composite mode).
|
2017-04-06 04:34:50 +03:00
|
|
|
nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>
|
|
|
|
mBaseStyleValuesForServo;
|
2016-12-04 02:07:40 +03:00
|
|
|
|
2017-07-05 04:29:58 +03:00
|
|
|
// True if this effect is in the EffectSet for its target element. This is
|
|
|
|
// used as an optimization to avoid unnecessary hashmap lookups on the
|
|
|
|
// EffectSet.
|
|
|
|
bool mInEffectSet = false;
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
private:
|
|
|
|
nsChangeHint mCumulativeChangeHint;
|
|
|
|
|
2017-05-01 12:45:41 +03:00
|
|
|
void ComposeStyleRule(RawServoAnimationValueMap& aAnimationValues,
|
2017-03-17 06:48:56 +03:00
|
|
|
const AnimationProperty& aProperty,
|
|
|
|
const AnimationPropertySegment& aSegment,
|
|
|
|
const ComputedTiming& aComputedTiming);
|
|
|
|
|
2017-10-12 11:12:54 +03:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
already_AddRefed<ComputedStyle> CreateComputedStyleForAnimationValue(
|
2017-10-12 11:12:54 +03:00
|
|
|
nsCSSPropertyID aProperty,
|
|
|
|
const AnimationValue& aValue,
|
2018-04-06 15:49:45 +03:00
|
|
|
nsPresContext* aPresContext,
|
2018-03-22 21:20:41 +03:00
|
|
|
const ComputedStyle* aBaseComputedStyle);
|
2017-10-12 11:12:54 +03:00
|
|
|
|
2018-05-08 23:53:47 +03:00
|
|
|
// Return the primary frame for the target (pseudo-)element.
|
|
|
|
nsIFrame* GetPrimaryFrame() const;
|
2018-05-08 23:53:46 +03:00
|
|
|
// Returns the frame which is used for styling.
|
|
|
|
nsIFrame* GetStyleFrame() const;
|
2016-09-04 10:34:21 +03:00
|
|
|
|
|
|
|
bool CanThrottle() const;
|
2018-06-25 03:12:21 +03:00
|
|
|
bool CanThrottleOverflowChanges(const nsIFrame& aFrame) const;
|
|
|
|
bool CanThrottleOverflowChangesInScrollable(nsIFrame& aFrame) const;
|
2018-06-25 05:51:05 +03:00
|
|
|
bool CanThrottleIfNotVisible(nsIFrame& aFrame) const;
|
2016-09-04 10:34:21 +03:00
|
|
|
|
2016-09-13 05:48:45 +03:00
|
|
|
// Returns true if the computedTiming has changed since the last
|
|
|
|
// composition.
|
|
|
|
bool HasComputedTimingChanged() const;
|
|
|
|
|
2016-09-04 10:34:21 +03:00
|
|
|
// Returns true unless Gecko limitations prevent performing transform
|
|
|
|
// animations for |aFrame|. When returning true, the reason for the
|
|
|
|
// limitation is stored in |aOutPerformanceWarning|.
|
|
|
|
static bool CanAnimateTransformOnCompositor(
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
AnimationPerformanceWarning::Type& aPerformanceWarning);
|
|
|
|
static bool IsGeometricProperty(const nsCSSPropertyID aProperty);
|
|
|
|
|
|
|
|
static const TimeDuration OverflowRegionRefreshInterval();
|
2016-12-21 07:52:19 +03:00
|
|
|
|
2017-06-20 09:42:26 +03:00
|
|
|
void UpdateEffectSet(mozilla::EffectSet* aEffectSet = nullptr) const;
|
2017-05-16 14:11:04 +03:00
|
|
|
|
2018-06-25 03:12:21 +03:00
|
|
|
// Returns true if this effect has properties that might affect the overflow
|
|
|
|
// region.
|
2018-02-27 08:46:32 +03:00
|
|
|
// This function is used for updating scroll bars or notifying intersection
|
|
|
|
// observers reflected by the transform.
|
2018-06-25 03:12:21 +03:00
|
|
|
bool HasPropertiesThatMightAffectOverflow() const
|
2018-02-27 08:46:32 +03:00
|
|
|
{
|
2018-06-25 05:50:56 +03:00
|
|
|
return mCumulativeChangeHint & (nsChangeHint_AddOrRemoveTransform |
|
|
|
|
nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_UpdatePostTransformOverflow |
|
2018-02-27 08:46:32 +03:00
|
|
|
nsChangeHint_UpdateTransformLayer);
|
|
|
|
}
|
2018-05-03 08:14:11 +03:00
|
|
|
|
|
|
|
// Returns true if this effect causes visibility change.
|
|
|
|
// (i.e. 'visibility: hidden' -> 'visibility: visible' and vice versa.)
|
|
|
|
bool HasVisibilityChange() const
|
|
|
|
{
|
|
|
|
return mCumulativeChangeHint & nsChangeHint_VisibilityChange;
|
|
|
|
}
|
2016-09-04 10:34:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2018-05-07 05:07:06 +03:00
|
|
|
#endif // mozilla_dom_KeyframeEffect_h
|