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 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 // This class is implemented as a singleton whose instance represents the presen
ce of percentages being used in a Length value | 13 // This class is implemented as a singleton whose instance represents the |
14 // while nullptr represents the absence of any percentages. | 14 // presence of percentages being used in a Length value while nullptr represents |
| 15 // the absence of any percentages. |
15 class CSSLengthNonInterpolableValue : public NonInterpolableValue { | 16 class CSSLengthNonInterpolableValue : public NonInterpolableValue { |
16 public: | 17 public: |
17 ~CSSLengthNonInterpolableValue() final { NOTREACHED(); } | 18 ~CSSLengthNonInterpolableValue() final { NOTREACHED(); } |
18 static PassRefPtr<CSSLengthNonInterpolableValue> create(bool hasPercentage) { | 19 static PassRefPtr<CSSLengthNonInterpolableValue> create(bool hasPercentage) { |
19 DEFINE_STATIC_REF(CSSLengthNonInterpolableValue, singleton, | 20 DEFINE_STATIC_REF(CSSLengthNonInterpolableValue, singleton, |
20 adoptRef(new CSSLengthNonInterpolableValue())); | 21 adoptRef(new CSSLengthNonInterpolableValue())); |
21 DCHECK(singleton); | 22 DCHECK(singleton); |
22 return hasPercentage ? singleton : nullptr; | 23 return hasPercentage ? singleton : nullptr; |
23 } | 24 } |
24 static PassRefPtr<CSSLengthNonInterpolableValue> merge( | 25 static PassRefPtr<CSSLengthNonInterpolableValue> merge( |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 return Length( | 190 return Length( |
190 CalculationValue::create(PixelsAndPercent(pixels, percentage), range)); | 191 CalculationValue::create(PixelsAndPercent(pixels, percentage), range)); |
191 if (hasPercentage) | 192 if (hasPercentage) |
192 return Length(clampToRange(percentage, range), Percent); | 193 return Length(clampToRange(percentage, range), Percent); |
193 return Length( | 194 return Length( |
194 CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels, range)), | 195 CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels, range)), |
195 Fixed); | 196 Fixed); |
196 } | 197 } |
197 | 198 |
198 } // namespace blink | 199 } // namespace blink |
OLD | NEW |