| 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" |
| 11 #include <memory> |
| 10 | 12 |
| 11 namespace blink { | 13 namespace blink { |
| 12 | 14 |
| 13 class UnderlyingLengthChecker : public InterpolationType::ConversionChecker { | 15 class UnderlyingLengthChecker : public InterpolationType::ConversionChecker { |
| 14 public: | 16 public: |
| 15 static PassOwnPtr<UnderlyingLengthChecker> create(size_t underlyingLength) | 17 static std::unique_ptr<UnderlyingLengthChecker> create(size_t underlyingLeng
th) |
| 16 { | 18 { |
| 17 return adoptPtr(new UnderlyingLengthChecker(underlyingLength)); | 19 return wrapUnique(new UnderlyingLengthChecker(underlyingLength)); |
| 18 } | 20 } |
| 19 | 21 |
| 20 static size_t getUnderlyingLength(const InterpolationValue& underlying) | 22 static size_t getUnderlyingLength(const InterpolationValue& underlying) |
| 21 { | 23 { |
| 22 if (!underlying) | 24 if (!underlying) |
| 23 return 0; | 25 return 0; |
| 24 return toInterpolableList(*underlying.interpolableValue).length(); | 26 return toInterpolableList(*underlying.interpolableValue).length(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 bool isValid(const InterpolationEnvironment&, const InterpolationValue& unde
rlying) const final | 29 bool isValid(const InterpolationEnvironment&, const InterpolationValue& unde
rlying) const final |
| 28 { | 30 { |
| 29 return m_underlyingLength == getUnderlyingLength(underlying); | 31 return m_underlyingLength == getUnderlyingLength(underlying); |
| 30 } | 32 } |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 UnderlyingLengthChecker(size_t underlyingLength) | 35 UnderlyingLengthChecker(size_t underlyingLength) |
| 34 : m_underlyingLength(underlyingLength) | 36 : m_underlyingLength(underlyingLength) |
| 35 {} | 37 {} |
| 36 | 38 |
| 37 size_t m_underlyingLength; | 39 size_t m_underlyingLength; |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 } // namespace blink | 42 } // namespace blink |
| 41 | 43 |
| 42 #endif // UnderlyingLengthChecker_h | 44 #endif // UnderlyingLengthChecker_h |
| OLD | NEW |