Line data Source code
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_AnimationPropertySegment_h
8 : #define mozilla_dom_AnimationPropertySegment_h
9 :
10 : #include "mozilla/ComputedTimingFunction.h"
11 : #include "mozilla/Maybe.h"
12 : #include "mozilla/StyleAnimationValue.h" // For AnimationValue
13 : #include "mozilla/dom/BaseKeyframeTypesBinding.h" // For CompositeOperation
14 :
15 : namespace mozilla {
16 :
17 14 : struct AnimationPropertySegment
18 : {
19 : float mFromKey, mToKey;
20 : // NOTE: In the case that no keyframe for 0 or 1 offset is specified
21 : // the unit of mFromValue or mToValue is eUnit_Null.
22 : AnimationValue mFromValue, mToValue;
23 :
24 : Maybe<ComputedTimingFunction> mTimingFunction;
25 : dom::CompositeOperation mFromComposite = dom::CompositeOperation::Replace;
26 : dom::CompositeOperation mToComposite = dom::CompositeOperation::Replace;
27 :
28 10 : bool HasReplaceableValues() const
29 : {
30 10 : return HasReplaceableFromValue() && HasReplaceableToValue();
31 : }
32 :
33 10 : bool HasReplaceableFromValue() const
34 : {
35 20 : return !mFromValue.IsNull() &&
36 20 : mFromComposite == dom::CompositeOperation::Replace;
37 : }
38 :
39 10 : bool HasReplaceableToValue() const
40 : {
41 20 : return !mToValue.IsNull() &&
42 20 : mToComposite == dom::CompositeOperation::Replace;
43 : }
44 :
45 6 : bool operator==(const AnimationPropertySegment& aOther) const
46 : {
47 12 : return mFromKey == aOther.mFromKey &&
48 12 : mToKey == aOther.mToKey &&
49 12 : mFromValue == aOther.mFromValue &&
50 12 : mToValue == aOther.mToValue &&
51 12 : mTimingFunction == aOther.mTimingFunction &&
52 18 : mFromComposite == aOther.mFromComposite &&
53 12 : mToComposite == aOther.mToComposite;
54 : }
55 : bool operator!=(const AnimationPropertySegment& aOther) const
56 : {
57 : return !(*this == aOther);
58 : }
59 : };
60 :
61 : }
62 :
63 : #endif // mozilla_dom_AnimationPropertySegment_h
|