From a699413b9a974b4541cac85bf5a11487787945fe Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 16:31:12 +0800 Subject: [PATCH] Bug 1343753 - Part 5: Support ServoComputedValues in ExtractNonDiscreteComputedValue. r=birtles,hiro,manishearth We use ServoComputedStyleValues as the argument here, instead of ServoComputedValues, because I will use template for nsStyleContext and ServoComputedValuesWithParent in UpdateTransitions() and ConsiderInitiatingTransition(). Besides, add an FFI to check if a proeprty is discrete animation type. MozReview-Commit-ID: 7VtcMDtgl55 --HG-- extra : rebase_source : eeef2e634887b66bb6650d66fb2e3929a5ea1855 --- layout/style/ServoBindingList.h | 2 ++ layout/style/nsTransitionManager.cpp | 34 ++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/layout/style/ServoBindingList.h b/layout/style/ServoBindingList.h index 5de061b715b8..3d5247bc6f5c 100644 --- a/layout/style/ServoBindingList.h +++ b/layout/style/ServoBindingList.h @@ -143,6 +143,8 @@ SERVO_BINDING_FUNC(Servo_ComputedValues_ExtractAnimationValue, RawServoAnimationValueStrong, ServoComputedValuesBorrowed computed_values, nsCSSPropertyID property) +SERVO_BINDING_FUNC(Servo_Property_IsDiscreteAnimatable, bool, + nsCSSPropertyID property) // AnimationValues handling SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate, diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index 3775acdc7113..d3229dbc9810 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -434,12 +434,29 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsTransitionManager, Release) static inline bool ExtractNonDiscreteComputedValue(nsCSSPropertyID aProperty, nsStyleContext* aStyleContext, - StyleAnimationValue& aComputedValue) + AnimationValue& aAnimationValue) { return (nsCSSProps::kAnimTypeTable[aProperty] != eStyleAnimType_Discrete || aProperty == eCSSProperty_visibility) && StyleAnimationValue::ExtractComputedValue(aProperty, aStyleContext, - aComputedValue); + aAnimationValue.mGecko); +} + +static inline bool +ExtractNonDiscreteComputedValue(nsCSSPropertyID aProperty, + const ServoComputedValuesWithParent& + aComputedStyle, + AnimationValue& aAnimationValue) +{ + if (Servo_Property_IsDiscreteAnimatable(aProperty) && + aProperty != eCSSProperty_visibility) { + return false; + } + + aAnimationValue.mServo = + Servo_ComputedValues_ExtractAnimationValue(aComputedStyle.mCurrentStyle, + aProperty).Consume(); + return !!aAnimationValue.mServo; } void @@ -700,7 +717,7 @@ nsTransitionManager::UpdateTransitions( OwningCSSTransitionPtrArray& animations = aElementTransitions->mAnimations; size_t i = animations.Length(); MOZ_ASSERT(i != 0, "empty transitions list?"); - StyleAnimationValue currentValue; + AnimationValue currentValue; do { --i; CSSTransition* anim = animations[i]; @@ -714,7 +731,7 @@ nsTransitionManager::UpdateTransitions( // matching currentValue !ExtractNonDiscreteComputedValue(anim->TransitionProperty(), aNewStyleContext, currentValue) || - currentValue != anim->ToValue().mGecko) { + currentValue != anim->ToValue()) { // stop the transition if (anim->HasCurrentEffect()) { EffectSet* effectSet = @@ -822,10 +839,8 @@ nsTransitionManager::ConsiderInitiatingTransition( AnimationValue startValue, endValue; bool haveValues = - ExtractNonDiscreteComputedValue(aProperty, aOldStyleContext, - startValue.mGecko) && - ExtractNonDiscreteComputedValue(aProperty, aNewStyleContext, - endValue.mGecko); + ExtractNonDiscreteComputedValue(aProperty, aOldStyleContext, startValue) && + ExtractNonDiscreteComputedValue(aProperty, aNewStyleContext, endValue); bool haveChange = startValue != endValue; @@ -1088,8 +1103,7 @@ nsTransitionManager::PruneCompletedTransitions(mozilla::dom::Element* aElement, // influence style. AnimationValue currentValue; if (!ExtractNonDiscreteComputedValue(anim->TransitionProperty(), - aNewStyleContext, - currentValue.mGecko) || + aNewStyleContext, currentValue) || currentValue != anim->ToValue()) { anim->CancelFromStyle(); animations.RemoveElementAt(i);