diff options
| author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
| commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
| tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/page/animation | |
| parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
| download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 | |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/page/animation')
| -rw-r--r-- | Source/WebCore/page/animation/AnimationBase.cpp | 41 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/AnimationBase.h | 17 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/AnimationController.cpp | 144 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/AnimationController.h | 3 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/AnimationControllerPrivate.h | 27 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/CompositeAnimation.cpp | 29 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/CompositeAnimation.h | 3 |
7 files changed, 145 insertions, 119 deletions
diff --git a/Source/WebCore/page/animation/AnimationBase.cpp b/Source/WebCore/page/animation/AnimationBase.cpp index 9a906e2..0fe98be 100644 --- a/Source/WebCore/page/animation/AnimationBase.cpp +++ b/Source/WebCore/page/animation/AnimationBase.cpp @@ -113,7 +113,7 @@ static inline Color blendFunc(const AnimationBase* anim, const Color& from, cons static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress) { - return to.blend(from, progress); + return to.blend(from, narrowPrecisionToFloat(progress)); } static inline LengthSize blendFunc(const AnimationBase* anim, const LengthSize& from, const LengthSize& to, double progress) @@ -798,7 +798,6 @@ AnimationBase::AnimationBase(const Animation* transition, RenderObject* renderer , m_isAccelerated(false) , m_transformFunctionListValid(false) , m_nextIterationDuration(-1) - , m_next(0) { // Compute the total duration m_totalDuration = -1; @@ -806,12 +805,6 @@ AnimationBase::AnimationBase(const Animation* transition, RenderObject* renderer m_totalDuration = m_animation->duration() * m_animation->iterationCount(); } -AnimationBase::~AnimationBase() -{ - m_compAnim->animationController()->removeFromStyleAvailableWaitList(this); - m_compAnim->animationController()->removeFromStartTimeResponseWaitList(this); -} - bool AnimationBase::propertiesEqual(int prop, const RenderStyle* a, const RenderStyle* b) { ensurePropertyMap(); @@ -936,7 +929,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) // If we get AnimationStateInputRestartAnimation then we force a new animation, regardless of state. if (input == AnimationStateInputMakeNew) { if (m_animState == AnimationStateStartWaitStyleAvailable) - m_compAnim->animationController()->removeFromStyleAvailableWaitList(this); + m_compAnim->animationController()->removeFromAnimationsWaitingForStyle(this); m_animState = AnimationStateNew; m_startTime = 0; m_pauseTime = -1; @@ -948,7 +941,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) if (input == AnimationStateInputRestartAnimation) { if (m_animState == AnimationStateStartWaitStyleAvailable) - m_compAnim->animationController()->removeFromStyleAvailableWaitList(this); + m_compAnim->animationController()->removeFromAnimationsWaitingForStyle(this); m_animState = AnimationStateNew; m_startTime = 0; m_pauseTime = -1; @@ -963,7 +956,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) if (input == AnimationStateInputEndAnimation) { if (m_animState == AnimationStateStartWaitStyleAvailable) - m_compAnim->animationController()->removeFromStyleAvailableWaitList(this); + m_compAnim->animationController()->removeFromAnimationsWaitingForStyle(this); m_animState = AnimationStateDone; endAnimation(); return; @@ -1003,7 +996,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) ASSERT(param >= 0); // Start timer has fired, tell the animation to start and wait for it to respond with start time m_animState = AnimationStateStartWaitStyleAvailable; - m_compAnim->animationController()->addToStyleAvailableWaitList(this); + m_compAnim->animationController()->addToAnimationsWaitingForStyle(this); // Trigger a render so we can start the animation if (m_object) @@ -1038,7 +1031,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) timeOffset = -m_animation->delay(); bool started = startAnimation(timeOffset); - m_compAnim->animationController()->addToStartTimeResponseWaitList(this, started); + m_compAnim->animationController()->addToAnimationsWaitingForStartTimeResponse(this, started); m_isAccelerated = started; } } else { @@ -1072,7 +1065,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) } else { // We are pausing while waiting for a start response. Cancel the animation and wait. When // we unpause, we will act as though the start timer just fired - m_pauseTime = -1; + m_pauseTime = beginAnimationUpdateTime(); pauseAnimation(beginAnimationUpdateTime() - m_startTime); m_animState = AnimationStatePausedWaitResponse; } @@ -1167,7 +1160,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) m_isAccelerated = true; } else { bool started = startAnimation(beginAnimationUpdateTime() - m_startTime); - m_compAnim->animationController()->addToStartTimeResponseWaitList(this, started); + m_compAnim->animationController()->addToAnimationsWaitingForStartTimeResponse(this, started); m_isAccelerated = started; } } @@ -1397,5 +1390,21 @@ double AnimationBase::getElapsedTime() const return beginAnimationUpdateTime() - m_startTime; } - + +void AnimationBase::setElapsedTime(double time) +{ + // FIXME: implement this method + UNUSED_PARAM(time); +} + +void AnimationBase::play() +{ + // FIXME: implement this method +} + +void AnimationBase::pause() +{ + // FIXME: implement this method +} + } // namespace WebCore diff --git a/Source/WebCore/page/animation/AnimationBase.h b/Source/WebCore/page/animation/AnimationBase.h index 877d649..1ab14e3 100644 --- a/Source/WebCore/page/animation/AnimationBase.h +++ b/Source/WebCore/page/animation/AnimationBase.h @@ -51,7 +51,7 @@ class AnimationBase : public RefCounted<AnimationBase> { public: AnimationBase(const Animation* transition, RenderObject* renderer, CompositeAnimation* compAnim); - virtual ~AnimationBase(); + virtual ~AnimationBase() { } RenderObject* renderer() const { return m_object; } void clearRenderer() { m_object = 0; } @@ -163,13 +163,16 @@ public: // Freeze the animation; used by DumpRenderTree. void freezeAtTime(double t); + + // Play and pause API + void play(); + void pause(); double beginAnimationUpdateTime() const; double getElapsedTime() const; - - AnimationBase* next() const { return m_next; } - void setNext(AnimationBase* animation) { m_next = animation; } + // Setting the elapsed time will adjust the start time and possibly pause time. + void setElapsedTime(double); void styleAvailable() { @@ -182,7 +185,9 @@ public: #endif static HashSet<int> animatableShorthandsAffectingProperty(int property); - + + const Animation* animation() const { return m_animation.get(); } + protected: virtual void overrideAnimations() { } virtual void resumeOverriddenAnimations() { } @@ -230,8 +235,6 @@ protected: bool m_transformFunctionListValid; double m_totalDuration, m_nextIterationDuration; - AnimationBase* m_next; - private: static void ensurePropertyMap(); }; diff --git a/Source/WebCore/page/animation/AnimationController.cpp b/Source/WebCore/page/animation/AnimationController.cpp index dcdea03..5b166d4 100644 --- a/Source/WebCore/page/animation/AnimationController.cpp +++ b/Source/WebCore/page/animation/AnimationController.cpp @@ -37,12 +37,14 @@ #include "Frame.h" #include "RenderView.h" #include "WebKitAnimationEvent.h" +#include "WebKitAnimationList.h" #include "WebKitTransitionEvent.h" #include <wtf/CurrentTime.h> #include <wtf/UnusedParam.h> namespace WebCore { +// FIXME: Why isn't this set to 60fps or something? static const double cAnimationTimerDelay = 0.025; static const double cBeginAnimationUpdateTimeNotSet = -1; @@ -51,11 +53,9 @@ AnimationControllerPrivate::AnimationControllerPrivate(Frame* frame) , m_updateStyleIfNeededDispatcher(this, &AnimationControllerPrivate::updateStyleIfNeededDispatcherFired) , m_frame(frame) , m_beginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet) - , m_styleAvailableWaiters(0) - , m_lastStyleAvailableWaiter(0) - , m_startTimeResponseWaiters(0) - , m_lastStartTimeResponseWaiter(0) - , m_waitingForStartTimeResponse(false) + , m_animationsWaitingForStyle() + , m_animationsWaitingForStartTimeResponse() + , m_waitingForAsyncStartNotification(false) { } @@ -323,13 +323,13 @@ double AnimationControllerPrivate::beginAnimationUpdateTime() void AnimationControllerPrivate::endAnimationUpdate() { styleAvailable(); - if (!m_waitingForStartTimeResponse) + if (!m_waitingForAsyncStartNotification) startTimeResponse(beginAnimationUpdateTime()); } void AnimationControllerPrivate::receivedStartTimeResponse(double time) { - m_waitingForStartTimeResponse = false; + m_waitingForAsyncStartNotification = false; startTimeResponse(time); } @@ -365,52 +365,31 @@ unsigned AnimationControllerPrivate::numberOfActiveAnimations() const return count; } -void AnimationControllerPrivate::addToStyleAvailableWaitList(AnimationBase* animation) +void AnimationControllerPrivate::addToAnimationsWaitingForStyle(AnimationBase* animation) { - ASSERT(!animation->next()); - - if (m_styleAvailableWaiters) - m_lastStyleAvailableWaiter->setNext(animation); - else - m_styleAvailableWaiters = animation; - - m_lastStyleAvailableWaiter = animation; - animation->setNext(0); -} - -void AnimationControllerPrivate::removeFromStyleAvailableWaitList(AnimationBase* animationToRemove) -{ - AnimationBase* prevAnimation = 0; - for (AnimationBase* animation = m_styleAvailableWaiters; animation; animation = animation->next()) { - if (animation == animationToRemove) { - if (prevAnimation) - prevAnimation->setNext(animation->next()); - else - m_styleAvailableWaiters = animation->next(); - - if (m_lastStyleAvailableWaiter == animation) - m_lastStyleAvailableWaiter = prevAnimation; - - animationToRemove->setNext(0); - } - } + // Make sure this animation is not in the start time waiters + m_animationsWaitingForStartTimeResponse.remove(animation); + + m_animationsWaitingForStyle.add(animation); +} + +void AnimationControllerPrivate::removeFromAnimationsWaitingForStyle(AnimationBase* animationToRemove) +{ + m_animationsWaitingForStyle.remove(animationToRemove); } void AnimationControllerPrivate::styleAvailable() { // Go through list of waiters and send them on their way - for (AnimationBase* animation = m_styleAvailableWaiters; animation; ) { - AnimationBase* nextAnimation = animation->next(); - animation->setNext(0); - animation->styleAvailable(); - animation = nextAnimation; - } - - m_styleAvailableWaiters = 0; - m_lastStyleAvailableWaiter = 0; + WaitingAnimationsSet::const_iterator it = m_animationsWaitingForStyle.begin(); + WaitingAnimationsSet::const_iterator end = m_animationsWaitingForStyle.end(); + for (; it != end; ++it) + (*it)->styleAvailable(); + + m_animationsWaitingForStyle.clear(); } -void AnimationControllerPrivate::addToStartTimeResponseWaitList(AnimationBase* animation, bool willGetResponse) +void AnimationControllerPrivate::addToAnimationsWaitingForStartTimeResponse(AnimationBase* animation, bool willGetResponse) { // If willGetResponse is true, it means this animation is actually waiting for a response // (which will come in as a call to notifyAnimationStarted()). @@ -429,54 +408,48 @@ void AnimationControllerPrivate::addToStartTimeResponseWaitList(AnimationBase* a // This will synchronize all software and accelerated animations started in the same // updateStyleIfNeeded cycle. // - ASSERT(!animation->next()); if (willGetResponse) - m_waitingForStartTimeResponse = true; + m_waitingForAsyncStartNotification = true; - if (m_startTimeResponseWaiters) - m_lastStartTimeResponseWaiter->setNext(animation); - else - m_startTimeResponseWaiters = animation; - - m_lastStartTimeResponseWaiter = animation; - animation->setNext(0); -} - -void AnimationControllerPrivate::removeFromStartTimeResponseWaitList(AnimationBase* animationToRemove) -{ - AnimationBase* prevAnimation = 0; - for (AnimationBase* animation = m_startTimeResponseWaiters; animation; animation = animation->next()) { - if (animation == animationToRemove) { - if (prevAnimation) - prevAnimation->setNext(animation->next()); - else - m_startTimeResponseWaiters = animation->next(); - - if (m_lastStartTimeResponseWaiter == animation) - m_lastStartTimeResponseWaiter = prevAnimation; - - animationToRemove->setNext(0); - } - prevAnimation = animation; - } + m_animationsWaitingForStartTimeResponse.add(animation); +} + +void AnimationControllerPrivate::removeFromAnimationsWaitingForStartTimeResponse(AnimationBase* animationToRemove) +{ + m_animationsWaitingForStartTimeResponse.remove(animationToRemove); - if (!m_startTimeResponseWaiters) - m_waitingForStartTimeResponse = false; + if (m_animationsWaitingForStartTimeResponse.isEmpty()) + m_waitingForAsyncStartNotification = false; } void AnimationControllerPrivate::startTimeResponse(double time) { // Go through list of waiters and send them on their way - for (AnimationBase* animation = m_startTimeResponseWaiters; animation; ) { - AnimationBase* nextAnimation = animation->next(); - animation->setNext(0); - animation->onAnimationStartResponse(time); - animation = nextAnimation; - } + + WaitingAnimationsSet::const_iterator it = m_animationsWaitingForStartTimeResponse.begin(); + WaitingAnimationsSet::const_iterator end = m_animationsWaitingForStartTimeResponse.end(); + for (; it != end; ++it) + (*it)->onAnimationStartResponse(time); - m_startTimeResponseWaiters = 0; - m_lastStartTimeResponseWaiter = 0; + m_animationsWaitingForStartTimeResponse.clear(); + m_waitingForAsyncStartNotification = false; +} + +void AnimationControllerPrivate::animationWillBeRemoved(AnimationBase* animation) +{ + removeFromAnimationsWaitingForStyle(animation); + removeFromAnimationsWaitingForStartTimeResponse(animation); +} + +PassRefPtr<WebKitAnimationList> AnimationControllerPrivate::animationsForRenderer(RenderObject* renderer) const +{ + RefPtr<CompositeAnimation> animation = m_compositeAnimations.get(renderer); + + if (!animation) + return 0; + + return animation->animations(); } AnimationController::AnimationController(Frame* frame) @@ -612,4 +585,9 @@ bool AnimationController::supportsAcceleratedAnimationOfProperty(CSSPropertyID p #endif } +PassRefPtr<WebKitAnimationList> AnimationController::animationsForRenderer(RenderObject* renderer) const +{ + return m_data->animationsForRenderer(renderer); +} + } // namespace WebCore diff --git a/Source/WebCore/page/animation/AnimationController.h b/Source/WebCore/page/animation/AnimationController.h index 5279467..a355f87 100644 --- a/Source/WebCore/page/animation/AnimationController.h +++ b/Source/WebCore/page/animation/AnimationController.h @@ -42,6 +42,7 @@ class Frame; class Node; class RenderObject; class RenderStyle; +class WebKitAnimationList; class AnimationController { public: @@ -73,6 +74,8 @@ public: static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID); + PassRefPtr<WebKitAnimationList> animationsForRenderer(RenderObject*) const; + private: AnimationControllerPrivate* m_data; }; diff --git a/Source/WebCore/page/animation/AnimationControllerPrivate.h b/Source/WebCore/page/animation/AnimationControllerPrivate.h index 186dd7d..1146eba 100644 --- a/Source/WebCore/page/animation/AnimationControllerPrivate.h +++ b/Source/WebCore/page/animation/AnimationControllerPrivate.h @@ -33,6 +33,7 @@ #include "PlatformString.h" #include "Timer.h" #include <wtf/HashMap.h> +#include <wtf/HashSet.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> @@ -48,6 +49,7 @@ class Frame; class Node; class RenderObject; class RenderStyle; +class WebKitAnimationList; class AnimationControllerPrivate { WTF_MAKE_NONCOPYABLE(AnimationControllerPrivate); WTF_MAKE_FAST_ALLOCATED; @@ -87,11 +89,15 @@ public: void endAnimationUpdate(); void receivedStartTimeResponse(double); - void addToStyleAvailableWaitList(AnimationBase*); - void removeFromStyleAvailableWaitList(AnimationBase*); - - void addToStartTimeResponseWaitList(AnimationBase*, bool willGetResponse); - void removeFromStartTimeResponseWaitList(AnimationBase*); + void addToAnimationsWaitingForStyle(AnimationBase*); + void removeFromAnimationsWaitingForStyle(AnimationBase*); + + void addToAnimationsWaitingForStartTimeResponse(AnimationBase*, bool willGetResponse); + void removeFromAnimationsWaitingForStartTimeResponse(AnimationBase*); + + void animationWillBeRemoved(AnimationBase*); + + PassRefPtr<WebKitAnimationList> animationsForRenderer(RenderObject*) const; private: void animationTimerFired(Timer<AnimationControllerPrivate>*); @@ -119,12 +125,11 @@ private: Vector<RefPtr<Node> > m_nodeChangesToDispatch; double m_beginAnimationUpdateTime; - AnimationBase* m_styleAvailableWaiters; - AnimationBase* m_lastStyleAvailableWaiter; - - AnimationBase* m_startTimeResponseWaiters; - AnimationBase* m_lastStartTimeResponseWaiter; - bool m_waitingForStartTimeResponse; + + typedef HashSet<RefPtr<AnimationBase> > WaitingAnimationsSet; + WaitingAnimationsSet m_animationsWaitingForStyle; + WaitingAnimationsSet m_animationsWaitingForStartTimeResponse; + bool m_waitingForAsyncStartNotification; }; } // namespace WebCore diff --git a/Source/WebCore/page/animation/CompositeAnimation.cpp b/Source/WebCore/page/animation/CompositeAnimation.cpp index 602491e..27409d9 100644 --- a/Source/WebCore/page/animation/CompositeAnimation.cpp +++ b/Source/WebCore/page/animation/CompositeAnimation.cpp @@ -36,6 +36,8 @@ #include "KeyframeAnimation.h" #include "RenderObject.h" #include "RenderStyle.h" +#include "WebKitAnimation.h" +#include "WebKitAnimationList.h" namespace WebCore { @@ -54,6 +56,7 @@ void CompositeAnimation::clearRenderer() CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end(); for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) { ImplicitAnimation* transition = it->second.get(); + animationController()->animationWillBeRemoved(transition); transition->clearRenderer(); } } @@ -62,6 +65,7 @@ void CompositeAnimation::clearRenderer() AnimationNameMap::const_iterator animationsEnd = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != animationsEnd; ++it) { KeyframeAnimation* anim = it->second.get(); + animationController()->animationWillBeRemoved(anim); anim->clearRenderer(); } } @@ -173,8 +177,10 @@ void CompositeAnimation::updateTransitions(RenderObject* renderer, RenderStyle* end = m_transitions.end(); for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) { ImplicitAnimation* anim = it->second.get(); - if (!anim->active()) + if (!anim->active()) { + animationController()->animationWillBeRemoved(anim); toBeRemoved.append(anim->animatingProperty()); + } } // Now remove the transitions from the list @@ -252,8 +258,11 @@ void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, Render kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->second.get(); - if (keyframeAnim->index() < 0) + if (keyframeAnim->index() < 0) { animsToBeRemoved.append(keyframeAnim->name().impl()); + animationController()->animationWillBeRemoved(keyframeAnim); + keyframeAnim->clearRenderer(); + } } // Now remove the animations from the list. @@ -560,4 +569,20 @@ unsigned CompositeAnimation::numberOfActiveAnimations() const return count; } +PassRefPtr<WebKitAnimationList> CompositeAnimation::animations() const +{ + RefPtr<WebKitAnimationList> animations = WebKitAnimationList::create(); + if (!m_keyframeAnimations.isEmpty()) { + m_keyframeAnimations.checkConsistency(); + for (Vector<AtomicStringImpl*>::const_iterator it = m_keyframeAnimationOrderMap.begin(); it != m_keyframeAnimationOrderMap.end(); ++it) { + RefPtr<KeyframeAnimation> keyframeAnimation = m_keyframeAnimations.get(*it); + if (keyframeAnimation) { + RefPtr<WebKitAnimation> anim = WebKitAnimation::create(keyframeAnimation); + animations->append(anim); + } + } + } + return animations; +} + } // namespace WebCore diff --git a/Source/WebCore/page/animation/CompositeAnimation.h b/Source/WebCore/page/animation/CompositeAnimation.h index 249f4c3..1bfe585 100644 --- a/Source/WebCore/page/animation/CompositeAnimation.h +++ b/Source/WebCore/page/animation/CompositeAnimation.h @@ -41,6 +41,7 @@ class AnimationControllerPrivate; class AnimationController; class RenderObject; class RenderStyle; +class WebKitAnimationList; // A CompositeAnimation represents a collection of animations that are running // on a single RenderObject, such as a number of properties transitioning at once. @@ -80,6 +81,8 @@ public: bool pauseTransitionAtTime(int property, double t); unsigned numberOfActiveAnimations() const; + PassRefPtr<WebKitAnimationList> animations() const; + private: CompositeAnimation(AnimationControllerPrivate* animationController) : m_animationController(animationController) |
