mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Store all timelines associated with a document on the document
This will be required for propagating the current animation time to all relevant timelines, which each propagate that time to all of their relevant animations.
This commit is contained in:
parent
2fbb9649e3
commit
13ae2a4dab
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/13ae2a4dab Pull-request: https://github.com/SerenityOS/serenity/pull/21801 Reviewed-by: https://github.com/awesomekling ✅
5 changed files with 31 additions and 0 deletions
|
@ -26,6 +26,10 @@ WebIDL::ExceptionOr<void> AnimationTimeline::set_current_time(Optional<double> v
|
|||
|
||||
void AnimationTimeline::set_associated_document(JS::GCPtr<DOM::Document> document)
|
||||
{
|
||||
if (document)
|
||||
document->associate_with_timeline(*this);
|
||||
if (m_associated_document)
|
||||
m_associated_document->disassociate_with_timeline(*this);
|
||||
m_associated_document = document;
|
||||
}
|
||||
|
||||
|
@ -41,6 +45,12 @@ AnimationTimeline::AnimationTimeline(JS::Realm& realm)
|
|||
{
|
||||
}
|
||||
|
||||
AnimationTimeline::~AnimationTimeline()
|
||||
{
|
||||
if (m_associated_document)
|
||||
m_associated_document->disassociate_with_timeline(*this);
|
||||
}
|
||||
|
||||
void AnimationTimeline::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
|
||||
protected:
|
||||
AnimationTimeline(JS::Realm&);
|
||||
virtual ~AnimationTimeline() override;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
|
||||
private:
|
||||
DocumentTimeline(JS::Realm&, DOM::Document&, HighResolutionTime::DOMHighResTimeStamp origin_time);
|
||||
virtual ~DocumentTimeline() override = default;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
|
|
|
@ -404,6 +404,9 @@ void Document::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
for (auto& observer : m_intersection_observers)
|
||||
visitor.visit(observer);
|
||||
|
||||
for (auto& timeline : m_associated_animation_timelines)
|
||||
visitor.visit(timeline);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/selection-api/#dom-document-getselection
|
||||
|
@ -3572,4 +3575,14 @@ JS::NonnullGCPtr<Animations::DocumentTimeline> Document::timeline()
|
|||
return *m_default_timeline;
|
||||
}
|
||||
|
||||
void Document::associate_with_timeline(JS::NonnullGCPtr<Animations::AnimationTimeline> timeline)
|
||||
{
|
||||
m_associated_animation_timelines.set(timeline);
|
||||
}
|
||||
|
||||
void Document::disassociate_with_timeline(JS::NonnullGCPtr<Animations::AnimationTimeline> timeline)
|
||||
{
|
||||
m_associated_animation_timelines.remove(timeline);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -536,6 +536,9 @@ public:
|
|||
|
||||
JS::NonnullGCPtr<Animations::DocumentTimeline> timeline();
|
||||
|
||||
void associate_with_timeline(JS::NonnullGCPtr<Animations::AnimationTimeline>);
|
||||
void disassociate_with_timeline(JS::NonnullGCPtr<Animations::AnimationTimeline>);
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -743,6 +746,9 @@ private:
|
|||
|
||||
HashMap<AK::URL, HTML::SharedImageRequest*> m_shared_image_requests;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
|
||||
HashTable<JS::NonnullGCPtr<Animations::AnimationTimeline>> m_associated_animation_timelines;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#document-default-document-timeline
|
||||
JS::GCPtr<Animations::DocumentTimeline> m_default_timeline;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue