Title: [183364] trunk/Source/WebCore
Revision
183364
Author
simon.fra...@apple.com
Date
2015-04-26 13:38:20 -0700 (Sun, 26 Apr 2015)

Log Message

Modernize animations code
https://bugs.webkit.org/show_bug.cgi?id=144196

Reviewed by Darin Adler.

General cleanup in animation-related code.

Use C++ references where possible. Use modern loops. Make classes fast-allocated.
Use C++11 member initialization. Order member variables to optimize packing.

This removes some null checks in CompositeAnimation, but the values in m_transitions
and m_keyframeAnimations can never be null.

No behavior change.

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::AnimationBase):
(WebCore::AnimationBase::animationsMatch):
(WebCore::AnimationBase::updateStateMachine):
(WebCore::AnimationBase::fireAnimationEventsIfNeeded):
(WebCore::AnimationBase::beginAnimationUpdateTime):
(WebCore::AnimationBase::getElapsedTime):
* page/animation/AnimationBase.h:
(WebCore::AnimationBase::animation):
(WebCore::AnimationBase::setAnimation):
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::ensureCompositeAnimation):
(WebCore::AnimationControllerPrivate::addToAnimationsWaitingForStartTimeResponse):
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::CompositeAnimation):
(WebCore::CompositeAnimation::clearRenderer):
(WebCore::CompositeAnimation::updateTransitions):
(WebCore::CompositeAnimation::updateKeyframeAnimations):
(WebCore::CompositeAnimation::animate):
(WebCore::CompositeAnimation::getAnimatedStyle):
(WebCore::CompositeAnimation::timeToNextService):
(WebCore::CompositeAnimation::getAnimationForProperty):
(WebCore::CompositeAnimation::computeExtentOfTransformAnimation):
(WebCore::CompositeAnimation::suspendAnimations):
(WebCore::CompositeAnimation::resumeAnimations):
(WebCore::CompositeAnimation::overrideImplicitAnimations):
(WebCore::CompositeAnimation::resumeOverriddenImplicitAnimations):
(WebCore::CompositeAnimation::isAnimatingProperty):
(WebCore::CompositeAnimation::pauseTransitionAtTime):
(WebCore::CompositeAnimation::numberOfActiveAnimations):
* page/animation/CompositeAnimation.h:
(WebCore::CompositeAnimation::create):
(WebCore::CompositeAnimation::animationController):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::ImplicitAnimation):
(WebCore::ImplicitAnimation::sendTransitionEvent):
* page/animation/ImplicitAnimation.h:
(WebCore::ImplicitAnimation::create):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::animate):
(WebCore::KeyframeAnimation::getAnimatedStyle):
(WebCore::KeyframeAnimation::computeExtentOfTransformAnimation):
(WebCore::KeyframeAnimation::startAnimation):
(WebCore::KeyframeAnimation::sendAnimationEvent):
(WebCore::KeyframeAnimation::overrideAnimations):
(WebCore::KeyframeAnimation::resumeOverriddenAnimations):
(WebCore::KeyframeAnimation::timeToNextService):
* page/animation/KeyframeAnimation.h:
* platform/animation/Animation.cpp:
(WebCore::Animation::animationsMatch):
* platform/animation/Animation.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paint):
(WebCore::performOverlapTests):
* rendering/style/KeyframeList.h:
(WebCore::KeyframeList::properties):
(WebCore::KeyframeList::keyframes):
(WebCore::KeyframeList::beginProperties): Deleted.
(WebCore::KeyframeList::endProperties): Deleted.
(WebCore::KeyframeList::operator[]): Deleted.
* rendering/style/RenderStyle.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183363 => 183364)


--- trunk/Source/WebCore/ChangeLog	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/ChangeLog	2015-04-26 20:38:20 UTC (rev 183364)
@@ -1,3 +1,83 @@
+2015-04-26  Simon Fraser  <simon.fra...@apple.com>
+
+        Modernize animations code
+        https://bugs.webkit.org/show_bug.cgi?id=144196
+
+        Reviewed by Darin Adler.
+        
+        General cleanup in animation-related code.
+        
+        Use C++ references where possible. Use modern loops. Make classes fast-allocated.
+        Use C++11 member initialization. Order member variables to optimize packing.
+        
+        This removes some null checks in CompositeAnimation, but the values in m_transitions
+        and m_keyframeAnimations can never be null.
+        
+        No behavior change.
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::AnimationBase):
+        (WebCore::AnimationBase::animationsMatch):
+        (WebCore::AnimationBase::updateStateMachine):
+        (WebCore::AnimationBase::fireAnimationEventsIfNeeded):
+        (WebCore::AnimationBase::beginAnimationUpdateTime):
+        (WebCore::AnimationBase::getElapsedTime):
+        * page/animation/AnimationBase.h:
+        (WebCore::AnimationBase::animation):
+        (WebCore::AnimationBase::setAnimation):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::ensureCompositeAnimation):
+        (WebCore::AnimationControllerPrivate::addToAnimationsWaitingForStartTimeResponse):
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimation::CompositeAnimation):
+        (WebCore::CompositeAnimation::clearRenderer):
+        (WebCore::CompositeAnimation::updateTransitions):
+        (WebCore::CompositeAnimation::updateKeyframeAnimations):
+        (WebCore::CompositeAnimation::animate):
+        (WebCore::CompositeAnimation::getAnimatedStyle):
+        (WebCore::CompositeAnimation::timeToNextService):
+        (WebCore::CompositeAnimation::getAnimationForProperty):
+        (WebCore::CompositeAnimation::computeExtentOfTransformAnimation):
+        (WebCore::CompositeAnimation::suspendAnimations):
+        (WebCore::CompositeAnimation::resumeAnimations):
+        (WebCore::CompositeAnimation::overrideImplicitAnimations):
+        (WebCore::CompositeAnimation::resumeOverriddenImplicitAnimations):
+        (WebCore::CompositeAnimation::isAnimatingProperty):
+        (WebCore::CompositeAnimation::pauseTransitionAtTime):
+        (WebCore::CompositeAnimation::numberOfActiveAnimations):
+        * page/animation/CompositeAnimation.h:
+        (WebCore::CompositeAnimation::create):
+        (WebCore::CompositeAnimation::animationController):
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::ImplicitAnimation):
+        (WebCore::ImplicitAnimation::sendTransitionEvent):
+        * page/animation/ImplicitAnimation.h:
+        (WebCore::ImplicitAnimation::create):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::KeyframeAnimation):
+        (WebCore::KeyframeAnimation::animate):
+        (WebCore::KeyframeAnimation::getAnimatedStyle):
+        (WebCore::KeyframeAnimation::computeExtentOfTransformAnimation):
+        (WebCore::KeyframeAnimation::startAnimation):
+        (WebCore::KeyframeAnimation::sendAnimationEvent):
+        (WebCore::KeyframeAnimation::overrideAnimations):
+        (WebCore::KeyframeAnimation::resumeOverriddenAnimations):
+        (WebCore::KeyframeAnimation::timeToNextService):
+        * page/animation/KeyframeAnimation.h:
+        * platform/animation/Animation.cpp:
+        (WebCore::Animation::animationsMatch):
+        * platform/animation/Animation.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::paint):
+        (WebCore::performOverlapTests):
+        * rendering/style/KeyframeList.h:
+        (WebCore::KeyframeList::properties):
+        (WebCore::KeyframeList::keyframes):
+        (WebCore::KeyframeList::beginProperties): Deleted.
+        (WebCore::KeyframeList::endProperties): Deleted.
+        (WebCore::KeyframeList::operator[]): Deleted.
+        * rendering/style/RenderStyle.h:
+
 2015-04-25  Simon Fraser  <simon.fra...@apple.com>
 
         Expand compositing coverage rect when scrolling and animating

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (183363 => 183364)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -70,19 +70,10 @@
     return floor(numSteps * t) / numSteps;
 }
 
