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

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

Issue 1225553002: CSSValue Immediates: Make CSSPrimitiveValue a container (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase Created 5 years, 4 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/resolver/StyleBuilder.h" 9 #include "core/css/resolver/StyleBuilder.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 bool DoubleStyleInterpolation::canCreateFrom(const CSSValue& value) 13 bool DoubleStyleInterpolation::canCreateFrom(const CSSValue& value)
14 { 14 {
15 return value.isPrimitiveValue() && (toCSSPrimitiveValue(value).isNumber() || toCSSPrimitiveValue(value).isAngle()); 15 return value.isPrimitiveValue() && (toCSSPrimitiveValue(value).isNumber() || toCSSPrimitiveValue(value).isAngle());
16 } 16 }
17 17
18 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte rpolableValue(const CSSValue& value) 18 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::doubleToInte rpolableValue(const CSSValue& value)
19 { 19 {
20 ASSERT(canCreateFrom(value)); 20 ASSERT(canCreateFrom(value));
21 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); 21 const CSSPrimitiveValue primitive = toCSSPrimitiveValue(value);
22 if (primitive.isNumber()) 22 if (primitive.isNumber())
23 return InterpolableNumber::create(primitive.getDoubleValue()); 23 return InterpolableNumber::create(primitive.getDoubleValue());
24 if (primitive.isAngle()) 24 if (primitive.isAngle())
25 return InterpolableNumber::create(primitive.computeDegrees()); 25 return InterpolableNumber::create(primitive.computeDegrees());
26 ASSERT_NOT_REACHED(); 26 ASSERT_NOT_REACHED();
27 return nullptr; 27 return nullptr;
28 } 28 }
29 29
30 static double clampToRange(double value, InterpolationRange clamp) 30 static double clampToRange(double value, InterpolationRange clamp)
31 { 31 {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 if (!value.isValueList()) 99 if (!value.isValueList())
100 return false; 100 return false;
101 const CSSValueList& list = toCSSValueList(value); 101 const CSSValueList& list = toCSSValueList(value);
102 102
103 int len = list.length(); 103 int len = list.length();
104 for (int i = 0; i < len; i++) { 104 for (int i = 0; i < len; i++) {
105 const CSSValue item = list.item(i); 105 const CSSValue item = list.item(i);
106 if (!item.isPrimitiveValue()) 106 if (!item.isPrimitiveValue())
107 return false; 107 return false;
108 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(item); 108 const CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(item);
109 if (primitiveValue.getValueID() == CSSValueAuto) { 109 if (primitiveValue.getValueID() == CSSValueAuto) {
110 *rotationType = MotionRotationAuto; 110 *rotationType = MotionRotationAuto;
111 } else if (primitiveValue.getValueID() == CSSValueReverse) { 111 } else if (primitiveValue.getValueID() == CSSValueReverse) {
112 *rotationType = MotionRotationAuto; 112 *rotationType = MotionRotationAuto;
113 *rotation += 180; 113 *rotation += 180;
114 } else if (primitiveValue.isAngle()) { 114 } else if (primitiveValue.isAngle()) {
115 *rotation += primitiveValue.computeDegrees(); 115 *rotation += primitiveValue.computeDegrees();
116 } else { 116 } else {
117 return false; 117 return false;
118 } 118 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 || startRotationType != endRotationType) 151 || startRotationType != endRotationType)
152 return nullptr; 152 return nullptr;
153 153
154 return adoptRefWillBeNoop(new DoubleStyleInterpolation( 154 return adoptRefWillBeNoop(new DoubleStyleInterpolation(
155 motionRotationToInterpolableValue(start), 155 motionRotationToInterpolableValue(start),
156 motionRotationToInterpolableValue(end), 156 motionRotationToInterpolableValue(end),
157 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat ionAuto)); 157 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat ionAuto));
158 } 158 }
159 159
160 } 160 }
OLDNEW
« no previous file with comments | « Source/core/animation/DeferredLegacyStyleInterpolation.cpp ('k') | Source/core/animation/DoubleStyleInterpolationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698