Coverage Report

Created: 2025-03-04 07:22

/src/serenity/Userland/Libraries/LibWeb/Animations/AnimationTimeline.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>.
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <LibWeb/Bindings/PlatformObject.h>
10
11
namespace Web::Animations {
12
13
// https://www.w3.org/TR/web-animations-1/#animationtimeline
14
class AnimationTimeline : public Bindings::PlatformObject {
15
    WEB_PLATFORM_OBJECT(AnimationTimeline, Bindings::PlatformObject);
16
    JS_DECLARE_ALLOCATOR(AnimationTimeline);
17
18
public:
19
0
    Optional<double> current_time() const { return m_current_time; }
20
    virtual void set_current_time(Optional<double>);
21
22
0
    JS::GCPtr<DOM::Document> associated_document() const { return m_associated_document; }
23
    void set_associated_document(JS::GCPtr<DOM::Document>);
24
25
    virtual bool is_inactive() const;
26
0
    bool is_monotonically_increasing() const { return m_is_monotonically_increasing; }
27
28
    // https://www.w3.org/TR/web-animations-1/#timeline-time-to-origin-relative-time
29
0
    virtual Optional<double> convert_a_timeline_time_to_an_origin_relative_time(Optional<double>) { VERIFY_NOT_REACHED(); }
30
0
    virtual bool can_convert_a_timeline_time_to_an_origin_relative_time() const { return false; }
31
32
0
    void associate_with_animation(JS::NonnullGCPtr<Animation> value) { m_associated_animations.set(value); }
33
0
    void disassociate_with_animation(JS::NonnullGCPtr<Animation> value) { m_associated_animations.remove(value); }
34
0
    HashTable<JS::NonnullGCPtr<Animation>> const& associated_animations() const { return m_associated_animations; }
35
36
protected:
37
    AnimationTimeline(JS::Realm&);
38
39
    virtual void initialize(JS::Realm&) override;
40
    virtual void visit_edges(Cell::Visitor&) override;
41
    virtual void finalize() override;
42
43
    // https://www.w3.org/TR/web-animations-1/#dom-animationtimeline-currenttime
44
    Optional<double> m_current_time {};
45
46
    // https://www.w3.org/TR/web-animations-1/#monotonically-increasing-timeline
47
    bool m_is_monotonically_increasing { true };
48
49
    // https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
50
    JS::GCPtr<DOM::Document> m_associated_document {};
51
52
    HashTable<JS::NonnullGCPtr<Animation>> m_associated_animations {};
53
};
54
55
}