Bug 1334036 - Part 10: Return AnimationValue for BaseStyle. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 10 May 2017 11:06:19 +0800
changeset 581943 287ef9520b1ce20dd1eb59b9ec2736a17c537e2b
parent 581942 7492d38b17b2f3e7bcb55a6adb27ef4fb6ab8f88
child 581944 84c8765bc20eb5b325e53024ef9c1c7f1ae982a1
push id59916
push userbmo:boris.chiou@gmail.com
push dateSat, 20 May 2017 06:48:29 +0000
bugs1334036
milestone55.0a1
Bug 1334036 - Part 10: Return AnimationValue for BaseStyle. We need to retrieve the correct base style for Servo backend, so change the return value to AnimationValue and update KeyframeEffectReadOnly::BaseStyle(). MozReview-Commit-ID: 9FL3h1DLoJt
dom/animation/KeyframeEffectReadOnly.cpp
dom/animation/KeyframeEffectReadOnly.h
layout/base/nsLayoutUtils.cpp
layout/painting/nsDisplayList.cpp
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -422,17 +422,17 @@ KeyframeEffectReadOnly::GetUnderlyingSty
     // If we have already composed style for the property, we use the style
     // as the underlying style.
     DebugOnly<bool> success = aAnimationRule->GetValue(aProperty, result);
     MOZ_ASSERT(success, "AnimValuesStyleRule::GetValue should not fail");
   } else {
     // If we are composing with composite operation that is not 'replace'
     // and we have not composed style for the property yet, we have to get
     // the base style for the property.
-    result = BaseStyle(aProperty);
+    result = BaseStyle(aProperty).mGecko;
   }
 
   return result;
 }
 
 StyleAnimationValue
 KeyframeEffectReadOnly::CompositeValue(
   nsCSSPropertyID aProperty,
@@ -1292,17 +1292,18 @@ KeyframeEffectReadOnly::GetKeyframes(JSC
           // We use an uninitialized nsCSSValue to represent the
           // "neutral value". We currently only do this for keyframes generated
           // from CSS animations with missing 0%/100% keyframes. Furthermore,
           // currently (at least until bug 1339334) keyframes generated from
           // CSS animations only contain longhand properties so we only need to
           // handle null nsCSSValues for longhand properties.
           DebugOnly<bool> uncomputeResult =
             StyleAnimationValue::UncomputeValue(
-              propertyValue.mProperty, Move(BaseStyle(propertyValue.mProperty)),
+              propertyValue.mProperty,
+              Move(BaseStyle(propertyValue.mProperty).mGecko),
               cssValue);
 
           MOZ_ASSERT(uncomputeResult,
                      "Unable to get specified value from computed value");
           MOZ_ASSERT(cssValue.GetUnit() != eCSSUnit_Null,
                      "Got null computed value");
         }
         cssValue.AppendToString(propertyValue.mProperty,
@@ -1843,17 +1844,17 @@ KeyframeEffectReadOnly::ContainsAnimated
     return false;
   }
 
   for (const AnimationProperty& prop : mProperties) {
     if (prop.mProperty != eCSSProperty_transform) {
       continue;
     }
 
-    StyleAnimationValue baseStyle = BaseStyle(prop.mProperty);
+    AnimationValue baseStyle = BaseStyle(prop.mProperty);
     if (baseStyle.IsNull()) {
       // If we failed to get the base style, we consider it has scale value
       // here just to be safe.
       return true;
     }
     gfxSize size = baseStyle.GetScaleValue(aFrame);
     if (size != gfxSize(1.0f, 1.0f)) {
       return true;
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -274,20 +274,28 @@ public:
   // See nsChangeHint_Hints_CanIgnoreIfNotVisible in nsChangeHint.h
   // in detail which change hint can be ignored.
   bool CanIgnoreIfNotVisible() const;
 
   // Returns true if the effect is current state and has scale animation.
   // |aFrame| is used for calculation of scale values.
   bool ContainsAnimatedScale(const nsIFrame* aFrame) const;
 
-  StyleAnimationValue BaseStyle(nsCSSPropertyID aProperty) const
+  AnimationValue BaseStyle(nsCSSPropertyID aProperty) const
   {
-    StyleAnimationValue result;
-    DebugOnly<bool> hasProperty = mBaseStyleValues.Get(aProperty, &result);
+    AnimationValue result;
+    bool hasProperty = false;
+    if (mDocument->IsStyledByServo()) {
+      // We cannot use getters_AddRefs on RawServoAnimationValue because it is
+      // an incomplete type, so Get() doesn't work. Instead, use GetWeak, and
+      // then assign the raw pointer to a RefPtr.
+      result.mServo = mBaseStyleValuesForServo.GetWeak(aProperty, &hasProperty);
+    } else {
+      hasProperty = mBaseStyleValues.Get(aProperty, &result.mGecko);
+    }
     MOZ_ASSERT(hasProperty || result.IsNull());
     return result;
   }
 
 protected:
   KeyframeEffectReadOnly(nsIDocument* aDocument,
                          const Maybe<OwningAnimationTarget>& aTarget,
                          AnimationEffectTimingReadOnly* aTiming,
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -628,22 +628,19 @@ GetMinAndMaxScaleForAnimationProperty(co
     for (size_t propIdx = effect->Properties().Length(); propIdx-- != 0; ) {
       const AnimationProperty& prop = effect->Properties()[propIdx];
       if (prop.mProperty != eCSSProperty_transform) {
         continue;
       }
 
       // We need to factor in the scale of the base style if the base style
       // will be used on the compositor.
-      StyleAnimationValue baseStyle = effect->BaseStyle(prop.mProperty);
+      AnimationValue baseStyle = effect->BaseStyle(prop.mProperty);
       if (!baseStyle.IsNull()) {
-        // FIXME: Bug 1334036: We need to get the baseStyle for
-        //        RawServoAnimationValue.
-        UpdateMinMaxScale(aFrame, AnimationValue(baseStyle),
-                          aMinScale, aMaxScale);
+        UpdateMinMaxScale(aFrame, baseStyle, aMinScale, aMaxScale);
       }
 
       for (const AnimationPropertySegment& segment : prop.mSegments) {
         // In case of add or accumulate composite, StyleAnimationValue does
         // not have a valid value.
         if (segment.HasReplaceableFromValue()) {
           UpdateMinMaxScale(aFrame, segment.mFromValue, aMinScale, aMaxScale);
         }
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -561,23 +561,21 @@ AddAnimationForProperty(nsIFrame* aFrame
                          AsKeyframeEffect()->IterationComposite());
   animation->isNotPlaying() = !aAnimation->IsPlaying();
 
   TransformReferenceBox refBox(aFrame);
 
   // If the animation is additive or accumulates, we need to pass its base value
   // to the compositor.
 
-  StyleAnimationValue baseStyle =
+  AnimationValue baseStyle =
     aAnimation->GetEffect()->AsKeyframeEffect()->BaseStyle(aProperty.mProperty);
   if (!baseStyle.IsNull()) {
-    // FIXME: Bug 1334036: We need to get the baseValue for
-    //        RawServoAnimationValue.
     SetAnimatable(aProperty.mProperty,
-                  AnimationValue(baseStyle),
+                  baseStyle,
                   aFrame, refBox,
                   animation->baseStyle());
   } else {
     animation->baseStyle() = null_t();
   }
 
   for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {
     const AnimationPropertySegment& segment = aProperty.mSegments[segIdx];