mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
LibWeb: Keep track of associated Animations in AnimationTimeline
This allows the timeline to propagate changes in time to any relevant animation objects.
This commit is contained in:
parent
0d3c8a1cd9
commit
4efbb10a36
Notes:
sideshowbarker
2024-07-17 02:05:41 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/4efbb10a36 Pull-request: https://github.com/SerenityOS/serenity/pull/21871 Reviewed-by: https://github.com/alimpfard
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Animations/Animation.h>
|
||||
#include <LibWeb/Animations/AnimationTimeline.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
||||
@ -21,6 +22,9 @@ WebIDL::ExceptionOr<void> AnimationTimeline::set_current_time(Optional<double> v
|
||||
|
||||
m_current_time = value;
|
||||
|
||||
for (auto& animation : m_associated_animations)
|
||||
TRY(animation->set_current_time(value));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -61,6 +65,8 @@ void AnimationTimeline::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_associated_document);
|
||||
for (auto const& animation : m_associated_animations)
|
||||
visitor.visit(animation);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ public:
|
||||
virtual Optional<double> convert_a_timeline_time_to_an_original_relative_time(Optional<double>) { VERIFY_NOT_REACHED(); }
|
||||
virtual bool can_convert_a_timeline_time_to_an_original_relative_time() const { return false; }
|
||||
|
||||
void associate_with_animation(JS::NonnullGCPtr<Animation> value) { m_associated_animations.set(value); }
|
||||
void disassociate_with_animation(JS::NonnullGCPtr<Animation> value) { m_associated_animations.remove(value); }
|
||||
HashTable<JS::NonnullGCPtr<Animation>> const& associated_animations() const;
|
||||
|
||||
protected:
|
||||
AnimationTimeline(JS::Realm&);
|
||||
virtual ~AnimationTimeline() override;
|
||||
@ -43,6 +47,8 @@ protected:
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
|
||||
JS::GCPtr<DOM::Document> m_associated_document {};
|
||||
|
||||
HashTable<JS::NonnullGCPtr<Animation>> m_associated_animations {};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user