-AnimationBase::AnimationBase(const Animation& transition, RenderElement* renderer, CompositeAnimation* compositeAnimation)
-    : m_animationState(AnimationState::New)
-    , m_isAccelerated(false)
-    , m_transformFunctionListValid(false)
-    , m_filterFunctionListsMatch(false)
-    , m_startTime(0)
-    , m_pauseTime(-1)
-    , m_requestedStartTime(0)
-    , m_totalDuration(-1)
-    , m_nextIterationDuration(-1)
-    , m_object(renderer)
-    , m_animation(const_cast<Animation*>(&transition))
+AnimationBase::AnimationBase(Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation)
+    : m_object(renderer)
     , m_compositeAnimation(compositeAnimation)
+    , m_animation(animation)
 {
     // Compute the total duration
     if (m_animation->iterationCount() > 0)
@@ -106,9 +97,9 @@
     return m_animation->playState() == AnimPlayStatePlaying;
 }
 
-bool AnimationBase::animationsMatch(const Animation* anim) const
+bool AnimationBase::animationsMatch(const Animation& animation) const
 {
-    return m_animation->animationsMatch(anim);
+    return m_animation->animationsMatch(animation);
 }
 
 #if !LOG_DISABLED
@@ -161,7 +152,7 @@
     // If we get AnimationStateInput::RestartAnimation then we force a new animation, regardless of state.
     if (input == AnimationStateInput::MakeNew) {
         if (m_animationState == AnimationState::StartWaitStyleAvailable)
-            m_compositeAnimation->animationController()->removeFromAnimationsWaitingForStyle(this);
+            m_compositeAnimation->animationController().removeFromAnimationsWaitingForStyle(this);
         LOG(Animations, "%p AnimationState %s -> New", this, nameForState(m_animationState));
         m_animationState = AnimationState::New;
         m_startTime = 0;
@@ -174,7 +165,7 @@
 
     if (input == AnimationStateInput::RestartAnimation) {
         if (m_animationState == AnimationState::StartWaitStyleAvailable)
-            m_compositeAnimation->animationController()->removeFromAnimationsWaitingForStyle(this);
+            m_compositeAnimation->animationController().removeFromAnimationsWaitingForStyle(this);
         LOG(Animations, "%p AnimationState %s -> New", this, nameForState(m_animationState));
         m_animationState = AnimationState::New;
         m_startTime = 0;
@@ -190,7 +181,7 @@
 
     if (input == AnimationStateInput::EndAnimation) {
         if (m_animationState == AnimationState::StartWaitStyleAvailable)
-            m_compositeAnimation->animationController()->removeFromAnimationsWaitingForStyle(this);
+            m_compositeAnimation->animationController().removeFromAnimationsWaitingForStyle(this);
         LOG(Animations, "%p AnimationState %s -> Done", this, nameForState(m_animationState));
         m_animationState = AnimationState::Done;
         endAnimation();
@@ -232,7 +223,7 @@
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
             if (m_animation->trigger() && m_animation->trigger()->isScrollAnimationTrigger())
-                m_compositeAnimation->animationController()->addToAnimationsDependentOnScroll(this);
+                m_compositeAnimation->animationController().addToAnimationsDependentOnScroll(this);
 #endif
             break;
         case AnimationState::StartWaitTimer:
@@ -243,11 +234,11 @@
                 // Start timer has fired, tell the animation to start and wait for it to respond with start time
                 LOG(Animations, "%p AnimationState %s -> StartWaitStyleAvailable", this, nameForState(m_animationState));
                 m_animationState = AnimationState::StartWaitStyleAvailable;
-                m_compositeAnimation->animationController()->addToAnimationsWaitingForStyle(this);
+                m_compositeAnimation->animationController().addToAnimationsWaitingForStyle(this);
 
                 // Trigger a render so we can start the animation
                 if (m_object && m_object->element())
-                    m_compositeAnimation->animationController()->addElementChangeToDispatch(*m_object->element());
+                    m_compositeAnimation->animationController().addElementChangeToDispatch(*m_object->element());
             } else {
                 ASSERT(!paused());
                 // We're waiting for the start timer to fire and we got a pause. Cancel the timer, pause and wait
@@ -281,7 +272,7 @@
                         timeOffset = -m_animation->delay();
                     bool started = startAnimation(timeOffset);
 
-                    m_compositeAnimation->animationController()->addToAnimationsWaitingForStartTimeResponse(this, started);
+                    m_compositeAnimation->animationController().addToAnimationsWaitingForStartTimeResponse(this, started);
                     m_isAccelerated = started;
                 }
             } else {
@@ -312,7 +303,7 @@
 
                 // Dispatch updateStyleIfNeeded so we can start the animation
                 if (m_object && m_object->element())
-                    m_compositeAnimation->animationController()->addElementChangeToDispatch(*m_object->element());
+                    m_compositeAnimation->animationController().addElementChangeToDispatch(*m_object->element());
             } 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
@@ -363,7 +354,7 @@
 
                     // Fire off another style change so we can set the final value
                     if (m_object->element())
-                        m_compositeAnimation->animationController()->addElementChangeToDispatch(*m_object->element());
+                        m_compositeAnimation->animationController().addElementChangeToDispatch(*m_object->element());
                 }
             } else {
                 // We are pausing while running. Cancel the animation and wait
@@ -432,7 +423,7 @@
                         m_isAccelerated = true;
                     } else {
                         bool started = startAnimation(beginAnimationUpdateTime() - m_startTime);
-                        m_compositeAnimation->animationController()->addToAnimationsWaitingForStartTimeResponse(this, started);
+                        m_compositeAnimation->animationController().addToAnimationsWaitingForStartTimeResponse(this, started);
                         m_isAccelerated = started;
                     }
                 }
