Bug 1254419 - Make always-set members of AnimationProperty(Value)Details required draft
authorBrian Birtles <birtles@gmail.com>
Thu, 17 Mar 2016 10:13:50 +0800
changeset 341465 19a3926794a025bbe15c6754bd513d4f08fb7516
parent 341464 c30d955d7c204149af6dc0985cd7b04c41ae00b4
child 341489 3e519dd3d7426a318c390e3a843fe9c0d11c0ff2
push id13215
push userbbirtles@mozilla.com
push dateThu, 17 Mar 2016 02:17:54 +0000
bugs1254419
milestone48.0a1
Bug 1254419 - Make always-set members of AnimationProperty(Value)Details required At the same time we also make the 'warning' member of AnimationPropertyDetails no longer nullable and simply use the absence of the member to indicate "no warning" (which is what we were already doing -- we were never actually setting it to null). MozReview-Commit-ID: HdRDbqhCdmw
dom/animation/KeyframeEffect.cpp
dom/webidl/KeyframeEffect.webidl
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1801,51 +1801,49 @@ KeyframeEffectReadOnly::GetTarget(
 
 static void
 CreatePropertyValue(nsCSSProperty aProperty,
                     float aOffset,
                     const Maybe<ComputedTimingFunction>& aTimingFunction,
                     const StyleAnimationValue& aValue,
                     AnimationPropertyValueDetails& aResult)
 {
-  aResult.mOffset.Construct(aOffset);
+  aResult.mOffset = aOffset;
 
   nsString stringValue;
   StyleAnimationValue::UncomputeValue(aProperty, aValue, stringValue);
-  aResult.mValue.Construct(stringValue);
+  aResult.mValue = stringValue;
 
   if (aTimingFunction) {
     aResult.mEasing.Construct();
     aTimingFunction->AppendToString(aResult.mEasing.Value());
   } else {
     aResult.mEasing.Construct(NS_LITERAL_STRING("linear"));
   }
 
-  aResult.mComposite.Construct(CompositeOperation::Replace);
+  aResult.mComposite = CompositeOperation::Replace;
 }
 
 void
 KeyframeEffectReadOnly::GetProperties(
     nsTArray<AnimationPropertyDetails>& aProperties) const
 {
   for (const AnimationProperty& property : mProperties) {
     AnimationPropertyDetails propertyDetails;
-    propertyDetails.mProperty.Construct(
-      NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(property.mProperty)));
-    propertyDetails.mRunningOnCompositor.Construct(
-      property.mIsRunningOnCompositor);
+    propertyDetails.mProperty =
+      NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(property.mProperty));
+    propertyDetails.mRunningOnCompositor = property.mIsRunningOnCompositor;
 
     nsXPIDLString localizedString;
     if (property.mPerformanceWarning &&
         property.mPerformanceWarning->ToLocalizedString(localizedString)) {
       propertyDetails.mWarning.Construct(localizedString);
     }
 
-    propertyDetails.mValues.Construct();
-    if (!propertyDetails.mValues.Value().SetCapacity(
+    if (!propertyDetails.mValues.SetCapacity(
           property.mSegments.Length(), mozilla::fallible)) {
       MOZ_CRASH("Out of memory allocating values array");
     }
 
     for (size_t segmentIdx = 0, segmentLen = property.mSegments.Length();
          segmentIdx < segmentLen;
          segmentIdx++)
     {
@@ -1857,35 +1855,33 @@ KeyframeEffectReadOnly::GetProperties(
                           fromValue);
       // We don't apply timing functions for zero-length segments, so
       // don't return one here.
       if (segment.mFromKey == segment.mToKey) {
         fromValue.mEasing.Reset();
       }
       // The following won't fail since we have already allocated the capacity
       // above.
-      propertyDetails.mValues.Value().AppendElement(fromValue,
-                                                    mozilla::fallible);
+      propertyDetails.mValues.AppendElement(fromValue, mozilla::fallible);
 
       // Normally we can ignore the to-value for this segment since it is
       // identical to the from-value from the next segment. However, we need
       // to add it if either:
       // a) this is the last segment, or
       // b) the next segment's from-value differs.
       if (segmentIdx == segmentLen - 1 ||
           property.mSegments[segmentIdx + 1].mFromValue != segment.mToValue) {
         binding_detail::FastAnimationPropertyValueDetails toValue;
         CreatePropertyValue(property.mProperty, segment.mToKey,
                             Nothing(), segment.mToValue, toValue);
         // It doesn't really make sense to have a timing function on the
         // last property value or before a sudden jump so we just drop the
         // easing property altogether.
         toValue.mEasing.Reset();
-        propertyDetails.mValues.Value().AppendElement(toValue,
-                                                      mozilla::fallible);
+        propertyDetails.mValues.AppendElement(toValue, mozilla::fallible);
       }
     }
 
     aProperties.AppendElement(propertyDetails);
   }
 }
 
 void
--- a/dom/webidl/KeyframeEffect.webidl
+++ b/dom/webidl/KeyframeEffect.webidl
@@ -42,27 +42,27 @@ interface KeyframeEffectReadOnly : Anima
 
   // We use object instead of ComputedKeyframe so that we can put the
   // property-value pairs on the object.
   [Throws] sequence<object> getFrames();
 };
 
 // Non-standard extensions
 dictionary AnimationPropertyValueDetails {
-  double             offset;
-  DOMString          value;
-  DOMString          easing;
-  CompositeOperation composite;
+  required double             offset;
+  required DOMString          value;
+           DOMString          easing;
+  required CompositeOperation composite;
 };
 
 dictionary AnimationPropertyDetails {
-  DOMString                               property;
-  boolean                                 runningOnCompositor;
-  DOMString?                              warning;
-  sequence<AnimationPropertyValueDetails> values;
+  required DOMString                               property;
+  required boolean                                 runningOnCompositor;
+           DOMString                               warning;
+  required sequence<AnimationPropertyValueDetails> values;
 };
 
 partial interface KeyframeEffectReadOnly {
   [ChromeOnly] sequence<AnimationPropertyDetails> getProperties();
 };
 
 [Func="nsDocument::IsWebAnimationsEnabled",
  Constructor ((Element or CSSPseudoElement)? target,