From 91672cbe203b55ec355d118636d333e9e7d7f3d7 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Tue, 8 Mar 2011 17:06:17 -0800 Subject: [PATCH] Fix CSS animation bugs - we were replacing animations by new ones regardless of their types, so when two anims (i.e. transform and opacity) where set on the same layer, we'd only run the last one - the selection of the keys for keyframes animations was buggy bug:2453890 Change-Id: I03da3f6c2ba1f5bf778e099e52d71d2f5e67d27e --- WebCore/platform/graphics/android/AndroidAnimation.cpp | 13 ++++++++----- WebCore/platform/graphics/android/AndroidAnimation.h | 10 +++++++++- WebCore/platform/graphics/android/LayerAndroid.cpp | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/WebCore/platform/graphics/android/AndroidAnimation.cpp b/WebCore/platform/graphics/android/AndroidAnimation.cpp index 47fc82ce6..3280d077f 100644 --- a/WebCore/platform/graphics/android/AndroidAnimation.cpp +++ b/WebCore/platform/graphics/android/AndroidAnimation.cpp @@ -54,7 +54,8 @@ long AndroidAnimation::instancesCount() return gDebugAndroidAnimationInstances; } -AndroidAnimation::AndroidAnimation(const Animation* animation, +AndroidAnimation::AndroidAnimation(AndroidAnimationType type, + const Animation* animation, double beginTime) : m_beginTime(beginTime) , m_duration(animation->duration()) @@ -63,6 +64,7 @@ AndroidAnimation::AndroidAnimation(const Animation* animation, , m_direction(animation->direction()) , m_currentDirection(false) , m_timingFunction(animation->timingFunction()) + , m_type(type) { ASSERT(m_timingFunction); @@ -80,6 +82,7 @@ AndroidAnimation::AndroidAnimation(AndroidAnimation* anim) , m_direction(anim->m_direction) , m_currentDirection(false) , m_timingFunction(anim->m_timingFunction) + , m_type(anim->m_type) { gDebugAndroidAnimationInstances++; } @@ -147,7 +150,7 @@ PassRefPtr AndroidOpacityAnimation::create( AndroidOpacityAnimation::AndroidOpacityAnimation(const Animation* animation, KeyframeValueList* operations, double beginTime) - : AndroidAnimation(animation, beginTime) + : AndroidAnimation(AndroidAnimation::OPACITY, animation, beginTime) , m_operations(operations) { } @@ -231,7 +234,7 @@ PassRefPtr AndroidTransformAnimation::create( AndroidTransformAnimation::AndroidTransformAnimation(const Animation* animation, KeyframeValueList* operations, double beginTime) - : AndroidAnimation(animation, beginTime) + : AndroidAnimation(AndroidAnimation::TRANSFORM, animation, beginTime) , m_operations(operations) { } @@ -275,9 +278,9 @@ bool AndroidTransformAnimation::evaluate(LayerAndroid* layer, double time) TransformAnimationValue* value = (TransformAnimationValue*) m_operations->at(i); TransformOperations* values = (TransformOperations*) value->value(); float key = value->keyTime(); - float d = fabs(progress - key); + float d = progress - key; XLOG("[%d] Key %.2f, %d values", i, key, values->size()); - if (!fromValue || (d < distance && i + 1 < m_operations->size())) { + if (!fromValue || (d > 0 && d < distance && i + 1 < m_operations->size())) { fromValue = value; distance = d; foundAt = i; diff --git a/WebCore/platform/graphics/android/AndroidAnimation.h b/WebCore/platform/graphics/android/AndroidAnimation.h index ed2789eba..d6821039f 100644 --- a/WebCore/platform/graphics/android/AndroidAnimation.h +++ b/WebCore/platform/graphics/android/AndroidAnimation.h @@ -35,7 +35,13 @@ class TimingFunction; class AndroidAnimation : public RefCounted { public: - AndroidAnimation(const Animation* animation, + enum AndroidAnimationType { + UNDEFINED, + OPACITY, + TRANSFORM + }; + AndroidAnimation(AndroidAnimationType type, + const Animation* animation, double beginTime); AndroidAnimation(AndroidAnimation* anim); @@ -48,6 +54,7 @@ class AndroidAnimation : public RefCounted { static long instancesCount(); void setName(const String& name) { m_name = name; } String name() { return m_name; } + AndroidAnimationType type() { return m_type; } protected: double m_beginTime; @@ -59,6 +66,7 @@ class AndroidAnimation : public RefCounted { bool m_currentDirection; RefPtr m_timingFunction; String m_name; + AndroidAnimationType m_type; }; class AndroidOpacityAnimation : public AndroidAnimation { diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 714fa409d..7d68f035c 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -243,7 +243,8 @@ bool LayerAndroid::evaluateAnimations(double time) const void LayerAndroid::addAnimation(PassRefPtr prpAnim) { RefPtr anim = prpAnim; - if (m_animations.get(anim->name())) + RefPtr currentAnim = m_animations.get(anim->name()); + if (currentAnim && currentAnim->type() == anim->type()) removeAnimation(anim->name()); m_animations.add(anim->name(), anim); } -- 2.11.0