Bug 1244590 - Part 5: Make the default value of computed offsets be -1. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 12 May 2016 16:00:47 +0800
changeset 369280 62c4f215a5d400c338cd931648a5edf14df0ea0e
parent 369279 887010c3b05118e3effb8cd86193806f869c48e1
child 369281 55f22e782b94108fce7fd4226972f1f730cf6e19
child 369630 e89818d0897cff301f3ecba778309ebe84fafefa
push id18826
push userbmo:boris.chiou@gmail.com
push dateSat, 21 May 2016 11:25:24 +0000
bugs1244590
milestone49.0a1
Bug 1244590 - Part 5: Make the default value of computed offsets be -1. When we apply paced spacing, we have to check if there are still null computed offsets after applying paced spacing to paceable Keyframes because the calculation of distance may be failed or some Keyframes are not paceable in the specific range. Therefore, using -1 would be easier to check it. MozReview-Commit-ID: GPhj7cdiX2W
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
dom/animation/KeyframeUtils.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1023,17 +1023,19 @@ KeyframeEffectReadOnly::GetKeyframes(JSC
   }
 
   for (const Keyframe& keyframe : mKeyframes) {
     // Set up a dictionary object for the explicit members
     BaseComputedKeyframe keyframeDict;
     if (keyframe.mOffset) {
       keyframeDict.mOffset.SetValue(keyframe.mOffset.value());
     }
-    keyframeDict.mComputedOffset.Construct(keyframe.mComputedOffset);
+    MOZ_ASSERT(keyframe.mComputedOffset != -1.0, "Invalid computed offset");
+    keyframeDict.mComputedOffset.Construct(
+      keyframe.mComputedOffset == -1.0 ? 0.0 : keyframe.mComputedOffset);
     if (keyframe.mTimingFunction) {
       keyframeDict.mEasing.Truncate();
       keyframe.mTimingFunction.ref().AppendToString(keyframeDict.mEasing);
     } // else if null, leave easing as its default "linear".
 
     JS::Rooted<JS::Value> keyframeJSValue(aCx);
     if (!ToJSValue(aCx, keyframeDict, &keyframeJSValue)) {
       aRv.Throw(NS_ERROR_FAILURE);
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -102,17 +102,17 @@ struct Keyframe
     mOffset         = aOther.mOffset;
     mComputedOffset = aOther.mComputedOffset;
     mTimingFunction = Move(aOther.mTimingFunction);
     mPropertyValues = Move(aOther.mPropertyValues);
     return *this;
   }
 
   Maybe<double>                 mOffset;
-  double                        mComputedOffset = 0.0;
+  double                        mComputedOffset = -1.0;
   Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
                                                  // "linear"
   nsTArray<PropertyValuePair>   mPropertyValues;
 };
 
 struct AnimationPropertySegment
 {
   float mFromKey, mToKey;
--- a/dom/animation/KeyframeUtils.cpp
+++ b/dom/animation/KeyframeUtils.cpp
@@ -539,16 +539,17 @@ KeyframeUtils::GetAnimationPropertiesFro
       for (auto& value : values) {
         // If we already got a value for this property on the keyframe,
         // skip this one.
         if (propertiesOnThisKeyframe.HasProperty(value.mProperty)) {
           continue;
         }
 
         KeyframeValueEntry* entry = entries.AppendElement();
+        MOZ_ASSERT(frame.mComputedOffset != -1.0, "Invalid computed offset");
         entry->mOffset = frame.mComputedOffset;
         entry->mProperty = value.mProperty;
         entry->mValue = value.mValue;
         entry->mTimingFunction = frame.mTimingFunction;
 
         propertiesOnThisKeyframe.AddProperty(value.mProperty);
       }
     }