Bug 1244590 - Part 9: Update spacing in SetTarget.
Handle these cases:
1. When creating null-target effect whose spacing mode is "paced":
- Fall back to distribute spacing. This case is already included by previous
patches.
2. When setting a target to null:
- Apply distribute spacing.
3. When style context is null.
- Fall back to distribute spacing.
4. When setting a new valid target:
- Use this new target as the context element and re-calculate the computed
offsets. This case is already included by previous patches.
MozReview-Commit-ID: 1zhSOAylnZb
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1535,24 +1535,29 @@ KeyframeEffect::SetTarget(const Nullable
mTarget = newTarget;
if (mTarget) {
UpdateTargetRegistration();
RefPtr<nsStyleContext> styleContext = GetTargetStyleContext();
if (styleContext) {
UpdateProperties(styleContext);
+ } else if (mEffectOptions.mSpacingMode == SpacingMode::paced) {
+ KeyframeUtils::ApplySpacing(mKeyframes, SpacingMode::distribute);
}
RequestRestyle(EffectCompositor::RestyleType::Layer);
nsAutoAnimationMutationBatch mb(mTarget->mElement->OwnerDoc());
if (mAnimation) {
nsNodeUtils::AnimationAdded(mAnimation);
}
+ } else if (mEffectOptions.mSpacingMode == SpacingMode::paced) {
+ // New target is null, so fall back to distribute spacing.
+ KeyframeUtils::ApplySpacing(mKeyframes, SpacingMode::distribute);
}
}
KeyframeEffect::~KeyframeEffect()
{
// mTiming is cycle collected, so we have to do null check first even though
// mTiming shouldn't be null during the lifetime of KeyframeEffect.
if (mTiming) {