Bug 1244590 - Part 9: Update spacing in SetTarget. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 11 May 2016 15:34:58 +0800
changeset 371288 ca6ac8725020ba8c112a70cf978dc7024af3ee4e
parent 371287 49a66b65699e4857ac48f508a2d2e30df44fe412
child 371289 3229c028521f7f7bb3eecfee309cc2c37890c4fe
push id19290
push userbmo:boris.chiou@gmail.com
push dateThu, 26 May 2016 09:18:45 +0000
bugs1244590
milestone49.0a1
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
dom/animation/KeyframeEffect.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1488,24 +1488,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) {