/* * Copyright (c) 2024, Matthew Olsson * Copyright (c) 2024, Sam Atkins * Copyright (c) 2025, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::CSS { class CSSTransition; } namespace Web::Animations { // https://drafts.csswg.org/web-animations-1/#dictdef-keyframeanimationoptions struct KeyframeAnimationOptions : public KeyframeEffectOptions { FlyString id { ""_fly_string }; Optional> timeline; }; // https://drafts.csswg.org/web-animations-1/#dictdef-getanimationsoptions struct GetAnimationsOptions { bool subtree { false }; Optional pseudo_element {}; }; // https://drafts.csswg.org/web-animations-1/#animatable class Animatable { public: struct TransitionAttributes { double delay; double duration; CSS::EasingStyleValue::Function timing_function; CSS::TransitionBehavior transition_behavior; }; virtual ~Animatable() = default; WebIDL::ExceptionOr> animate(Optional> keyframes, Variant options = {}); WebIDL::ExceptionOr>> get_animations(Optional options = {}); WebIDL::ExceptionOr>> get_animations_internal(Optional options = {}); void associate_with_animation(GC::Ref); void disassociate_with_animation(GC::Ref); GC::Ptr cached_animation_name_source(Optional) const; void set_cached_animation_name_source(GC::Ptr value, Optional); GC::Ptr cached_animation_name_animation(Optional) const; void set_cached_animation_name_animation(GC::Ptr value, Optional); GC::Ptr cached_transition_property_source(Optional) const; void set_cached_transition_property_source(Optional, GC::Ptr value); void add_transitioned_properties(Optional, Vector> properties, CSS::StyleValueVector delays, CSS::StyleValueVector durations, CSS::StyleValueVector timing_functions, CSS::StyleValueVector transition_behaviors); Optional property_transition_attributes(Optional, CSS::PropertyID) const; void set_transition(Optional, CSS::PropertyID, GC::Ref); void remove_transition(Optional, CSS::PropertyID); GC::Ptr property_transition(Optional, CSS::PropertyID) const; void clear_transitions(Optional); protected: void visit_edges(JS::Cell::Visitor&); private: struct Transition; struct Impl { Vector> associated_animations; bool is_sorted_by_composite_order { true }; Array, to_underlying(CSS::PseudoElement::KnownPseudoElementCount) + 1> cached_animation_name_source; Array, to_underlying(CSS::PseudoElement::KnownPseudoElementCount) + 1> cached_animation_name_animation; mutable Array, to_underlying(CSS::PseudoElement::KnownPseudoElementCount) + 1> transitions; ~Impl(); }; Impl& ensure_impl() const; Transition* ensure_transition(Optional) const; mutable OwnPtr m_impl; }; }