@@ -487,7 +478,7 @@
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
         if (m_animation->trigger() && m_animation->trigger()->isScrollAnimationTrigger()) {
             if (m_object) {
-                float offset = m_compositeAnimation->animationController()->scrollPosition();
+                float offset = m_compositeAnimation->animationController().scrollPosition();
                 ScrollAnimationTrigger& scrollTrigger = downcast<ScrollAnimationTrigger>(*m_animation->trigger().get());
                 if (offset > scrollTrigger.startValue().value())
                     updateStateMachine(AnimationStateInput::StartTimerFired, 0);
@@ -724,7 +715,7 @@
     if (!m_compositeAnimation)
         return 0;
 
-    return m_compositeAnimation->animationController()->beginAnimationUpdateTime();
+    return m_compositeAnimation->animationController().beginAnimationUpdateTime();
 }
 
 double AnimationBase::getElapsedTime() const
@@ -733,7 +724,7 @@
     if (m_animation->trigger() && m_animation->trigger()->isScrollAnimationTrigger()) {
         ScrollAnimationTrigger& scrollTrigger = downcast<ScrollAnimationTrigger>(*m_animation->trigger().get());
         if (scrollTrigger.hasEndValue() && m_object) {
-            float offset = m_compositeAnimation->animationController()->scrollPosition();
+            float offset = m_compositeAnimation->animationController().scrollPosition();
             float startValue = scrollTrigger.startValue().value();
             if (offset < startValue)
                 return 0;

Modified: trunk/Source/WebCore/page/animation/AnimationBase.h (183363 => 183364)


--- trunk/Source/WebCore/page/animation/AnimationBase.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/AnimationBase.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -50,9 +50,9 @@
 class AnimationBase : public RefCounted<AnimationBase> {
     friend class CompositeAnimation;
     friend class CSSPropertyAnimation;
-
+    WTF_MAKE_FAST_ALLOCATED;
 public:
-    AnimationBase(const Animation& transition, RenderElement*, CompositeAnimation*);
+    AnimationBase(Animation& transition, RenderElement*, CompositeAnimation*);
     virtual ~AnimationBase() { }
 
     RenderElement* renderer() const { return m_object; }
@@ -144,9 +144,10 @@
 
     void fireAnimationEventsIfNeeded();
 
-    bool animationsMatch(const Animation*) const;
+    bool animationsMatch(const Animation&) const;
 
-    void setAnimation(const Animation& animation) { m_animation = const_cast<Animation*>(&animation); }
+    const Animation& animation() const { return m_animation; }
+    void setAnimation(Animation& animation) { m_animation = animation; }
 
     // Return true if this animation is overridden. This will only be the case for
     // ImplicitAnimations and is used to determine whether or not we should force
@@ -210,8 +211,6 @@
         updateStateMachine(AnimationStateInput::StyleAvailable, -1);
     }
 
-    const Animation& animation() const { return *m_animation; }
-
 protected:
     virtual void overrideAnimations() { }
     virtual void resumeOverriddenAnimations() { }
@@ -244,22 +243,20 @@
     bool computeTransformedExtentViaTransformList(const FloatRect& rendererBox, const RenderStyle&, LayoutRect& bounds) const;
     bool computeTransformedExtentViaMatrix(const FloatRect& rendererBox, const RenderStyle&, LayoutRect& bounds) const;
 
-    AnimationState m_animationState;
-
-    bool m_isAccelerated;
-    bool m_transformFunctionListValid;
-    bool m_filterFunctionListsMatch;
-    double m_startTime;
-    double m_pauseTime;
-    double m_requestedStartTime;
-
-    double m_totalDuration;
-    double m_nextIterationDuration;
-
     RenderElement* m_object;
+    CompositeAnimation* m_compositeAnimation; // Ideally this would be a reference, but it has to be cleared if an animation is destroyed inside an event callback.
+    Ref<Animation> m_animation;
 
-    RefPtr<Animation> m_animation;
-    CompositeAnimation* m_compositeAnimation;
+    double m_startTime { 0 };
+    double m_pauseTime { -1 };
+    double m_requestedStartTime { 0 };
+    double m_totalDuration { -1 };
+    double m_nextIterationDuration { -1 };
+
+    AnimationState m_animationState { AnimationState::New };
+    bool m_isAccelerated { false };
+    bool m_transformFunctionListValid { false };
+    bool m_filterFunctionListsMatch { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/animation/AnimationController.cpp (183363 => 183364)


--- trunk/Source/WebCore/page/animation/AnimationController.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/AnimationController.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -89,7 +89,7 @@
 {
     auto result = m_compositeAnimations.add(&renderer, nullptr);
     if (result.isNewEntry) {
-        result.iterator->value = CompositeAnimation::create(this);
+        result.iterator->value = CompositeAnimation::create(*this);
         renderer.setIsCSSAnimating(true);
     }
 
@@ -487,7 +487,7 @@
     
     if (willGetResponse)
         m_waitingForAsyncStartNotification = true;
-    
+
     m_animationsWaitingForStartTimeResponse.add(animation);
 }
 

Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.cpp (183363 => 183364)


--- trunk/Source/WebCore/page/animation/CompositeAnimation.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -41,13 +41,10 @@
 
 namespace WebCore {
 
-CompositeAnimation::CompositeAnimation(AnimationControllerPrivate* animationController)
+CompositeAnimation::CompositeAnimation(AnimationControllerPrivate& animationController)
     : m_animationController(animationController)
-#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
-    , m_hasScrollTriggeredAnimation(false)
-#endif
 {
-    m_suspended = animationController->isSuspended() && !animationController->allowsNewAnimationsWhileSuspended();
+    m_suspended = m_animationController.isSuspended() && !m_animationController.allowsNewAnimationsWhileSuspended();
 }
 
 CompositeAnimation::~CompositeAnimation()
@@ -65,20 +62,16 @@
     if (!m_transitions.isEmpty()) {
         // Clear the renderers from all running animations, in case we are in the middle of
         // an animation callback (see https://bugs.webkit.org/show_bug.cgi?id=22052)
-        CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
-            ImplicitAnimation* transition = it->value.get();
-            animationController()->animationWillBeRemoved(transition);
+        for (auto& transition : m_transitions.values()) {
+            animationController().animationWillBeRemoved(transition.get());
             transition->clear();
         }
     }
     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) {
-            KeyframeAnimation* anim = it->value.get();
-            animationController()->animationWillBeRemoved(anim);
-            anim->clear();
+        for (auto& animation : m_keyframeAnimations.values()) {
+            animationController().animationWillBeRemoved(animation.get());
+            animation->clear();
         }
     }
 }
@@ -91,16 +84,15 @@
 
     // Mark all existing transitions as no longer active. We will mark the still active ones
     // in the next loop and then toss the ones that didn't get marked.
-    CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
-    for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it)
-        it->value->setActive(false);
+    for (auto& transition : m_transitions.values())
+        transition->setActive(false);
         
     RefPtr<RenderStyle> modifiedCurrentStyle;
     
     // Check to see if we need to update the active transitions
     if (targetStyle->transitions()) {
         for (size_t i = 0; i < targetStyle->transitions()->size(); ++i) {
-            const Animation& animation = targetStyle->transitions()->animation(i);
+            Animation& animation = targetStyle->transitions()->animation(i);
             bool isActiveTransition = !m_suspended && (animation.duration() || animation.delay() > 0);
 
             Animation::AnimationMode mode = animation.animationMode();
@@ -160,7 +152,7 @@
                             implAnim->blendPropertyValueInStyle(prop, modifiedCurrentStyle.get());
                         }
                         LOG(Animations, "Removing existing ImplicitAnimation %p for property %s", implAnim, getPropertyName(prop));
-                        animationController()->animationWillBeRemoved(implAnim);
+                        animationController().animationWillBeRemoved(implAnim);
                         m_transitions.remove(prop);
                         equal = false;
                     }
@@ -189,19 +181,17 @@
 
     // Make a list of transitions to be removed
     Vector<int> toBeRemoved;
-    end = m_transitions.end();
-    for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
-        ImplicitAnimation* anim = it->value.get();
-        if (!anim->active()) {
-            animationController()->animationWillBeRemoved(anim);
-            toBeRemoved.append(anim->animatingProperty());
-            LOG(Animations, "Removing ImplicitAnimation %p for property %s", anim, getPropertyName(anim->animatingProperty()));
+    for (auto& transition : m_transitions.values()) {
+        if (!transition->active()) {
+            animationController().animationWillBeRemoved(transition.get());
+            toBeRemoved.append(transition->animatingProperty());
+            LOG(Animations, "Removing ImplicitAnimation %p for property %s", transition.get(), getPropertyName(transition->animatingProperty()));
         }
     }
 
     // Now remove the transitions from the list
-    for (size_t j = 0; j < toBeRemoved.size(); ++j)
-        m_transitions.remove(toBeRemoved[j]);
+    for (auto propertyToRemove : toBeRemoved)
+        m_transitions.remove(propertyToRemove);
 }
 
 void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle)
@@ -211,20 +201,18 @@
         return;
 
     m_keyframeAnimations.checkConsistency();
-
-    AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end();
     
     if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) {
         // The current and target animations are the same so we just need to toss any 
         // animation which is finished (postActive).
-        for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) {
-            if (it->value->postActive())
-                it->value->setIndex(-1);
+        for (auto& animation : m_keyframeAnimations.values()) {
+            if (animation->postActive())
+                animation->setIndex(-1);
         }
     } else {
         // Mark all existing animations as no longer active.
-        for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it)
-            it->value->setIndex(-1);
+        for (auto& animation : m_keyframeAnimations.values())
+            animation->setIndex(-1);
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
         m_hasScrollTriggeredAnimation = false;
