| 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 "core/animation/DoubleStyleInterpolation.h" | 5 #include "core/animation/DoubleStyleInterpolation.h" |
| 6 | 6 |
| 7 #include "core/css/CSSValueList.h" | 7 #include "core/css/CSSValueList.h" |
| 8 #include "core/css/resolver/StyleBuilder.h" | 8 #include "core/css/resolver/StyleBuilder.h" |
| 9 #include "core/style/ComputedStyleConstants.h" | 9 #include "core/style/ComputedStyleConstants.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 case RangeGreaterThanOrEqualToOne: | 46 case RangeGreaterThanOrEqualToOne: |
| 47 return clampTo<float>(value, 1); | 47 return clampTo<float>(value, 1); |
| 48 case RangeNonNegative: | 48 case RangeNonNegative: |
| 49 return clampTo<float>(value, 0); | 49 return clampTo<float>(value, 0); |
| 50 default: | 50 default: |
| 51 ASSERT_NOT_REACHED(); | 51 ASSERT_NOT_REACHED(); |
| 52 return value; | 52 return value; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDo
uble(const InterpolableValue* value, bool isNumber, InterpolationRange clamp) | 56 RawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToDouble(const Inter
polableValue* value, bool isNumber, InterpolationRange clamp) |
| 57 { | 57 { |
| 58 ASSERT(value->isNumber()); | 58 ASSERT(value->isNumber()); |
| 59 double doubleValue = clampToRange(toInterpolableNumber(value)->value(), clam
p); | 59 double doubleValue = clampToRange(toInterpolableNumber(value)->value(), clam
p); |
| 60 | 60 |
| 61 if (isNumber) | 61 if (isNumber) |
| 62 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::UnitTyp
e::Number); | 62 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::UnitTyp
e::Number); |
| 63 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::UnitType::D
egrees); | 63 return CSSPrimitiveValue::create(doubleValue, CSSPrimitiveValue::UnitType::D
egrees); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void DoubleStyleInterpolation::apply(StyleResolverState& state) const | 66 void DoubleStyleInterpolation::apply(StyleResolverState& state) const |
| 67 { | 67 { |
| 68 if (m_id != CSSPropertyMotionRotation) { | 68 if (m_id != CSSPropertyMotionRotation) { |
| 69 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac
hedValue.get(), m_isNumber, m_clamp).get()); | 69 StyleBuilder::applyProperty(m_id, state, interpolableValueToDouble(m_cac
hedValue.get(), m_isNumber, m_clamp).get()); |
| 70 return; | 70 return; |
| 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 PassOwnPtr<InterpolableValue> DoubleStyleInterpolation::toInterpolableValue(cons
t CSSValue& value, CSSPropertyID property) | 76 PassOwnPtr<InterpolableValue> DoubleStyleInterpolation::toInterpolableValue(cons
t CSSValue& value, CSSPropertyID property) |
| 77 { | 77 { |
| 78 ASSERT(canCreateFrom(value)); | 78 ASSERT(canCreateFrom(value)); |
| 79 return doubleToInterpolableValue(value); | 79 return doubleToInterpolableValue(value); |
| 80 } | 80 } |
| 81 | 81 |
| 82 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::fromInterpolableValue
(const InterpolableValue& value, InterpolationRange range) | 82 RawPtr<CSSValue> DoubleStyleInterpolation::fromInterpolableValue(const Interpola
bleValue& value, InterpolationRange range) |
| 83 { | 83 { |
| 84 return interpolableValueToDouble(&value, true, range); | 84 return interpolableValueToDouble(&value, true, range); |
| 85 } | 85 } |
| 86 | 86 |
| 87 namespace { | 87 namespace { |
| 88 | 88 |
| 89 bool extractMotionRotation(const CSSValue& value, float* rotation, MotionRotatio
nType* rotationType) | 89 bool extractMotionRotation(const CSSValue& value, float* rotation, MotionRotatio
nType* rotationType) |
| 90 { | 90 { |
| 91 *rotation = 0; | 91 *rotation = 0; |
| 92 *rotationType = MotionRotationFixed; | 92 *rotationType = MotionRotationFixed; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 110 *rotation += primitiveValue->computeDegrees(); | 110 *rotation += primitiveValue->computeDegrees(); |
| 111 } else { | 111 } else { |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 PassRefPtrWillBeRawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToMo
tionRotation(InterpolableValue* value, bool flag) | 120 RawPtr<CSSValue> DoubleStyleInterpolation::interpolableValueToMotionRotation(Int
erpolableValue* value, bool flag) |
| 121 { | 121 { |
| 122 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 122 RawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
| 123 if (flag) | 123 if (flag) |
| 124 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); | 124 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); |
| 125 ASSERT(value->isNumber()); | 125 ASSERT(value->isNumber()); |
| 126 list->append(CSSPrimitiveValue::create(toInterpolableNumber(value)->value(),
CSSPrimitiveValue::UnitType::Degrees)); | 126 list->append(CSSPrimitiveValue::create(toInterpolableNumber(value)->value(),
CSSPrimitiveValue::UnitType::Degrees)); |
| 127 return list.release(); | 127 return list.release(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 PassOwnPtr<InterpolableValue> DoubleStyleInterpolation::motionRotationToInterpol
ableValue(const CSSValue& value) | 130 PassOwnPtr<InterpolableValue> DoubleStyleInterpolation::motionRotationToInterpol
ableValue(const CSSValue& value) |
| 131 { | 131 { |
| 132 float rotation; | 132 float rotation; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 146 || startRotationType != endRotationType) | 146 || startRotationType != endRotationType) |
| 147 return nullptr; | 147 return nullptr; |
| 148 | 148 |
| 149 return adoptRef(new DoubleStyleInterpolation( | 149 return adoptRef(new DoubleStyleInterpolation( |
| 150 motionRotationToInterpolableValue(start), | 150 motionRotationToInterpolableValue(start), |
| 151 motionRotationToInterpolableValue(end), | 151 motionRotationToInterpolableValue(end), |
| 152 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); | 152 id, true, InterpolationRange::RangeAll, startRotationType == MotionRotat
ionAuto)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace blink | 155 } // namespace blink |
| OLD | NEW |