Index: third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp |
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp b/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp |
index 78a1c61a723bc3c84343a33abf4da3fe4cef3bba..002573e7bdd2bb97fe33fd85cce07260861a32a2 100644 |
--- a/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp |
+++ b/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp |
@@ -37,8 +37,14 @@ |
#include "core/animation/ElementAnimations.h" |
#include "core/animation/InertEffect.h" |
#include "core/animation/Interpolation.h" |
+#include "core/animation/InterpolationEnvironment.h" |
+#include "core/animation/InterpolationType.h" |
#include "core/animation/KeyframeEffectModel.h" |
#include "core/animation/LegacyStyleInterpolation.h" |
+#include "core/animation/PairwiseInterpolationValue.h" |
+#include "core/animation/PrimitiveInterpolation.h" |
+#include "core/animation/PropertyInterpolationTypesMapping.h" |
+#include "core/animation/TransitionEffectModel.h" |
#include "core/animation/css/CSSAnimatableValueFactory.h" |
#include "core/css/CSSKeyframeRule.h" |
#include "core/css/CSSPropertyEquality.h" |
@@ -537,29 +543,45 @@ void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const |
if (activeTransitions) { |
TransitionMap::const_iterator activeTransitionIter = activeTransitions->find(id); |
if (activeTransitionIter != activeTransitions->end()) { |
- const RunningTransition* runningTransition = &activeTransitionIter->value; |
+ const RunningTransition& runningTransition = activeTransitionIter->value; |
to = CSSAnimatableValueFactory::create(id, style); |
- const AnimatableValue* activeTo = runningTransition->to; |
- if (to->equals(activeTo)) |
+ if (to->equals(runningTransition.to.get())) |
return; |
update.cancelTransition(id); |
ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAnimationStyleChange()); |
- if (to->equals(runningTransition->reversingAdjustedStartValue.get())) |
- interruptedTransition = runningTransition; |
+ if (to->equals(runningTransition.reversingAdjustedStartValue.get())) |
+ interruptedTransition = &runningTransition; |
} |
} |
if (CSSPropertyEquality::propertiesEqual(id, oldStyle, style)) |
return; |
+ |
+ RefPtr<PairwiseInterpolation> pairwiseInterpolation; |
+ InterpolationEnvironment oldEnvironment(oldStyle); |
+ InterpolationEnvironment newEnvironment(style); |
+ for (const std::unique_ptr<const InterpolationType>& interpolationType : PropertyInterpolationTypesMapping::get(PropertyHandle(id))) { |
+ InterpolationValue start = interpolationType->maybeConvertUnderlyingValue(oldEnvironment); |
+ if (!start) |
+ continue; |
+ InterpolationValue end = interpolationType->maybeConvertUnderlyingValue(newEnvironment); |
+ if (!end) |
+ continue; |
+ if ((pairwiseInterpolation = PairwiseInterpolation::maybeCreate(*interpolationType, std::move(start), std::move(end)))) |
+ break; |
+ } |
+ |
+ // No smooth interpolation exists between these values so don't start a transition. |
+ if (!pairwiseInterpolation) |
+ return; |
+ |
if (!to) |
to = CSSAnimatableValueFactory::create(id, style); |
- |
RefPtr<AnimatableValue> from = CSSAnimatableValueFactory::create(id, oldStyle); |
+ |
// If we have multiple transitions on the same property, we will use the |
// last one since we iterate over them in order. |
- if (AnimatableValue::usesDefaultInterpolation(to.get(), from.get())) |
- return; |
Timing timing = transitionData.convertToTiming(transitionIndex); |
if (timing.startDelay + timing.iterationDuration <= 0) |
@@ -571,7 +593,7 @@ void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const |
const double interruptedProgress = interruptedTransition->animation->effect()->progress(); |
if (!std::isnan(interruptedProgress)) { |
// const_cast because we need to take a ref later when passing to startTransition. |
- reversingAdjustedStartValue = const_cast<AnimatableValue*>(interruptedTransition->to); |
+ reversingAdjustedStartValue = const_cast<AnimatableValue*>(interruptedTransition->to.get()); |
reversingShorteningFactor = clampTo( |
(interruptedProgress * interruptedTransition->reversingShorteningFactor) + |
(1 - interruptedTransition->reversingShorteningFactor), 0.0, 1.0); |
@@ -582,35 +604,17 @@ void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const |
} |
} |
- AnimatableValueKeyframeVector keyframes; |
- double startKeyframeOffset = 0; |
- |
+ double delayOffset = 0; |
if (timing.startDelay > 0) { |
timing.iterationDuration += timing.startDelay; |
- startKeyframeOffset = timing.startDelay / timing.iterationDuration; |
+ delayOffset = timing.startDelay / timing.iterationDuration; |
timing.startDelay = 0; |
} |
- RefPtr<AnimatableValueKeyframe> delayKeyframe = AnimatableValueKeyframe::create(); |
- delayKeyframe->setPropertyValue(id, from.get()); |
- delayKeyframe->setOffset(0); |
- keyframes.append(delayKeyframe); |
- |
- RefPtr<AnimatableValueKeyframe> startKeyframe = AnimatableValueKeyframe::create(); |
- startKeyframe->setPropertyValue(id, from.get()); |
- startKeyframe->setOffset(startKeyframeOffset); |
- startKeyframe->setEasing(timing.timingFunction.release()); |
+ TransitionEffectModel* model = TransitionEffectModel::create(pairwiseInterpolation.release(), delayOffset, timing.timingFunction.release()); |
timing.timingFunction = LinearTimingFunction::shared(); |
- keyframes.append(startKeyframe); |
- |
- RefPtr<AnimatableValueKeyframe> endKeyframe = AnimatableValueKeyframe::create(); |
- endKeyframe->setPropertyValue(id, to.get()); |
- endKeyframe->setOffset(1); |
- keyframes.append(endKeyframe); |
- |
- AnimatableValueKeyframeEffectModel* model = AnimatableValueKeyframeEffectModel::create(keyframes); |
update.startTransition( |
- id, from.get(), to.get(), reversingAdjustedStartValue, reversingShorteningFactor, |
+ id, from.release(), to.release(), reversingAdjustedStartValue, reversingShorteningFactor, |
*InertEffect::create(model, timing, false, 0)); |
ASSERT(!element->elementAnimations() || !element->elementAnimations()->isAnimationStyleChange()); |
} |