OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/animation/TransitionInterpolation.h" |
| 6 |
| 7 #include "core/animation/CSSInterpolationTypesMap.h" |
| 8 #include "core/animation/InterpolationEnvironment.h" |
| 9 #include "core/animation/InterpolationType.h" |
| 10 #include "core/css/resolver/StyleResolverState.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 void TransitionInterpolation::interpolate(int iteration, double fraction) { |
| 15 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { |
| 16 if (fraction != 0 && fraction != 1) { |
| 17 m_merge.startInterpolableValue->interpolate( |
| 18 *m_merge.endInterpolableValue, fraction, *m_cachedInterpolableValue); |
| 19 } |
| 20 m_cachedIteration = iteration; |
| 21 m_cachedFraction = fraction; |
| 22 } |
| 23 } |
| 24 |
| 25 const InterpolableValue& TransitionInterpolation::currentInterpolableValue() |
| 26 const { |
| 27 if (m_cachedFraction == 0) { |
| 28 return *m_start.interpolableValue; |
| 29 } |
| 30 if (m_cachedFraction == 1) { |
| 31 return *m_end.interpolableValue; |
| 32 } |
| 33 return *m_cachedInterpolableValue; |
| 34 } |
| 35 |
| 36 NonInterpolableValue* TransitionInterpolation::currentNonInterpolableValue() |
| 37 const { |
| 38 if (m_cachedFraction == 0) { |
| 39 return m_start.nonInterpolableValue.get(); |
| 40 } |
| 41 if (m_cachedFraction == 1) { |
| 42 return m_end.nonInterpolableValue.get(); |
| 43 } |
| 44 return m_merge.nonInterpolableValue.get(); |
| 45 } |
| 46 |
| 47 void TransitionInterpolation::apply(StyleResolverState& state) const { |
| 48 CSSInterpolationTypesMap map(state.document().propertyRegistry()); |
| 49 InterpolationEnvironment environment(map, state); |
| 50 m_type.apply(currentInterpolableValue(), currentNonInterpolableValue(), |
| 51 environment); |
| 52 } |
| 53 |
| 54 std::unique_ptr<TypedInterpolationValue> |
| 55 TransitionInterpolation::getInterpolatedValue() const { |
| 56 return TypedInterpolationValue::create(m_type, |
| 57 currentInterpolableValue().clone(), |
| 58 currentNonInterpolableValue()); |
| 59 } |
| 60 |
| 61 RefPtr<AnimatableValue> |
| 62 TransitionInterpolation::getInterpolatedCompositorValue() const { |
| 63 return AnimatableValue::interpolate(m_compositorStart.get(), |
| 64 m_compositorEnd.get(), m_cachedFraction); |
| 65 } |
| 66 |
| 67 } // namespace blink |
OLD | NEW |