mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibWeb: Add helpers to convert between FillMode and Direction enums
This commit is contained in:
parent
c9234f35f1
commit
35859c0467
2 changed files with 38 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
* Copyright (c) 2023-2024, Matthew Olsson <mattco@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +16,38 @@ namespace Web::Animations {
|
||||||
|
|
||||||
JS_DEFINE_ALLOCATOR(AnimationEffect);
|
JS_DEFINE_ALLOCATOR(AnimationEffect);
|
||||||
|
|
||||||
|
Bindings::FillMode css_fill_mode_to_bindings_fill_mode(CSS::AnimationFillMode mode)
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
case CSS::AnimationFillMode::Backwards:
|
||||||
|
return Bindings::FillMode::Backwards;
|
||||||
|
case CSS::AnimationFillMode::Both:
|
||||||
|
return Bindings::FillMode::Both;
|
||||||
|
case CSS::AnimationFillMode::Forwards:
|
||||||
|
return Bindings::FillMode::Forwards;
|
||||||
|
case CSS::AnimationFillMode::None:
|
||||||
|
return Bindings::FillMode::None;
|
||||||
|
default:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bindings::PlaybackDirection css_animation_direction_to_bindings_playback_direction(CSS::AnimationDirection direction)
|
||||||
|
{
|
||||||
|
switch (direction) {
|
||||||
|
case CSS::AnimationDirection::Alternate:
|
||||||
|
return Bindings::PlaybackDirection::Alternate;
|
||||||
|
case CSS::AnimationDirection::AlternateReverse:
|
||||||
|
return Bindings::PlaybackDirection::AlternateReverse;
|
||||||
|
case CSS::AnimationDirection::Normal:
|
||||||
|
return Bindings::PlaybackDirection::Normal;
|
||||||
|
case CSS::AnimationDirection::Reverse:
|
||||||
|
return Bindings::PlaybackDirection::Reverse;
|
||||||
|
default:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<AnimationEffect> AnimationEffect::create(JS::Realm& realm)
|
JS::NonnullGCPtr<AnimationEffect> AnimationEffect::create(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
return realm.heap().allocate<AnimationEffect>(realm, realm);
|
return realm.heap().allocate<AnimationEffect>(realm, realm);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
* Copyright (c) 2023-2024, Matthew Olsson <mattco@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
#include <LibWeb/Animations/TimingFunction.h>
|
#include <LibWeb/Animations/TimingFunction.h>
|
||||||
#include <LibWeb/Bindings/AnimationEffectPrototype.h>
|
#include <LibWeb/Bindings/AnimationEffectPrototype.h>
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/CSS/Enums.h>
|
||||||
|
|
||||||
namespace Web::Animations {
|
namespace Web::Animations {
|
||||||
|
|
||||||
|
@ -55,6 +56,9 @@ enum class AnimationDirection {
|
||||||
Backwards,
|
Backwards,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Bindings::FillMode css_fill_mode_to_bindings_fill_mode(CSS::AnimationFillMode mode);
|
||||||
|
Bindings::PlaybackDirection css_animation_direction_to_bindings_playback_direction(CSS::AnimationDirection direction);
|
||||||
|
|
||||||
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
|
// https://www.w3.org/TR/web-animations-1/#the-animationeffect-interface
|
||||||
class AnimationEffect : public Bindings::PlatformObject {
|
class AnimationEffect : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(AnimationEffect, Bindings::PlatformObject);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue