Chromium Code Reviews| 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 RangeFractions: | |
|
dstockwell
2015/02/04 11:09:28
Why did this one get renamed from RangeOpacityFIXM
alancutter (OOO until 2018)
2015/02/04 20:24:37
RangeZeroToLessThanOne for clarity.
BTW, you shoul
jadeg
2015/02/05 23:37:02
I renamed it because Eve named it this in her Inte
| |
| 40 doubleValue = clampTo<float>(doubleValue, 0, nextafter(1, 0)); | |
| 41 break; | |
| 42 case RangeFloor: | |
| 43 doubleValue = floor(doubleValue); | |
| 44 break; | |
| 45 case RangeGreaterThanZero: | |
|
alancutter (OOO until 2018)
2015/02/04 20:24:37
RangePositive?
jadeg
2015/02/05 23:37:02
Done.
| |
| 46 doubleValue = clampTo<double>(doubleValue, nextafterf(0, 1)); | |
| 47 break; | |
| 48 case RangeRound: | |
|
alancutter (OOO until 2018)
2015/02/04 20:24:37
RangeRoundPositive for clarity.
jadeg
2015/02/05 23:37:02
Done.
| |
| 49 doubleValue = clampTo<int>((doubleValue + 0.5), 1); | |
|
dstockwell
2015/02/04 11:09:27
Just use round?
jadeg
2015/02/05 23:37:02
Done.
| |
| 50 break; | |
| 51 case RangeGreaterThanOne: | |
|
dstockwell
2015/02/04 11:09:27
Isn't this RangeGreaterThanOrEqualToOne?
jadeg
2015/02/05 23:37:02
Done.
| |
| 52 doubleValue = clampTo<float>(doubleValue, 1); | |
| 39 break; | 53 break; |
|
alancutter (OOO until 2018)
2015/02/04 20:24:37
RangeAtLeastOne for correctness.
jadeg
2015/02/05 23:37:02
Done.
| |
| 40 case RangeNonNegative: | 54 case RangeNonNegative: |
| 41 doubleValue = clampTo<float>(doubleValue, 0); | 55 doubleValue = clampTo<float>(doubleValue, 0); |
| 42 break; | 56 break; |
| 43 case RangeAll: | 57 case RangeAbsoluteValueFloor: |
|
alancutter (OOO until 2018)
2015/02/04 20:24:37
RangeRound.
jadeg
2015/02/05 23:37:02
Done.
| |
| 58 if (doubleValue < 0) | |
|
dstockwell
2015/02/04 11:09:28
Doesn't this use round() in AnimatedStyleBuidler.c
jadeg
2015/02/05 23:37:02
Done.
| |
| 59 doubleValue = clampTo<int>(doubleValue - 0.5); | |
| 60 if (doubleValue > 0) | |
| 61 doubleValue = clampTo<int>(doubleValue + 0.5); | |
|
dstockwell
2015/02/04 11:09:28
Does this still work without the clampTo<int>? (ju
alancutter (OOO until 2018)
2015/02/04 20:24:37
Just use round() instead of (doubleValue + 0.5) he
jadeg
2015/02/05 23:37:02
Done.
jadeg
2015/02/05 23:37:02
Done.
| |
| 44 break; | 62 break; |
| 45 default: | |
| 46 ASSERT_NOT_REACHED(); | |
|
alancutter (OOO until 2018)
2015/02/04 20:24:37
Leave this assert in.
jadeg
2015/02/05 23:37:02
Done.
| |
| 47 } | 63 } |
| 48 | |
| 49 if (isNumber) | 64 if (isNumber) |
| 50 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM BER); | 65 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM BER); |
| 51 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); | 66 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); |
| 52 } | 67 } |
| 53 | 68 |
| 54 void DoubleStyleInterpolation::apply(StyleResolverState& state) const | 69 void DoubleStyleInterpolation::apply(StyleResolverState& state) const |
| 55 { | 70 { |
| 56 if (m_id != CSSPropertyMotionRotation) { | 71 if (m_id != CSSPropertyMotionRotation) { |
| 57 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac hedValue.get(), m_isNumber, m_clamp).get()); | 72 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac hedValue.get(), m_isNumber, m_clamp).get()); |
| 58 return; | 73 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 || startRotationType != endRotationType) | 143 || startRotationType != endRotationType) |
| 129 return nullptr; | 144 return nullptr; |
| 130 | 145 |
| 131 return adoptRefWillBeNoop(new DoubleStyleInterpolation( | 146 return adoptRefWillBeNoop(new DoubleStyleInterpolation( |
| 132 motionRotationToInterpolableValue(start), | 147 motionRotationToInterpolableValue(start), |
| 133 motionRotationToInterpolableValue(end), | 148 motionRotationToInterpolableValue(end), |
| 134 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat ionAuto)); | 149 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat ionAuto)); |
| 135 } | 150 } |
| 136 | 151 |
| 137 } | 152 } |
| OLD | NEW |