| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/LengthInterpolationFunctions.h" | 5 #include "core/animation/LengthInterpolationFunctions.h" |
| 6 | 6 |
| 7 #include "core/css/CSSPrimitiveValue.h" | 7 #include "core/css/CSSPrimitiveValue.h" |
| 8 #include "core/css/CSSToLengthConversionData.h" | 8 #include "core/css/CSSToLengthConversionData.h" |
| 9 #include "platform/CalculationValue.h" | 9 #include "platform/CalculationValue.h" |
| 10 | 10 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 Length LengthInterpolationFunctions::createLength(const InterpolableValue& inter
polableValue, const NonInterpolableValue* nonInterpolableValue, const CSSToLengt
hConversionData& conversionData, ValueRange range) | 144 Length LengthInterpolationFunctions::createLength(const InterpolableValue& inter
polableValue, const NonInterpolableValue* nonInterpolableValue, const CSSToLengt
hConversionData& conversionData, ValueRange range) |
| 145 { | 145 { |
| 146 const InterpolableList& interpolableList = toInterpolableList(interpolableVa
lue); | 146 const InterpolableList& interpolableList = toInterpolableList(interpolableVa
lue); |
| 147 bool hasPercentage = CSSLengthNonInterpolableValue::hasPercentage(nonInterpo
lableValue); | 147 bool hasPercentage = CSSLengthNonInterpolableValue::hasPercentage(nonInterpo
lableValue); |
| 148 double pixels = 0; | 148 double pixels = 0; |
| 149 double percentage = 0; | 149 double percentage = 0; |
| 150 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { | 150 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { |
| 151 double value = toInterpolableNumber(*interpolableList.get(i)).value(); | 151 double value = toInterpolableNumber(*interpolableList.get(i)).value(); |
| 152 if (value == 0) |
| 153 continue; |
| 152 if (i == CSSPrimitiveValue::UnitTypePercentage) { | 154 if (i == CSSPrimitiveValue::UnitTypePercentage) { |
| 153 percentage = value; | 155 percentage = value; |
| 154 } else { | 156 } else { |
| 155 CSSPrimitiveValue::UnitType type = CSSPrimitiveValue::lengthUnitType
ToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(i)); | 157 CSSPrimitiveValue::UnitType type = CSSPrimitiveValue::lengthUnitType
ToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(i)); |
| 156 pixels += conversionData.zoomedComputedPixels(value, type); | 158 pixels += conversionData.zoomedComputedPixels(value, type); |
| 157 } | 159 } |
| 158 } | 160 } |
| 159 | 161 |
| 160 if (percentage != 0) | 162 if (percentage != 0) |
| 161 hasPercentage = true; | 163 hasPercentage = true; |
| 162 if (pixels != 0 && hasPercentage) | 164 if (pixels != 0 && hasPercentage) |
| 163 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta
ge), range)); | 165 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta
ge), range)); |
| 164 if (hasPercentage) | 166 if (hasPercentage) |
| 165 return Length(clampToRange(percentage, range), Percent); | 167 return Length(clampToRange(percentage, range), Percent); |
| 166 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels,
range)), Fixed); | 168 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels,
range)), Fixed); |
| 167 } | 169 } |
| 168 | 170 |
| 169 } // namespace blink | 171 } // namespace blink |
| OLD | NEW |