| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/animation/animatable/AnimatableShadow.h" | 31 #include "core/animation/animatable/AnimatableShadow.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 PassRefPtr<AnimatableValue> AnimatableShadow::interpolateTo( | |
| 36 const AnimatableValue* value, | |
| 37 double fraction) const { | |
| 38 if (usesDefaultInterpolationWith(value)) | |
| 39 return defaultInterpolateTo(this, value, fraction); | |
| 40 | |
| 41 const AnimatableShadow* shadowList = toAnimatableShadow(value); | |
| 42 return AnimatableShadow::create( | |
| 43 ShadowList::blend(m_shadowList.get(), shadowList->m_shadowList.get(), | |
| 44 fraction, m_currentColor), | |
| 45 m_currentColor); | |
| 46 } | |
| 47 | |
| 48 bool AnimatableShadow::usesDefaultInterpolationWith( | |
| 49 const AnimatableValue* value) const { | |
| 50 const AnimatableShadow* target = toAnimatableShadow(value); | |
| 51 if (!m_shadowList || !target->m_shadowList) | |
| 52 return false; | |
| 53 | |
| 54 size_t minLength = std::min(m_shadowList->shadows().size(), | |
| 55 target->m_shadowList->shadows().size()); | |
| 56 for (size_t i = 0; i < minLength; ++i) { | |
| 57 ShadowStyle fromShadowStyle = m_shadowList->shadows()[i].style(); | |
| 58 ShadowStyle toShadowStyle = target->m_shadowList->shadows()[i].style(); | |
| 59 | |
| 60 if (fromShadowStyle != toShadowStyle) | |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 return false; | |
| 65 } | |
| 66 | |
| 67 bool AnimatableShadow::equalTo(const AnimatableValue* value) const { | 35 bool AnimatableShadow::equalTo(const AnimatableValue* value) const { |
| 68 const ShadowList* shadowList = toAnimatableShadow(value)->m_shadowList.get(); | 36 const ShadowList* shadowList = toAnimatableShadow(value)->m_shadowList.get(); |
| 69 return m_shadowList == shadowList || | 37 return m_shadowList == shadowList || |
| 70 (m_shadowList && shadowList && *m_shadowList == *shadowList); | 38 (m_shadowList && shadowList && *m_shadowList == *shadowList); |
| 71 } | 39 } |
| 72 | 40 |
| 73 } // namespace blink | 41 } // namespace blink |
| OLD | NEW |