Chromium Code Reviews| Index: Source/core/animation/AnimatableDouble.cpp |
| diff --git a/Source/core/animation/AnimatableVisibility.cpp b/Source/core/animation/AnimatableDouble.cpp |
| similarity index 65% |
| copy from Source/core/animation/AnimatableVisibility.cpp |
| copy to Source/core/animation/AnimatableDouble.cpp |
| index 2cfc097ada77aa7750f4157b2240c07ba9ce1b0f..211452c2b5b24bd12ea4483eab700cd5ed10a425 100644 |
| --- a/Source/core/animation/AnimatableVisibility.cpp |
| +++ b/Source/core/animation/AnimatableDouble.cpp |
| @@ -29,21 +29,35 @@ |
| */ |
| #include "config.h" |
| -#include "core/animation/AnimatableVisibility.h" |
| +#include "core/animation/AnimatableDouble.h" |
| + |
| +#include "core/css/CSSPrimitiveValue.h" |
| +#include "core/css/CSSValuePool.h" |
| +#include "core/platform/animation/AnimationUtilities.h" |
| namespace WebCore { |
| -PassRefPtr<AnimatableValue> AnimatableVisibility::interpolateTo(const AnimatableValue* value, double fraction) const |
| +PassRefPtr<CSSValue> AnimatableDouble::toCSSValue() const |
| { |
| - EVisibility from = m_visibility; |
| - EVisibility to = toAnimatableVisibility(value)->m_visibility; |
| - if (from != VISIBLE && to != VISIBLE) |
| - return defaultInterpolateTo(this, value, fraction); |
| - if (fraction <= 0) |
| - return takeConstRef(this); |
| - if (fraction >= 1) |
| + return cssValuePool().createValue(m_number, CSSPrimitiveValue::CSS_NUMBER); |
| +} |
| + |
| +PassRefPtr<AnimatableValue> AnimatableDouble::interpolateTo(const AnimatableValue* value, double fraction) const |
| +{ |
| + const AnimatableDouble* other = toAnimatableDouble(value); |
| + return AnimatableDouble::create(blend(m_number, other->m_number, fraction)); |
| +} |
| + |
| +PassRefPtr<AnimatableValue> AnimatableDouble::addWith(const AnimatableValue* value) const |
| +{ |
| + // Optimization for adding with 0. |
|
Timothy Loh
2013/09/30 23:27:59
You might want to add tests for taking the two bra
alancutter (OOO until 2018)
2013/10/01 09:32:24
Done.
|
| + if (!m_number) |
| return takeConstRef(value); |
| - return takeConstRef(from == VISIBLE ? this : value); |
| + const AnimatableDouble* other = toAnimatableDouble(value); |
| + if (!other->m_number) |
| + return takeConstRef(this); |
| + |
| + return AnimatableDouble::create(m_number + other->m_number); |
| } |
| } // namespace WebCore |