| 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/Interpolation.h" | 6 #include "core/animation/Interpolation.h" |
| 7 | 7 |
| 8 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
| 9 #include "core/css/resolver/AnimatedStyleBuilder.h" | 9 #include "core/css/resolver/AnimatedStyleBuilder.h" |
| 10 #include "core/css/resolver/StyleBuilder.h" | 10 #include "core/css/resolver/StyleBuilder.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre
ate(subValue->value(), toUnitType(position))); | 129 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre
ate(subValue->value(), toUnitType(position))); |
| 130 return constructCalcExpression(next, list, position + 1); | 130 return constructCalcExpression(next, list, position + 1); |
| 131 } | 131 } |
| 132 position++; | 132 position++; |
| 133 } | 133 } |
| 134 return previous; | 134 return previous; |
| 135 } | 135 } |
| 136 | 136 |
| 137 } | 137 } |
| 138 | 138 |
| 139 PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe
ngth(InterpolableValue* value) | 139 PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe
ngth(InterpolableValue* value, ValueRange range) |
| 140 { | 140 { |
| 141 InterpolableList* listValue = toInterpolableList(value); | 141 InterpolableList* listValue = toInterpolableList(value); |
| 142 unsigned unitCount = 0; | 142 unsigned unitCount = 0; |
| 143 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | 143 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| 144 const InterpolableNumber* subValue = toInterpolableNumber(listValue->get
(i)); | 144 const InterpolableNumber* subValue = toInterpolableNumber(listValue->get
(i)); |
| 145 if (subValue->value()) { | 145 if (subValue->value()) { |
| 146 unitCount++; | 146 unitCount++; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 switch (unitCount) { | 150 switch (unitCount) { |
| 151 case 0: | 151 case 0: |
| 152 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX); | 152 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX); |
| 153 case 1: | 153 case 1: |
| 154 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | 154 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| 155 const InterpolableNumber* subValue = toInterpolableNumber(listValue-
>get(i)); | 155 const InterpolableNumber* subValue = toInterpolableNumber(listValue-
>get(i)); |
| 156 if (subValue->value()) { | 156 double value = subValue->value(); |
| 157 return CSSPrimitiveValue::create(subValue->value(), toUnitType(i
)); | 157 if (value) { |
| 158 if (range == ValueRangeNonNegative && value < 0) |
| 159 value = 0; |
| 160 return CSSPrimitiveValue::create(value, toUnitType(i)); |
| 158 } | 161 } |
| 159 } | 162 } |
| 163 ASSERT_NOT_REACHED(); |
| 160 default: | 164 default: |
| 161 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre
ssion(nullptr, listValue, 0))); | 165 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre
ssion(nullptr, listValue, 0), range)); |
| 162 } | 166 } |
| 163 } | 167 } |
| 164 | 168 |
| 165 void LengthStyleInterpolation::apply(StyleResolverState& state) const | 169 void LengthStyleInterpolation::apply(StyleResolverState& state) const |
| 166 { | 170 { |
| 167 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV
alue.get()).get()); | 171 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV
alue.get(), m_range).get()); |
| 168 } | 172 } |
| 169 | 173 |
| 170 void LengthStyleInterpolation::trace(Visitor* visitor) | 174 void LengthStyleInterpolation::trace(Visitor* visitor) |
| 171 { | 175 { |
| 172 StyleInterpolation::trace(visitor); | 176 StyleInterpolation::trace(visitor); |
| 173 } | 177 } |
| 174 | 178 |
| 175 void DefaultStyleInterpolation::apply(StyleResolverState& state) const | 179 void DefaultStyleInterpolation::apply(StyleResolverState& state) const |
| 176 { | 180 { |
| 177 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValue.ge
t())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); | 181 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValue.ge
t())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); |
| 178 } | 182 } |
| 179 | 183 |
| 180 void DefaultStyleInterpolation::trace(Visitor* visitor) | 184 void DefaultStyleInterpolation::trace(Visitor* visitor) |
| 181 { | 185 { |
| 182 StyleInterpolation::trace(visitor); | 186 StyleInterpolation::trace(visitor); |
| 183 visitor->trace(m_startCSSValue); | 187 visitor->trace(m_startCSSValue); |
| 184 visitor->trace(m_endCSSValue); | 188 visitor->trace(m_endCSSValue); |
| 185 } | 189 } |
| 186 | 190 |
| 187 } | 191 } |
| OLD | NEW |