@@ -239,7 +227,7 @@
         if (targetStyle->animations()) {
             int numAnims = targetStyle->animations()->size();
             for (int i = 0; i < numAnims; ++i) {
-                const Animation& animation = targetStyle->animations()->animation(i);
+                Animation& animation = targetStyle->animations()->animation(i);
                 AtomicString animationName(animation.name());
 
                 if (!animation.isValidAnimation())
@@ -274,8 +262,8 @@
                         LOG(Animations, "  (created in suspended/paused state)");
                     }
 #if !LOG_DISABLED
-                    for (auto it = keyframeAnim->keyframes().beginProperties(), end = keyframeAnim->keyframes().endProperties(); it != end; ++it)
-                        LOG(Animations, "  property %s", getPropertyName(*it));
+                    for (auto propertyID : keyframeAnim->keyframes().properties())
+                        LOG(Animations, "  property %s", getPropertyName(propertyID));
 #endif
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
@@ -295,20 +283,18 @@
     
     // Make a list of animations to be removed.
     Vector<AtomicStringImpl*> animsToBeRemoved;
-    kfend = m_keyframeAnimations.end();
-    for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) {
-        KeyframeAnimation* keyframeAnim = it->value.get();
-        if (keyframeAnim->index() < 0) {
-            animsToBeRemoved.append(keyframeAnim->name().impl());
-            animationController()->animationWillBeRemoved(keyframeAnim);
-            keyframeAnim->clear();
-            LOG(Animations, "Removing KeyframeAnimation %p", keyframeAnim);
+    for (auto& animation : m_keyframeAnimations.values()) {
+        if (animation->index() < 0) {
+            animsToBeRemoved.append(animation->name().impl());
+            animationController().animationWillBeRemoved(animation.get());
+            animation->clear();
+            LOG(Animations, "Removing KeyframeAnimation %p", animation.get());
         }
     }
     
     // Now remove the animations from the list.
-    for (size_t j = 0; j < animsToBeRemoved.size(); ++j)
-        m_keyframeAnimations.remove(animsToBeRemoved[j]);
+    for (auto nameForRemoval : animsToBeRemoved)
+        m_keyframeAnimations.remove(nameForRemoval);
 }
 
 Ref<RenderStyle> CompositeAnimation::animate(RenderElement& renderer, RenderStyle* currentStyle, RenderStyle& targetStyle)
@@ -324,40 +310,35 @@
         // Now that we have transition objects ready, let them know about the new goal state.  We want them
         // to fill in a RenderStyle*& only if needed.
         if (!m_transitions.isEmpty()) {
-            CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
-            for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
-                if (ImplicitAnimation* anim = it->value.get())
-                    anim->animate(this, &renderer, currentStyle, &targetStyle, resultStyle);
-            }
+            for (auto& transition : m_transitions.values())
+                transition->animate(this, &renderer, currentStyle, &targetStyle, resultStyle);
         }
     }
 
     // Now that we have animation objects ready, let them know about the new goal state.  We want them
     // to fill in a RenderStyle*& only if needed.
-    for (Vector<AtomicStringImpl*>::const_iterator it = m_keyframeAnimationOrderMap.begin(); it != m_keyframeAnimationOrderMap.end(); ++it) {
-        RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(*it);
+    for (auto& name : m_keyframeAnimationOrderMap) {
+        RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name);
         if (keyframeAnim)
             keyframeAnim->animate(this, &renderer, currentStyle, &targetStyle, resultStyle);
     }
 
     if (resultStyle)
         return resultStyle.releaseNonNull();
+
     return targetStyle;
 }
 
 PassRefPtr<RenderStyle> CompositeAnimation::getAnimatedStyle() const
 {
     RefPtr<RenderStyle> resultStyle;
-    CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
-    for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
-        if (ImplicitAnimation* implicitAnimation = it->value.get())
-            implicitAnimation->getAnimatedStyle(resultStyle);
-    }
+    for (auto& transition : m_transitions.values())
+        transition->getAnimatedStyle(resultStyle);
 
     m_keyframeAnimations.checkConsistency();
 
