1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:27:35 +00:00

LibWeb: Add keyframe state to KeyframeEffect

This was taken from StyleComputer, and will eventually be removed from
StyleComputer once we transition to using Web animations.
This commit is contained in:
Matthew Olsson 2024-02-02 16:29:11 -07:00 committed by Andreas Kling
parent 7d5e17eddd
commit 1735f3d9aa

View file

@ -7,12 +7,12 @@
#pragma once
#include <AK/Optional.h>
#include <AK/RedBlackTree.h>
#include <LibWeb/Animations/AnimationEffect.h>
#include <LibWeb/Bindings/KeyframeEffectPrototype.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/DOM/Element.h>
namespace Web::Animations {
@ -58,6 +58,14 @@ class KeyframeEffect : public AnimationEffect {
JS_DECLARE_ALLOCATOR(KeyframeEffect);
public:
struct KeyFrameSet : public RefCounted<KeyFrameSet> {
struct UseInitial { };
struct ResolvedKeyFrame {
HashMap<CSS::PropertyID, Variant<UseInitial, NonnullRefPtr<CSS::StyleValue const>>> resolved_properties {};
};
RedBlackTree<u64, ResolvedKeyFrame> keyframes_by_key;
};
static JS::NonnullGCPtr<KeyframeEffect> create(JS::Realm&);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<KeyframeEffect>> construct_impl(
@ -80,6 +88,9 @@ public:
WebIDL::ExceptionOr<Vector<JS::Object*>> get_keyframes();
WebIDL::ExceptionOr<void> set_keyframes(Optional<JS::Handle<JS::Object>> const&);
KeyFrameSet const* key_frame_set() { return m_key_frame_set; }
void set_key_frame_set(RefPtr<KeyFrameSet const> key_frame_set) { m_key_frame_set = key_frame_set; }
private:
KeyframeEffect(JS::Realm&);
@ -100,6 +111,8 @@ private:
// A cached version of m_keyframes suitable for returning from get_keyframes()
Vector<JS::Object*> m_keyframe_objects {};
RefPtr<KeyFrameSet const> m_key_frame_set {};
};
}