@@ -72,10 +72,10 @@ WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS
7272WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations (Optional<GetAnimationsOptions> options)
7373{
7474 as<DOM::Element>(*this ).document ().update_style ();
75- return get_animations_internal (options);
75+ return get_animations_internal (GetAnimationsSorted::Yes, options);
7676}
7777
78- WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations_internal (Optional<GetAnimationsOptions> options)
78+ WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations_internal (GetAnimationsSorted sorted, Optional<GetAnimationsOptions> options)
7979{
8080 // 1. Let object be the object on which this method was called.
8181
@@ -107,18 +107,20 @@ WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations_inter
107107 if (options.has_value () && options->subtree ) {
108108 Optional<WebIDL::Exception> exception;
109109 TRY (target->for_each_child_of_type_fallible <DOM::Element>([&](auto & child) -> WebIDL::ExceptionOr<IterationDecision> {
110- relevant_animations.extend (TRY (child.get_animations ( options)));
110+ relevant_animations.extend (TRY (child.get_animations_internal (GetAnimationsSorted::No, options)));
111111 return IterationDecision::Continue;
112112 }));
113113 }
114114
115115 // The returned list is sorted using the composite order described for the associated animations of effects in
116116 // §5.4.2 The effect stack.
117- quick_sort (relevant_animations, [](GC::Ref<Animation>& a, GC::Ref<Animation>& b) {
118- auto & a_effect = as<KeyframeEffect>(*a->effect ());
119- auto & b_effect = as<KeyframeEffect>(*b->effect ());
120- return KeyframeEffect::composite_order (a_effect, b_effect) < 0 ;
121- });
117+ if (sorted == GetAnimationsSorted::Yes) {
118+ quick_sort (relevant_animations, [](GC::Ref<Animation>& a, GC::Ref<Animation>& b) {
119+ auto & a_effect = as<KeyframeEffect>(*a->effect ());
120+ auto & b_effect = as<KeyframeEffect>(*b->effect ());
121+ return KeyframeEffect::composite_order (a_effect, b_effect) < 0 ;
122+ });
123+ }
122124
123125 return relevant_animations;
124126}
0 commit comments