Bug 1244590 - Part 9: Update spacing in SetTarget. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 11 May 2016 15:34:58 +0800
changeset 369284 02417a19d3948e0454b5a4b881e968b3ad50f9c4
parent 369283 c2d881e7ae7e15c66f281e24e77b918f5d5a0e21
child 369285 5c6435df39f7b14f82c2bd623de20be9d65012bb
push id18826
push userbmo:boris.chiou@gmail.com
push dateSat, 21 May 2016 11:25:24 +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
@@ -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) {