| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/DoubleStyleInterpolation.h" | 6 #include "core/animation/DoubleStyleInterpolation.h" |
| 7 | 7 |
| 8 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
| 9 #include "core/css/resolver/StyleBuilder.h" | 9 #include "core/css/resolver/StyleBuilder.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 if (primitive.isAngle()) | 25 if (primitive.isAngle()) |
| 26 return InterpolableNumber::create(primitive.computeDegrees()); | 26 return InterpolableNumber::create(primitive.computeDegrees()); |
| 27 ASSERT_NOT_REACHED(); | 27 ASSERT_NOT_REACHED(); |
| 28 return nullptr; | 28 return nullptr; |
| 29 } | 29 } |
| 30 | 30 |
| 31 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo
uble(InterpolableValue* value, bool isNumber, InterpolationRange clamp) | 31 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo
uble(InterpolableValue* value, bool isNumber, InterpolationRange clamp) |
| 32 { | 32 { |
| 33 ASSERT(value->isNumber()); | 33 ASSERT(value->isNumber()); |
| 34 double doubleValue = toInterpolableNumber(value)->value(); | 34 double doubleValue = toInterpolableNumber(value)->value(); |
| 35 | |
| 36 switch (clamp) { | 35 switch (clamp) { |
| 37 case RangeOpacityFIXME: | 36 case RangeAll: |
| 38 doubleValue = clampTo<float>(doubleValue, 0, nextafterf(1, 0)); | 37 // Do nothing |
| 38 break; |
| 39 case RangeZeroToOne: |
| 40 doubleValue = clampTo<float>(doubleValue, 0, 1); |
| 41 break; |
| 42 case RangeZeroToLessThanOne: |
| 43 doubleValue = clampTo<float>(doubleValue, 0, nextafter(1, 0)); |
| 44 break; |
| 45 case RangeFloor: |
| 46 doubleValue = floor(doubleValue); |
| 47 break; |
| 48 case RangePositive: |
| 49 doubleValue = clampTo<double>(doubleValue, nextafterf(0, 1)); |
| 50 break; |
| 51 case RangeRound: |
| 52 doubleValue = round(doubleValue); |
| 53 break; |
| 54 case RangeGreaterThanOrEqualToOne: |
| 55 doubleValue = clampTo<float>(doubleValue, 1); |
| 39 break; | 56 break; |
| 40 case RangeNonNegative: | 57 case RangeNonNegative: |
| 41 doubleValue = clampTo<float>(doubleValue, 0); | 58 doubleValue = clampTo<float>(doubleValue, 0); |
| 42 break; | 59 break; |
| 43 case RangeAll: | |
| 44 break; | |
| 45 default: | 60 default: |
| 46 ASSERT_NOT_REACHED(); | 61 ASSERT_NOT_REACHED(); |
| 47 } | 62 } |
| 48 | |
| 49 if (isNumber) | 63 if (isNumber) |
| 50 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM
BER); | 64 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM
BER); |
| 51 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); | 65 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); |
| 52 } | 66 } |
| 53 | 67 |
| 54 void DoubleStyleInterpolation::apply(StyleResolverState& state) const | 68 void DoubleStyleInterpolation::apply(StyleResolverState& state) const |
| 55 { | 69 { |
| 56 if (m_id != CSSPropertyMotionRotation) { | 70 if (m_id != CSSPropertyMotionRotation) { |
| 57 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac
hedValue.get(), m_isNumber, m_clamp).get()); | 71 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac
hedValue.get(), m_isNumber, m_clamp).get()); |
| 58 return; | 72 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 || startRotationType != endRotationType) | 142 || startRotationType != endRotationType) |
| 129 return nullptr; | 143 return nullptr; |
| 130 | 144 |
| 131 return adoptRefWillBeNoop(new DoubleStyleInterpolation( | 145 return adoptRefWillBeNoop(new DoubleStyleInterpolation( |
| 132 motionRotationToInterpolableValue(start), | 146 motionRotationToInterpolableValue(start), |
| 133 motionRotationToInterpolableValue(end), | 147 motionRotationToInterpolableValue(end), |
| 134 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); | 148 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); |
| 135 } | 149 } |
| 136 | 150 |
| 137 } | 151 } |
| OLD | NEW |