Title: [183295] trunk/Source/WebCore
Revision
183295
Author
[email protected]
Date
2015-04-24 17:11:07 -0700 (Fri, 24 Apr 2015)

Log Message

AnimationController::scrollWasUpdated() shows up in scrolling profiles on pages that don't use scroll triggers
https://bugs.webkit.org/show_bug.cgi?id=144173
<rdar://problem/20526168>

Reviewed by Simon Fraser.

Keep a list of Animations that care about scroll updates, and only
run the animation update if the list is not empty.

Covered by existing tests.

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::updateStateMachine): Tell the AnimationController
if this is an animation that depends on scrolling.
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::animationWillBeRemoved): Call the
new removeFromAnimationsDependentOnScroll as this animation is deleted.
(WebCore::AnimationControllerPrivate::addToAnimationsDependentOnScroll):
(WebCore::AnimationControllerPrivate::removeFromAnimationsDependentOnScroll):
(WebCore::AnimationControllerPrivate::scrollWasUpdated): Only update if
there are animations that care.
(WebCore::AnimationController::wantsScrollUpdates): Helper to expose this
value to FrameView.
* page/animation/AnimationController.h:
* page/animation/AnimationControllerPrivate.h:
(WebCore::AnimationControllerPrivate::wantsScrollUpdates):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183294 => 183295)


--- trunk/Source/WebCore/ChangeLog	2015-04-25 00:09:25 UTC (rev 183294)
+++ trunk/Source/WebCore/ChangeLog	2015-04-25 00:11:07 UTC (rev 183295)
@@ -1,3 +1,32 @@
+2015-04-24  Dean Jackson  <[email protected]>
+
+        AnimationController::scrollWasUpdated() shows up in scrolling profiles on pages that don't use scroll triggers
+        https://bugs.webkit.org/show_bug.cgi?id=144173
+        <rdar://problem/20526168>
+
+        Reviewed by Simon Fraser.
+
+        Keep a list of Animations that care about scroll updates, and only
+        run the animation update if the list is not empty.
+
+        Covered by existing tests.
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::updateStateMachine): Tell the AnimationController
+        if this is an animation that depends on scrolling.
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::animationWillBeRemoved): Call the
+        new removeFromAnimationsDependentOnScroll as this animation is deleted.
+        (WebCore::AnimationControllerPrivate::addToAnimationsDependentOnScroll):
+        (WebCore::AnimationControllerPrivate::removeFromAnimationsDependentOnScroll):
+        (WebCore::AnimationControllerPrivate::scrollWasUpdated): Only update if
+        there are animations that care.
+        (WebCore::AnimationController::wantsScrollUpdates): Helper to expose this
+        value to FrameView.
+        * page/animation/AnimationController.h:
+        * page/animation/AnimationControllerPrivate.h:
+        (WebCore::AnimationControllerPrivate::wantsScrollUpdates):
+
 2015-04-24  Tim Horton  <[email protected]>
 
         WKPDFView does not support password-protected PDFs

Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (183294 => 183295)


--- trunk/Source/WebCore/page/animation/AnimationBase.cpp	2015-04-25 00:09:25 UTC (rev 183294)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp	2015-04-25 00:11:07 UTC (rev 183295)
@@ -229,6 +229,11 @@
                 LOG(Animations, "%p AnimationState %s -> AnimationState::PausedNew", this, nameForState(m_animationState));
                 m_animationState = AnimationState::PausedNew;
             }
+
+#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
+            if (m_animation->trigger() && m_animation->trigger()->isScrollAnimationTrigger())
+                m_compositeAnimation->animationController()->addToAnimationsDependentOnScroll(this);
+#endif
             break;
         case AnimationState::StartWaitTimer:
             ASSERT(input == AnimationStateInput::StartTimerFired || input == AnimationStateInput::PlayStatePaused);

Modified: trunk/Source/WebCore/page/animation/AnimationController.cpp (183294 => 183295)


--- trunk/Source/WebCore/page/animation/AnimationController.cpp	2015-04-25 00:09:25 UTC (rev 183294)
+++ trunk/Source/WebCore/page/animation/AnimationController.cpp	2015-04-25 00:11:07 UTC (rev 183295)
@@ -514,15 +514,33 @@
 {
     removeFromAnimationsWaitingForStyle(animation);
     removeFromAnimationsWaitingForStartTimeResponse(animation);
+#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
+    removeFromAnimationsDependentOnScroll(animation);
+#endif
 }
 
 #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)
+    if (!view || !wantsScrollUpdates())
         return;
     m_scrollPosition = view->scrollOffsetForFixedPosition().height().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
@@ -714,6 +732,11 @@
 }
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
+bool AnimationController::wantsScrollUpdates() const
+{
+    return m_data->wantsScrollUpdates();
+}
+
 void AnimationController::scrollWasUpdated()
 {
     m_data->scrollWasUpdated();

Modified: trunk/Source/WebCore/page/animation/AnimationController.h (183294 => 183295)


--- trunk/Source/WebCore/page/animation/AnimationController.h	2015-04-25 00:09:25 UTC (rev 183294)
+++ trunk/Source/WebCore/page/animation/AnimationController.h	2015-04-25 00:11:07 UTC (rev 183295)
@@ -87,6 +87,7 @@
     static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID);
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
+    bool wantsScrollUpdates() const;
     void scrollWasUpdated();
 #endif
 

Modified: trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h (183294 => 183295)


--- trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h	2015-04-25 00:09:25 UTC (rev 183294)
+++ trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h	2015-04-25 00:11:07 UTC (rev 183295)
@@ -118,6 +118,10 @@
     void setAllowsNewAnimationsWhileSuspended(bool);
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
+    bool wantsScrollUpdates() const { return !m_animationsDependentOnScroll.isEmpty(); }
+    void addToAnimationsDependentOnScroll(AnimationBase*);
+    void removeFromAnimationsDependentOnScroll(AnimationBase*);
+
     void scrollWasUpdated();
     float scrollPosition() const { return m_scrollPosition; }
 #endif
@@ -147,9 +151,9 @@
     
     double m_beginAnimationUpdateTime;
 
-    typedef HashSet<RefPtr<AnimationBase>> WaitingAnimationsSet;
-    WaitingAnimationsSet m_animationsWaitingForStyle;
-    WaitingAnimationsSet m_animationsWaitingForStartTimeResponse;
+    typedef HashSet<RefPtr<AnimationBase>> AnimationsSet;
+    AnimationsSet m_animationsWaitingForStyle;
+    AnimationsSet m_animationsWaitingForStartTimeResponse;
 
     int m_beginAnimationUpdateCount;
 
@@ -162,7 +166,8 @@
     bool m_allowsNewAnimationsWhileSuspended;
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
-    float m_scrollPosition = 0;
+    AnimationsSet m_animationsDependentOnScroll;
+    float m_scrollPosition { 0 };
 #endif
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to