Bug 1334036 - Part 9: Handle unsupported interpolation properly for OMTA. draft
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 20 Feb 2017 14:58:39 +0800
changeset 486982 0016ffab4e24d4fa59b65dd5e989b2818a67aafa
parent 486981 e5c057002cca946db349e4e8d430bbb11f57d294
child 486983 f5313ca9440c79967041ab457b2863f3587375ba
push id46109
push userbmo:boris.chiou@gmail.com
push dateMon, 20 Feb 2017 11:01:51 +0000
bugs1334036
milestone54.0a1
Bug 1334036 - Part 9: Handle unsupported interpolation properly for OMTA. MozReview-Commit-ID: Gg3siwB2Alr
gfx/layers/AnimationHelper.cpp
layout/style/StyleAnimationValue.cpp
--- a/gfx/layers/AnimationHelper.cpp
+++ b/gfx/layers/AnimationHelper.cpp
@@ -62,24 +62,26 @@ SampleValue(float aPortion, const layers
       StyleAnimationValue::Accumulate(aAnimation.property(),
                                       aLastValue.IsNull()
                                         ? aUnderlyingValue
                                         : aLastValue,
                                       Move(endValue),
                                       aCurrentIteration);
   }
 
+  // FIXME: Bug 1340961: stylo, it is possible to pass a null startValue or
+  // endValue into the interpolate function because we don't handle missing 0.0
+  // or 1.0 keyframe properly and don't support additive animation now.
   StyleAnimationValue interpolatedValue;
-  // This should never fail because we only pass transform and opacity values
-  // to the compositor and they should never fail to interpolate.
-  DebugOnly<bool> uncomputeResult =
-    StyleAnimationValue::Interpolate(aAnimation.property(),
-                                     startValue, endValue,
-                                     aPortion, interpolatedValue);
-  MOZ_ASSERT(uncomputeResult, "could not uncompute value");
+  if (!StyleAnimationValue::Interpolate(aAnimation.property(),
+                                        startValue, endValue,
+                                        aPortion, interpolatedValue)) {
+    NS_ERROR("Interpolation failed in SampleValue");
+    return !startValue.IsNull() ? startValue : endValue;
+  }
   return interpolatedValue;
 }
 
 bool
 AnimationHelper::SampleAnimationForEachNode(TimeStamp aPoint,
                            AnimationArray& aAnimations,
                            InfallibleTArray<AnimData>& aAnimationData,
                            StyleAnimationValue& aAnimationValue,
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -2857,16 +2857,22 @@ AddWeightedFilterList(double aCoeff1, co
 bool
 StyleAnimationValue::AddWeighted(nsCSSPropertyID aProperty,
                                  double aCoeff1,
                                  const StyleAnimationValue& aValue1,
                                  double aCoeff2,
                                  const StyleAnimationValue& aValue2,
                                  StyleAnimationValue& aResultValue)
 {
+  // Shouldn't pass null values into this function.
+  if (aValue1.IsNull() || aValue2.IsNull()) {
+    NS_ERROR("Shouldn't pass uninitialized StyleAnimationValue to AddWeighted");
+    return false;
+  }
+
   Unit commonUnit =
     GetCommonUnit(aProperty, aValue1.GetUnit(), aValue2.GetUnit());
   // Maybe need a followup method to convert the inputs into the common
   // unit-type, if they don't already match it. (Or would it make sense to do
   // that in GetCommonUnit? in which case maybe ConvertToCommonUnit would be
   // better.)
 
   switch (commonUnit) {