-    for (Vector<AtomicStringImpl*>::const_iterator it = m_keyframeAnimationOrderMap.begin(); it != m_keyframeAnimationOrderMap.end(); ++it) {
-        RefPtr<KeyframeAnimation> keyframeAnimation = m_keyframeAnimations.get(*it);
+    for (auto& name : m_keyframeAnimationOrderMap) {
+        RefPtr<KeyframeAnimation> keyframeAnimation = m_keyframeAnimations.get(name);
         if (keyframeAnimation)
             keyframeAnimation->getAnimatedStyle(resultStyle);
     }
@@ -372,10 +353,8 @@
     double minT = -1;
     
     if (!m_transitions.isEmpty()) {
-        CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
-            ImplicitAnimation* transition = it->value.get();
-            double t = transition ? transition->timeToNextService() : -1;
+        for (auto& transition : m_transitions.values()) {
+            double t = transition->timeToNextService();
             if (t < minT || minT == -1)
                 minT = t;
             if (minT == 0)
@@ -384,10 +363,8 @@
     }
     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) {
-            KeyframeAnimation* animation = it->value.get();
-            double t = animation ? animation->timeToNextService() : -1;
+        for (auto& animation : m_keyframeAnimations.values()) {
+            double t = animation->timeToNextService();
             if (t < minT || minT == -1)
                 minT = t;
             if (minT == 0)
@@ -406,11 +383,9 @@
     // So we need to iterate through all animations
     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) {
-            RefPtr<KeyframeAnimation> anim = it->value;
-            if (anim->hasAnimationForProperty(property))
-                retval = anim;
+        for (auto& animation : m_keyframeAnimations.values()) {
+            if (animation->hasAnimationForProperty(property))
+                retval = animation;
         }
     }
     
@@ -422,32 +397,28 @@
     // If more than one transition and animation affect transform, give up.
     bool seenTransformAnimation = false;
     
-    for (auto& it : m_keyframeAnimations) {
-        if (KeyframeAnimation* anim = it.value.get()) {
-            if (!anim->hasAnimationForProperty(CSSPropertyTransform))
-                continue;
+    for (auto& animation : m_keyframeAnimations.values()) {
+        if (!animation->hasAnimationForProperty(CSSPropertyTransform))
+            continue;
 
-            if (seenTransformAnimation)
-                return false;
+        if (seenTransformAnimation)
+            return false;
 
-            seenTransformAnimation = true;
+        seenTransformAnimation = true;
 
-            if (!anim->computeExtentOfTransformAnimation(bounds))
-                return false;
-        }
+        if (!animation->computeExtentOfTransformAnimation(bounds))
+            return false;
     }
 
-    for (auto& it : m_transitions) {
-        if (ImplicitAnimation* anim = it.value.get()) {
-            if (anim->animatingProperty() != CSSPropertyTransform || !anim->hasStyle())
-                continue;
+    for (auto& transition : m_transitions.values()) {
+        if (transition->animatingProperty() != CSSPropertyTransform || !transition->hasStyle())
+            continue;
 
-            if (seenTransformAnimation)
-                return false;
+        if (seenTransformAnimation)
+            return false;
 
-            if (!anim->computeExtentOfTransformAnimation(bounds))
-                return false;
-        }
+        if (!transition->computeExtentOfTransformAnimation(bounds))
+            return false;
     }
     
     return true;
@@ -462,18 +433,14 @@
 
     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->value.get())
-                anim->updatePlayState(AnimPlayStatePaused);
-        }
+        for (auto& animation : m_keyframeAnimations.values())
+            animation->updatePlayState(AnimPlayStatePaused);
     }
+
     if (!m_transitions.isEmpty()) {
-        CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
-            ImplicitAnimation* anim = it->value.get();
-            if (anim && anim->hasStyle())
-                anim->updatePlayState(AnimPlayStatePaused);
+        for (auto& transition : m_transitions.values()) {
+            if (transition->hasStyle())
+                transition->updatePlayState(AnimPlayStatePaused);
         }
     }
 }
@@ -487,32 +454,26 @@
 
     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) {
-            KeyframeAnimation* anim = it->value.get();
-            if (anim && anim->playStatePlaying())
-                anim->updatePlayState(AnimPlayStatePlaying);
+        for (auto& animation : m_keyframeAnimations.values()) {
+            if (animation->playStatePlaying())
+                animation->updatePlayState(AnimPlayStatePlaying);
         }
     }
 
     if (!m_transitions.isEmpty()) {
-        CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
-            ImplicitAnimation* anim = it->value.get();
-            if (anim && anim->hasStyle())
-                anim->updatePlayState(AnimPlayStatePlaying);
+        for (auto& transition : m_transitions.values()) {
+            if (transition->hasStyle())
+                transition->updatePlayState(AnimPlayStatePlaying);
         }
     }
 }
 
 void CompositeAnimation::overrideImplicitAnimations(CSSPropertyID property)
 {
-    CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
     if (!m_transitions.isEmpty()) {
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
-            ImplicitAnimation* anim = it->value.get();
-            if (anim && anim->animatingProperty() == property)
-                anim->setOverridden(true);
+        for (auto& transition : m_transitions.values()) {
+            if (transition->animatingProperty() == property)
+                transition->setOverridden(true);
         }
     }
 }
@@ -520,11 +481,9 @@
 void CompositeAnimation::resumeOverriddenImplicitAnimations(CSSPropertyID property)
 {
     if (!m_transitions.isEmpty()) {
-        CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
-            ImplicitAnimation* anim = it->value.get();
-            if (anim && anim->animatingProperty() == property)
-                anim->setOverridden(false);
+        for (auto& transition : m_transitions.values()) {
+            if (transition->animatingProperty() == property)
+                transition->setOverridden(false);
         }
     }
 }
@@ -533,19 +492,15 @@
 {
     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) {
-            KeyframeAnimation* anim = it->value.get();
-            if (anim && anim->isAnimatingProperty(property, acceleratedOnly, runningState))
+        for (auto& animation : m_keyframeAnimations.values()) {
+            if (animation->isAnimatingProperty(property, acceleratedOnly, runningState))
                 return true;
         }
     }
 
     if (!m_transitions.isEmpty()) {
-        CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
-            ImplicitAnimation* anim = it->value.get();
-            if (anim && anim->isAnimatingProperty(property, acceleratedOnly, runningState))
+        for (auto& transition : m_transitions.values()) {
+            if (transition->isAnimatingProperty(property, acceleratedOnly, runningState))
                 return true;
         }
     }
@@ -580,9 +535,8 @@
         // This code is only used for testing, so performance is not critical here.
         HashSet<CSSPropertyID> shorthandProperties = CSSPropertyAnimation::animatableShorthandsAffectingProperty(property);
         bool anyPaused = false;
