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 struct AnimationPropertySegment { 18 float mFromKey, mToKey; 19 // NOTE: In the case that no keyframe for 0 or 1 offset is specified 20 // the unit of mFromValue or mToValue is eUnit_Null. 21 AnimationValue mFromValue, mToValue; 22 23 Maybe<ComputedTimingFunction> mTimingFunction; 24 dom::CompositeOperation mFromComposite = dom::CompositeOperation::Replace; 25 dom::CompositeOperation mToComposite = dom::CompositeOperation::Replace; 26 HasReplaceableValuesAnimationPropertySegment27 bool HasReplaceableValues() const { 28 return HasReplaceableFromValue() && HasReplaceableToValue(); 29 } 30 HasReplaceableFromValueAnimationPropertySegment31 bool HasReplaceableFromValue() const { 32 return !mFromValue.IsNull() && 33 mFromComposite == dom::CompositeOperation::Replace; 34 } 35 HasReplaceableToValueAnimationPropertySegment36 bool HasReplaceableToValue() const { 37 return !mToValue.IsNull() && 38 mToComposite == dom::CompositeOperation::Replace; 39 } 40 41 bool operator==(const AnimationPropertySegment& aOther) const { 42 return mFromKey == aOther.mFromKey && mToKey == aOther.mToKey && 43 mFromValue == aOther.mFromValue && mToValue == aOther.mToValue && 44 mTimingFunction == aOther.mTimingFunction && 45 mFromComposite == aOther.mFromComposite && 46 mToComposite == aOther.mToComposite; 47 } 48 bool operator!=(const AnimationPropertySegment& aOther) const { 49 return !(*this == aOther); 50 } 51 }; 52 53 } // namespace mozilla 54 55 #endif // mozilla_dom_AnimationPropertySegment_h 56