diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/page/animation/AnimationController.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/page/animation/AnimationController.cpp')
-rw-r--r-- | Source/WebCore/page/animation/AnimationController.cpp | 345 |
1 files changed, 110 insertions, 235 deletions
diff --git a/Source/WebCore/page/animation/AnimationController.cpp b/Source/WebCore/page/animation/AnimationController.cpp index 9bcb2fed1..5b8c90b8a 100644 --- a/Source/WebCore/page/animation/AnimationController.cpp +++ b/Source/WebCore/page/animation/AnimationController.cpp @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -31,7 +31,6 @@ #include "AnimationBase.h" #include "AnimationControllerPrivate.h" -#include "AnimationEvent.h" #include "CSSParser.h" #include "CSSPropertyAnimation.h" #include "CompositeAnimation.h" @@ -51,28 +50,13 @@ namespace WebCore { static const double cAnimationTimerDelay = 0.025; static const double cBeginAnimationUpdateTimeNotSet = -1; -class AnimationPrivateUpdateBlock { -public: - AnimationPrivateUpdateBlock(AnimationControllerPrivate& animationController) - : m_animationController(animationController) - { - m_animationController.beginAnimationUpdate(); - } - - ~AnimationPrivateUpdateBlock() - { - m_animationController.endAnimationUpdate(); - } - - AnimationControllerPrivate& m_animationController; -}; - AnimationControllerPrivate::AnimationControllerPrivate(Frame& frame) - : m_animationTimer(*this, &AnimationControllerPrivate::animationTimerFired) - , m_updateStyleIfNeededDispatcher(*this, &AnimationControllerPrivate::updateStyleIfNeededDispatcherFired) + : m_animationTimer(this, &AnimationControllerPrivate::animationTimerFired) + , m_updateStyleIfNeededDispatcher(this, &AnimationControllerPrivate::updateStyleIfNeededDispatcherFired) , m_frame(frame) , m_beginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet) - , m_beginAnimationUpdateCount(0) + , m_animationsWaitingForStyle() + , m_animationsWaitingForStartTimeResponse() , m_waitingForAsyncStartNotification(false) , m_isSuspended(false) , m_allowsNewAnimationsWhileSuspended(false) @@ -83,51 +67,33 @@ AnimationControllerPrivate::~AnimationControllerPrivate() { } -CompositeAnimation& AnimationControllerPrivate::ensureCompositeAnimation(RenderElement& renderer) +CompositeAnimation& AnimationControllerPrivate::ensureCompositeAnimation(RenderElement* renderer) { - auto result = m_compositeAnimations.add(&renderer, nullptr); - if (result.isNewEntry) { - result.iterator->value = CompositeAnimation::create(*this); - renderer.setIsCSSAnimating(true); - } - + auto result = m_compositeAnimations.add(renderer, nullptr); + if (result.isNewEntry) + result.iterator->value = CompositeAnimation::create(this); return *result.iterator->value; } -bool AnimationControllerPrivate::clear(RenderElement& renderer) +bool AnimationControllerPrivate::clear(RenderElement* renderer) { - LOG(Animations, "AnimationControllerPrivate %p clear: %p", this, &renderer); - - ASSERT(renderer.isCSSAnimating()); - ASSERT(m_compositeAnimations.contains(&renderer)); - - Element* element = renderer.element(); - - m_eventsToDispatch.removeAllMatching([element] (const EventToDispatch& info) { - return info.element == element; - }); - - m_elementChangesToDispatch.removeAllMatching([element] (const Ref<Element>& currElement) { - return &currElement.get() == element; - }); - // Return false if we didn't do anything OR we are suspended (so we don't try to // do a setNeedsStyleRecalc() when suspended). - RefPtr<CompositeAnimation> animation = m_compositeAnimations.take(&renderer); - ASSERT(animation); - renderer.setIsCSSAnimating(false); + RefPtr<CompositeAnimation> animation = m_compositeAnimations.take(renderer); + if (!animation) + return false; animation->clearRenderer(); return animation->isSuspended(); } double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/* = DoNotCallSetChanged*/) { - AnimationPrivateUpdateBlock updateBlock(*this); double timeToNextService = -1; bool calledSetChanged = false; - for (auto& compositeAnimation : m_compositeAnimations) { - CompositeAnimation& animation = *compositeAnimation.value; + auto end = m_compositeAnimations.end(); + for (auto it = m_compositeAnimations.begin(); it != end; ++it) { + CompositeAnimation& animation = *it->value; if (!animation.isSuspended() && animation.hasAnimations()) { double t = animation.timeToNextService(); if (t != -1 && (t < timeToNextService || timeToNextService == -1)) @@ -135,7 +101,7 @@ double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/* if (!timeToNextService) { if (callSetChanged != CallSetChanged) break; - Element* element = compositeAnimation.key->element(); + Element* element = it->key->element(); ASSERT(element); ASSERT(!element->document().inPageCache()); element->setNeedsStyleRecalc(SyntheticStyleChange); @@ -150,11 +116,11 @@ double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/* return timeToNextService; } -void AnimationControllerPrivate::updateAnimationTimerForRenderer(RenderElement& renderer) +void AnimationControllerPrivate::updateAnimationTimerForRenderer(RenderElement* renderer) { double timeToNextService = 0; - const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(&renderer); + const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(renderer); if (!compositeAnimation->isSuspended() && compositeAnimation->hasAnimations()) timeToNextService = compositeAnimation->timeToNextService(); @@ -188,7 +154,7 @@ void AnimationControllerPrivate::updateAnimationTimer(SetChanged callSetChanged/ m_animationTimer.startOneShot(timeToNextService); } -void AnimationControllerPrivate::updateStyleIfNeededDispatcherFired() +void AnimationControllerPrivate::updateStyleIfNeededDispatcherFired(Timer<AnimationControllerPrivate>&) { fireEventsAndUpdateStyle(); } @@ -201,17 +167,18 @@ void AnimationControllerPrivate::fireEventsAndUpdateStyle() bool updateStyle = !m_eventsToDispatch.isEmpty() || !m_elementChangesToDispatch.isEmpty(); // fire all the events - Vector<EventToDispatch> eventsToDispatch = WTFMove(m_eventsToDispatch); - for (auto& event : eventsToDispatch) { - Element& element = *event.element; - if (event.eventType == eventNames().transitionendEvent) - element.dispatchEvent(TransitionEvent::create(event.eventType, event.name, event.elapsedTime, PseudoElement::pseudoElementNameForEvents(element.pseudoId()))); + Vector<EventToDispatch> eventsToDispatch = std::move(m_eventsToDispatch); + Vector<EventToDispatch>::const_iterator eventsToDispatchEnd = eventsToDispatch.end(); + for (Vector<EventToDispatch>::const_iterator it = eventsToDispatch.begin(); it != eventsToDispatchEnd; ++it) { + Element* element = it->element.get(); + if (it->eventType == eventNames().transitionendEvent) + element->dispatchEvent(TransitionEvent::create(it->eventType, it->name, it->elapsedTime, PseudoElement::pseudoElementNameForEvents(element->pseudoId()))); else - element.dispatchEvent(AnimationEvent::create(event.eventType, event.name, event.elapsedTime)); + element->dispatchEvent(WebKitAnimationEvent::create(it->eventType, it->name, it->elapsedTime)); } - for (auto& change : m_elementChangesToDispatch) - change->setNeedsStyleRecalc(SyntheticStyleChange); + for (unsigned i = 0, size = m_elementChangesToDispatch.size(); i < size; ++i) + m_elementChangesToDispatch[i]->setNeedsStyleRecalc(SyntheticStyleChange); m_elementChangesToDispatch.clear(); @@ -237,9 +204,9 @@ void AnimationControllerPrivate::addEventToDispatch(PassRefPtr<Element> element, startUpdateStyleIfNeededDispatcher(); } -void AnimationControllerPrivate::addElementChangeToDispatch(Ref<Element>&& element) +void AnimationControllerPrivate::addElementChangeToDispatch(PassRef<Element> element) { - m_elementChangesToDispatch.append(WTFMove(element)); + m_elementChangesToDispatch.append(std::move(element)); ASSERT(!m_elementChangesToDispatch.last()->document().inPageCache()); startUpdateStyleIfNeededDispatcher(); } @@ -254,14 +221,11 @@ void AnimationControllerPrivate::animationFrameCallbackFired() } #endif -void AnimationControllerPrivate::animationTimerFired() +void AnimationControllerPrivate::animationTimerFired(Timer<AnimationControllerPrivate>&) { - // We need to keep the frame alive, since it owns us. - Ref<Frame> protector(m_frame); - // Make sure animationUpdateTime is updated, so that it is current even if no // styleChange has happened (e.g. accelerated animations) - AnimationPrivateUpdateBlock updateBlock(*this); + setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); // When the timer fires, all we do is call setChanged on all DOM nodes with running animations and then do an immediate // updateStyleIfNeeded. It will then call back to us with new information. @@ -272,20 +236,16 @@ void AnimationControllerPrivate::animationTimerFired() fireEventsAndUpdateStyle(); } -bool AnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const +bool AnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, bool isRunningNow) const { - ASSERT(renderer.isCSSAnimating()); - ASSERT(m_compositeAnimations.contains(&renderer)); - const CompositeAnimation& animation = *m_compositeAnimations.get(&renderer); - return animation.isAnimatingProperty(property, false, runningState); + const CompositeAnimation* animation = m_compositeAnimations.get(renderer); + return animation && animation->isAnimatingProperty(property, false, isRunningNow); } -bool AnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const +bool AnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, bool isRunningNow) const { - ASSERT(renderer.isCSSAnimating()); - ASSERT(m_compositeAnimations.contains(&renderer)); - const CompositeAnimation& animation = *m_compositeAnimations.get(&renderer); - return animation.isAnimatingProperty(property, true, runningState); + const CompositeAnimation* animation = m_compositeAnimations.get(renderer); + return animation && animation->isAnimatingProperty(property, true, isRunningNow); } void AnimationControllerPrivate::suspendAnimations() @@ -318,11 +278,11 @@ void AnimationControllerPrivate::resumeAnimations() void AnimationControllerPrivate::suspendAnimationsForDocument(Document* document) { - AnimationPrivateUpdateBlock updateBlock(*this); + setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); - for (auto& animation : m_compositeAnimations) { - if (&animation.key->document() == document) - animation.value->suspendAnimations(); + for (auto it = m_compositeAnimations.begin(), end = m_compositeAnimations.end(); it != end; ++it) { + if (&it->key->document() == document) + it->value->suspendAnimations(); } updateAnimationTimer(); @@ -330,11 +290,11 @@ void AnimationControllerPrivate::suspendAnimationsForDocument(Document* document void AnimationControllerPrivate::resumeAnimationsForDocument(Document* document) { - AnimationPrivateUpdateBlock updateBlock(*this); + setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); - for (auto& animation : m_compositeAnimations) { - if (&animation.key->document() == document) - animation.value->resumeAnimations(); + for (auto it = m_compositeAnimations.begin(), end = m_compositeAnimations.end(); it != end; ++it) { + if (&it->key->document() == document) + it->value->resumeAnimations(); } updateAnimationTimer(); @@ -356,7 +316,7 @@ bool AnimationControllerPrivate::pauseAnimationAtTime(RenderElement* renderer, c if (!renderer) return false; - CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer); + CompositeAnimation& compositeAnimation = ensureCompositeAnimation(renderer); if (compositeAnimation.pauseAnimationAtTime(name, t)) { renderer->element()->setNeedsStyleRecalc(SyntheticStyleChange); startUpdateStyleIfNeededDispatcher(); @@ -371,7 +331,7 @@ bool AnimationControllerPrivate::pauseTransitionAtTime(RenderElement* renderer, if (!renderer) return false; - CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer); + CompositeAnimation& compositeAnimation = ensureCompositeAnimation(renderer); if (compositeAnimation.pauseTransitionAtTime(cssPropertyID(property), t)) { renderer->element()->setNeedsStyleRecalc(SyntheticStyleChange); startUpdateStyleIfNeededDispatcher(); @@ -383,72 +343,47 @@ bool AnimationControllerPrivate::pauseTransitionAtTime(RenderElement* renderer, double AnimationControllerPrivate::beginAnimationUpdateTime() { - ASSERT(m_beginAnimationUpdateCount); if (m_beginAnimationUpdateTime == cBeginAnimationUpdateTimeNotSet) m_beginAnimationUpdateTime = monotonicallyIncreasingTime(); - return m_beginAnimationUpdateTime; } -void AnimationControllerPrivate::beginAnimationUpdate() -{ - if (!m_beginAnimationUpdateCount) - setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); - ++m_beginAnimationUpdateCount; -} - void AnimationControllerPrivate::endAnimationUpdate() { - ASSERT(m_beginAnimationUpdateCount > 0); - if (m_beginAnimationUpdateCount == 1) { - styleAvailable(); - if (!m_waitingForAsyncStartNotification) - startTimeResponse(beginAnimationUpdateTime()); - } - --m_beginAnimationUpdateCount; + styleAvailable(); + if (!m_waitingForAsyncStartNotification) + startTimeResponse(beginAnimationUpdateTime()); } void AnimationControllerPrivate::receivedStartTimeResponse(double time) { - LOG(Animations, "AnimationControllerPrivate %p receivedStartTimeResponse %f", this, time); - m_waitingForAsyncStartNotification = false; startTimeResponse(time); } -PassRefPtr<RenderStyle> AnimationControllerPrivate::getAnimatedStyleForRenderer(RenderElement& renderer) +PassRefPtr<RenderStyle> AnimationControllerPrivate::getAnimatedStyleForRenderer(RenderElement* renderer) { - AnimationPrivateUpdateBlock animationUpdateBlock(*this); + if (!renderer) + return 0; - ASSERT(renderer.isCSSAnimating()); - ASSERT(m_compositeAnimations.contains(&renderer)); - const CompositeAnimation& rendererAnimations = *m_compositeAnimations.get(&renderer); - RefPtr<RenderStyle> animatingStyle = rendererAnimations.getAnimatedStyle(); + const CompositeAnimation* rendererAnimations = m_compositeAnimations.get(renderer); + if (!rendererAnimations) + return &renderer->style(); + + RefPtr<RenderStyle> animatingStyle = rendererAnimations->getAnimatedStyle(); if (!animatingStyle) - animatingStyle = &renderer.style(); + animatingStyle = &renderer->style(); return animatingStyle.release(); } -bool AnimationControllerPrivate::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const -{ - ASSERT(renderer.isCSSAnimating()); - ASSERT(m_compositeAnimations.contains(&renderer)); - - const CompositeAnimation& rendererAnimations = *m_compositeAnimations.get(&renderer); - if (!rendererAnimations.isAnimatingProperty(CSSPropertyTransform, false, AnimationBase::Running | AnimationBase::Paused)) - return true; - - return rendererAnimations.computeExtentOfTransformAnimation(bounds); -} - unsigned AnimationControllerPrivate::numberOfActiveAnimations(Document* document) const { unsigned count = 0; - for (auto& animation : m_compositeAnimations) { - if (&animation.key->document() == document) - count += animation.value->numberOfActiveAnimations(); + for (auto it = m_compositeAnimations.begin(), end = m_compositeAnimations.end(); it != end; ++it) { + if (&it->key->document() == document) + count += it->value->numberOfActiveAnimations(); } return count; @@ -498,7 +433,7 @@ void AnimationControllerPrivate::addToAnimationsWaitingForStartTimeResponse(Anim if (willGetResponse) m_waitingForAsyncStartNotification = true; - + m_animationsWaitingForStartTimeResponse.add(animation); } @@ -523,55 +458,13 @@ void AnimationControllerPrivate::startTimeResponse(double time) void AnimationControllerPrivate::animationWillBeRemoved(AnimationBase* animation) { - LOG(Animations, "AnimationControllerPrivate %p animationWillBeRemoved: %p", this, animation); - removeFromAnimationsWaitingForStyle(animation); removeFromAnimationsWaitingForStartTimeResponse(animation); -#if ENABLE(CSS_ANIMATIONS_LEVEL_2) - removeFromAnimationsDependentOnScroll(animation); -#endif - - bool anyAnimationsWaitingForAsyncStart = false; - for (auto& animation : m_animationsWaitingForStartTimeResponse) { - if (animation->waitingForStartTime() && animation->isAccelerated()) { - anyAnimationsWaitingForAsyncStart = true; - break; - } - } - - if (!anyAnimationsWaitingForAsyncStart) - m_waitingForAsyncStartNotification = false; -} - -#if ENABLE(CSS_ANIMATIONS_LEVEL_2) -void AnimationControllerPrivate::addToAnimationsDependentOnScroll(AnimationBase* animation) -{ - m_animationsDependentOnScroll.add(animation); -} - -void AnimationControllerPrivate::removeFromAnimationsDependentOnScroll(AnimationBase* animation) -{ - m_animationsDependentOnScroll.remove(animation); -} - -void AnimationControllerPrivate::scrollWasUpdated() -{ - auto* view = m_frame.view(); - if (!view || !wantsScrollUpdates()) - return; - - m_scrollPosition = view->scrollPositionForFixedPosition().y().toFloat(); - - // FIXME: This is updating all the animations, rather than just the ones - // that are dependent on scroll. We to go from our AnimationBase to its CompositeAnimation - // so we can execute code similar to updateAnimations. - // https://bugs.webkit.org/show_bug.cgi?id=144170 - updateAnimations(CallSetChanged); } -#endif AnimationController::AnimationController(Frame& frame) : m_data(std::make_unique<AnimationControllerPrivate>(frame)) + , m_beginAnimationUpdateCount(0) { } @@ -579,32 +472,33 @@ AnimationController::~AnimationController() { } -void AnimationController::cancelAnimations(RenderElement& renderer) +void AnimationController::cancelAnimations(RenderElement* renderer) { - if (!renderer.isCSSAnimating()) - return; - - if (!m_data->clear(renderer)) + if (!m_data->hasAnimations()) return; - Element* element = renderer.element(); - ASSERT(!element || !element->document().inPageCache()); - if (element) - element->setNeedsStyleRecalc(SyntheticStyleChange); + if (m_data->clear(renderer)) { + Element* element = renderer->element(); + ASSERT(!element || !element->document().inPageCache()); + if (element) + element->setNeedsStyleRecalc(SyntheticStyleChange); + } } -bool AnimationController::updateAnimations(RenderElement& renderer, RenderStyle& newStyle, Ref<RenderStyle>& animatedStyle) +PassRef<RenderStyle> AnimationController::updateAnimations(RenderElement& renderer, PassRef<RenderStyle> newStyle) { + // Don't do anything if we're in the cache + if (renderer.document().inPageCache()) + return newStyle; + RenderStyle* oldStyle = renderer.hasInitializedStyle() ? &renderer.style() : nullptr; - if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.animations() && !newStyle.transitions())) - return false; - if (renderer.document().inPageCache()) - return false; + if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.get().animations() && !newStyle.get().transitions())) + return newStyle; // Don't run transitions when printing. if (renderer.view().printing()) - return false; + return newStyle; // Fetch our current set of implicit animations from a hashtable. We then compare them // against the animations in the style and make sure we're in sync. If destination values @@ -614,53 +508,40 @@ bool AnimationController::updateAnimations(RenderElement& renderer, RenderStyle& // We don't support anonymous pseudo elements like :first-line or :first-letter. ASSERT(renderer.element()); - CompositeAnimation& rendererAnimations = m_data->ensureCompositeAnimation(renderer); - bool animationStateChanged = rendererAnimations.animate(renderer, oldStyle, newStyle, animatedStyle); + Ref<RenderStyle> newStyleBeforeAnimation(std::move(newStyle)); - if (renderer.parent() || newStyle.animations() || (oldStyle && oldStyle->animations())) { - m_data->updateAnimationTimerForRenderer(renderer); + CompositeAnimation& rendererAnimations = m_data->ensureCompositeAnimation(&renderer); + auto blendedStyle = rendererAnimations.animate(renderer, oldStyle, newStyleBeforeAnimation.get()); + + if (renderer.parent() || newStyleBeforeAnimation->animations() || (oldStyle && oldStyle->animations())) { + m_data->updateAnimationTimerForRenderer(&renderer); #if ENABLE(REQUEST_ANIMATION_FRAME) renderer.view().frameView().scheduleAnimation(); #endif } - if (animatedStyle.ptr() != &newStyle) { + if (&blendedStyle.get() != &newStyleBeforeAnimation.get()) { // If the animations/transitions change opacity or transform, we need to update // the style to impose the stacking rules. Note that this is also // done in StyleResolver::adjustRenderStyle(). - if (animatedStyle.get().hasAutoZIndex() && (animatedStyle.get().opacity() < 1.0f || animatedStyle.get().hasTransform())) - animatedStyle.get().setZIndex(0); + if (blendedStyle.get().hasAutoZIndex() && (blendedStyle.get().opacity() < 1.0f || blendedStyle.get().hasTransform())) + blendedStyle.get().setZIndex(0); } - return animationStateChanged; + return blendedStyle; } -PassRefPtr<RenderStyle> AnimationController::getAnimatedStyleForRenderer(RenderElement& renderer) +PassRefPtr<RenderStyle> AnimationController::getAnimatedStyleForRenderer(RenderElement* renderer) { - if (!renderer.isCSSAnimating()) - return &renderer.style(); return m_data->getAnimatedStyleForRenderer(renderer); } -bool AnimationController::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const -{ - if (!renderer.isCSSAnimating()) - return true; - - return m_data->computeExtentOfAnimation(renderer, bounds); -} - -void AnimationController::notifyAnimationStarted(RenderElement& renderer, double startTime) +void AnimationController::notifyAnimationStarted(RenderElement*, double startTime) { - LOG(Animations, "AnimationController %p notifyAnimationStarted on renderer %p, time=%f", this, &renderer, startTime); - UNUSED_PARAM(renderer); - - AnimationUpdateBlock animationUpdateBlock(this); m_data->receivedStartTimeResponse(startTime); } bool AnimationController::pauseAnimationAtTime(RenderElement* renderer, const AtomicString& name, double t) { - AnimationUpdateBlock animationUpdateBlock(this); return m_data->pauseAnimationAtTime(renderer, name, t); } @@ -671,18 +552,17 @@ unsigned AnimationController::numberOfActiveAnimations(Document* document) const bool AnimationController::pauseTransitionAtTime(RenderElement* renderer, const String& property, double t) { - AnimationUpdateBlock animationUpdateBlock(this); return m_data->pauseTransitionAtTime(renderer, property, t); } -bool AnimationController::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const +bool AnimationController::isRunningAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, bool isRunningNow) const { - return renderer.isCSSAnimating() && m_data->isRunningAnimationOnRenderer(renderer, property, runningState); + return m_data->isRunningAnimationOnRenderer(renderer, property, isRunningNow); } -bool AnimationController::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const +bool AnimationController::isRunningAcceleratedAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, bool isRunningNow) const { - return renderer.isCSSAnimating() && m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, runningState); + return m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, isRunningNow); } bool AnimationController::isSuspended() const @@ -728,43 +608,38 @@ void AnimationController::suspendAnimationsForDocument(Document* document) void AnimationController::resumeAnimationsForDocument(Document* document) { LOG(Animations, "resuming animations for document %p", document); - AnimationUpdateBlock animationUpdateBlock(this); m_data->resumeAnimationsForDocument(document); } void AnimationController::startAnimationsIfNotSuspended(Document* document) { LOG(Animations, "animations may start for document %p", document); - - AnimationUpdateBlock animationUpdateBlock(this); m_data->startAnimationsIfNotSuspended(document); } void AnimationController::beginAnimationUpdate() { - m_data->beginAnimationUpdate(); + if (!m_beginAnimationUpdateCount) + m_data->setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet); + ++m_beginAnimationUpdateCount; } void AnimationController::endAnimationUpdate() { - m_data->endAnimationUpdate(); + ASSERT(m_beginAnimationUpdateCount > 0); + --m_beginAnimationUpdateCount; + if (!m_beginAnimationUpdateCount) + m_data->endAnimationUpdate(); } bool AnimationController::supportsAcceleratedAnimationOfProperty(CSSPropertyID property) { +#if USE(ACCELERATED_COMPOSITING) return CSSPropertyAnimation::animationOfPropertyIsAccelerated(property); -} - -#if ENABLE(CSS_ANIMATIONS_LEVEL_2) -bool AnimationController::wantsScrollUpdates() const -{ - return m_data->wantsScrollUpdates(); -} - -void AnimationController::scrollWasUpdated() -{ - m_data->scrollWasUpdated(); -} +#else + UNUSED_PARAM(property); + return false; #endif +} } // namespace WebCore |