Bug 1311257 - Move AnimationPropertySegment in a separate header and expose it in FFI. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 06 Apr 2017 10:34:50 +0900
changeset 556564 30c53ded768d58d4f6931154d324857eb95c3d1d
parent 556563 efbcad9a8e91665f7ad54c814c44d909dbe4a38c
child 556565 3868ec2d1d3afc2e9d87c8b95da8ec3c05692b19
push id52584
push userhikezoe@mozilla.com
push dateThu, 06 Apr 2017 03:01:12 +0000
reviewersheycam
bugs1311257
milestone55.0a1
Bug 1311257 - Move AnimationPropertySegment in a separate header and expose it in FFI. r?heycam This will be used for animation value composition in Rust. MozReview-Commit-ID: Lg4dZrQW1WC
dom/animation/AnimationPropertySegment.h
dom/animation/KeyframeEffectReadOnly.h
dom/animation/moz.build
new file mode 100644
--- /dev/null
+++ b/dom/animation/AnimationPropertySegment.h
@@ -0,0 +1,63 @@
+/* -*- 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/. */
+
+#ifndef mozilla_dom_AnimationPropertySegment_h
+#define mozilla_dom_AnimationPropertySegment_h
+
+#include "mozilla/ComputedTimingFunction.h"
+#include "mozilla/Maybe.h"
+#include "mozilla/StyleAnimationValue.h" // For AnimationValue
+#include "mozilla/dom/BaseKeyframeTypesBinding.h" // For CompositeOperation
+
+namespace mozilla {
+
+struct AnimationPropertySegment
+{
+  float mFromKey, mToKey;
+  // NOTE: In the case that no keyframe for 0 or 1 offset is specified
+  // the unit of mFromValue or mToValue is eUnit_Null.
+  AnimationValue mFromValue, mToValue;
+
+  Maybe<ComputedTimingFunction> mTimingFunction;
+  dom::CompositeOperation mFromComposite = dom::CompositeOperation::Replace;
+  dom::CompositeOperation mToComposite = dom::CompositeOperation::Replace;
+
+  bool HasReplaceableValues() const
+  {
+    return HasReplaceableFromValue() && HasReplaceableToValue();
+  }
+
+  bool HasReplaceableFromValue() const
+  {
+    return !mFromValue.IsNull() &&
+           mFromComposite == dom::CompositeOperation::Replace;
+  }
+
+  bool HasReplaceableToValue() const
+  {
+    return !mToValue.IsNull() &&
+           mToComposite == dom::CompositeOperation::Replace;
+  }
+
+  bool operator==(const AnimationPropertySegment& aOther) const
+  {
+    return mFromKey == aOther.mFromKey &&
+           mToKey == aOther.mToKey &&
+           mFromValue == aOther.mFromValue &&
+           mToValue == aOther.mToValue &&
+           mTimingFunction == aOther.mTimingFunction &&
+           mFromComposite == aOther.mFromComposite &&
+           mToComposite == aOther.mToComposite;
+  }
+  bool operator!=(const AnimationPropertySegment& aOther) const
+  {
+    return !(*this == aOther);
+  }
+};
+
+}
+
+#endif // mozilla_dom_AnimationPropertySegment_h
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -11,16 +11,17 @@
 #include "nsCSSPropertyID.h"
 #include "nsCSSPropertyIDSet.h"
 #include "nsCSSValue.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTArray.h"
 #include "nsWrapperCache.h"
 #include "mozilla/AnimationPerformanceWarning.h"
+#include "mozilla/AnimationPropertySegment.h"
 #include "mozilla/AnimationTarget.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ComputedTimingFunction.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/Keyframe.h"
 #include "mozilla/KeyframeEffectParams.h"
 // RawServoDeclarationBlock and associated RefPtrTraits
 #include "mozilla/ServoBindingTypes.h"
@@ -50,60 +51,16 @@ class GlobalObject;
 class OwningElementOrCSSPseudoElement;
 class UnrestrictedDoubleOrKeyframeAnimationOptions;
 class UnrestrictedDoubleOrKeyframeEffectOptions;
 enum class IterationCompositeOperation : uint8_t;
 enum class CompositeOperation : uint8_t;
 struct AnimationPropertyDetails;
 }
 
-struct AnimationPropertySegment
-{
-  float mFromKey, mToKey;
-  // NOTE: In the case that no keyframe for 0 or 1 offset is specified
-  // the unit of mFromValue or mToValue is eUnit_Null.
-  AnimationValue mFromValue, mToValue;
-
-  Maybe<ComputedTimingFunction> mTimingFunction;
-  dom::CompositeOperation mFromComposite = dom::CompositeOperation::Replace;
-  dom::CompositeOperation mToComposite = dom::CompositeOperation::Replace;
-
-  bool HasReplaceableValues() const
-  {
-    return HasReplaceableFromValue() && HasReplaceableToValue();
-  }
-
-  bool HasReplaceableFromValue() const
-  {
-    return !mFromValue.IsNull() &&
-           mFromComposite == dom::CompositeOperation::Replace;
-  }
-
-  bool HasReplaceableToValue() const
-  {
-    return !mToValue.IsNull() &&
-           mToComposite == dom::CompositeOperation::Replace;
-  }
-
-  bool operator==(const AnimationPropertySegment& aOther) const
-  {
-    return mFromKey == aOther.mFromKey &&
-           mToKey == aOther.mToKey &&
-           mFromValue == aOther.mFromValue &&
-           mToValue == aOther.mToValue &&
-           mTimingFunction == aOther.mTimingFunction &&
-           mFromComposite == aOther.mFromComposite &&
-           mToComposite == aOther.mToComposite;
-  }
-  bool operator!=(const AnimationPropertySegment& aOther) const
-  {
-    return !(*this == aOther);
-  }
-};
-
 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
--- a/dom/animation/moz.build
+++ b/dom/animation/moz.build
@@ -20,16 +20,17 @@ EXPORTS.mozilla.dom += [
     'DocumentTimeline.h',
     'KeyframeEffect.h',
     'KeyframeEffectReadOnly.h',
 ]
 
 EXPORTS.mozilla += [
     'AnimationComparator.h',
     'AnimationPerformanceWarning.h',
+    'AnimationPropertySegment.h',
     'AnimationTarget.h',
     'AnimationUtils.h',
     'AnimValuesStyleRule.h',
     'ComputedTiming.h',
     'ComputedTimingFunction.h',
     'EffectCompositor.h',
     'EffectSet.h',
     'Keyframe.h',