mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibWeb: Add the AnimationEvent IDL objects
This commit is contained in:
parent
3a87c000c4
commit
faaf5b9652
5 changed files with 105 additions and 0 deletions
|
@ -29,6 +29,7 @@ set(SOURCES
|
||||||
Crypto/CryptoKey.cpp
|
Crypto/CryptoKey.cpp
|
||||||
Crypto/SubtleCrypto.cpp
|
Crypto/SubtleCrypto.cpp
|
||||||
CSS/Angle.cpp
|
CSS/Angle.cpp
|
||||||
|
CSS/AnimationEvent.cpp
|
||||||
CSS/CalculatedOr.cpp
|
CSS/CalculatedOr.cpp
|
||||||
CSS/Clip.cpp
|
CSS/Clip.cpp
|
||||||
CSS/CSS.cpp
|
CSS/CSS.cpp
|
||||||
|
|
36
Userland/Libraries/LibWeb/CSS/AnimationEvent.cpp
Normal file
36
Userland/Libraries/LibWeb/CSS/AnimationEvent.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/CSS/AnimationEvent.h>
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
JS::NonnullGCPtr<AnimationEvent> AnimationEvent::create(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||||
|
{
|
||||||
|
return realm.heap().allocate<AnimationEvent>(realm, realm, type, event_init);
|
||||||
|
}
|
||||||
|
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationEvent>> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||||
|
{
|
||||||
|
return create(realm, type, event_init);
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationEvent::AnimationEvent(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init)
|
||||||
|
: DOM::Event(realm, type, event_init)
|
||||||
|
, m_animation_name(event_init.animation_name)
|
||||||
|
, m_elapsed_time(event_init.elapsed_time)
|
||||||
|
, m_pseudo_element(event_init.pseudo_element)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimationEvent::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
Base::initialize(realm);
|
||||||
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::AnimationEventPrototype>(realm, "AnimationEvent"_fly_string));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
Userland/Libraries/LibWeb/CSS/AnimationEvent.h
Normal file
50
Userland/Libraries/LibWeb/CSS/AnimationEvent.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, 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::CSS {
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#dictdef-animationeventinit
|
||||||
|
struct AnimationEventInit : public DOM::EventInit {
|
||||||
|
FlyString animation_name { ""_fly_string };
|
||||||
|
double elapsed_time { 0.0 };
|
||||||
|
FlyString pseudo_element { ""_fly_string };
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#animationevent
|
||||||
|
class AnimationEvent : public DOM::Event {
|
||||||
|
WEB_PLATFORM_OBJECT(AnimationEvent, DOM::Event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
[[nodiscard]] static JS::NonnullGCPtr<AnimationEvent> create(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init = {});
|
||||||
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
|
||||||
|
|
||||||
|
virtual ~AnimationEvent() override = default;
|
||||||
|
|
||||||
|
FlyString const& animation_name() const { return m_animation_name; }
|
||||||
|
double elapsed_time() const { return m_elapsed_time; }
|
||||||
|
FlyString const& pseudo_element() const { return m_pseudo_element; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
AnimationEvent(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#dom-animationevent-animationname
|
||||||
|
FlyString m_animation_name {};
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#dom-animationevent-elapsedtime
|
||||||
|
double m_elapsed_time { 0.0 };
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#dom-animationevent-pseudoelement
|
||||||
|
FlyString m_pseudo_element {};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
17
Userland/Libraries/LibWeb/CSS/AnimationEvent.idl
Normal file
17
Userland/Libraries/LibWeb/CSS/AnimationEvent.idl
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#import <DOM/Event.idl>
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#animationevent
|
||||||
|
[Exposed=Window]
|
||||||
|
interface AnimationEvent : Event {
|
||||||
|
constructor(CSSOMString type, optional AnimationEventInit animationEventInitDict = {});
|
||||||
|
readonly attribute CSSOMString animationName;
|
||||||
|
readonly attribute double elapsedTime;
|
||||||
|
readonly attribute CSSOMString pseudoElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/css-animations-1/#dictdef-animationeventinit
|
||||||
|
dictionary AnimationEventInit : EventInit {
|
||||||
|
CSSOMString animationName = "";
|
||||||
|
double elapsedTime = 0.0;
|
||||||
|
CSSOMString pseudoElement = "";
|
||||||
|
};
|
|
@ -11,6 +11,7 @@ libweb_js_bindings(Clipboard/Clipboard)
|
||||||
libweb_js_bindings(Crypto/Crypto)
|
libweb_js_bindings(Crypto/Crypto)
|
||||||
libweb_js_bindings(Crypto/CryptoKey)
|
libweb_js_bindings(Crypto/CryptoKey)
|
||||||
libweb_js_bindings(Crypto/SubtleCrypto)
|
libweb_js_bindings(Crypto/SubtleCrypto)
|
||||||
|
libweb_js_bindings(CSS/AnimationEvent)
|
||||||
libweb_js_bindings(CSS/CSSAnimation)
|
libweb_js_bindings(CSS/CSSAnimation)
|
||||||
libweb_js_bindings(CSS/CSSConditionRule)
|
libweb_js_bindings(CSS/CSSConditionRule)
|
||||||
libweb_js_bindings(CSS/CSSFontFaceRule)
|
libweb_js_bindings(CSS/CSSFontFaceRule)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue