/* * Copyright (c) 2024, Matthew Olsson * Copyright (c) 2024, Sam Atkins * * 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; }; 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() const { return m_cached_transition_property_source; } void set_cached_transition_property_source(GC::Ptr value) { m_cached_transition_property_source = value; } void add_transitioned_properties(Vector> properties, CSS::StyleValueVector delays, CSS::StyleValueVector durations, CSS::StyleValueVector timing_functions); Optional property_transition_attributes(CSS::PropertyID) const; void set_transition(CSS::PropertyID, GC::Ref); void remove_transition(CSS::PropertyID); GC::Ptr property_transition(CSS::PropertyID) const; void clear_transitions(); protected: void visit_edges(JS::Cell::Visitor&); private: Vector> m_associated_animations; bool m_is_sorted_by_composite_order { true }; Array, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_source; Array, to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount) + 1> m_cached_animation_name_animation; HashMap m_transition_attribute_indices; Vector m_transition_attributes; GC::Ptr m_cached_transition_property_source; HashMap> m_associated_transitions; }; }