From 3ffcee093773fb48820f0ba57ef42175b6638716 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Fri, 14 Jan 2011 19:57:53 -0800 Subject: [PATCH] Don't cancel transitions that are almost completed (and round to their final value) when we get an unrelated style change. (Bug 613888) r=bzbarsky a2.0=blocking --- layout/style/nsTransitionManager.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index de0a9412b7c1..166e467ebd23 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -588,9 +588,11 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty, ElementPropertyTransition pt; nsStyleAnimation::Value dummyValue; - PRBool shouldAnimate = + PRBool haveValues = TransExtractComputedValue(aProperty, aOldStyleContext, pt.mStartValue) && - TransExtractComputedValue(aProperty, aNewStyleContext, pt.mEndValue) && + TransExtractComputedValue(aProperty, aNewStyleContext, pt.mEndValue); + PRBool shouldAnimate = + haveValues && pt.mStartValue != pt.mEndValue && // Check that we can interpolate between these values // (If this is ever a performance problem, we could add a @@ -613,13 +615,19 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty, nsPresContext *presContext = aNewStyleContext->PresContext(); if (!shouldAnimate) { - if (currentIndex != nsTArray::NoIndex) { + nsTArray &pts = + aElementTransitions->mPropertyTransitions; + if (currentIndex != nsTArray::NoIndex && + (!haveValues || pts[currentIndex].mEndValue != pt.mEndValue)) { // We're in the middle of a transition, but just got a // non-transition style change changing to exactly the // current in-progress value. (This is quite easy to cause // using 'transition-delay'.) - nsTArray &pts = - aElementTransitions->mPropertyTransitions; + // + // We also check that this current in-progress value is different + // from the end value; we don't want to cancel a transition that + // is almost done (and whose current value rounds to its end + // value) just because we got an unrelated style change. pts.RemoveElementAt(currentIndex); if (pts.IsEmpty()) { aElementTransitions->Destroy();