| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 StyleBuilder::applyProperty(m_id, state, interpolableValueToMotionRotation(m
_cachedValue.get(), m_flag).get()); | 73 StyleBuilder::applyProperty(m_id, state, interpolableValueToMotionRotation(m
_cachedValue.get(), m_flag).get()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 DEFINE_TRACE(DoubleStyleInterpolation) | 76 DEFINE_TRACE(DoubleStyleInterpolation) |
| 77 { | 77 { |
| 78 StyleInterpolation::trace(visitor); | 78 StyleInterpolation::trace(visitor); |
| 79 } | 79 } |
| 80 | 80 |
| 81 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::toInterpolab
leValue(const CSSValue& value, CSSPropertyID property) | 81 InterpolableValue* DoubleStyleInterpolation::toInterpolableValue(const CSSValue&
value, CSSPropertyID property) |
| 82 { | 82 { |
| 83 ASSERT(canCreateFrom(value)); | 83 ASSERT(canCreateFrom(value)); |
| 84 return doubleToInterpolableValue(value); | 84 return doubleToInterpolableValue(value); |
| 85 } | 85 } |
| 86 | 86 |
| 87 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::fromInterpolableValue
(const InterpolableValue& value, InterpolationRange range) | 87 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::fromInterpolableValue
(const InterpolableValue& value, InterpolationRange range) |
| 88 { | 88 { |
| 89 return interpolableValueToDouble(&value, true, range); | 89 return interpolableValueToDouble(&value, true, range); |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToMo
tionRotation(InterpolableValue* value, bool flag) | 125 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToMo
tionRotation(InterpolableValue* value, bool flag) |
| 126 { | 126 { |
| 127 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 127 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
| 128 if (flag) | 128 if (flag) |
| 129 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); | 129 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); |
| 130 ASSERT(value->isNumber()); | 130 ASSERT(value->isNumber()); |
| 131 list->append(CSSPrimitiveValue::create(toInterpolableNumber(value)->value(),
CSSPrimitiveValue::UnitType::Degrees)); | 131 list->append(CSSPrimitiveValue::create(toInterpolableNumber(value)->value(),
CSSPrimitiveValue::UnitType::Degrees)); |
| 132 return list.release(); | 132 return list.release(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 PassOwnPtrWillBeRawPtr<InterpolableValue> DoubleStyleInterpolation::motionRotati
onToInterpolableValue(const CSSValue& value) | 135 InterpolableValue* DoubleStyleInterpolation::motionRotationToInterpolableValue(c
onst CSSValue& value) |
| 136 { | 136 { |
| 137 float rotation; | 137 float rotation; |
| 138 MotionRotationType rotationType; | 138 MotionRotationType rotationType; |
| 139 extractMotionRotation(value, &rotation, &rotationType); | 139 extractMotionRotation(value, &rotation, &rotationType); |
| 140 | 140 |
| 141 return InterpolableNumber::create(rotation); | 141 return InterpolableNumber::create(rotation); |
| 142 } | 142 } |
| 143 | 143 |
| 144 PassRefPtrWillBeRawPtr<DoubleStyleInterpolation> DoubleStyleInterpolation::maybe
CreateFromMotionRotation(const CSSValue& start, const CSSValue& end, CSSProperty
ID id) | 144 DoubleStyleInterpolation* DoubleStyleInterpolation::maybeCreateFromMotionRotatio
n(const CSSValue& start, const CSSValue& end, CSSPropertyID id) |
| 145 { | 145 { |
| 146 float startRotation, endRotation; | 146 float startRotation, endRotation; |
| 147 MotionRotationType startRotationType, endRotationType; | 147 MotionRotationType startRotationType, endRotationType; |
| 148 | 148 |
| 149 if (!extractMotionRotation(start, &startRotation, &startRotationType) | 149 if (!extractMotionRotation(start, &startRotation, &startRotationType) |
| 150 || !extractMotionRotation(end, &endRotation, &endRotationType) | 150 || !extractMotionRotation(end, &endRotation, &endRotationType) |
| 151 || startRotationType != endRotationType) | 151 || startRotationType != endRotationType) |
| 152 return nullptr; | 152 return nullptr; |
| 153 | 153 |
| 154 return adoptRefWillBeNoop(new DoubleStyleInterpolation( | 154 return new DoubleStyleInterpolation(motionRotationToInterpolableValue(start)
, motionRotationToInterpolableValue(end), id, true, InterpolationRange::RangeAll
, startRotationType == MotionRotationAuto); |
| 155 motionRotationToInterpolableValue(start), | |
| 156 motionRotationToInterpolableValue(end), | |
| 157 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); | |
| 158 } | 155 } |
| 159 | 156 |
| 160 } | 157 } |
| OLD | NEW |