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 |
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 InterpolableValue* DoubleStyleInterpolation::doubleToInterpolableValue(const CSS
Value& 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 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToMo
tionRotation(InterpolableValue* value, bool flag) | 116 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToMo
tionRotation(InterpolableValue* value, bool flag) |
117 { | 117 { |
118 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 118 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
119 if (flag) | 119 if (flag) |
120 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); | 120 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); |
121 ASSERT(value->isNumber()); | 121 ASSERT(value->isNumber()); |
122 list->append(CSSPrimitiveValue::create(toInterpolableNumber(value)->value(),
CSSPrimitiveValue::CSS_DEG)); | 122 list->append(CSSPrimitiveValue::create(toInterpolableNumber(value)->value(),
CSSPrimitiveValue::CSS_DEG)); |
123 return list.release(); | 123 return list.release(); |
124 } | 124 } |
125 | 125 |
126 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::motionRotati
onToInterpolableValue(const CSSValue& value) | 126 InterpolableValue* DoubleStyleInterpolation::motionRotationToInterpolableValue(c
onst CSSValue& value) |
127 { | 127 { |
128 float rotation; | 128 float rotation; |
129 MotionRotationType rotationType; | 129 MotionRotationType rotationType; |
130 extractMotionRotation(value, &rotation, &rotationType); | 130 extractMotionRotation(value, &rotation, &rotationType); |
131 | 131 |
132 return InterpolableNumber::create(rotation); | 132 return InterpolableNumber::create(rotation); |
133 } | 133 } |
134 | 134 |
135 PassRefPtrWillBeRawPtr<DoubleStyleInterpolation> DoubleStyleInterpolation::maybe
CreateFromMotionRotation(const CSSValue& start, const CSSValue& end, CSSProperty
ID id) | 135 DoubleStyleInterpolation* DoubleStyleInterpolation::maybeCreateFromMotionRotatio
n(const CSSValue& start, const CSSValue& end, CSSPropertyID id) |
136 { | 136 { |
137 float startRotation, endRotation; | 137 float startRotation, endRotation; |
138 MotionRotationType startRotationType, endRotationType; | 138 MotionRotationType startRotationType, endRotationType; |
139 | 139 |
140 if (!extractMotionRotation(start, &startRotation, &startRotationType) | 140 if (!extractMotionRotation(start, &startRotation, &startRotationType) |
141 || !extractMotionRotation(end, &endRotation, &endRotationType) | 141 || !extractMotionRotation(end, &endRotation, &endRotationType) |
142 || startRotationType != endRotationType) | 142 || startRotationType != endRotationType) |
143 return nullptr; | 143 return nullptr; |
144 | 144 |
145 return adoptRefWillBeNoop(new DoubleStyleInterpolation( | 145 return new DoubleStyleInterpolation(motionRotationToInterpolableValue(start)
, motionRotationToInterpolableValue(end), id, true, InterpolationRange::RangeAll
, startRotationType == MotionRotationAuto); |
146 motionRotationToInterpolableValue(start), | |
147 motionRotationToInterpolableValue(end), | |
148 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); | |
149 } | 146 } |
150 | 147 |
151 } | 148 } |
OLD | NEW |