[Web Animations] Add support for the options parameter to getAnimations()
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jan 2020 16:51:08 +0000 (16:51 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jan 2020 16:51:08 +0000 (16:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202191
<rdar://problem/55697751>

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Mark some WPT progressions. In the CSS Animations case, we are returning the expected animations but not quite sorted as expected.

* web-platform-tests/css/css-animations/Element-getAnimations.tentative-expected.txt:
* web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt:

Source/WebCore:

Add support for the GetAnimationsOptions dictionary as a parameter to Animatable.getAnimations(). When it is provided
and has its sole "subtree" property set to "true", we call Document.getAnimations() and filter out animations that are
not targeting elements that are either this element, one of its descendants, one of its pseudo-elements or one of its
descendants' pseudo-elements.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* animation/Animatable.idl:
* animation/GetAnimationsOptions.h: Added.
* animation/GetAnimationsOptions.idl: Added.
* dom/Element.cpp:
(WebCore::Element::getAnimations):
* dom/Element.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255149 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-animations/Element-getAnimations.tentative-expected.txt
LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Headers.cmake
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/animation/Animatable.idl
Source/WebCore/animation/GetAnimationsOptions.h [new file with mode: 0644]
Source/WebCore/animation/GetAnimationsOptions.idl [new file with mode: 0644]
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h

index 48fe200..dcc49b4 100644 (file)
@@ -1,3 +1,16 @@
+2020-01-27  Antoine Quint  <graouts@apple.com>
+
+        [Web Animations] Add support for the options parameter to getAnimations()
+        https://bugs.webkit.org/show_bug.cgi?id=202191
+        <rdar://problem/55697751>
+
+        Reviewed by Antti Koivisto.
+
+        Mark some WPT progressions. In the CSS Animations case, we are returning the expected animations but not quite sorted as expected.
+
+        * web-platform-tests/css/css-animations/Element-getAnimations.tentative-expected.txt:
+        * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt:
+
 2020-01-26  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Update all DocumentTimeline objects when updating animations
index fcf752b..4a1b167 100644 (file)
@@ -17,8 +17,8 @@ PASS getAnimations returns objects with the same identity
 PASS getAnimations for CSS Animations that are canceled 
 PASS getAnimations for CSS Animations follows animation-name order 
 PASS { subtree: false } on a leaf element returns the element's animations and ignore pseudo-elements 
-FAIL { subtree: true } on a leaf element returns the element's animations and its pseudo-elements' animations assert_equals: getAnimations({ subtree: true }) should return animations on pseudo-elements expected 3 but got 1
+FAIL { subtree: true } on a leaf element returns the element's animations and its pseudo-elements' animations assert_equals: The animation targeting the ::before pseudo-element should be returned second expected (string) "::before" but got (undefined) undefined
 PASS { subtree: false } on an element with a child returns only the element's animations 
-FAIL { subtree: true } on an element with a child returns animations from the element, its pseudo-elements, its child and its child pseudo-elements assert_equals: Should find all elements, pesudo-elements that parent has expected 6 but got 1
-FAIL { subtree: true } on an element with many descendants returns animations from all the descendants assert_equals: Should find all descendants of the element expected 5 but got 1
+FAIL { subtree: true } on an element with a child returns animations from the element, its pseudo-elements, its child and its child pseudo-elements assert_equals: The animation targeting the ::before pseudo-element should be returned second expected (string) "::before" but got (undefined) undefined
+FAIL { subtree: true } on an element with many descendants returns animations from all the descendants assert_equals: The animation targeting the child1 element should be returned second expected Element node <div id="child1" style="animation: anim1 100s;"><div id="... but got Element node <div id="grandchild1" style="animation: anim1 100s;"></div>
 
index cf6ae6c..9b1fe5c 100644 (file)
@@ -3,9 +3,9 @@ PASS Returns an empty array for an element with no animations
 PASS Returns both animations for an element with two animations 
 PASS Returns only the animations specific to each sibling element 
 PASS Returns only the animations specific to each parent/child element 
-FAIL Returns animations on descendants when subtree: true is specified assert_array_equals: Returns expected animations from parent lengths differ, expected 3 got 0
-FAIL Returns animations on pseudo-elements when subtree: true is specified assert_equals: Returns one animation when subtree is true expected 1 but got 0
-FAIL Does NOT cross shadow-tree boundaries when subtree: true is specified assert_equals: Returns one animation when called on a parent in the shadow tree expected 1 but got 0
+PASS Returns animations on descendants when subtree: true is specified 
+PASS Returns animations on pseudo-elements when subtree: true is specified 
+PASS Does NOT cross shadow-tree boundaries when subtree: true is specified 
 PASS Returns animations for a foreign element 
 PASS Does not return finished animations that do not fill forwards 
 PASS Returns finished animations that fill forwards 
index 861283d..17271e4 100644 (file)
@@ -589,6 +589,7 @@ set(WebCore_NON_SVG_IDL_FILES
     animation/DocumentTimeline.idl
     animation/DocumentTimelineOptions.idl
     animation/FillMode.idl
+    animation/GetAnimationsOptions.idl
     animation/IterationCompositeOperation.idl
     animation/KeyframeAnimationOptions.idl
     animation/KeyframeEffect.idl
index 172b560..2e6fa80 100644 (file)
@@ -1,3 +1,30 @@
+2020-01-27  Antoine Quint  <graouts@apple.com>
+
+        [Web Animations] Add support for the options parameter to getAnimations()
+        https://bugs.webkit.org/show_bug.cgi?id=202191
+        <rdar://problem/55697751>
+
+        Reviewed by Antti Koivisto.
+
+        Add support for the GetAnimationsOptions dictionary as a parameter to Animatable.getAnimations(). When it is provided
+        and has its sole "subtree" property set to "true", we call Document.getAnimations() and filter out animations that are
+        not targeting elements that are either this element, one of its descendants, one of its pseudo-elements or one of its
+        descendants' pseudo-elements.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Headers.cmake:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * animation/Animatable.idl:
+        * animation/GetAnimationsOptions.h: Added.
+        * animation/GetAnimationsOptions.idl: Added.
+        * dom/Element.cpp:
+        (WebCore::Element::getAnimations):
+        * dom/Element.h:
+
 2020-01-27  Jonathan Bedard  <jbedard@apple.com>
 
         WebCore: Remove iOS 11 macros from NetworkStorageSessionCocoa.mm
index 0ac5e5e..e59bf82 100644 (file)
@@ -446,6 +446,7 @@ $(PROJECT_DIR)/animation/DocumentTimeline.idl
 $(PROJECT_DIR)/animation/DocumentTimelineOptions.idl
 $(PROJECT_DIR)/animation/EffectTiming.idl
 $(PROJECT_DIR)/animation/FillMode.idl
+$(PROJECT_DIR)/animation/GetAnimationsOptions.idl
 $(PROJECT_DIR)/animation/IterationCompositeOperation.idl
 $(PROJECT_DIR)/animation/KeyframeAnimationOptions.idl
 $(PROJECT_DIR)/animation/KeyframeEffect.idl
index 1d66cec..8ee6aa7 100644 (file)
@@ -689,6 +689,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGeoposition.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGeoposition.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGestureEvent.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGestureEvent.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGetAnimationsOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGetAnimationsOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGlobalCrypto.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGlobalCrypto.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGlobalEventHandlers.cpp
index 21fb1ad..c3dbe86 100644 (file)
@@ -491,6 +491,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/animation/DocumentTimelineOptions.idl \
     $(WebCore)/animation/EffectTiming.idl \
     $(WebCore)/animation/FillMode.idl \
+    $(WebCore)/animation/GetAnimationsOptions.idl \
     $(WebCore)/animation/IterationCompositeOperation.idl \
     $(WebCore)/animation/KeyframeAnimationOptions.idl \
     $(WebCore)/animation/KeyframeEffect.idl \
index d3e44d4..54db716 100644 (file)
@@ -178,6 +178,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
     animation/CompositeOperation.h
     animation/EffectTiming.h
     animation/FillMode.h
+    animation/GetAnimationsOptions.h
     animation/IterationCompositeOperation.h
     animation/KeyframeAnimationOptions.h
     animation/KeyframeEffectOptions.h
index efb3aee..8e0558a 100644 (file)
@@ -2891,6 +2891,7 @@ JSFillMode.cpp
 JSFocusEvent.cpp
 JSFontFace.cpp
 JSFontFaceSet.cpp
+JSGetAnimationsOptions.cpp
 JSGPUCanvasContext.cpp
 JSGPUColor.cpp
 JSGPUColorStateDescriptor.cpp
index ed2a313..311e762 100644 (file)
                713171341FBE78DB00F758DE /* CSSPropertyBlendingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 713171321FBE78C500F758DE /* CSSPropertyBlendingClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7132445120109DA500AE7FB2 /* WebAnimationUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7132444F20109D9B00AE7FB2 /* WebAnimationUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7134496E146941B300720312 /* SVGLengthContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 7134496C146941B300720312 /* SVGLengthContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               713F1D5A23DF1D8D003F5EFA /* GetAnimationsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 713F1D5923DF1D7D003F5EFA /* GetAnimationsOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               713F1D5D23DF2582003F5EFA /* JSGetAnimationsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 713F1D5B23DF2560003F5EFA /* JSGetAnimationsOptions.h */; };
                71495DDB202B06F100ADFD34 /* JSEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 71495DDA202B06DE00ADFD34 /* JSEffectTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
                714C7C661FDAD2A100F2BEE1 /* AnimationPlaybackEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 714C7C651FDAD27B00F2BEE1 /* AnimationPlaybackEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                714C7C671FDAD2A900F2BEE1 /* AnimationPlaybackEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 714C7C621FDAD27A00F2BEE1 /* AnimationPlaybackEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7134496B146941B300720312 /* SVGLengthContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLengthContext.cpp; sourceTree = "<group>"; };
                7134496C146941B300720312 /* SVGLengthContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLengthContext.h; sourceTree = "<group>"; };
                713E70AF1733E8B300A22D00 /* plugIns.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = plugIns.js; sourceTree = "<group>"; };
+               713F1D5723DF1D7D003F5EFA /* GetAnimationsOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GetAnimationsOptions.idl; sourceTree = "<group>"; };
+               713F1D5923DF1D7D003F5EFA /* GetAnimationsOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetAnimationsOptions.h; sourceTree = "<group>"; };
+               713F1D5B23DF2560003F5EFA /* JSGetAnimationsOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGetAnimationsOptions.h; sourceTree = "<group>"; };
+               713F1D5C23DF2560003F5EFA /* JSGetAnimationsOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGetAnimationsOptions.cpp; sourceTree = "<group>"; };
                714131471DC9D6AF00336107 /* fullscreen-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "fullscreen-support.js"; sourceTree = "<group>"; };
                714131481DC9D6EF00336107 /* js-files */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "js-files"; sourceTree = "<group>"; };
                7146DF8B1DEFC2ED0046F98B /* tracks-panel.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "tracks-panel.css"; sourceTree = "<group>"; };
                                71495DDA202B06DE00ADFD34 /* JSEffectTiming.h */,
                                712BE4841FE867C2002031CC /* JSFillMode.cpp */,
                                712BE4851FE86818002031CC /* JSFillMode.h */,
+                               713F1D5C23DF2560003F5EFA /* JSGetAnimationsOptions.cpp */,
+                               713F1D5B23DF2560003F5EFA /* JSGetAnimationsOptions.h */,
                                71247E281FEA5F61008C08CE /* JSIterationCompositeOperation.cpp */,
                                71247E2C1FEA5F64008C08CE /* JSIterationCompositeOperation.h */,
                                71247E291FEA5F62008C08CE /* JSKeyframeAnimationOptions.cpp */,
                                712BE47A1FE86447002031CC /* EffectTiming.idl */,
                                712BE4811FE865D4002031CC /* FillMode.h */,
                                712BE4821FE865D5002031CC /* FillMode.idl */,
+                               713F1D5923DF1D7D003F5EFA /* GetAnimationsOptions.h */,
+                               713F1D5723DF1D7D003F5EFA /* GetAnimationsOptions.idl */,
                                71247E331FEA5F80008C08CE /* IterationCompositeOperation.h */,
                                71247E311FEA5F7E008C08CE /* IterationCompositeOperation.idl */,
                                71247E2F1FEA5F7D008C08CE /* KeyframeAnimationOptions.h */,
                                9746AF2E14F4DDE6003E7A70 /* GeolocationPositionError.h in Headers */,
                                0FB6252F18DE1B1500A07C05 /* GeometryUtilities.h in Headers */,
                                46C83EFE1A9BBE2900A79A41 /* GeoNotifier.h in Headers */,
+                               713F1D5A23DF1D8D003F5EFA /* GetAnimationsOptions.h in Headers */,
                                46B95198207D634700A7D2DD /* GlobalFrameIdentifier.h in Headers */,
                                46B95197207D634000A7D2DD /* GlobalWindowIdentifier.h in Headers */,
                                086BBD0F136039C2008B15D8 /* Glyph.h in Headers */,
                                FE80DA640E9C4703000D6F75 /* JSGeolocation.h in Headers */,
                                FE80DA660E9C4703000D6F75 /* JSGeoposition.h in Headers */,
                                0FDA7C1F188322FC00C954B5 /* JSGestureEvent.h in Headers */,
+                               713F1D5D23DF2582003F5EFA /* JSGetAnimationsOptions.h in Headers */,
                                8482B7521198CB6B00BFB005 /* JSHashChangeEvent.h in Headers */,
                                BC94D14F0C275C68006BC617 /* JSHistory.h in Headers */,
                                57957CB71E972C78008072AB /* JSHkdfParams.h in Headers */,
                                7C193C011F5E11050088F3E6 /* JSImageSmoothingQuality.h in Headers */,
                                A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */,
                                9175CE5E21E281ED00DF2C28 /* JSInspectorAuditAccessibilityObject.h in Headers */,
-                               41B8776223DE1045003638B8 /* RealtimeMediaSourceIdentifier.h in Headers */,
                                9175CE5C21E281ED00DF2C28 /* JSInspectorAuditDOMObject.h in Headers */,
                                9109E9C8222CABCA00BB6265 /* JSInspectorAuditResourcesObject.h in Headers */,
                                7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */,
                                4A4F65721AA997F100E38CDD /* RealtimeMediaSourceCapabilities.h in Headers */,
                                4A0FFAA21AAF5EA20062803B /* RealtimeMediaSourceCenter.h in Headers */,
                                0754A5EA215EA3B8002D3A99 /* RealtimeMediaSourceFactory.h in Headers */,
+                               41B8776223DE1045003638B8 /* RealtimeMediaSourceIdentifier.h in Headers */,
                                4A4F65741AA997F100E38CDD /* RealtimeMediaSourceSettings.h in Headers */,
                                07C1C0E51BFB60ED00BD2256 /* RealtimeMediaSourceSupportedConstraints.h in Headers */,
                                41103AAC1E39791000769F03 /* RealtimeOutgoingAudioSource.h in Headers */,
index 27daa3b..6c44cb5 100644 (file)
@@ -28,5 +28,5 @@
     NoInterfaceObject
 ] interface Animatable {
     [MayThrowException, CallWith=GlobalObject] WebAnimation animate(object? keyframes, optional (unrestricted double or KeyframeAnimationOptions) options);
-    sequence<WebAnimation> getAnimations();
+    sequence<WebAnimation> getAnimations(optional GetAnimationsOptions options);
 };
