mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +00:00
LibWeb: Add the AnimationPlaybackEvent IDL object
This commit is contained in:
parent
82c36b303c
commit
43dc9dfb69
6 changed files with 102 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Animations/AnimationPlaybackEvent.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
|
||||
namespace Web::Animations {
|
||||
|
||||
JS::NonnullGCPtr<AnimationPlaybackEvent> AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& event_name, AnimationPlaybackEventInit const& event_init)
|
||||
{
|
||||
return realm.heap().allocate<AnimationPlaybackEvent>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animationplaybackevent-animationplaybackevent
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationPlaybackEvent>> AnimationPlaybackEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, AnimationPlaybackEventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
AnimationPlaybackEvent::AnimationPlaybackEvent(JS::Realm& realm, FlyString const& event_name, AnimationPlaybackEventInit const& event_init)
|
||||
: DOM::Event(realm, event_name, event_init)
|
||||
, m_current_time(event_init.current_time)
|
||||
, m_timeline_time(event_init.timeline_time)
|
||||
{
|
||||
}
|
||||
|
||||
void AnimationPlaybackEvent::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::AnimationPlaybackEventPrototype>(realm, "AnimationPlaybackEvent"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
|
||||
namespace Web::Animations {
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dictdef-animationplaybackeventinit
|
||||
struct AnimationPlaybackEventInit : public DOM::EventInit {
|
||||
Optional<double> current_time {};
|
||||
Optional<double> timeline_time {};
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#animationplaybackevent
|
||||
class AnimationPlaybackEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& event_name, AnimationPlaybackEventInit const& event_init = {});
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationPlaybackEvent>> construct_impl(JS::Realm&, FlyString const& event_name, AnimationPlaybackEventInit const& event_init);
|
||||
|
||||
virtual ~AnimationPlaybackEvent() override = default;
|
||||
|
||||
Optional<double> current_time() const { return m_current_time; }
|
||||
void set_current_time(Optional<double> current_time) { m_current_time = current_time; }
|
||||
|
||||
Optional<double> timeline_time() const { return m_timeline_time; }
|
||||
void set_timeline_time(Optional<double> timeline_time) { m_timeline_time = timeline_time; }
|
||||
|
||||
private:
|
||||
AnimationPlaybackEvent(JS::Realm&, FlyString const& event_name, AnimationPlaybackEventInit const& event_init);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animationplaybackeventinit-currenttime
|
||||
Optional<double> m_current_time {};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dom-animationplaybackeventinit-timelinetime
|
||||
Optional<double> m_timeline_time {};
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#animationplaybackevent
|
||||
[Exposed=Window]
|
||||
interface AnimationPlaybackEvent : Event {
|
||||
constructor(DOMString type, optional AnimationPlaybackEventInit eventInitDict = {});
|
||||
readonly attribute double? currentTime;
|
||||
readonly attribute double? timelineTime;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/web-animations-1/#dictdef-animationplaybackeventinit
|
||||
dictionary AnimationPlaybackEventInit : EventInit {
|
||||
double? currentTime = null;
|
||||
double? timelineTime = null;
|
||||
};
|
|
@ -4,6 +4,7 @@ include(accelerated_graphics)
|
|||
set(SOURCES
|
||||
Animations/Animation.cpp
|
||||
Animations/AnimationEffect.cpp
|
||||
Animations/AnimationPlaybackEvent.cpp
|
||||
Animations/AnimationTimeline.cpp
|
||||
Animations/DocumentTimeline.cpp
|
||||
Animations/TimingFunction.cpp
|
||||
|
|
|
@ -29,6 +29,7 @@ class RecordingPainter;
|
|||
namespace Web::Animations {
|
||||
class Animation;
|
||||
class AnimationEffect;
|
||||
class AnimationPlaybackEvent;
|
||||
class AnimationTimeline;
|
||||
class DocumentTimeline;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
libweb_js_bindings(Animations/Animation)
|
||||
libweb_js_bindings(Animations/AnimationEffect)
|
||||
libweb_js_bindings(Animations/AnimationPlaybackEvent)
|
||||
libweb_js_bindings(Animations/AnimationTimeline)
|
||||
libweb_js_bindings(Animations/DocumentTimeline)
|
||||
libweb_js_bindings(Clipboard/Clipboard)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue