diff options
author | Nicolas Roard <nicolas@android.com> | 2010-01-25 22:10:44 +0000 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2010-01-26 18:06:08 +0000 |
commit | ec745133ebaf0e3ede2d6656a96399f960a95876 (patch) | |
tree | 13d085e1a3a5d0495da29923e88d9d16adc5985f /WebCore | |
parent | aefef8d800d34d6733c13b05c7cfe214d06b62d8 (diff) | |
download | external_webkit-ec745133ebaf0e3ede2d6656a96399f960a95876.zip external_webkit-ec745133ebaf0e3ede2d6656a96399f960a95876.tar.gz external_webkit-ec745133ebaf0e3ede2d6656a96399f960a95876.tar.bz2 |
Fix potential crash with layers enabled.
See bug http://b/2395197
We remove the AndroidAnimationTimer class, and use a callback mechanism instead
in GraphicsLayerAndroid.
Diffstat (limited to 'WebCore')
4 files changed, 25 insertions, 30 deletions
diff --git a/WebCore/platform/graphics/android/AndroidAnimation.cpp b/WebCore/platform/graphics/android/AndroidAnimation.cpp index 9cdb0c7..052e0a2 100644 --- a/WebCore/platform/graphics/android/AndroidAnimation.cpp +++ b/WebCore/platform/graphics/android/AndroidAnimation.cpp @@ -42,15 +42,6 @@ void AndroidTransformAnimationValue::apply() m_layer->setRotation(m_rotation); } -void AndroidAnimationTimer::fired() -{ - if (!m_notificationSent) { - m_notificationSent = true; - if (m_layer && m_layer->client()) - m_layer->client()->notifyAnimationStarted(m_layer, WTF::currentTime()); - } -} - static long gDebugAndroidAnimationInstances; long AndroidAnimation::instancesCount() diff --git a/WebCore/platform/graphics/android/AndroidAnimation.h b/WebCore/platform/graphics/android/AndroidAnimation.h index 05d6a76..1ecc22f 100644 --- a/WebCore/platform/graphics/android/AndroidAnimation.h +++ b/WebCore/platform/graphics/android/AndroidAnimation.h @@ -180,23 +180,6 @@ class AndroidTransformAnimation : public AndroidAnimation { float m_toScaleX, m_toScaleY, m_toScaleZ; }; -class AndroidAnimationTimer : public TimerBase { - public: - - AndroidAnimationTimer(GraphicsLayerAndroid* layer, double beginTime) - { - m_layer = layer; - m_notificationSent = false; - m_beginTime = beginTime; - } - - private: - void fired(); - GraphicsLayerAndroid* m_layer; - double m_beginTime; - bool m_notificationSent; -}; - } // namespace WebCore diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 9d9d067..068a55b 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -96,6 +96,7 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) : m_needsSyncMask(false), m_needsRepaint(false), m_needsDisplay(false), + m_needsNotifyClient(false), m_haveContents(false), m_haveImage(false), m_translateX(0), @@ -536,14 +537,19 @@ bool GraphicsLayerAndroid::createAnimationFromKeyframes(const KeyframeValueList& anim->setName(keyframesName); m_contentLayer->addAnimation(anim.release()); - AndroidAnimationTimer* timer = new AndroidAnimationTimer(this, WTF::currentTime()); - timer->startOneShot(0); + needsNotifyClient(); return true; } break; } return false; } +void GraphicsLayerAndroid::needsNotifyClient() +{ + m_needsNotifyClient = true; + askForSync(); +} + bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& keyframesName, @@ -725,8 +731,7 @@ bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const Keyframe toScaleX, toScaleY, toScaleZ); m_contentLayer->addAnimation(anim.release()); - AndroidAnimationTimer* timer = new AndroidAnimationTimer(this, WTF::currentTime()); - timer->startOneShot(0); + needsNotifyClient(); return true; } @@ -860,6 +865,19 @@ void GraphicsLayerAndroid::syncCompositingState() repaintAll(); } +void GraphicsLayerAndroid::notifyClientAnimationStarted() +{ + for (unsigned int i = 0; i < m_children.size(); i++) { + GraphicsLayerAndroid* layer = static_cast<GraphicsLayerAndroid*>(m_children[i]); + layer->notifyClientAnimationStarted(); + } + + if (m_needsNotifyClient) { + if (client()) + client()->notifyAnimationStarted(this, WTF::currentTime()); + m_needsNotifyClient = false; + } +} } // namespace WebCore diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index fc88fbf..591a261 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -116,6 +116,7 @@ public: void syncMask(); virtual void syncCompositingState(); void setFrame(Frame*); + void notifyClientAnimationStarted(); void sendImmediateRepaint(); LayerAndroid* contentLayer() { return m_contentLayer.get(); } @@ -125,11 +126,13 @@ public: private: bool repaint(const FloatRect& rect); + void needsNotifyClient(); bool m_needsSyncChildren; bool m_needsSyncMask; bool m_needsRepaint; bool m_needsDisplay; + bool m_needsNotifyClient; bool m_haveContents; bool m_haveImage; |