diff --git a/Source/WebCore/animation/GetAnimationsOptions.h b/Source/WebCore/animation/GetAnimationsOptions.h
new file mode 100644 (file)
index 0000000..f15e8da
--- /dev/null
@@ -0,0 +1,35 @@
+
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+struct GetAnimationsOptions {
+    bool subtree { false };
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/animation/GetAnimationsOptions.idl b/Source/WebCore/animation/GetAnimationsOptions.idl
new file mode 100644 (file)
index 0000000..75a4370
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary GetAnimationsOptions {
+    boolean subtree = false;
+};
index f69c597..03b926b 100644 (file)
@@ -57,6 +57,7 @@
 #include "FrameSelection.h"
 #include "FrameView.h"
 #include "FullscreenManager.h"
+#include "GetAnimationsOptions.h"
 #include "HTMLBodyElement.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLCollection.h"
@@ -4379,9 +4380,26 @@ ExceptionOr<Ref<WebAnimation>> Element::animate(JSC::JSGlobalObject& lexicalGlob
     return animation;
 }
 
-Vector<RefPtr<WebAnimation>> Element::getAnimations()
-{
-    // FIXME: Filter and order the list as specified (webkit.org/b/179535).
+Vector<RefPtr<WebAnimation>> Element::getAnimations(Optional<GetAnimationsOptions> options)
+{
+    // If we are to return animations in the subtree, we can get all of the document's animations and filter
+    // animations targeting that are not registered on this element, one of its pseudo elements or a child's
+    // pseudo element.
+    if (options && options->subtree) {
+        Vector<RefPtr<WebAnimation>> animations;
+        for (auto& animation : document().getAnimations()) {
+            auto* effect = animation->effect();
+            ASSERT(is<KeyframeEffect>(animation->effect()));
+            auto* target = downcast<KeyframeEffect>(*effect).target();
+            ASSERT(target);
+            if (is<PseudoElement>(target)) {
+                if (contains(downcast<PseudoElement>(*target).hostElement()))
+                    animations.append(animation);
+            } else if (contains(target))
+                animations.append(animation);
+        }
+        return animations;
+    }
 
     // For the list of animations to be current, we need to account for any pending CSS changes,
     // such as updates to CSS Animations and CSS Transitions.
index 7ec9d96..2062543 100644 (file)
@@ -57,6 +57,7 @@ class RenderTreePosition;
 class StylePropertyMap;
 class WebAnimation;
 
+struct GetAnimationsOptions;
 struct KeyframeAnimationOptions;
 struct ScrollIntoViewOptions;
 struct ScrollToOptions;
@@ -597,7 +598,7 @@ public:
     Element* findAnchorElementForLink(String& outAnchorName);
 
     ExceptionOr<Ref<WebAnimation>> animate(JSC::JSGlobalObject&, JSC::Strong<JSC::JSObject>&&, Optional<Variant<double, KeyframeAnimationOptions>>&&);
-    Vector<RefPtr<WebAnimation>> getAnimations();
+    Vector<RefPtr<WebAnimation>> getAnimations(Optional<GetAnimationsOptions>);
 
     ElementIdentifier createElementIdentifier();