Bug 1244590 - Part 2: Retrieve KeyframeEffectOptions from constructor. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 05 May 2016 18:50:16 +0800
changeset 371281 133a4f0d803d43c3e80b552b82366b4bce282d8c
parent 371280 218b1ae6384cafdd6f8e497541cae6189683c24f
child 371282 33fc5677b9b824d7689f56e058cecd5f32827774
child 371471 d71295ab92093176e5888ce92d270bbf9211a86a
child 371500 276c3faf2b610a70a2b0093dbcf88de2c8585d60
child 371919 84b17fb0897425fb837fc8ea19851c76fc310813
child 371930 8c0f83938caa0bb082900ede5cd83c51ca8ff0d2
child 372061 a213e5168d20397efb556f49e9c1a5e8015b27ca
push id19290
push userbmo:boris.chiou@gmail.com
push dateThu, 26 May 2016 09:18:45 +0000
bugs1244590
milestone49.0a1
Bug 1244590 - Part 2: Retrieve KeyframeEffectOptions from constructor. MozReview-Commit-ID: DtkJ6eLj4tl
dom/animation/KeyframeEffect.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -701,16 +701,48 @@ KeyframeEffectReadOnly::ResetIsRunningOn
     property.mIsRunningOnCompositor = false;
   }
 }
 
 KeyframeEffectReadOnly::~KeyframeEffectReadOnly()
 {
 }
 
+static const KeyframeEffectOptions&
+KeyframeEffectOptionsFromUnion(
+  const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions)
+{
+  MOZ_ASSERT(aOptions.IsKeyframeEffectOptions());
+  return aOptions.GetAsKeyframeEffectOptions();
+}
+
+static const KeyframeEffectOptions&
+KeyframeEffectOptionsFromUnion(
+  const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions)
+{
+  MOZ_ASSERT(aOptions.IsKeyframeAnimationOptions());
+  return aOptions.GetAsKeyframeAnimationOptions();
+}
+
+template <class OptionsType>
+static KeyframeEffectParams
+KeyframeEffectParamsFromUnion(const OptionsType& aOptions,
+                              ErrorResult& aRv)
+{
+  KeyframeEffectParams result;
+  if (!aOptions.IsUnrestrictedDouble()) {
+    const KeyframeEffectOptions& options =
+      KeyframeEffectOptionsFromUnion(aOptions);
+    // TODO: If the grammar of spacing is not correct, we should throw a
+    //       TypeError, aRv.Throw(NS_ERROR_TYPE_ERR). Parse spacing string and
+    //       handle TypeError in the next patch.
+  }
+  return result;
+}
+
 static Maybe<OwningAnimationTarget>
 ConvertTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget)
 {
   // Return value optimization.
   Maybe<OwningAnimationTarget> result;
 
   if (aTarget.IsNull()) {
     return result;
@@ -745,19 +777,19 @@ KeyframeEffectReadOnly::ConstructKeyfram
   }
 
   TimingParams timingParams =
     TimingParams::FromOptionsUnion(aOptions, doc, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
+  KeyframeEffectParams effectOptions =
+    KeyframeEffectParamsFromUnion(aOptions, aRv);
   Maybe<OwningAnimationTarget> target = ConvertTarget(aTarget);
-  // TODO: Use options data from input in the next patch.
-  KeyframeEffectParams effectOptions;
   RefPtr<KeyframeEffectType> effect =
     new KeyframeEffectType(doc, target, timingParams, effectOptions);
 
   effect->SetKeyframes(aGlobal.Context(), aKeyframes, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }