/work/obj-fuzz/dist/include/mozilla/Keyframe.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_Keyframe_h |
8 | | #define mozilla_dom_Keyframe_h |
9 | | |
10 | | #include "nsCSSPropertyID.h" |
11 | | #include "nsCSSValue.h" |
12 | | #include "nsTArray.h" |
13 | | #include "mozilla/dom/BaseKeyframeTypesBinding.h" // CompositeOperationOrAuto |
14 | | #include "mozilla/ComputedTimingFunction.h" |
15 | | #include "mozilla/Maybe.h" |
16 | | #include "mozilla/RefPtr.h" |
17 | | |
18 | | struct RawServoDeclarationBlock; |
19 | | namespace mozilla { |
20 | | |
21 | | /** |
22 | | * A property-value pair specified on a keyframe. |
23 | | */ |
24 | | struct PropertyValuePair |
25 | | { |
26 | | explicit PropertyValuePair(nsCSSPropertyID aProperty) |
27 | 0 | : mProperty(aProperty) { } |
28 | | PropertyValuePair(nsCSSPropertyID aProperty, |
29 | | RefPtr<RawServoDeclarationBlock>&& aValue) |
30 | | : mProperty(aProperty), mServoDeclarationBlock(std::move(aValue)) |
31 | 0 | { |
32 | 0 | MOZ_ASSERT(mServoDeclarationBlock, "Should be valid property value"); |
33 | 0 | } |
34 | | |
35 | | nsCSSPropertyID mProperty; |
36 | | |
37 | | // The specified value when using the Servo backend. |
38 | | RefPtr<RawServoDeclarationBlock> mServoDeclarationBlock; |
39 | | |
40 | | #ifdef DEBUG |
41 | | // Flag to indicate that when we call StyleAnimationValue::ComputeValues on |
42 | | // this value we should behave as if that function had failed. |
43 | | bool mSimulateComputeValuesFailure = false; |
44 | | #endif |
45 | | |
46 | | bool operator==(const PropertyValuePair&) const; |
47 | | }; |
48 | | |
49 | | /** |
50 | | * A single keyframe. |
51 | | * |
52 | | * This is the canonical form in which keyframe effects are stored and |
53 | | * corresponds closely to the type of objects returned via the getKeyframes() |
54 | | * API. |
55 | | * |
56 | | * Before computing an output animation value, however, we flatten these frames |
57 | | * down to a series of per-property value arrays where we also resolve any |
58 | | * overlapping shorthands/longhands, convert specified CSS values to computed |
59 | | * values, etc. |
60 | | * |
61 | | * When the target element or computed style changes, however, we rebuild these |
62 | | * per-property arrays from the original list of keyframes objects. As a result, |
63 | | * these objects represent the master definition of the effect's values. |
64 | | */ |
65 | | struct Keyframe |
66 | | { |
67 | 0 | Keyframe() = default; |
68 | 0 | Keyframe(const Keyframe& aOther) = default; |
69 | | Keyframe(Keyframe&& aOther) |
70 | 0 | { |
71 | 0 | *this = std::move(aOther); |
72 | 0 | } |
73 | | |
74 | | Keyframe& operator=(const Keyframe& aOther) = default; |
75 | | Keyframe& operator=(Keyframe&& aOther) |
76 | 0 | { |
77 | 0 | mOffset = aOther.mOffset; |
78 | 0 | mComputedOffset = aOther.mComputedOffset; |
79 | 0 | mTimingFunction = std::move(aOther.mTimingFunction); |
80 | 0 | mComposite = std::move(aOther.mComposite); |
81 | 0 | mPropertyValues = std::move(aOther.mPropertyValues); |
82 | 0 | return *this; |
83 | 0 | } |
84 | | |
85 | | Maybe<double> mOffset; |
86 | | static constexpr double kComputedOffsetNotSet = -1.0; |
87 | | double mComputedOffset = kComputedOffsetNotSet; |
88 | | Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means |
89 | | // "linear" |
90 | | dom::CompositeOperationOrAuto mComposite = |
91 | | dom::CompositeOperationOrAuto::Auto; |
92 | | nsTArray<PropertyValuePair> mPropertyValues; |
93 | | }; |
94 | | |
95 | | } |
96 | | |
97 | | #endif // mozilla_dom_Keyframe_h |