From a80af938eb78c13fecb831afe386bde003c8ac6d Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Tue, 28 May 2024 04:19:50 -0700 Subject: [PATCH] LibWeb: Support subtree option in Animatable.getAnimations() --- .../WebAnimations/misc/animatable.txt | 6 +++++ .../input/WebAnimations/misc/animatable.html | 26 +++++++++++++++++++ .../LibWeb/Animations/Animatable.cpp | 13 +++++++--- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/WebAnimations/misc/animatable.txt create mode 100644 Tests/LibWeb/Text/input/WebAnimations/misc/animatable.html diff --git a/Tests/LibWeb/Text/expected/WebAnimations/misc/animatable.txt b/Tests/LibWeb/Text/expected/WebAnimations/misc/animatable.txt new file mode 100644 index 00000000000..3f07845f98e --- /dev/null +++ b/Tests/LibWeb/Text/expected/WebAnimations/misc/animatable.txt @@ -0,0 +1,6 @@ + num animations without subtree: 1 +num animations with subtree: 4 +Anim for element parent is in the correct order: true +Anim for element child1 is in the correct order: true +Anim for element child2 is in the correct order: true +Anim for element child3 is in the correct order: true diff --git a/Tests/LibWeb/Text/input/WebAnimations/misc/animatable.html b/Tests/LibWeb/Text/input/WebAnimations/misc/animatable.html new file mode 100644 index 00000000000..3ea88abe046 --- /dev/null +++ b/Tests/LibWeb/Text/input/WebAnimations/misc/animatable.html @@ -0,0 +1,26 @@ + +
+
+
+
+
+
+ + diff --git a/Userland/Libraries/LibWeb/Animations/Animatable.cpp b/Userland/Libraries/LibWeb/Animations/Animatable.cpp index a9cde62ae16..e0ea78139b7 100644 --- a/Userland/Libraries/LibWeb/Animations/Animatable.cpp +++ b/Userland/Libraries/LibWeb/Animations/Animatable.cpp @@ -55,7 +55,7 @@ WebIDL::ExceptionOr> Animatable::animate(Optional> Animatable::get_animations(Web::Animations::GetAnimationsOptions options) +Vector> Animatable::get_animations(GetAnimationsOptions options) { // Returns the set of relevant animations for this object, or, if an options parameter is passed with subtree set to // true, returns the set of relevant animations for a subtree for this object. @@ -71,15 +71,20 @@ Vector> Animatable::get_animations(Web::Animations:: m_is_sorted_by_composite_order = true; } - // FIXME: Support subtree - (void)options; - Vector> relevant_animations; for (auto const& animation : m_associated_animations) { if (animation->is_relevant()) relevant_animations.append(*animation); } + if (options.subtree) { + JS::NonnullGCPtr target { *static_cast(this) }; + target->for_each_child_of_type([&](auto& child) { + relevant_animations.extend(child.get_animations(options)); + return IterationDecision::Continue; + }); + } + return relevant_animations; }