/* * Copyright (c) 2023, Matthew Olsson . * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::Animations { // https://www.w3.org/TR/web-animations-1/#dictdef-animationplaybackeventinit struct AnimationPlaybackEventInit : public DOM::EventInit { Optional current_time; Optional timeline_time; }; // https://www.w3.org/TR/web-animations-1/#animationplaybackevent class AnimationPlaybackEvent : public DOM::Event { WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event); GC_DECLARE_ALLOCATOR(AnimationPlaybackEvent); public: [[nodiscard]] static GC::Ref create(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init); virtual ~AnimationPlaybackEvent() override = default; NullableCSSNumberish current_time() const { return m_current_time.map([](auto const& value) { return NullableCSSNumberish { value }; }).value_or(Empty {}); } NullableCSSNumberish timeline_time() const { return m_timeline_time.map([](auto const& value) { return NullableCSSNumberish { value }; }).value_or(Empty {}); } private: AnimationPlaybackEvent(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init); virtual void initialize(JS::Realm&) override; // https://drafts.csswg.org/web-animations-2/#dom-animationplaybackevent-currenttime Optional m_current_time; // https://drafts.csswg.org/web-animations-2/#dom-animationplaybackevent-timelinetime Optional m_timeline_time; }; }