| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/animation/InvalidatableInterpolation.h" | 5 #include "core/animation/InvalidatableInterpolation.h" |
| 6 | 6 |
| 7 #include "core/animation/InterpolationEnvironment.h" | 7 #include "core/animation/InterpolationEnvironment.h" |
| 8 #include "core/animation/StringKeyframe.h" | 8 #include "core/animation/StringKeyframe.h" |
| 9 #include "core/css/resolver/StyleResolverState.h" | 9 #include "core/css/resolver/StyleResolverState.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 { | 28 { |
| 29 ASSERT(m_currentFraction != 0 && m_currentFraction != 1); | 29 ASSERT(m_currentFraction != 0 && m_currentFraction != 1); |
| 30 for (const auto& interpolationType : m_interpolationTypes) { | 30 for (const auto& interpolationType : m_interpolationTypes) { |
| 31 if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && (!un
derlyingValueOwner || underlyingValueOwner.type() != *interpolationType)) | 31 if ((m_startKeyframe->isNeutral() || m_endKeyframe->isNeutral()) && (!un
derlyingValueOwner || underlyingValueOwner.type() != *interpolationType)) |
| 32 continue; | 32 continue; |
| 33 ConversionCheckers conversionCheckers; | 33 ConversionCheckers conversionCheckers; |
| 34 PairwiseInterpolationValue result = interpolationType->maybeConvertPairw
ise(*m_startKeyframe, *m_endKeyframe, environment, underlyingValueOwner.value(),
conversionCheckers); | 34 PairwiseInterpolationValue result = interpolationType->maybeConvertPairw
ise(*m_startKeyframe, *m_endKeyframe, environment, underlyingValueOwner.value(),
conversionCheckers); |
| 35 addConversionCheckers(*interpolationType, conversionCheckers); | 35 addConversionCheckers(*interpolationType, conversionCheckers); |
| 36 if (result) { | 36 if (result) { |
| 37 return PairwisePrimitiveInterpolation::create(*interpolationType, | 37 return PairwisePrimitiveInterpolation::create(*interpolationType, |
| 38 result.startInterpolableValue.release(), | 38 std::move(result.startInterpolableValue), |
| 39 result.endInterpolableValue.release(), | 39 std::move(result.endInterpolableValue), |
| 40 result.nonInterpolableValue.release()); | 40 result.nonInterpolableValue.release()); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 return nullptr; | 43 return nullptr; |
| 44 } | 44 } |
| 45 | 45 |
| 46 PassOwnPtr<TypedInterpolationValue> InvalidatableInterpolation::convertSingleKey
frame(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment&
environment, const UnderlyingValueOwner& underlyingValueOwner) const | 46 PassOwnPtr<TypedInterpolationValue> InvalidatableInterpolation::convertSingleKey
frame(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment&
environment, const UnderlyingValueOwner& underlyingValueOwner) const |
| 47 { | 47 { |
| 48 if (keyframe.isNeutral() && !underlyingValueOwner) | 48 if (keyframe.isNeutral() && !underlyingValueOwner) |
| 49 return nullptr; | 49 return nullptr; |
| 50 for (const auto& interpolationType : m_interpolationTypes) { | 50 for (const auto& interpolationType : m_interpolationTypes) { |
| 51 if (keyframe.isNeutral() && underlyingValueOwner.type() != *interpolatio
nType) | 51 if (keyframe.isNeutral() && underlyingValueOwner.type() != *interpolatio
nType) |
| 52 continue; | 52 continue; |
| 53 ConversionCheckers conversionCheckers; | 53 ConversionCheckers conversionCheckers; |
| 54 InterpolationValue result = interpolationType->maybeConvertSingle(keyfra
me, environment, underlyingValueOwner.value(), conversionCheckers); | 54 InterpolationValue result = interpolationType->maybeConvertSingle(keyfra
me, environment, underlyingValueOwner.value(), conversionCheckers); |
| 55 addConversionCheckers(*interpolationType, conversionCheckers); | 55 addConversionCheckers(*interpolationType, conversionCheckers); |
| 56 if (result) | 56 if (result) |
| 57 return TypedInterpolationValue::create(*interpolationType, result.in
terpolableValue.release(), result.nonInterpolableValue.release()); | 57 return TypedInterpolationValue::create(*interpolationType, std::move
(result.interpolableValue), result.nonInterpolableValue.release()); |
| 58 } | 58 } |
| 59 ASSERT(keyframe.isNeutral()); | 59 ASSERT(keyframe.isNeutral()); |
| 60 return nullptr; | 60 return nullptr; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void InvalidatableInterpolation::addConversionCheckers(const InterpolationType&
type, ConversionCheckers& conversionCheckers) const | 63 void InvalidatableInterpolation::addConversionCheckers(const InterpolationType&
type, ConversionCheckers& conversionCheckers) const |
| 64 { | 64 { |
| 65 for (size_t i = 0; i < conversionCheckers.size(); i++) { | 65 for (size_t i = 0; i < conversionCheckers.size(); i++) { |
| 66 conversionCheckers[i]->setType(type); | 66 conversionCheckers[i]->setType(type); |
| 67 m_conversionCheckers.append(conversionCheckers[i].release()); | 67 m_conversionCheckers.append(std::move(conversionCheckers[i])); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 PassOwnPtr<TypedInterpolationValue> InvalidatableInterpolation::maybeConvertUnde
rlyingValue(const InterpolationEnvironment& environment) const | 71 PassOwnPtr<TypedInterpolationValue> InvalidatableInterpolation::maybeConvertUnde
rlyingValue(const InterpolationEnvironment& environment) const |
| 72 { | 72 { |
| 73 for (const auto& interpolationType : m_interpolationTypes) { | 73 for (const auto& interpolationType : m_interpolationTypes) { |
| 74 InterpolationValue result = interpolationType->maybeConvertUnderlyingVal
ue(environment); | 74 InterpolationValue result = interpolationType->maybeConvertUnderlyingVal
ue(environment); |
| 75 if (result) | 75 if (result) |
| 76 return TypedInterpolationValue::create(*interpolationType, result.in
terpolableValue.release(), result.nonInterpolableValue.release()); | 76 return TypedInterpolationValue::create(*interpolationType, std::move
(result.interpolableValue), result.nonInterpolableValue.release()); |
| 77 } | 77 } |
| 78 return nullptr; | 78 return nullptr; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool InvalidatableInterpolation::dependsOnUnderlyingValue() const | 81 bool InvalidatableInterpolation::dependsOnUnderlyingValue() const |
| 82 { | 82 { |
| 83 return (m_startKeyframe->underlyingFraction() != 0 && m_currentFraction != 1
) || (m_endKeyframe->underlyingFraction() != 0 && m_currentFraction != 0); | 83 return (m_startKeyframe->underlyingFraction() != 0 && m_currentFraction != 1
) || (m_endKeyframe->underlyingFraction() != 0 && m_currentFraction != 0); |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool InvalidatableInterpolation::isNeutralKeyframeActive() const | 86 bool InvalidatableInterpolation::isNeutralKeyframeActive() const |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return m_cachedValue.get(); | 121 return m_cachedValue.get(); |
| 122 clearCache(); | 122 clearCache(); |
| 123 if (m_currentFraction == 0) { | 123 if (m_currentFraction == 0) { |
| 124 m_cachedValue = convertSingleKeyframe(*m_startKeyframe, environment, und
erlyingValueOwner); | 124 m_cachedValue = convertSingleKeyframe(*m_startKeyframe, environment, und
erlyingValueOwner); |
| 125 } else if (m_currentFraction == 1) { | 125 } else if (m_currentFraction == 1) { |
| 126 m_cachedValue = convertSingleKeyframe(*m_endKeyframe, environment, under
lyingValueOwner); | 126 m_cachedValue = convertSingleKeyframe(*m_endKeyframe, environment, under
lyingValueOwner); |
| 127 } else { | 127 } else { |
| 128 OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = maybeConvert
Pairwise(environment, underlyingValueOwner); | 128 OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = maybeConvert
Pairwise(environment, underlyingValueOwner); |
| 129 if (pairwiseConversion) { | 129 if (pairwiseConversion) { |
| 130 m_cachedValue = pairwiseConversion->initialValue(); | 130 m_cachedValue = pairwiseConversion->initialValue(); |
| 131 m_cachedPairConversion = pairwiseConversion.release(); | 131 m_cachedPairConversion = std::move(pairwiseConversion); |
| 132 } else { | 132 } else { |
| 133 m_cachedPairConversion = FlipPrimitiveInterpolation::create( | 133 m_cachedPairConversion = FlipPrimitiveInterpolation::create( |
| 134 convertSingleKeyframe(*m_startKeyframe, environment, underlyingV
alueOwner), | 134 convertSingleKeyframe(*m_startKeyframe, environment, underlyingV
alueOwner), |
| 135 convertSingleKeyframe(*m_endKeyframe, environment, underlyingVal
ueOwner)); | 135 convertSingleKeyframe(*m_endKeyframe, environment, underlyingVal
ueOwner)); |
| 136 } | 136 } |
| 137 m_cachedPairConversion->interpolateValue(m_currentFraction, m_cachedValu
e); | 137 m_cachedPairConversion->interpolateValue(m_currentFraction, m_cachedValu
e); |
| 138 } | 138 } |
| 139 m_isCached = true; | 139 m_isCached = true; |
| 140 return m_cachedValue.get(); | 140 return m_cachedValue.get(); |
| 141 } | 141 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 underlyingValueOwner.set(currentValue); | 202 underlyingValueOwner.set(currentValue); |
| 203 else | 203 else |
| 204 currentValue->type().composite(underlyingValueOwner, underlyingFract
ion, currentValue->value(), currentInterpolation.m_currentFraction); | 204 currentValue->type().composite(underlyingValueOwner, underlyingFract
ion, currentValue->value(), currentInterpolation.m_currentFraction); |
| 205 } | 205 } |
| 206 | 206 |
| 207 if (shouldApply && underlyingValueOwner) | 207 if (shouldApply && underlyingValueOwner) |
| 208 underlyingValueOwner.type().apply(*underlyingValueOwner.value().interpol
ableValue, underlyingValueOwner.value().nonInterpolableValue.get(), environment)
; | 208 underlyingValueOwner.type().apply(*underlyingValueOwner.value().interpol
ableValue, underlyingValueOwner.value().nonInterpolableValue.get(), environment)
; |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace blink | 211 } // namespace blink |
| OLD | NEW |