| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 { | 42 { |
| 43 return cssValuePool().createValue(m_number, CSSPrimitiveValue::CSS_NUMBER); | 43 return cssValuePool().createValue(m_number, CSSPrimitiveValue::CSS_NUMBER); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool AnimatableDouble::usesDefaultInterpolationWith(const AnimatableValue* value
) const | 46 bool AnimatableDouble::usesDefaultInterpolationWith(const AnimatableValue* value
) const |
| 47 { | 47 { |
| 48 const AnimatableDouble* other = toAnimatableDouble(value); | 48 const AnimatableDouble* other = toAnimatableDouble(value); |
| 49 return (m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number
|| !other->m_number); | 49 return (m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number
|| !other->m_number); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtr<AnimatableValue> AnimatableDouble::interpolateTo(const AnimatableValu
e* value, double fraction) const | 52 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableDouble::interpolateTo(const An
imatableValue* value, double fraction) const |
| 53 { | 53 { |
| 54 const AnimatableDouble* other = toAnimatableDouble(value); | 54 const AnimatableDouble* other = toAnimatableDouble(value); |
| 55 ASSERT(m_constraint == other->m_constraint); | 55 ASSERT(m_constraint == other->m_constraint); |
| 56 if ((m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number ||
!other->m_number)) | 56 if ((m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number ||
!other->m_number)) |
| 57 return defaultInterpolateTo(this, value, fraction); | 57 return defaultInterpolateTo(this, value, fraction); |
| 58 return AnimatableDouble::create(blend(m_number, other->m_number, fraction)); | 58 return AnimatableDouble::create(blend(m_number, other->m_number, fraction)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 PassRefPtr<AnimatableValue> AnimatableDouble::addWith(const AnimatableValue* val
ue) const | 61 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableDouble::addWith(const Animatab
leValue* value) const |
| 62 { | 62 { |
| 63 // Optimization for adding with 0. | 63 // Optimization for adding with 0. |
| 64 if (!m_number) | 64 if (!m_number) |
| 65 return takeConstRef(value); | 65 return takeConstRef(value); |
| 66 const AnimatableDouble* other = toAnimatableDouble(value); | 66 const AnimatableDouble* other = toAnimatableDouble(value); |
| 67 if (!other->m_number) | 67 if (!other->m_number) |
| 68 return takeConstRef(this); | 68 return takeConstRef(this); |
| 69 | 69 |
| 70 return AnimatableDouble::create(m_number + other->m_number); | 70 return AnimatableDouble::create(m_number + other->m_number); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool AnimatableDouble::equalTo(const AnimatableValue* value) const | 73 bool AnimatableDouble::equalTo(const AnimatableValue* value) const |
| 74 { | 74 { |
| 75 return m_number == toAnimatableDouble(value)->m_number; | 75 return m_number == toAnimatableDouble(value)->m_number; |
| 76 } | 76 } |
| 77 | 77 |
| 78 double AnimatableDouble::distanceTo(const AnimatableValue* value) const | 78 double AnimatableDouble::distanceTo(const AnimatableValue* value) const |
| 79 { | 79 { |
| 80 const AnimatableDouble* other = toAnimatableDouble(value); | 80 const AnimatableDouble* other = toAnimatableDouble(value); |
| 81 return fabs(m_number - other->m_number); | 81 return fabs(m_number - other->m_number); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void AnimatableDouble::trace(Visitor* visitor) |
| 85 { |
| 86 AnimatableValue::trace(visitor); |
| 87 } |
| 88 |
| 84 } // namespace WebCore | 89 } // namespace WebCore |
| OLD | NEW |