Title: [290122] trunk
Revision
290122
Author
grao...@webkit.org
Date
2022-02-18 07:35:59 -0800 (Fri, 18 Feb 2022)

Log Message

[custom-effect] Animations associated with a custom effect should appear in document.getAnimations() result
https://bugs.webkit.org/show_bug.cgi?id=236828

Reviewed by Dean Jackson.

Source/WebCore:

Test: webanimations/custom-effect/custom-effect-get-animations.html

* dom/Document.cpp:
(WebCore::Document::matchingAnimations):

LayoutTests:

* webanimations/custom-effect/custom-effect-get-animations-expected.txt: Added.
* webanimations/custom-effect/custom-effect-get-animations.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290121 => 290122)


--- trunk/LayoutTests/ChangeLog	2022-02-18 10:47:13 UTC (rev 290121)
+++ trunk/LayoutTests/ChangeLog	2022-02-18 15:35:59 UTC (rev 290122)
@@ -1,5 +1,15 @@
 2022-02-18  Antoine Quint  <grao...@webkit.org>
 
+        [custom-effect] Animations associated with a custom effect should appear in document.getAnimations() result
+        https://bugs.webkit.org/show_bug.cgi?id=236828
+
+        Reviewed by Dean Jackson.
+
+        * webanimations/custom-effect/custom-effect-get-animations-expected.txt: Added.
+        * webanimations/custom-effect/custom-effect-get-animations.html: Added.
+
+2022-02-18  Antoine Quint  <grao...@webkit.org>
+
         [frame-rate] animation with different but compatible frame rates should be aligned
         https://bugs.webkit.org/show_bug.cgi?id=236778
         <rdar://problem/89083932>

Added: trunk/LayoutTests/webanimations/custom-effect/custom-effect-get-animations-expected.txt (0 => 290122)


--- trunk/LayoutTests/webanimations/custom-effect/custom-effect-get-animations-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webanimations/custom-effect/custom-effect-get-animations-expected.txt	2022-02-18 15:35:59 UTC (rev 290122)
@@ -0,0 +1,3 @@
+
+PASS Animation created with document.timeline.animate() appears in getAnimations() result.
+

Added: trunk/LayoutTests/webanimations/custom-effect/custom-effect-get-animations.html (0 => 290122)


--- trunk/LayoutTests/webanimations/custom-effect/custom-effect-get-animations.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/custom-effect/custom-effect-get-animations.html	2022-02-18 15:35:59 UTC (rev 290122)
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>CustomEffect</title>
+<script src=""
+<script src=""
+<body>
+<script>
+'use strict';
+
+test(t => {
+    const animation = document.timeline.animate(progress => { }, { duration: 1 });
+    assert_array_equals(document.getAnimations(), [animation]);
+}, "Animation created with document.timeline.animate() appears in getAnimations() result.");
+
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (290121 => 290122)


--- trunk/Source/WebCore/ChangeLog	2022-02-18 10:47:13 UTC (rev 290121)
+++ trunk/Source/WebCore/ChangeLog	2022-02-18 15:35:59 UTC (rev 290122)
@@ -1,5 +1,17 @@
 2022-02-18  Antoine Quint  <grao...@webkit.org>
 
+        [custom-effect] Animations associated with a custom effect should appear in document.getAnimations() result
+        https://bugs.webkit.org/show_bug.cgi?id=236828
+
+        Reviewed by Dean Jackson.
+
+        Test: webanimations/custom-effect/custom-effect-get-animations.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::matchingAnimations):
+
+2022-02-18  Antoine Quint  <grao...@webkit.org>
+
         [frame-rate] animation with different but compatible frame rates should be aligned
         https://bugs.webkit.org/show_bug.cgi?id=236778
         <rdar://problem/89083932>

Modified: trunk/Source/WebCore/dom/Document.cpp (290121 => 290122)


--- trunk/Source/WebCore/dom/Document.cpp	2022-02-18 10:47:13 UTC (rev 290121)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-02-18 15:35:59 UTC (rev 290122)
@@ -53,6 +53,7 @@
 #include "ContentSecurityPolicy.h"
 #include "ContentfulPaintChecker.h"
 #include "CookieJar.h"
+#include "CustomEffect.h"
 #include "CustomElementReactionQueue.h"
 #include "CustomElementRegistry.h"
 #include "CustomEvent.h"
@@ -8515,12 +8516,21 @@
     updateStyleIfNeeded();
 
     Vector<RefPtr<WebAnimation>> animations;
+
+    auto effectCanBeListed = [&](AnimationEffect* effect) {
+        if (is<CustomEffect>(effect))
+            return true;
+
+        if (auto* keyframeEffect = dynamicDowncast<KeyframeEffect>(effect)) {
+            auto* target = keyframeEffect->target();
+            return target && target->isConnected() && &target->document() == this && function(*target);
+        }
+
+        return false;
+    };
+
     for (auto* animation : WebAnimation::instances()) {
-        if (!animation->isRelevant() || !is<KeyframeEffect>(animation->effect()))
-            continue;
-
-        auto* target = downcast<KeyframeEffect>(*animation->effect()).target();
-        if (target && target->isConnected() && &target->document() == this && function(*target))
+        if (animation->isRelevant() && effectCanBeListed(animation->effect()))
             animations.append(animation);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to