| 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/UnderlyingValueOwner.h" | 5 #include "core/animation/UnderlyingValueOwner.h" |
| 6 | 6 |
| 7 #include <memory> | |
| 8 | |
| 9 namespace blink { | 7 namespace blink { |
| 10 | 8 |
| 11 struct NullValueWrapper { | 9 struct NullValueWrapper { |
| 12 NullValueWrapper() : value(nullptr) {} | 10 NullValueWrapper() : value(nullptr) {} |
| 13 const InterpolationValue value; | 11 const InterpolationValue value; |
| 14 }; | 12 }; |
| 15 | 13 |
| 16 const InterpolationValue& UnderlyingValueOwner::value() const | 14 const InterpolationValue& UnderlyingValueOwner::value() const |
| 17 { | 15 { |
| 18 DEFINE_STATIC_LOCAL(NullValueWrapper, nullValueWrapper, ()); | 16 DEFINE_STATIC_LOCAL(NullValueWrapper, nullValueWrapper, ()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 } | 35 } |
| 38 | 36 |
| 39 void UnderlyingValueOwner::set(const InterpolationType& type, InterpolationValue
&& value) | 37 void UnderlyingValueOwner::set(const InterpolationType& type, InterpolationValue
&& value) |
| 40 { | 38 { |
| 41 ASSERT(value); | 39 ASSERT(value); |
| 42 m_type = &type; | 40 m_type = &type; |
| 43 m_valueOwner = std::move(value); | 41 m_valueOwner = std::move(value); |
| 44 m_value = &m_valueOwner; | 42 m_value = &m_valueOwner; |
| 45 } | 43 } |
| 46 | 44 |
| 47 void UnderlyingValueOwner::set(std::unique_ptr<TypedInterpolationValue> value) | 45 void UnderlyingValueOwner::set(PassOwnPtr<TypedInterpolationValue> value) |
| 48 { | 46 { |
| 49 if (value) | 47 if (value) |
| 50 set(value->type(), std::move(value->mutableValue())); | 48 set(value->type(), std::move(value->mutableValue())); |
| 51 else | 49 else |
| 52 set(nullptr); | 50 set(nullptr); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void UnderlyingValueOwner::set(const TypedInterpolationValue* value) | 53 void UnderlyingValueOwner::set(const TypedInterpolationValue* value) |
| 56 { | 54 { |
| 57 if (value) | 55 if (value) |
| 58 set(value->type(), value->value()); | 56 set(value->type(), value->value()); |
| 59 else | 57 else |
| 60 set(nullptr); | 58 set(nullptr); |
| 61 } | 59 } |
| 62 | 60 |
| 63 InterpolationValue& UnderlyingValueOwner::mutableValue() | 61 InterpolationValue& UnderlyingValueOwner::mutableValue() |
| 64 { | 62 { |
| 65 ASSERT(m_type && m_value); | 63 ASSERT(m_type && m_value); |
| 66 if (!m_valueOwner) { | 64 if (!m_valueOwner) { |
| 67 m_valueOwner = m_value->clone(); | 65 m_valueOwner = m_value->clone(); |
| 68 m_value = &m_valueOwner; | 66 m_value = &m_valueOwner; |
| 69 } | 67 } |
| 70 return m_valueOwner; | 68 return m_valueOwner; |
| 71 } | 69 } |
| 72 | 70 |
| 73 } // namespace blink | 71 } // namespace blink |
| OLD | NEW |