1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

LibWeb: Respect the animation-fill-mode CSS property

This commit is contained in:
Ali Mohammad Pur 2023-05-27 09:45:21 +03:30 committed by Andreas Kling
parent 2e71263c5c
commit 19c92fa354
2 changed files with 43 additions and 13 deletions

View file

@ -185,6 +185,10 @@ private:
Active,
};
struct AnimationStateSnapshot {
Array<RefPtr<StyleValue const>, to_underlying(last_property_id) + 1> state;
};
struct Animation {
String name;
CSS::Time duration;
@ -197,7 +201,9 @@ private:
CSS::Percentage progress { 0 };
CSS::Time remaining_delay { 0, CSS::Time::Type::Ms };
AnimationState current_state { AnimationState::Before };
mutable Array<RefPtr<StyleValue const>, to_underlying(last_property_id) + 1> initial_state {};
mutable AnimationStateSnapshot initial_state {};
mutable OwnPtr<AnimationStateSnapshot> active_state_if_fill_forward {};
AnimationStepTransition step(CSS::Time const& time_step);
ErrorOr<void> collect_into(StyleProperties&, RuleCache const&) const;
@ -205,7 +211,7 @@ private:
};
mutable HashMap<AnimationKey, NonnullOwnPtr<Animation>> m_active_animations;
mutable HashTable<AnimationKey> m_finished_animations;
mutable HashMap<AnimationKey, OwnPtr<AnimationStateSnapshot>> m_finished_animations; // If fill-mode is forward/both, this is non-null and contains the final state.
mutable RefPtr<Platform::Timer> m_animation_driver_timer;
};