mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibWeb: Support subtree option in Animatable.getAnimations()
This commit is contained in:
parent
e2cb25e35c
commit
a80af938eb
Notes:
sideshowbarker
2024-07-17 11:30:05 +09:00
Author: https://github.com/mattco98
Commit: a80af938eb
Pull-request: https://github.com/SerenityOS/serenity/pull/24514
3 changed files with 41 additions and 4 deletions
|
@ -55,7 +55,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> Animatable::animate(Optional<JS
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animatable-getanimations
|
||||
Vector<JS::NonnullGCPtr<Animation>> Animatable::get_animations(Web::Animations::GetAnimationsOptions options)
|
||||
Vector<JS::NonnullGCPtr<Animation>> 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<JS::NonnullGCPtr<Animation>> Animatable::get_animations(Web::Animations::
|
|||
m_is_sorted_by_composite_order = true;
|
||||
}
|
||||
|
||||
// FIXME: Support subtree
|
||||
(void)options;
|
||||
|
||||
Vector<JS::NonnullGCPtr<Animation>> 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<DOM::Element*>(this) };
|
||||
target->for_each_child_of_type<DOM::Element>([&](auto& child) {
|
||||
relevant_animations.extend(child.get_animations(options));
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
return relevant_animations;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue