Bug 1263486 part 3 - Use nsCSSValue move constructor in CSSAnimationBuilder::GetComputedValue draft
authorBrian Birtles <birtles@gmail.com>
Fri, 20 May 2016 09:09:37 +0900
changeset 368986 54d9e1570f668ecb7004f3ba9d103f51f8f0f0ab
parent 368985 a6742b5a8537abff793cd87e37d741572abc880f
child 521417 e9f47a7ae2bdaf7928bfc2b423571e05b82ff11f
push id18687
push userbbirtles@mozilla.com
push dateFri, 20 May 2016 00:11:47 +0000
bugs1263486
milestone49.0a1
Bug 1263486 part 3 - Use nsCSSValue move constructor in CSSAnimationBuilder::GetComputedValue MozReview-Commit-ID: H79OAEkdq4L
layout/style/nsAnimationManager.cpp
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -558,27 +558,26 @@ private:
     nsCSSPropertySet aAnimatedProperties,
     nsCSSPropertySet aPropertiesSetAtStart,
     nsCSSPropertySet aPropertiesSetAtEnd,
     const Maybe<ComputedTimingFunction>& aInheritedTimingFunction,
     nsTArray<Keyframe>& aKeyframes);
   void AppendProperty(nsPresContext* aPresContext,
                       nsCSSProperty aProperty,
                       nsTArray<PropertyValuePair>& aPropertyValues);
-  void GetComputedValue(nsPresContext* aPresContext,
-                        nsCSSProperty aProperty,
-                        nsCSSValue& aResult);
+  nsCSSValue GetComputedValue(nsPresContext* aPresContext,
+                              nsCSSProperty aProperty);
 
   static TimingParams TimingParamsFrom(
     const StyleAnimation& aStyleAnimation)
   {
     TimingParams timing;
 
     timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(
-			       aStyleAnimation.GetDuration()));
+                               aStyleAnimation.GetDuration()));
     timing.mDelay = TimeDuration::FromMilliseconds(aStyleAnimation.GetDelay());
     timing.mIterations = aStyleAnimation.GetIterationCount();
     MOZ_ASSERT(timing.mIterations >= 0.0 && !IsNaN(timing.mIterations),
                "mIterations should be nonnegative & finite, as ensured by "
                "CSSParser");
     timing.mDirection = aStyleAnimation.GetDirection();
     timing.mFill = aStyleAnimation.GetFillMode();
 
@@ -1018,52 +1017,49 @@ CSSAnimationBuilder::FillInMissingKeyfra
 void
 CSSAnimationBuilder::AppendProperty(
     nsPresContext* aPresContext,
     nsCSSProperty aProperty,
     nsTArray<PropertyValuePair>& aPropertyValues)
 {
   PropertyValuePair propertyValue;
   propertyValue.mProperty = aProperty;
-  GetComputedValue(aPresContext, aProperty, propertyValue.mValue);
+  propertyValue.mValue = GetComputedValue(aPresContext, aProperty);
 
   aPropertyValues.AppendElement(Move(propertyValue));
 }
 
-void
+nsCSSValue
 CSSAnimationBuilder::GetComputedValue(nsPresContext* aPresContext,
-                                      nsCSSProperty aProperty,
-                                      nsCSSValue& aResult)
+                                      nsCSSProperty aProperty)
 {
+  nsCSSValue result;
   StyleAnimationValue computedValue;
 
   if (!mStyleWithoutAnimation) {
     MOZ_ASSERT(aPresContext->StyleSet()->IsGecko(),
                "ServoStyleSet should not use nsAnimationManager for "
                "animations");
     mStyleWithoutAnimation = aPresContext->StyleSet()->AsGecko()->
       ResolveStyleWithoutAnimation(mTarget, mStyleContext,
                                    eRestyle_AllHintsWithAnimations);
   }
 
   if (StyleAnimationValue::ExtractComputedValue(aProperty,
                                                 mStyleWithoutAnimation,
-                                                computedValue) &&
-      StyleAnimationValue::UncomputeValue(
-        aProperty, Move(computedValue), aResult)) {
-    // If we hit this assertion or the MOZ_ASSERT_UNREACHABLE below, it
-    // probably means we are fetching a value from the computed style that
-    // we don't know how to represent as a StyleAnimationValue.
-    MOZ_ASSERT(aResult.GetUnit() != eCSSUnit_Null,
-               "Got null computed value");
-    return;
+                                                computedValue)) {
+    StyleAnimationValue::UncomputeValue(aProperty, Move(computedValue), result);
   }
 
-  MOZ_ASSERT_UNREACHABLE("Failed to get computed value");
-  aResult.Reset();
+  // If we hit this assertion, it probably means we are fetching a value from
+  // the computed style that we don't know how to represent as
+  // a StyleAnimationValue.
+  MOZ_ASSERT(result.GetUnit() != eCSSUnit_Null, "Got null computed value");
+
+  return result;
 }
 
 void
 nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
                                     dom::Element* aTarget,
                                     CSSAnimationCollection* aCollection,
                                     OwningCSSAnimationPtrArray& aAnimations)
 {