Title: [233585] trunk
Revision
233585
Author
grao...@webkit.org
Date
2018-07-06 11:43:57 -0700 (Fri, 06 Jul 2018)

Log Message

[Web Animations] Make WPT test at interfaces/Animation/finish.html pass reliably
https://bugs.webkit.org/show_bug.cgi?id=186496
<rdar://problem/41000179>

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Mark a WPT progression.

* web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt:

Source/WebCore:

We used to only resolve animations that had a target element, but animations need not have a target and their
current time should still advance so that their finished promise may resolve. We now maintain a list of animations
without targets and we iterate through them as well as animations with targets in DocumentTimeline::updateAnimations().

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::addAnimation):
(WebCore::AnimationTimeline::removeAnimation):
(WebCore::AnimationTimeline::animationWasAddedToElement):
(WebCore::AnimationTimeline::animationWasRemovedFromElement):
* animation/AnimationTimeline.h:
(WebCore::AnimationTimeline:: const):
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::updateAnimations):
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::resolve):
* animation/WebAnimation.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (233584 => 233585)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-07-06 18:43:57 UTC (rev 233585)
@@ -1,5 +1,17 @@
 2018-07-05  Antoine Quint  <grao...@apple.com>
 
+        [Web Animations] Make WPT test at interfaces/Animation/finish.html pass reliably
+        https://bugs.webkit.org/show_bug.cgi?id=186496
+        <rdar://problem/41000179>
+
+        Reviewed by Dean Jackson.
+
+        Mark a WPT progression.
+
+        * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt:
+
+2018-07-05  Antoine Quint  <grao...@apple.com>
+
         [Web Animations] Make WPT test at interfaces/Animation/finished.html pass reliably
         https://bugs.webkit.org/show_bug.cgi?id=186497
         <rdar://problem/41000193>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt (233584 => 233585)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt	2018-07-06 18:43:57 UTC (rev 233585)
@@ -13,5 +13,5 @@
 PASS Test resetting of computed style 
 PASS Test finish() resolves finished promise synchronously 
 PASS Test finish() resolves finished promise synchronously with an animation without a target 
-FAIL Test normally finished animation resolves finished promise synchronously with an animation without a target assert_true: Animation.finished should be resolved soon after Animation finishes normally expected true got false
+PASS Test normally finished animation resolves finished promise synchronously with an animation without a target 
 

Modified: trunk/Source/WebCore/ChangeLog (233584 => 233585)


--- trunk/Source/WebCore/ChangeLog	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/Source/WebCore/ChangeLog	2018-07-06 18:43:57 UTC (rev 233585)
@@ -1,5 +1,30 @@
 2018-07-05  Antoine Quint  <grao...@apple.com>
 
+        [Web Animations] Make WPT test at interfaces/Animation/finish.html pass reliably
+        https://bugs.webkit.org/show_bug.cgi?id=186496
+        <rdar://problem/41000179>
+
+        Reviewed by Dean Jackson.
+
+        We used to only resolve animations that had a target element, but animations need not have a target and their
+        current time should still advance so that their finished promise may resolve. We now maintain a list of animations
+        without targets and we iterate through them as well as animations with targets in DocumentTimeline::updateAnimations().
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::addAnimation):
+        (WebCore::AnimationTimeline::removeAnimation):
+        (WebCore::AnimationTimeline::animationWasAddedToElement):
+        (WebCore::AnimationTimeline::animationWasRemovedFromElement):
+        * animation/AnimationTimeline.h:
+        (WebCore::AnimationTimeline:: const):
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::updateAnimations):
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::resolve):
+        * animation/WebAnimation.h:
+
+2018-07-05  Antoine Quint  <grao...@apple.com>
+
         [Web Animations] Make WPT test at interfaces/Animation/finished.html pass reliably
         https://bugs.webkit.org/show_bug.cgi?id=186497
         <rdar://problem/41000193>

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (233584 => 233585)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2018-07-06 18:43:57 UTC (rev 233585)
@@ -56,6 +56,7 @@
 
 void AnimationTimeline::addAnimation(Ref<WebAnimation>&& animation)
 {
+    m_animationsWithoutTarget.add(animation.ptr());
     m_animations.add(WTFMove(animation));
     timingModelDidChange();
 }
@@ -62,6 +63,7 @@
 
 void AnimationTimeline::removeAnimation(Ref<WebAnimation>&& animation)
 {
+    m_animationsWithoutTarget.remove(animation.ptr());
     m_animations.remove(WTFMove(animation));
     timingModelDidChange();
 }
