| 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/LengthStyleInterpolation.h" | 6 #include "core/animation/LengthStyleInterpolation.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 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 unsigned unitTypeCount = 0; | 88 unsigned unitTypeCount = 0; |
| 89 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | 89 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| 90 const InterpolableNumber* subType = toInterpolableNumber(listOfTypes->ge
t(i)); | 90 const InterpolableNumber* subType = toInterpolableNumber(listOfTypes->ge
t(i)); |
| 91 if (subType->value()) { | 91 if (subType->value()) { |
| 92 unitTypeCount++; | 92 unitTypeCount++; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 switch (unitTypeCount) { | 96 switch (unitTypeCount) { |
| 97 case 0: | 97 case 0: |
| 98 ASSERT_NOT_REACHED(); | 98 // TODO: this case should never be reached. This issue should be fixed o
nce we have multiple interpolators. |
| 99 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX); |
| 99 case 1: | 100 case 1: |
| 100 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | 101 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| 101 const InterpolableNumber *subValueType = toInterpolableNumber(listOf
Types->get(i)); | 102 const InterpolableNumber *subValueType = toInterpolableNumber(listOf
Types->get(i)); |
| 102 if (subValueType->value()) { | 103 if (subValueType->value()) { |
| 103 double value = toInterpolableNumber(listOfValues->get(i))->value
(); | 104 double value = toInterpolableNumber(listOfValues->get(i))->value
(); |
| 104 if (range == ValueRangeNonNegative && value < 0) | 105 if (range == ValueRangeNonNegative && value < 0) |
| 105 value = 0; | 106 value = 0; |
| 106 return CSSPrimitiveValue::create(value, toUnitType(i)); | 107 return CSSPrimitiveValue::create(value, toUnitType(i)); |
| 107 } | 108 } |
| 108 } | 109 } |
| 109 ASSERT_NOT_REACHED(); | 110 ASSERT_NOT_REACHED(); |
| 110 default: | 111 default: |
| 111 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre
ssion(nullptr, listOfValuesAndTypes, 0), range)); | 112 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre
ssion(nullptr, listOfValuesAndTypes, 0), range)); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 void LengthStyleInterpolation::apply(StyleResolverState& state) const | 116 void LengthStyleInterpolation::apply(StyleResolverState& state) const |
| 116 { | 117 { |
| 117 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV
alue.get(), m_range).get()); | 118 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV
alue.get(), m_range).get()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void LengthStyleInterpolation::trace(Visitor* visitor) | 121 void LengthStyleInterpolation::trace(Visitor* visitor) |
| 121 { | 122 { |
| 122 StyleInterpolation::trace(visitor); | 123 StyleInterpolation::trace(visitor); |
| 123 } | 124 } |
| 124 | 125 |
| 125 } | 126 } |
| OLD | NEW |