summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorNicolas Roard <nicolasroard@google.com>2011-03-08 17:06:17 -0800
committerNicolas Roard <nicolasroard@google.com>2011-03-08 19:04:37 -0800
commit91672cbe203b55ec355d118636d333e9e7d7f3d7 (patch)
treee242ad245e4c2c1be7d47c7fbdfddb3b89b74c5d /WebCore
parent42046545ce1012ef3f925011573d265339778bed (diff)
downloadexternal_webkit-91672cbe203b55ec355d118636d333e9e7d7f3d7.zip
external_webkit-91672cbe203b55ec355d118636d333e9e7d7f3d7.tar.gz
external_webkit-91672cbe203b55ec355d118636d333e9e7d7f3d7.tar.bz2
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
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/platform/graphics/android/AndroidAnimation.cpp13
-rw-r--r--WebCore/platform/graphics/android/AndroidAnimation.h10
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp3
3 files changed, 19 insertions, 7 deletions
diff --git a/WebCore/platform/graphics/android/AndroidAnimation.cpp b/WebCore/platform/graphics/android/AndroidAnimation.cpp
index 47fc82c..3280d07 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> 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> 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 ed2789e..d682103 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<AndroidAnimation> {
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<AndroidAnimation> {
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<AndroidAnimation> {
bool m_currentDirection;
RefPtr<TimingFunction> 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 714fa40..7d68f03 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<AndroidAnimation> prpAnim)
{
RefPtr<AndroidAnimation> anim = prpAnim;
- if (m_animations.get(anim->name()))
+ RefPtr<AndroidAnimation> currentAnim = m_animations.get(anim->name());
+ if (currentAnim && currentAnim->type() == anim->type())
removeAnimation(anim->name());
m_animations.add(anim->name(), anim);
}