Bug 1244590 - Part 9: Update spacing in SetTarget. r=birtles

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

--HG--
extra : rebase_source : e2988f433f395a398090dc08f262b0154de3dc50
This commit is contained in:
Boris Chiou 2016-05-11 15:34:58 +08:00
parent 0a3a365c73
commit 2768dbb547

View File

@ -1539,6 +1539,8 @@ KeyframeEffect::SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget)
RefPtr<nsStyleContext> styleContext = GetTargetStyleContext();
if (styleContext) {
UpdateProperties(styleContext);
} else if (mEffectOptions.mSpacingMode == SpacingMode::paced) {
KeyframeUtils::ApplyDistributeSpacing(mKeyframes);
}
RequestRestyle(EffectCompositor::RestyleType::Layer);
@ -1547,6 +1549,9 @@ KeyframeEffect::SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget)
if (mAnimation) {
nsNodeUtils::AnimationAdded(mAnimation);
}
} else if (mEffectOptions.mSpacingMode == SpacingMode::paced) {
// New target is null, so fall back to distribute spacing.
KeyframeUtils::ApplyDistributeSpacing(mKeyframes);
}
}