Bug 1343753 - Part 5: Support ServoComputedValues in ExtractNonDiscreteComputedValue.
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
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -138,16 +138,18 @@ SERVO_BINDING_FUNC(Servo_GetComputedKeyf
SERVO_BINDING_FUNC(Servo_AnimationValueMap_Push, void,
RawServoAnimationValueMapBorrowed,
nsCSSPropertyID property,
RawServoAnimationValueBorrowed value)
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,
RawServoAnimationValueStrong,
RawServoAnimationValueBorrowed from,
RawServoAnimationValueBorrowed to,
double progress)
SERVO_BINDING_FUNC(Servo_AnimationValues_IsInterpolable, bool,
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -429,22 +429,39 @@ CSSTransition::SetEffectFromStyle(dom::A
NS_IMPL_CYCLE_COLLECTION(nsTransitionManager, mEventDispatcher)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsTransitionManager, AddRef)
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
nsTransitionManager::StyleContextChanged(dom::Element *aElement,
nsStyleContext *aOldStyleContext,
RefPtr<nsStyleContext>* aNewStyleContext /* inout */)
{
nsStyleContext* newStyleContext = *aNewStyleContext;
@@ -695,31 +712,31 @@ nsTransitionManager::UpdateTransitions(
allTransitionProperties.AddProperty(property);
}
}
}
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];
// properties no longer in 'transition-property'
if ((checkProperties &&
!allTransitionProperties.HasProperty(anim->TransitionProperty())) ||
// properties whose computed values changed but for which we
// did not start a new transition (because delay and
// duration are both zero, or because the new value is not
// interpolable); a new transition would have anim->ToValue()
// matching currentValue
!ExtractNonDiscreteComputedValue(anim->TransitionProperty(),
aNewStyleContext, currentValue) ||
- currentValue != anim->ToValue().mGecko) {
+ currentValue != anim->ToValue()) {
// stop the transition
if (anim->HasCurrentEffect()) {
EffectSet* effectSet =
EffectSet::GetEffectSet(aElement,
aNewStyleContext->GetPseudoType());
if (effectSet) {
effectSet->UpdateAnimationGeneration(mPresContext);
}
@@ -817,20 +834,18 @@ nsTransitionManager::ConsiderInitiatingT
if (nsCSSProps::kAnimTypeTable[aProperty] == eStyleAnimType_None) {
return;
}
dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
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;
bool shouldAnimate =
haveValues &&
haveChange &&
startValue.IsInterpolableWith(aProperty, endValue);
@@ -1083,18 +1098,17 @@ nsTransitionManager::PruneCompletedTrans
if (anim->HasCurrentEffect()) {
continue;
}
// Since effect is a finished transition, we know it didn't
// influence style.
AnimationValue currentValue;
if (!ExtractNonDiscreteComputedValue(anim->TransitionProperty(),
- aNewStyleContext,
- currentValue.mGecko) ||
+ aNewStyleContext, currentValue) ||
currentValue != anim->ToValue()) {
anim->CancelFromStyle();
animations.RemoveElementAt(i);
}
} while (i != 0);
if (collection->mAnimations.IsEmpty()) {
collection->Destroy();