Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: Source/core/animation/DoubleStyleInterpolation.cpp

Issue 811993002: Animation: Implement DoubleStyleInterpolation in StringKeyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Implement value cache function Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/animation/Keyframe.h » ('j') | Source/core/animation/Keyframe.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 RangeFloatFractions:
40 doubleValue = clampTo<float>(doubleValue, 0, nextafter(1, 0));
41 break;
42 case RangeFloor:
43 doubleValue = floor(doubleValue);
44 break;
45 case RangeDoubleFractions:
46 doubleValue = clampTo<double>(doubleValue, 0.000000000000000000000000000 000000000000000001);
Eric Willigers 2015/01/28 22:24:44 Consider using clampTo<double>(doubleValue, std:
47 break;
48 case RangeCeiling:
49 doubleValue = clampTo<int>((doubleValue + 0.5), 1);
50 break;
51 case RangeGreaterThanOne:
52 doubleValue = clampTo<float>(doubleValue, 1);
39 break; 53 break;
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:
44 break;
45 default:
46 ASSERT_NOT_REACHED();
47 } 57 }
48
49 if (isNumber) 58 if (isNumber)
50 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM BER); 59 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUM BER);
51 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG); 60 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_DEG);
52 } 61 }
53 62
54 void DoubleStyleInterpolation::apply(StyleResolverState& state) const 63 void DoubleStyleInterpolation::apply(StyleResolverState& state) const
55 { 64 {
56 if (m_id != CSSPropertyMotionRotation) { 65 if (m_id != CSSPropertyMotionRotation) {
57 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac hedValue.get(), m_isNumber, m_clamp).get()); 66 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac hedValue.get(), m_isNumber, m_clamp).get());
58 return; 67 return;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 || startRotationType != endRotationType) 137 || startRotationType != endRotationType)
129 return nullptr; 138 return nullptr;
130 139
131 return adoptRefWillBeNoop(new DoubleStyleInterpolation( 140 return adoptRefWillBeNoop(new DoubleStyleInterpolation(
132 motionRotationToInterpolableValue(start), 141 motionRotationToInterpolableValue(start),
133 motionRotationToInterpolableValue(end), 142 motionRotationToInterpolableValue(end),
134 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat ionAuto)); 143 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat ionAuto));
135 } 144 }
136 145
137 } 146 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/animation/Keyframe.h » ('j') | Source/core/animation/Keyframe.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698