Bug 1311257 - Use underlying value for missing keyframes. r?birtles, heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 06 Apr 2017 10:34:51 +0900
changeset 556567 b53a15e99910b212e528f43f086a3f9d98ca9a5e
parent 556566 77211d4304ba7e702c12b6b44700265778e1c462
child 556568 6e26f1db3e7cdb771558a61c2ea985e6ed87264e
push id52584
push userhikezoe@mozilla.com
push dateThu, 06 Apr 2017 03:01:12 +0000
reviewersbirtles, heycam
bugs1311257
milestone55.0a1
Bug 1311257 - Use underlying value for missing keyframes. r?birtles, heycam mBaseStyleValuesForServo is a nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue> In this patch, we use void* instead of exposing nsRefPtrHashtable in FFI because we just use the hash table as an argument of a C++ function, it means we don't touch the hash table in Rust at all. MozReview-Commit-ID: 1wM6NeF2S0t
dom/animation/KeyframeEffectReadOnly.cpp
layout/style/ServoBindingList.h
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -675,16 +675,17 @@ KeyframeEffectReadOnly::ComposeStyleRule
   // For unsupported or non-animatable animation types, we get nullptrs.
   if (!aSegment.mFromValue.mServo|| !aSegment.mToValue.mServo) {
     NS_ERROR("Compose style for unsupported or non-animatable property, "
              "so get invalid RawServoAnimationValues");
     return;
   }
 
   Servo_AnimationCompose(&aAnimationValues,
+                         &mBaseStyleValuesForServo,
                          aProperty.mProperty,
                          &aSegment,
                          &aComputedTiming);
 }
 
 template<typename ComposeAnimationResult>
 void
 KeyframeEffectReadOnly::ComposeStyle(
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -199,21 +199,25 @@ SERVO_BINDING_FUNC(Servo_DeclarationBloc
                    const nsACString* value, bool is_important,
                    RawGeckoURLExtraData* data)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    const nsACString* property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemovePropertyById, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property)
+// Compose animation value for a given property.
+// |base_values| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
+// We use void* to avoid exposing nsRefPtrHashtable in FFI.
 SERVO_BINDING_FUNC(Servo_AnimationCompose, void,
-                   RawServoAnimationValueMapBorrowed,
+                   RawServoAnimationValueMapBorrowed animation_values,
+                   void* base_values,
                    nsCSSPropertyID property,
-                   RawGeckoAnimationPropertySegmentBorrowed,
-                   RawGeckoComputedTimingBorrowed)
+                   RawGeckoAnimationPropertySegmentBorrowed animation_segment,
+                   RawGeckoComputedTimingBorrowed computed_timing)
 
 // presentation attributes
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_PropertyIsSet, bool,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetIdentStringValue, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property,
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -530,16 +530,25 @@ Gecko_GetPositionInSegment(RawGeckoAnima
   double positionInSegment =
     (aProgress - aSegment->mFromKey) / (aSegment->mToKey - aSegment->mFromKey);
 
   return ComputedTimingFunction::GetPortion(aSegment->mTimingFunction,
                                             positionInSegment,
                                             aBeforeFlag);
 }
 
+RawServoAnimationValueBorrowedOrNull
+Gecko_AnimationGetBaseStyle(void* aBaseStyles, nsCSSPropertyID aProperty)
+{
+  auto base =
+    static_cast<nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>*>
+      (aBaseStyles);
+  return base->GetWeak(aProperty);
+}
+
 void
 Gecko_FillAllBackgroundLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
 {
   nsRuleNode::FillAllBackgroundLists(*aLayers, aMaxLen);
 }
 
 void
 Gecko_FillAllMaskLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
@@ -1168,17 +1177,17 @@ Gecko_EnsureImageLayersLength(nsStyleIma
     aLayers->mLayers[i].Initialize(aLayerType);
   }
 }
 
 void
 Gecko_EnsureStyleAnimationArrayLength(void* aArray, size_t aLen)
 {
   auto base =
-    reinterpret_cast<nsStyleAutoArray<StyleAnimation>*>(aArray);
+    static_cast<nsStyleAutoArray<StyleAnimation>*>(aArray);
 
   size_t oldLength = base->Length();
 
   base->EnsureLengthAtLeast(aLen);
 
   for (size_t i = oldLength; i < aLen; ++i) {
     (*base)[i].SetInitialValues();
   }
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -194,16 +194,23 @@ bool Gecko_ElementHasAnimations(RawGecko
                                 nsIAtom* aPseudoTagOrNull);
 bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement,
                                    nsIAtom* aPseudoTagOrNull);
 double Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming);
 double Gecko_GetPositionInSegment(
   RawGeckoAnimationPropertySegmentBorrowed aSegment,
   double aProgress,
   mozilla::ComputedTimingFunction::BeforeFlag aBeforeFlag);
+// Get servo's AnimationValue for |aProperty| from the cached base style
+// |aBaseStyles|.
+// |aBaseStyles| is nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>.
+// We use void* to avoid exposing nsRefPtrHashtable in FFI.
+RawServoAnimationValueBorrowedOrNull Gecko_AnimationGetBaseStyle(
+  void* aBaseStyles,
+  nsCSSPropertyID aProperty);
 
 // Atoms.
 nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
 void Gecko_AddRefAtom(nsIAtom* aAtom);
 void Gecko_ReleaseAtom(nsIAtom* aAtom);
 const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
 bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
 bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);