OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef UnderlyingLengthChecker_h | 5 #ifndef UnderlyingLengthChecker_h |
6 #define UnderlyingLengthChecker_h | 6 #define UnderlyingLengthChecker_h |
7 | 7 |
8 #include "core/animation/InterpolableValue.h" | 8 #include "core/animation/InterpolableValue.h" |
9 #include "core/animation/InterpolationType.h" | 9 #include "core/animation/InterpolationType.h" |
10 #include "wtf/PtrUtil.h" | 10 #include "wtf/PtrUtil.h" |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class UnderlyingLengthChecker : public InterpolationType::ConversionChecker { | 15 class UnderlyingLengthChecker : public InterpolationType::ConversionChecker { |
16 public: | 16 public: |
17 static std::unique_ptr<UnderlyingLengthChecker> create( | 17 static std::unique_ptr<UnderlyingLengthChecker> create( |
18 size_t underlyingLength) { | 18 size_t underlyingLength) { |
19 return wrapUnique(new UnderlyingLengthChecker(underlyingLength)); | 19 return WTF::wrapUnique(new UnderlyingLengthChecker(underlyingLength)); |
20 } | 20 } |
21 | 21 |
22 static size_t getUnderlyingLength(const InterpolationValue& underlying) { | 22 static size_t getUnderlyingLength(const InterpolationValue& underlying) { |
23 if (!underlying) | 23 if (!underlying) |
24 return 0; | 24 return 0; |
25 return toInterpolableList(*underlying.interpolableValue).length(); | 25 return toInterpolableList(*underlying.interpolableValue).length(); |
26 } | 26 } |
27 | 27 |
28 bool isValid(const InterpolationEnvironment&, | 28 bool isValid(const InterpolationEnvironment&, |
29 const InterpolationValue& underlying) const final { | 29 const InterpolationValue& underlying) const final { |
30 return m_underlyingLength == getUnderlyingLength(underlying); | 30 return m_underlyingLength == getUnderlyingLength(underlying); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 UnderlyingLengthChecker(size_t underlyingLength) | 34 UnderlyingLengthChecker(size_t underlyingLength) |
35 : m_underlyingLength(underlyingLength) {} | 35 : m_underlyingLength(underlyingLength) {} |
36 | 36 |
37 size_t m_underlyingLength; | 37 size_t m_underlyingLength; |
38 }; | 38 }; |
39 | 39 |
40 } // namespace blink | 40 } // namespace blink |
41 | 41 |
42 #endif // UnderlyingLengthChecker_h | 42 #endif // UnderlyingLengthChecker_h |
OLD | NEW |