diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2010-11-10 15:31:59 -0800 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2010-11-17 13:35:59 -0800 |
commit | 28040489d744e0c5d475a88663056c9040ed5320 (patch) | |
tree | c463676791e4a63e452a95f0a12b2a8519730693 /WebCore/page/animation | |
parent | eff9be92c41913c92fb1d3b7983c071f3e718678 (diff) | |
download | external_webkit-28040489d744e0c5d475a88663056c9040ed5320.zip external_webkit-28040489d744e0c5d475a88663056c9040ed5320.tar.gz external_webkit-28040489d744e0c5d475a88663056c9040ed5320.tar.bz2 |
Merge WebKit at r71558: Initial merge by git.
Change-Id: Ib345578fa29df7e4bc72b4f00e4a6fddcb754c4c
Diffstat (limited to 'WebCore/page/animation')
-rw-r--r-- | WebCore/page/animation/AnimationBase.cpp | 13 | ||||
-rw-r--r-- | WebCore/page/animation/AnimationBase.h | 3 | ||||
-rw-r--r-- | WebCore/page/animation/AnimationController.cpp | 44 | ||||
-rw-r--r-- | WebCore/page/animation/AnimationController.h | 7 | ||||
-rw-r--r-- | WebCore/page/animation/AnimationControllerPrivate.h | 7 | ||||
-rw-r--r-- | WebCore/page/animation/CompositeAnimation.cpp | 18 | ||||
-rw-r--r-- | WebCore/page/animation/CompositeAnimation.h | 6 |
7 files changed, 70 insertions, 28 deletions
diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp index ade68b5..ad5257e 100644 --- a/WebCore/page/animation/AnimationBase.cpp +++ b/WebCore/page/animation/AnimationBase.cpp @@ -1206,10 +1206,17 @@ void AnimationBase::fireAnimationEventsIfNeeded() } } -void AnimationBase::updatePlayState(bool run) +void AnimationBase::updatePlayState(EAnimPlayState playState) { - if (paused() == run || isNew()) - updateStateMachine(run ? AnimationStateInputPlayStateRunning : AnimationStateInputPlayStatePaused, -1); + // When we get here, we can have one of 4 desired states: running, paused, suspended, paused & suspended. + // The state machine can be in one of two states: running, paused. + // Set the state machine to the desired state. + bool pause = playState == AnimPlayStatePaused || m_compAnim->suspended(); + + if (pause == paused() && !isNew()) + return; + + updateStateMachine(pause ? AnimationStateInputPlayStatePaused : AnimationStateInputPlayStateRunning, -1); } double AnimationBase::timeToNextService() diff --git a/WebCore/page/animation/AnimationBase.h b/WebCore/page/animation/AnimationBase.h index f5f3172..eb9bd12 100644 --- a/WebCore/page/animation/AnimationBase.h +++ b/WebCore/page/animation/AnimationBase.h @@ -29,6 +29,7 @@ #ifndef AnimationBase_h #define AnimationBase_h +#include "RenderStyleConstants.h" #include <wtf/HashMap.h> #include <wtf/text/AtomicString.h> @@ -102,7 +103,7 @@ public: } // Called to change to or from paused state - void updatePlayState(bool running); + void updatePlayState(EAnimPlayState); bool playStatePlaying() const; bool waitingToStart() const { return m_animState == AnimationStateNew || m_animState == AnimationStateStartWaitTimer; } diff --git a/WebCore/page/animation/AnimationController.cpp b/WebCore/page/animation/AnimationController.cpp index b5d87e6..e8e990c 100644 --- a/WebCore/page/animation/AnimationController.cpp +++ b/WebCore/page/animation/AnimationController.cpp @@ -81,7 +81,7 @@ bool AnimationControllerPrivate::clear(RenderObject* renderer) if (!animation) return false; animation->clearRenderer(); - return animation->isSuspended(); + return animation->suspended(); } void AnimationControllerPrivate::updateAnimationTimer(bool callSetChanged/* = false*/) @@ -92,7 +92,7 @@ void AnimationControllerPrivate::updateAnimationTimer(bool callSetChanged/* = fa RenderObjectAnimationMap::const_iterator animationsEnd = m_compositeAnimations.end(); for (RenderObjectAnimationMap::const_iterator it = m_compositeAnimations.begin(); it != animationsEnd; ++it) { CompositeAnimation* compAnim = it->second.get(); - if (!compAnim->isSuspended() && compAnim->hasAnimations()) { + if (!compAnim->suspended() && compAnim->hasAnimations()) { double t = compAnim->timeToNextService(); if (t != -1 && (t < needsService || needsService == -1)) needsService = t; @@ -227,7 +227,25 @@ bool AnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderO return animation->isAnimatingProperty(property, true, isRunningNow); } -void AnimationControllerPrivate::suspendAnimations(Document* document) +void AnimationControllerPrivate::suspendAnimations() +{ + suspendAnimationsForDocument(m_frame->document()); + + // Traverse subframes + for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) + child->animation()->suspendAnimations(); +} + +void AnimationControllerPrivate::resumeAnimations() +{ + resumeAnimationsForDocument(m_frame->document()); + + // Traverse subframes + for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) + child->animation()->resumeAnimations(); +} + +void AnimationControllerPrivate::suspendAnimationsForDocument(Document* document) { setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); @@ -243,7 +261,7 @@ void AnimationControllerPrivate::suspendAnimations(Document* document) updateAnimationTimer(); } -void AnimationControllerPrivate::resumeAnimations(Document* document) +void AnimationControllerPrivate::resumeAnimationsForDocument(Document* document) { setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); @@ -551,14 +569,24 @@ bool AnimationController::isRunningAcceleratedAnimationOnRenderer(RenderObject* return m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, isRunningNow); } -void AnimationController::suspendAnimations(Document* document) +void AnimationController::suspendAnimations() +{ + m_data->suspendAnimations(); +} + +void AnimationController::resumeAnimations() +{ + m_data->resumeAnimations(); +} + +void AnimationController::suspendAnimationsForDocument(Document* document) { - m_data->suspendAnimations(document); + m_data->suspendAnimationsForDocument(document); } -void AnimationController::resumeAnimations(Document* document) +void AnimationController::resumeAnimationsForDocument(Document* document) { - m_data->resumeAnimations(document); + m_data->resumeAnimationsForDocument(document); } void AnimationController::beginAnimationUpdate() diff --git a/WebCore/page/animation/AnimationController.h b/WebCore/page/animation/AnimationController.h index 4528dae..5279467 100644 --- a/WebCore/page/animation/AnimationController.h +++ b/WebCore/page/animation/AnimationController.h @@ -62,8 +62,11 @@ public: bool isRunningAnimationOnRenderer(RenderObject*, CSSPropertyID, bool isRunningNow = true) const; bool isRunningAcceleratedAnimationOnRenderer(RenderObject*, CSSPropertyID, bool isRunningNow = true) const; - void suspendAnimations(Document*); - void resumeAnimations(Document*); + void suspendAnimations(); + void resumeAnimations(); + + void suspendAnimationsForDocument(Document*); + void resumeAnimationsForDocument(Document*); void beginAnimationUpdate(); void endAnimationUpdate(); diff --git a/WebCore/page/animation/AnimationControllerPrivate.h b/WebCore/page/animation/AnimationControllerPrivate.h index 3305e24..893c717 100644 --- a/WebCore/page/animation/AnimationControllerPrivate.h +++ b/WebCore/page/animation/AnimationControllerPrivate.h @@ -67,8 +67,11 @@ public: bool hasAnimations() const { return !m_compositeAnimations.isEmpty(); } - void suspendAnimations(Document*); - void resumeAnimations(Document*); + void suspendAnimations(); + void resumeAnimations(); + + void suspendAnimationsForDocument(Document*); + void resumeAnimationsForDocument(Document*); bool isRunningAnimationOnRenderer(RenderObject*, CSSPropertyID, bool isRunningNow) const; bool isRunningAcceleratedAnimationOnRenderer(RenderObject*, CSSPropertyID, bool isRunningNow) const; diff --git a/WebCore/page/animation/CompositeAnimation.cpp b/WebCore/page/animation/CompositeAnimation.cpp index 57c2aa4..9d021b4 100644 --- a/WebCore/page/animation/CompositeAnimation.cpp +++ b/WebCore/page/animation/CompositeAnimation.cpp @@ -229,7 +229,7 @@ void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, Render // This one is still active. // Animations match, but play states may differ. Update if needed. - keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); + keyframeAnim->updatePlayState(anim->playState()); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(anim); @@ -386,17 +386,17 @@ PassRefPtr<KeyframeAnimation> CompositeAnimation::getAnimationForProperty(int pr void CompositeAnimation::suspendAnimations() { - if (m_isSuspended) + if (m_suspended) return; - m_isSuspended = true; + m_suspended = true; if (!m_keyframeAnimations.isEmpty()) { m_keyframeAnimations.checkConsistency(); AnimationNameMap::const_iterator animationsEnd = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != animationsEnd; ++it) { if (KeyframeAnimation* anim = it->second.get()) - anim->updatePlayState(false); + anim->updatePlayState(AnimPlayStatePaused); } } if (!m_transitions.isEmpty()) { @@ -404,17 +404,17 @@ void CompositeAnimation::suspendAnimations() for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) { ImplicitAnimation* anim = it->second.get(); if (anim && anim->hasStyle()) - anim->updatePlayState(false); + anim->updatePlayState(AnimPlayStatePaused); } } } void CompositeAnimation::resumeAnimations() { - if (!m_isSuspended) + if (!m_suspended) return; - m_isSuspended = false; + m_suspended = false; if (!m_keyframeAnimations.isEmpty()) { m_keyframeAnimations.checkConsistency(); @@ -422,7 +422,7 @@ void CompositeAnimation::resumeAnimations() for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != animationsEnd; ++it) { KeyframeAnimation* anim = it->second.get(); if (anim && anim->playStatePlaying()) - anim->updatePlayState(true); + anim->updatePlayState(AnimPlayStatePlaying); } } @@ -431,7 +431,7 @@ void CompositeAnimation::resumeAnimations() for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) { ImplicitAnimation* anim = it->second.get(); if (anim && anim->hasStyle()) - anim->updatePlayState(true); + anim->updatePlayState(AnimPlayStatePlaying); } } } diff --git a/WebCore/page/animation/CompositeAnimation.h b/WebCore/page/animation/CompositeAnimation.h index a0ac455..249f4c3 100644 --- a/WebCore/page/animation/CompositeAnimation.h +++ b/WebCore/page/animation/CompositeAnimation.h @@ -64,7 +64,7 @@ public: void suspendAnimations(); void resumeAnimations(); - bool isSuspended() const { return m_isSuspended; } + bool suspended() const { return m_suspended; } bool hasAnimations() const { return !m_transitions.isEmpty() || !m_keyframeAnimations.isEmpty(); } @@ -84,7 +84,7 @@ private: CompositeAnimation(AnimationControllerPrivate* animationController) : m_animationController(animationController) , m_numStyleAvailableWaiters(0) - , m_isSuspended(false) + , m_suspended(false) { } @@ -99,7 +99,7 @@ private: AnimationNameMap m_keyframeAnimations; Vector<AtomicStringImpl*> m_keyframeAnimationOrderMap; unsigned m_numStyleAvailableWaiters; - bool m_isSuspended; + bool m_suspended; }; } // namespace WebCore |