1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 17:55:08 +00:00
serenity/Userland/Libraries/LibWeb/Animations/Animatable.h
Matthew Olsson ae3326a447 LibWeb: Transition StyleComputer to Web Animations
With this commit, we are finally running animations off of the web
animations spec! A lot of the work StyleComputer is doing is now done
elsewhere. For example, fill-forward animations are handled by
Animation::is_relevant() returning true in the after phase, meaning the
"active_state_if_fill_forward" map is no longer needed.
2024-02-23 20:52:37 +01:00

45 lines
1.6 KiB
C++

/*
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <LibWeb/Animations/KeyframeEffect.h>
namespace Web::Animations {
// https://www.w3.org/TR/web-animations-1/#dictdef-keyframeanimationoptions
struct KeyframeAnimationOptions : public KeyframeEffectOptions {
FlyString id { ""_fly_string };
JS::GCPtr<AnimationTimeline> timeline;
};
// https://www.w3.org/TR/web-animations-1/#dictdef-getanimationsoptions
struct GetAnimationsOptions {
bool subtree { false };
};
// https://www.w3.org/TR/web-animations-1/#animatable
class Animatable {
public:
virtual ~Animatable() = default;
WebIDL::ExceptionOr<JS::NonnullGCPtr<Animation>> animate(Optional<JS::Handle<JS::Object>> keyframes, Variant<Empty, double, KeyframeAnimationOptions> options = {});
Vector<JS::NonnullGCPtr<Animation>> get_animations(GetAnimationsOptions options = {});
void associate_with_effect(JS::NonnullGCPtr<AnimationEffect> effect);
void disassociate_with_effect(JS::NonnullGCPtr<AnimationEffect> effect);
JS::GCPtr<CSS::CSSStyleDeclaration const> cached_animation_name_source() const { return m_cached_animation_name_source; }
void set_cached_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclaration const> value) { m_cached_animation_name_source = value; }
private:
Vector<JS::NonnullGCPtr<AnimationEffect>> m_associated_effects;
bool m_is_sorted_by_composite_order { true };
JS::GCPtr<CSS::CSSStyleDeclaration const> m_cached_animation_name_source;
};
}