ladybird/Libraries/LibWeb/CSS/CSSAnimation.h
Andreas Kling 2bf1f41805 LibWeb: Make computed properties immutable
Move CSS animation values into a mutable overlay on computed properties
and make base computed style data immutable after construction. Base
style mutation now goes through a builder that is consumed on publish,
so installed styles no longer expose mutation APIs.

Build new base style data for inherited style updates instead of cloning
and mutating installed computed properties. Element-specific computed
style adjustments now run before publication, while animation and
transition updates continue to mutate only the animated overlay.
2026-06-20 23:43:17 +02:00

53 lines
1.7 KiB
C++

/*
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Animations/Animation.h>
#include <LibWeb/CSS/CSSAnimationProperties.h>
#include <LibWeb/CSS/EasingFunction.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
// https://www.w3.org/TR/css-animations-2/#cssanimation
class CSSAnimation : public Animations::Animation {
WEB_PLATFORM_OBJECT(CSSAnimation, Animations::Animation);
GC_DECLARE_ALLOCATOR(CSSAnimation);
public:
static GC::Ref<CSSAnimation> create(JS::Realm&);
FlyString const& animation_name() const { return m_animation_name; }
void set_animation_name(FlyString const& animation_name) { m_animation_name = animation_name; }
virtual Animations::AnimationClass animation_class() const override;
virtual int class_specific_composite_order(GC::Ref<Animations::Animation> other) const override;
void apply_css_properties(AnimationProperties const&);
EasingFunction const& default_easing() const { return m_default_easing; }
virtual void set_timeline_for_bindings(GC::Ptr<Animations::AnimationTimeline> timeline) override;
private:
explicit CSSAnimation(JS::Realm&);
virtual void initialize(JS::Realm&) override;
virtual bool is_css_animation() const override { return true; }
// https://drafts.csswg.org/css-animations-2/#dom-cssanimation-animationname
FlyString m_animation_name;
// https://drafts.csswg.org/css-animations-1/#animation-timing-function
// The default per-keyframe easing, from the animation-timing-function property on the element.
EasingFunction m_default_easing { EasingFunction::ease() };
HashTable<CSS::PropertyID> m_ignored_css_properties;
};
}