| 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 16 matching lines...) Expand all Loading... |
| 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 | 35 |
| 36 switch (clamp) { | 36 switch (clamp) { |
| 37 case RangeAll: |
| 38 // Do nothing |
| 39 break; |
| 40 case RangeZeroToOne: |
| 41 doubleValue = clampTo<float>(doubleValue, 0, 1); |
| 42 break; |
| 37 case RangeOpacityFIXME: | 43 case RangeOpacityFIXME: |
| 38 doubleValue = clampTo<float>(doubleValue, 0, nextafterf(1, 0)); | 44 doubleValue = clampTo<float>(doubleValue, 0, nextafter(1, 0)); |
| 45 break; |
| 46 case RangeFloor: |
| 47 doubleValue = floor(doubleValue); |
| 48 break; |
| 49 case RangePositive: |
| 50 doubleValue = clampTo<double>(doubleValue, nextafterf(0, 1)); |
| 51 break; |
| 52 case RangeRound: |
| 53 doubleValue = round(doubleValue); |
| 54 break; |
| 55 case RangeRoundGreaterThanOrEqualToOne: |
| 56 doubleValue = clampTo<float>(round(doubleValue), 1); |
| 57 break; |
| 58 case RangeGreaterThanOrEqualToOne: |
| 59 doubleValue = clampTo<float>(doubleValue, 1); |
| 39 break; | 60 break; |
| 40 case RangeNonNegative: | 61 case RangeNonNegative: |
| 41 doubleValue = clampTo<float>(doubleValue, 0); | 62 doubleValue = clampTo<float>(doubleValue, 0); |
| 42 break; | 63 break; |
| 43 case RangeAll: | |
| 44 break; | |
| 45 default: | 64 default: |
| 46 ASSERT_NOT_REACHED(); | 65 ASSERT_NOT_REACHED(); |
| 47 } | 66 } |
| 48 | |
| 49 if (isNumber) | 67 if (isNumber) |
| 50 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM
BER); | 68 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM
BER); |
| 51 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); | 69 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); |
| 52 } | 70 } |
| 53 | 71 |
| 54 void DoubleStyleInterpolation::apply(StyleResolverState& state) const | 72 void DoubleStyleInterpolation::apply(StyleResolverState& state) const |
| 55 { | 73 { |
| 56 if (m_id != CSSPropertyMotionRotation) { | 74 if (m_id != CSSPropertyMotionRotation) { |
| 57 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac
hedValue.get(), m_isNumber, m_clamp).get()); | 75 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac
hedValue.get(), m_isNumber, m_clamp).get()); |
| 58 return; | 76 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 || startRotationType != endRotationType) | 146 || startRotationType != endRotationType) |
| 129 return nullptr; | 147 return nullptr; |
| 130 | 148 |
| 131 return adoptRefWillBeNoop(new DoubleStyleInterpolation( | 149 return adoptRefWillBeNoop(new DoubleStyleInterpolation( |
| 132 motionRotationToInterpolableValue(start), | 150 motionRotationToInterpolableValue(start), |
| 133 motionRotationToInterpolableValue(end), | 151 motionRotationToInterpolableValue(end), |
| 134 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); | 152 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); |
| 135 } | 153 } |
| 136 | 154 |
| 137 } | 155 } |
| OLD | NEW |