@@ -91,6 +93,8 @@
 
 void AnimationTimeline::animationWasAddedToElement(WebAnimation& animation, Element& element)
 {
+    m_animationsWithoutTarget.remove(&animation);
+
     relevantMapForAnimation(animation).ensure(&element, [] {
         return ListHashSet<RefPtr<WebAnimation>> { };
     }).iterator->value.add(&animation);
@@ -111,6 +115,9 @@
 
 void AnimationTimeline::animationWasRemovedFromElement(WebAnimation& animation, Element& element)
 {
+    // This animation doesn't have a target for now.
+    m_animationsWithoutTarget.add(&animation);
+
     // First, we clear this animation from one of the m_elementToCSSAnimationsMap, m_elementToCSSTransitionsMap,
     // m_elementToAnimationsMap or m_elementToCompletedCSSTransitionByCSSPropertyID map, whichever is relevant to
     // this type of animation.

Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (233584 => 233585)


--- trunk/Source/WebCore/animation/AnimationTimeline.h	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h	2018-07-06 18:43:57 UTC (rev 233585)
@@ -81,6 +81,7 @@
 
     bool hasElementAnimations() const { return !m_elementToAnimationsMap.isEmpty() || !m_elementToCSSAnimationsMap.isEmpty() || !m_elementToCSSTransitionsMap.isEmpty(); }
 
+    const ListHashSet<WebAnimation*>& animationsWithoutTarget() const { return m_animationsWithoutTarget; }
     const HashMap<Element*, ListHashSet<RefPtr<WebAnimation>>>& elementToAnimationsMap() { return m_elementToAnimationsMap; }
     const HashMap<Element*, ListHashSet<RefPtr<WebAnimation>>>& elementToCSSAnimationsMap() { return m_elementToCSSAnimationsMap; }
     const HashMap<Element*, ListHashSet<RefPtr<WebAnimation>>>& elementToCSSTransitionsMap() { return m_elementToCSSTransitionsMap; }
@@ -97,6 +98,7 @@
     HashMap<Element*, ListHashSet<RefPtr<WebAnimation>>> m_elementToCSSTransitionsMap;
     ListHashSet<RefPtr<WebAnimation>> m_animations;
 
+    ListHashSet<WebAnimation*> m_animationsWithoutTarget;
     HashMap<Element*, HashMap<String, RefPtr<CSSAnimation>>> m_elementToCSSAnimationByName;
     HashMap<Element*, HashMap<CSSPropertyID, RefPtr<CSSTransition>>> m_elementToRunningCSSTransitionByCSSPropertyID;
     HashMap<Element*, HashMap<CSSPropertyID, RefPtr<CSSTransition>>> m_elementToCompletedCSSTransitionByCSSPropertyID;

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (233584 => 233585)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2018-07-06 18:43:57 UTC (rev 233585)
@@ -280,6 +280,12 @@
     // running pending tasks can fire right away.
     MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
 
+    // Let's first resolve any animation that does not have a target.
+    for (auto* animation : animationsWithoutTarget())
+        animation->resolve();
+
+    // For the rest of the animations, we will resolve them via TreeResolver::createAnimatedElementUpdate()
+    // by invalidating their target element's style.
     if (m_document && hasElementAnimations()) {
         for (const auto& elementToAnimationsMapItem : elementToAnimationsMap())
             elementToAnimationsMapItem.key->invalidateStyleAndLayerComposition();

Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (233584 => 233585)


--- trunk/Source/WebCore/animation/WebAnimation.cpp	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp	2018-07-06 18:43:57 UTC (rev 233585)
@@ -1055,10 +1055,14 @@
         runPendingPlayTask();
 }
 
-void WebAnimation::resolve(RenderStyle& targetStyle)
+void WebAnimation::resolve()
 {
     updateFinishedState(DidSeek::No, SynchronouslyNotify::Yes);
+}
 
+void WebAnimation::resolve(RenderStyle& targetStyle)
+{
+    resolve();
     if (m_effect)
         m_effect->apply(targetStyle);
 }

Modified: trunk/Source/WebCore/animation/WebAnimation.h (233584 => 233585)


--- trunk/Source/WebCore/animation/WebAnimation.h	2018-07-06 18:37:21 UTC (rev 233584)
+++ trunk/Source/WebCore/animation/WebAnimation.h	2018-07-06 18:43:57 UTC (rev 233585)
@@ -105,6 +105,7 @@
     virtual ExceptionOr<void> bindingsPause() { return pause(); }
 
     Seconds timeToNextRequiredTick() const;
+    void resolve();
     virtual void resolve(RenderStyle&);
     void runPendingTasks();
     void effectTargetDidChange(Element* previousTarget, Element* newTarget);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to