1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_Keyframe_h
8 #define mozilla_dom_Keyframe_h
10 #include "nsCSSValue.h"
12 #include "mozilla/dom/BaseKeyframeTypesBinding.h" // CompositeOperationOrAuto
13 #include "mozilla/AnimatedPropertyID.h"
14 #include "mozilla/ServoStyleConsts.h"
15 #include "mozilla/Maybe.h"
16 #include "mozilla/RefPtr.h"
19 struct StyleLockedDeclarationBlock
;
22 * A property-value pair specified on a keyframe.
24 struct PropertyValuePair
{
25 explicit PropertyValuePair(const AnimatedPropertyID
& aProperty
)
26 : mProperty(aProperty
) {}
28 PropertyValuePair(const AnimatedPropertyID
& aProperty
,
29 RefPtr
<StyleLockedDeclarationBlock
>&& aValue
)
30 : mProperty(aProperty
), mServoDeclarationBlock(std::move(aValue
)) {
31 MOZ_ASSERT(mServoDeclarationBlock
, "Should be valid property value");
34 AnimatedPropertyID mProperty
;
36 // The specified value when using the Servo backend.
37 RefPtr
<StyleLockedDeclarationBlock
> mServoDeclarationBlock
;
40 // Flag to indicate that when we call StyleAnimationValue::ComputeValues on
41 // this value we should behave as if that function had failed.
42 bool mSimulateComputeValuesFailure
= false;
45 bool operator==(const PropertyValuePair
&) const;
51 * This is the canonical form in which keyframe effects are stored and
52 * corresponds closely to the type of objects returned via the getKeyframes()
55 * Before computing an output animation value, however, we flatten these frames
56 * down to a series of per-property value arrays where we also resolve any
57 * overlapping shorthands/longhands, convert specified CSS values to computed
60 * When the target element or computed style changes, however, we rebuild these
61 * per-property arrays from the original list of keyframes objects. As a result,
62 * these objects represent the master definition of the effect's values.
66 Keyframe(const Keyframe
& aOther
) = default;
67 Keyframe(Keyframe
&& aOther
) = default;
69 Keyframe
& operator=(const Keyframe
& aOther
) = default;
70 Keyframe
& operator=(Keyframe
&& aOther
) = default;
72 Maybe
<double> mOffset
;
73 static constexpr double kComputedOffsetNotSet
= -1.0;
74 double mComputedOffset
= kComputedOffsetNotSet
;
75 Maybe
<StyleComputedTimingFunction
> mTimingFunction
; // Nothing() here means
77 dom::CompositeOperationOrAuto mComposite
=
78 dom::CompositeOperationOrAuto::Auto
;
79 CopyableTArray
<PropertyValuePair
> mPropertyValues
;
82 } // namespace mozilla
84 #endif // mozilla_dom_Keyframe_h