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

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: Add length Prtoperty 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
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/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/resolver/StyleBuilder.h" 10 #include "core/css/resolver/StyleBuilder.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte rpolableValue(const CSSValue& value) 14 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte rpolableValue(const CSSValue& value)
15 { 15 {
16 ASSERT(canCreateFrom(value)); 16 ASSERT(canCreateFrom(value));
17 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); 17 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
18 return InterpolableNumber::create(primitive.getDoubleValue()); 18 return InterpolableNumber::create(primitive.getDoubleValue());
19 } 19 }
20 20
21 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo uble(InterpolableValue* value, ClampRange clamp) 21 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo uble(InterpolableValue* value, ClampRange clamp)
22 { 22 {
23 ASSERT(value->isNumber()); 23 ASSERT(value->isNumber());
24 double doubleValue = toInterpolableNumber(value)->value(); 24 double doubleValue = toInterpolableNumber(value)->value();
25 if (clamp == ClampOpacity) { 25 if (clamp == ClampOpacity)
Eric Willigers 2015/01/14 01:43:36 switch (clamp)
jadeg 2015/01/18 22:59:41 Done.
26 doubleValue = clampTo<float>(doubleValue, 0, nextafterf(1, 0)); 26 doubleValue = clampTo<float>(doubleValue, 0, nextafter(0.9999, 0));
27 } 27 if (clamp == ClampInteger)
28 doubleValue = floor(doubleValue);
29 if (clamp == ClampZoom)
30 doubleValue = clampTo<float>(doubleValue, 0.0000000000000000000000000000 00000000000000001);
31 if (clamp == ClampOrphans)
32 doubleValue = clampTo<int>((doubleValue + 0.5), 1);
33 if (clamp == ClampOne)
34 doubleValue = clampTo<float>(doubleValue, 1);
35 if (clamp == ClampZero)
36 doubleValue = clampTo<float>(doubleValue, 0);
28 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUMBER) ; 37 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::CSS_NUMBER) ;
29 } 38 }
30 39
31 bool DoubleStyleInterpolation::canCreateFrom(const CSSValue& value) 40 bool DoubleStyleInterpolation::canCreateFrom(const CSSValue& value)
32 { 41 {
33 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).isNumber(); 42 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).isNumber();
34 } 43 }
35 44
36 void DoubleStyleInterpolation::apply(StyleResolverState& state) const 45 void DoubleStyleInterpolation::apply(StyleResolverState& state) const
37 { 46 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 || startRotationType != endRotationType) 119 || startRotationType != endRotationType)
111 return nullptr; 120 return nullptr;
112 121
113 return adoptRefWillBeNoop(new DoubleStyleInterpolation( 122 return adoptRefWillBeNoop(new DoubleStyleInterpolation(
114 motionRotationToInterpolableValue(start), 123 motionRotationToInterpolableValue(start),
115 motionRotationToInterpolableValue(end), 124 motionRotationToInterpolableValue(end),
116 id, NoClamp, startRotationType == MotionRotationAuto)); 125 id, NoClamp, startRotationType == MotionRotationAuto));
117 } 126 }
118 127
119 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698