-        HashSet<CSSPropertyID>::const_iterator end = shorthandProperties.end();
-        for (HashSet<CSSPropertyID>::const_iterator it = shorthandProperties.begin(); it != end; ++it) {
-            if (pauseTransitionAtTime(*it, t))
+        for (auto propertyID : shorthandProperties) {
+            if (pauseTransitionAtTime(propertyID, t))
                 anyPaused = true;
         }
         return anyPaused;
@@ -603,23 +557,15 @@
 {
     unsigned count = 0;
     
-    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) {
-            KeyframeAnimation* anim = it->value.get();
-            if (anim->running())
-                ++count;
-        }
+    m_keyframeAnimations.checkConsistency();
+    for (auto& animation : m_keyframeAnimations.values()) {
+        if (animation->running())
+            ++count;
     }
 
-    if (!m_transitions.isEmpty()) {
-        CSSPropertyTransitionsMap::const_iterator transitionsEnd = m_transitions.end();
-        for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != transitionsEnd; ++it) {
-            ImplicitAnimation* anim = it->value.get();
-            if (anim->running())
-                ++count;
-        }
+    for (auto& transition : m_transitions.values()) {
+        if (transition->running())
+            ++count;
     }
     
     return count;

Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.h (183363 => 183364)


--- trunk/Source/WebCore/page/animation/CompositeAnimation.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -45,8 +45,9 @@
 // A CompositeAnimation represents a collection of animations that are running
 // on a single RenderElement, such as a number of properties transitioning at once.
 class CompositeAnimation : public RefCounted<CompositeAnimation> {
+    WTF_MAKE_FAST_ALLOCATED;
 public:
-    static Ref<CompositeAnimation> create(AnimationControllerPrivate* animationController)
+    static Ref<CompositeAnimation> create(AnimationControllerPrivate& animationController)
     {
         return adoptRef(*new CompositeAnimation(animationController));
     };
@@ -61,7 +62,7 @@
 
     double timeToNextService() const;
     
-    AnimationControllerPrivate* animationController() const { return m_animationController; }
+    AnimationControllerPrivate& animationController() const { return m_animationController; }
 
     void suspendAnimations();
     void resumeAnimations();
@@ -85,7 +86,7 @@
 #endif
 
 private:
-    CompositeAnimation(AnimationControllerPrivate*);
+    CompositeAnimation(AnimationControllerPrivate&);
 
     void updateTransitions(RenderElement*, RenderStyle* currentStyle, RenderStyle* targetStyle);
     void updateKeyframeAnimations(RenderElement*, RenderStyle* currentStyle, RenderStyle* targetStyle);
@@ -93,13 +94,13 @@
     typedef HashMap<int, RefPtr<ImplicitAnimation>> CSSPropertyTransitionsMap;
     typedef HashMap<AtomicStringImpl*, RefPtr<KeyframeAnimation>> AnimationNameMap;
 
-    AnimationControllerPrivate* m_animationController;
+    AnimationControllerPrivate& m_animationController;
     CSSPropertyTransitionsMap m_transitions;
     AnimationNameMap m_keyframeAnimations;
     Vector<AtomicStringImpl*> m_keyframeAnimationOrderMap;
     bool m_suspended;
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
-    bool m_hasScrollTriggeredAnimation;
+    bool m_hasScrollTriggeredAnimation { false };
 #endif
 };
 

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp (183363 => 183364)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -39,13 +39,11 @@
 
 namespace WebCore {
 
-ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compAnim, RenderStyle* fromStyle)
+ImplicitAnimation::ImplicitAnimation(Animation& transition, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compAnim, RenderStyle* fromStyle)
     : AnimationBase(transition, renderer, compAnim)
+    , m_fromStyle(fromStyle)
     , m_transitionProperty(transition.property())
     , m_animatingProperty(animatingProperty)
-    , m_overridden(false)
-    , m_active(true)
-    , m_fromStyle(fromStyle)
 {
     ASSERT(animatingProperty != CSSPropertyInvalid);
 }
@@ -189,7 +187,7 @@
                 return false;
 
             // Schedule event handling
-            m_compositeAnimation->animationController()->addEventToDispatch(element, eventType, propertyName, elapsedTime);
+            m_compositeAnimation->animationController().addEventToDispatch(element, eventType, propertyName, elapsedTime);
 
             // Restore the original (unanimated) style
             if (eventType == eventNames().transitionendEvent && element->renderer())

Modified: trunk/Source/WebCore/page/animation/ImplicitAnimation.h (183363 => 183364)


--- trunk/Source/WebCore/page/animation/ImplicitAnimation.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/ImplicitAnimation.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -41,7 +41,7 @@
 // for a single RenderElement.
 class ImplicitAnimation : public AnimationBase {
 public:
-    static PassRefPtr<ImplicitAnimation> create(const Animation& animation, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compositeAnimation, RenderStyle* fromStyle)
+    static PassRefPtr<ImplicitAnimation> create(Animation& animation, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compositeAnimation, RenderStyle* fromStyle)
     {
         return adoptRef(new ImplicitAnimation(animation, animatingProperty, renderer, compositeAnimation, fromStyle));
     };
@@ -84,17 +84,18 @@
     void checkForMatchingFilterFunctionLists();
 
 private:
-    ImplicitAnimation(const Animation&, CSSPropertyID, RenderElement*, CompositeAnimation*, RenderStyle*);
+    ImplicitAnimation(Animation&, CSSPropertyID, RenderElement*, CompositeAnimation*, RenderStyle*);
     virtual ~ImplicitAnimation();
 
+    // The two styles that we are blending.
+    RefPtr<RenderStyle> m_fromStyle;
+    RefPtr<RenderStyle> m_toStyle;
+
     CSSPropertyID m_transitionProperty; // Transition property as specified in the RenderStyle.
     CSSPropertyID m_animatingProperty; // Specific property for this ImplicitAnimation
-    bool m_overridden;          // true when there is a keyframe animation that overrides the transitioning property
-    bool m_active;              // used for culling the list of transitions
 
-    // The two styles that we are blending.
-    RefPtr<RenderStyle> m_fromStyle;
-    RefPtr<RenderStyle> m_toStyle;
+    bool m_active { true }; // Used for culling the list of transitions.
+    bool m_overridden { false }; // True when there is a keyframe animation that overrides the transitioning property
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp (183363 => 183364)


--- trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -41,12 +41,11 @@
 
 namespace WebCore {
 
-KeyframeAnimation::KeyframeAnimation(const Animation& animation, RenderElement* renderer, int index, CompositeAnimation* compositeAnimation, RenderStyle* unanimatedStyle)
+KeyframeAnimation::KeyframeAnimation(Animation& animation, RenderElement* renderer, int index, CompositeAnimation* compositeAnimation, RenderStyle* unanimatedStyle)
     : AnimationBase(animation, renderer, compositeAnimation)
     , m_keyframes(animation.name())
-    , m_index(index)
-    , m_startEventDispatched(false)
     , m_unanimatedStyle(unanimatedStyle)
+    , m_index(index)
 {
     // Get the keyframe RenderStyles
     if (m_object && m_object->element())
@@ -157,15 +156,14 @@
 
     // FIXME: we need to be more efficient about determining which keyframes we are animating between.
     // We should cache the last pair or something.
-    HashSet<CSSPropertyID>::const_iterator endProperties = m_keyframes.endProperties();
-    for (HashSet<CSSPropertyID>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) {
+    for (auto propertyID : m_keyframes.properties()) {
         // Get the from/to styles and progress between
         const RenderStyle* fromStyle = nullptr;
         const RenderStyle* toStyle = nullptr;
         double progress = 0;
-        fetchIntervalEndpointsForProperty(*it, fromStyle, toStyle, progress);
+        fetchIntervalEndpointsForProperty(propertyID, fromStyle, toStyle, progress);
 
-        bool needsAnim = CSSPropertyAnimation::blendProperties(this, *it, animatedStyle.get(), fromStyle, toStyle, progress);
+        bool needsAnim = CSSPropertyAnimation::blendProperties(this, propertyID, animatedStyle.get(), fromStyle, toStyle, progress);
         if (!needsAnim)
             // If we are running an accelerated animation, set a flag in the style
             // to indicate it. This can be used to make sure we get an updated
@@ -187,15 +185,14 @@
     if (!animatedStyle)
         animatedStyle = RenderStyle::clone(&m_object->style());
 
-    HashSet<CSSPropertyID>::const_iterator endProperties = m_keyframes.endProperties();
-    for (HashSet<CSSPropertyID>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) {
+    for (auto propertyID : m_keyframes.properties()) {
         // Get the from/to styles and progress between
         const RenderStyle* fromStyle = nullptr;
         const RenderStyle* toStyle = nullptr;
         double progress = 0;
-        fetchIntervalEndpointsForProperty(*it, fromStyle, toStyle, progress);
+        fetchIntervalEndpointsForProperty(propertyID, fromStyle, toStyle, progress);
 
-        CSSPropertyAnimation::blendProperties(this, *it, animatedStyle.get(), fromStyle, toStyle, progress);
+        CSSPropertyAnimation::blendProperties(this, propertyID, animatedStyle.get(), fromStyle, toStyle, progress);
     }
 }
 
@@ -211,20 +208,17 @@
 
     FloatRect cumulativeBounds = bounds;
 
-    size_t numKeyframes = m_keyframes.size();
-    for (size_t i = 0; i < numKeyframes; ++i) {
-        const KeyframeValue& currKeyFrame = m_keyframes[i];
-
-        if (!currKeyFrame.containsProperty(CSSPropertyTransform))
+    for (auto& keyframe : m_keyframes.keyframes()) {
+        if (!keyframe.containsProperty(CSSPropertyTransform))
             continue;
 
         LayoutRect keyframeBounds = bounds;
         
         bool canCompute;
         if (isTransformFunctionListValid())
-            canCompute = computeTransformedExtentViaTransformList(rendererBox, *currKeyFrame.style(), keyframeBounds);
+            canCompute = computeTransformedExtentViaTransformList(rendererBox, *keyframe.style(), keyframeBounds);
         else
-            canCompute = computeTransformedExtentViaMatrix(rendererBox, *currKeyFrame.style(), keyframeBounds);
+            canCompute = computeTransformedExtentViaMatrix(rendererBox, *keyframe.style(), keyframeBounds);
         
         if (!canCompute)
             return false;
@@ -244,7 +238,7 @@
 bool KeyframeAnimation::startAnimation(double timeOffset)
 {
     if (m_object && m_object->isComposited())
-        return downcast<RenderBoxModelObject>(*m_object).startAnimation(timeOffset, m_animation.get(), m_keyframes);
+        return downcast<RenderBoxModelObject>(*m_object).startAnimation(timeOffset, m_animation.ptr(), m_keyframes);
     return false;
 }
 
@@ -322,7 +316,7 @@
             return false;
 
         // Schedule event handling
-        m_compositeAnimation->animationController()->addEventToDispatch(element, eventType, m_keyframes.animationName(), elapsedTime);
+        m_compositeAnimation->animationController().addEventToDispatch(element, eventType, m_keyframes.animationName(), elapsedTime);
 
         // Restore the original (unanimated) style
         if ((eventType == eventNames().webkitAnimationEndEvent || eventType == eventNames().animationendEvent) && element->renderer())
@@ -337,17 +331,15 @@
 void KeyframeAnimation::overrideAnimations()
 {
     // This will override implicit animations that match the properties in the keyframe animation
-    HashSet<CSSPropertyID>::const_iterator end = m_keyframes.endProperties();
-    for (HashSet<CSSPropertyID>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it)
-        compositeAnimation()->overrideImplicitAnimations(*it);
+    for (auto propertyID : m_keyframes.properties())
+        compositeAnimation()->overrideImplicitAnimations(propertyID);
 }
 
 void KeyframeAnimation::resumeOverriddenAnimations()
 {
     // This will resume overridden implicit animations
-    HashSet<CSSPropertyID>::const_iterator end = m_keyframes.endProperties();
-    for (HashSet<CSSPropertyID>::const_iterator it = m_keyframes.beginProperties(); it != end; ++it)
-        compositeAnimation()->resumeOverriddenImplicitAnimations(*it);
+    for (auto propertyID : m_keyframes.properties())
+        compositeAnimation()->resumeOverriddenImplicitAnimations(propertyID);
 }
 
 bool KeyframeAnimation::affectsProperty(CSSPropertyID property) const
@@ -447,11 +439,10 @@
         
     // A return value of 0 means we need service. But if we only have accelerated animations we 
     // only need service at the end of the transition
-    HashSet<CSSPropertyID>::const_iterator endProperties = m_keyframes.endProperties();
     bool acceleratedPropertiesOnly = true;
     
-    for (HashSet<CSSPropertyID>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) {
-        if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(*it) || !isAccelerated()) {
+    for (auto propertyID : m_keyframes.properties()) {
+        if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(propertyID) || !isAccelerated()) {
             acceleratedPropertiesOnly = false;
             break;
         }

Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.h (183363 => 183364)


--- trunk/Source/WebCore/page/animation/KeyframeAnimation.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -40,7 +40,7 @@
 // A KeyframeAnimation tracks the state of an explicit animation for a single RenderElement.
 class KeyframeAnimation final : public AnimationBase {
 public:
-    static RefPtr<KeyframeAnimation> create(const Animation& animation, RenderElement* renderer, int index, CompositeAnimation* compositeAnimation, RenderStyle* unanimatedStyle)
+    static RefPtr<KeyframeAnimation> create(Animation& animation, RenderElement* renderer, int index, CompositeAnimation* compositeAnimation, RenderStyle* unanimatedStyle)
     {
         return adoptRef(new KeyframeAnimation(animation, renderer, index, compositeAnimation, unanimatedStyle));
     }
@@ -87,21 +87,17 @@
     void checkForMatchingFilterFunctionLists();
 
 private:
-    KeyframeAnimation(const Animation&, RenderElement*, int index, CompositeAnimation*, RenderStyle* unanimatedStyle);
+    KeyframeAnimation(Animation&, RenderElement*, int index, CompositeAnimation*, RenderStyle* unanimatedStyle);
     virtual ~KeyframeAnimation();
     
     // Get the styles for the given property surrounding the current animation time and the progress between them.
     void fetchIntervalEndpointsForProperty(CSSPropertyID, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& progress) const;
 
-    // The keyframes that we are blending.
     KeyframeList m_keyframes;
+    RefPtr<RenderStyle> m_unanimatedStyle; // The style just before we started animation
 
-    // The order in which this animation appears in the animation-name style.
-    int m_index;
-    bool m_startEventDispatched;
-
-    // The style just before we started animation
-    RefPtr<RenderStyle> m_unanimatedStyle;
+    int m_index; // The order in which this animation appears in the animation-name style.
+    bool m_startEventDispatched { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/animation/Animation.cpp (183363 => 183364)


--- trunk/Source/WebCore/platform/animation/Animation.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/platform/animation/Animation.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -125,40 +125,37 @@
 {
 }
 
-bool Animation::animationsMatch(const Animation* o, bool matchPlayStates) const
+bool Animation::animationsMatch(const Animation& other, bool matchPlayStates) const
 {
-    if (!o)
-        return false;
-    
-    bool result = m_name == o->m_name
-                  && m_property == o->m_property 
-                  && m_mode == o->m_mode
-                  && m_iterationCount == o->m_iterationCount
-                  && m_delay == o->m_delay
-                  && m_duration == o->m_duration
-                  && *(m_timingFunction.get()) == *(o->m_timingFunction.get())
+    bool result = m_name == other.m_name
+        && m_property == other.m_property
+        && m_mode == other.m_mode
+        && m_iterationCount == other.m_iterationCount
+        && m_delay == other.m_delay
+        && m_duration == other.m_duration
+        && *(m_timingFunction.get()) == *(other.m_timingFunction.get())
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
-                  && *(m_trigger.get()) == *(o->m_trigger.get())
+        && *(m_trigger.get()) == *(other.m_trigger.get())
 #endif
-                  && m_direction == o->m_direction
-                  && m_fillMode == o->m_fillMode
-                  && m_delaySet == o->m_delaySet
-                  && m_directionSet == o->m_directionSet
-                  && m_durationSet == o->m_durationSet
-                  && m_fillModeSet == o->m_fillModeSet
-                  && m_iterationCountSet == o->m_iterationCountSet
-                  && m_nameSet == o->m_nameSet
-                  && m_propertySet == o->m_propertySet
-                  && m_timingFunctionSet == o->m_timingFunctionSet
+        && m_direction == other.m_direction
+        && m_fillMode == other.m_fillMode
+        && m_delaySet == other.m_delaySet
+        && m_directionSet == other.m_directionSet
+        && m_durationSet == other.m_durationSet
+        && m_fillModeSet == other.m_fillModeSet
+        && m_iterationCountSet == other.m_iterationCountSet
+        && m_nameSet == other.m_nameSet
+        && m_propertySet == other.m_propertySet
+        && m_timingFunctionSet == other.m_timingFunctionSet
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
-                  && m_triggerSet == o->m_triggerSet
+        && m_triggerSet == other.m_triggerSet
 #endif
-                  && m_isNone == o->m_isNone;
+        && m_isNone == other.m_isNone;
 
     if (!result)
         return false;
 
-    return !matchPlayStates || (m_playState == o->m_playState && m_playStateSet == o->m_playStateSet);
+    return !matchPlayStates || (m_playState == other.m_playState && m_playStateSet == other.m_playStateSet);
 }
 
 const String& Animation::initialName()

Modified: trunk/Source/WebCore/platform/animation/Animation.h (183363 => 183364)


--- trunk/Source/WebCore/platform/animation/Animation.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/platform/animation/Animation.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -160,10 +160,10 @@
     Animation& operator=(const Animation& o);
 
     // return true if all members of this class match (excluding m_next)
-    bool animationsMatch(const Animation*, bool matchPlayStates = true) const;
+    bool animationsMatch(const Animation&, bool matchPlayStates = true) const;
 
     // return true every Animation in the chain (defined by m_next) match 
-    bool operator==(const Animation& o) const { return animationsMatch(&o); }
+    bool operator==(const Animation& o) const { return animationsMatch(o); }
     bool operator!=(const Animation& o) const { return !(*this == o); }
 
     bool fillsBackwards() const { return m_fillModeSet && (m_fillMode == AnimationFillModeBackwards || m_fillMode == AnimationFillModeBoth); }

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (183363 => 183364)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2015-04-26 20:38:20 UTC (rev 183364)
@@ -3750,8 +3750,8 @@
     LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBehavior, subpixelAccumulation, subtreePaintRoot, &overlapTestRequests);
     paintLayer(context, paintingInfo, paintFlags);
 
-    for (auto it : overlapTestRequests)
-        it.key->setOverlapTestResult(false);
+    for (auto& widget : overlapTestRequests.keys())
+        widget->setOverlapTestResult(false);
 }
 
 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject* subtreePaintRoot)
@@ -3820,12 +3820,12 @@
 {
     Vector<OverlapTestRequestClient*> overlappedRequestClients;
     LayoutRect boundingBox = layer->boundingBox(rootLayer, layer->offsetFromAncestor(rootLayer));
-    for (auto it : overlapTestRequests) {
-        if (!boundingBox.intersects(it.value))
+    for (auto& request : overlapTestRequests) {
+        if (!boundingBox.intersects(request.value))
             continue;
 
-        it.key->setOverlapTestResult(true);
-        overlappedRequestClients.append(it.key);
+        request.key->setOverlapTestResult(true);
+        overlappedRequestClients.append(request.key);
     }
     for (auto client : overlappedRequestClients)
         overlapTestRequests.remove(client);

Modified: trunk/Source/WebCore/rendering/style/KeyframeList.h (183363 => 183364)


--- trunk/Source/WebCore/rendering/style/KeyframeList.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/rendering/style/KeyframeList.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -82,13 +82,13 @@
     
     void addProperty(CSSPropertyID prop) { m_properties.add(prop); }
     bool containsProperty(CSSPropertyID prop) const { return m_properties.contains(prop); }
-    HashSet<CSSPropertyID>::const_iterator beginProperties() const { return m_properties.begin(); }
-    HashSet<CSSPropertyID>::const_iterator endProperties() const { return m_properties.end(); }
+    const HashSet<CSSPropertyID>& properties() const { return m_properties; }
     
     void clear();
     bool isEmpty() const { return m_keyframes.isEmpty(); }
     size_t size() const { return m_keyframes.size(); }
     const KeyframeValue& operator[](size_t index) const { return m_keyframes[index]; }
+    const Vector<KeyframeValue>& keyframes() const { return m_keyframes; }
 
 private:
     AtomicString m_animationName;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (183363 => 183364)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2015-04-26 20:36:09 UTC (rev 183363)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2015-04-26 20:38:20 UTC (rev 183364)
@@ -1060,6 +1060,9 @@
     const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
     const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); }
 
+    AnimationList* animations() { return rareNonInheritedData->m_animations.get(); }
+    AnimationList* transitions() { return rareNonInheritedData->m_transitions.get(); }
+
     AnimationList& ensureAnimations();
     AnimationList& ensureTransitions();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to