| 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> | 7 #include <memory> |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 void UnderlyingValueOwner::set(std::nullptr_t) { | 21 void UnderlyingValueOwner::set(std::nullptr_t) { |
| 22 m_type = nullptr; | 22 m_type = nullptr; |
| 23 m_valueOwner.clear(); | 23 m_valueOwner.clear(); |
| 24 m_value = nullptr; | 24 m_value = nullptr; |
| 25 } | 25 } |
| 26 | 26 |
| 27 void UnderlyingValueOwner::set(const InterpolationType& type, | 27 void UnderlyingValueOwner::set(const InterpolationType& type, |
| 28 const InterpolationValue& value) { | 28 const InterpolationValue& value) { |
| 29 DCHECK(value); | 29 DCHECK(value); |
| 30 m_type = &type; | 30 m_type = &type; |
| 31 // By clearing m_valueOwner we will perform a copy before attempting to mutate
m_value, | 31 // By clearing m_valueOwner we will perform a copy before attempting to mutate |
| 32 // thus upholding the const contract for this instance of interpolationValue. | 32 // m_value, thus upholding the const contract for this instance of |
| 33 // interpolationValue. |
| 33 m_valueOwner.clear(); | 34 m_valueOwner.clear(); |
| 34 m_value = &value; | 35 m_value = &value; |
| 35 } | 36 } |
| 36 | 37 |
| 37 void UnderlyingValueOwner::set(const InterpolationType& type, | 38 void UnderlyingValueOwner::set(const InterpolationType& type, |
| 38 InterpolationValue&& value) { | 39 InterpolationValue&& value) { |
| 39 DCHECK(value); | 40 DCHECK(value); |
| 40 m_type = &type; | 41 m_type = &type; |
| 41 m_valueOwner = std::move(value); | 42 m_valueOwner = std::move(value); |
| 42 m_value = &m_valueOwner; | 43 m_value = &m_valueOwner; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 59 InterpolationValue& UnderlyingValueOwner::mutableValue() { | 60 InterpolationValue& UnderlyingValueOwner::mutableValue() { |
| 60 DCHECK(m_type && m_value); | 61 DCHECK(m_type && m_value); |
| 61 if (!m_valueOwner) { | 62 if (!m_valueOwner) { |
| 62 m_valueOwner = m_value->clone(); | 63 m_valueOwner = m_value->clone(); |
| 63 m_value = &m_valueOwner; | 64 m_value = &m_valueOwner; |
| 64 } | 65 } |
| 65 return m_valueOwner; | 66 return m_valueOwner; |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |