Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Unified Diff: Source/core/animation/AnimatableDouble.cpp

Issue 25082007: Web Animations CSS: Split AnimatableNumber into AnimatableDouble and AnimatableLength (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review changes Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/AnimatableDouble.h ('k') | Source/core/animation/AnimatableDoubleTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+ 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
« no previous file with comments | « Source/core/animation/AnimatableDouble.h ('k') | Source/core/animation/AnimatableDoubleTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698