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
This commit is contained in:
Boris Chiou 2017-04-12 16:31:12 +08:00
Родитель fb53a02a99
Коммит a699413b9a
2 изменённых файлов: 26 добавлений и 10 удалений

Просмотреть файл

@ -143,6 +143,8 @@ SERVO_BINDING_FUNC(Servo_ComputedValues_ExtractAnimationValue,
RawServoAnimationValueStrong, RawServoAnimationValueStrong,
ServoComputedValuesBorrowed computed_values, ServoComputedValuesBorrowed computed_values,
nsCSSPropertyID property) nsCSSPropertyID property)
SERVO_BINDING_FUNC(Servo_Property_IsDiscreteAnimatable, bool,
nsCSSPropertyID property)
// AnimationValues handling // AnimationValues handling
SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate, SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,

Просмотреть файл

@ -434,12 +434,29 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsTransitionManager, Release)
static inline bool static inline bool
ExtractNonDiscreteComputedValue(nsCSSPropertyID aProperty, ExtractNonDiscreteComputedValue(nsCSSPropertyID aProperty,
nsStyleContext* aStyleContext, nsStyleContext* aStyleContext,
StyleAnimationValue& aComputedValue) AnimationValue& aAnimationValue)
{ {
return (nsCSSProps::kAnimTypeTable[aProperty] != eStyleAnimType_Discrete || return (nsCSSProps::kAnimTypeTable[aProperty] != eStyleAnimType_Discrete ||
aProperty == eCSSProperty_visibility) && aProperty == eCSSProperty_visibility) &&
StyleAnimationValue::ExtractComputedValue(aProperty, aStyleContext, 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 void
@ -700,7 +717,7 @@ nsTransitionManager::UpdateTransitions(
OwningCSSTransitionPtrArray& animations = aElementTransitions->mAnimations; OwningCSSTransitionPtrArray& animations = aElementTransitions->mAnimations;
size_t i = animations.Length(); size_t i = animations.Length();
MOZ_ASSERT(i != 0, "empty transitions list?"); MOZ_ASSERT(i != 0, "empty transitions list?");
StyleAnimationValue currentValue; AnimationValue currentValue;
do { do {
--i; --i;
CSSTransition* anim = animations[i]; CSSTransition* anim = animations[i];
@ -714,7 +731,7 @@ nsTransitionManager::UpdateTransitions(
// matching currentValue // matching currentValue
!ExtractNonDiscreteComputedValue(anim->TransitionProperty(), !ExtractNonDiscreteComputedValue(anim->TransitionProperty(),
aNewStyleContext, currentValue) || aNewStyleContext, currentValue) ||
currentValue != anim->ToValue().mGecko) { currentValue != anim->ToValue()) {
// stop the transition // stop the transition
if (anim->HasCurrentEffect()) { if (anim->HasCurrentEffect()) {
EffectSet* effectSet = EffectSet* effectSet =
@ -822,10 +839,8 @@ nsTransitionManager::ConsiderInitiatingTransition(
AnimationValue startValue, endValue; AnimationValue startValue, endValue;
bool haveValues = bool haveValues =
ExtractNonDiscreteComputedValue(aProperty, aOldStyleContext, ExtractNonDiscreteComputedValue(aProperty, aOldStyleContext, startValue) &&
startValue.mGecko) && ExtractNonDiscreteComputedValue(aProperty, aNewStyleContext, endValue);
ExtractNonDiscreteComputedValue(aProperty, aNewStyleContext,
endValue.mGecko);
bool haveChange = startValue != endValue; bool haveChange = startValue != endValue;
@ -1088,8 +1103,7 @@ nsTransitionManager::PruneCompletedTransitions(mozilla::dom::Element* aElement,
// influence style. // influence style.
AnimationValue currentValue; AnimationValue currentValue;
if (!ExtractNonDiscreteComputedValue(anim->TransitionProperty(), if (!ExtractNonDiscreteComputedValue(anim->TransitionProperty(),
aNewStyleContext, aNewStyleContext, currentValue) ||
currentValue.mGecko) ||
currentValue != anim->ToValue()) { currentValue != anim->ToValue()) {
anim->CancelFromStyle(); anim->CancelFromStyle();
animations.RemoveElementAt(i); animations.RemoveElementAt(i);