AnimationPlaybackEvent.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. #include <LibWeb/DOM/Event.h>
  9. namespace Web::Animations {
  10. // https://www.w3.org/TR/web-animations-1/#dictdef-animationplaybackeventinit
  11. struct AnimationPlaybackEventInit : public DOM::EventInit {
  12. Optional<double> current_time {};
  13. Optional<double> timeline_time {};
  14. };
  15. // https://www.w3.org/TR/web-animations-1/#animationplaybackevent
  16. class AnimationPlaybackEvent : public DOM::Event {
  17. WEB_PLATFORM_OBJECT(AnimationPlaybackEvent, DOM::Event);
  18. JS_DECLARE_ALLOCATOR(AnimationPlaybackEvent);
  19. public:
  20. [[nodiscard]] static JS::NonnullGCPtr<AnimationPlaybackEvent> create(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init = {});
  21. static WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationPlaybackEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init);
  22. virtual ~AnimationPlaybackEvent() override = default;
  23. Optional<double> current_time() const { return m_current_time; }
  24. void set_current_time(Optional<double> current_time) { m_current_time = current_time; }
  25. Optional<double> timeline_time() const { return m_timeline_time; }
  26. void set_timeline_time(Optional<double> timeline_time) { m_timeline_time = timeline_time; }
  27. private:
  28. AnimationPlaybackEvent(JS::Realm&, FlyString const& type, AnimationPlaybackEventInit const& event_init);
  29. virtual void initialize(JS::Realm&) override;
  30. // https://www.w3.org/TR/web-animations-1/#dom-animationplaybackeventinit-currenttime
  31. Optional<double> m_current_time {};
  32. // https://www.w3.org/TR/web-animations-1/#dom-animationplaybackeventinit-timelinetime
  33. Optional<double> m_timeline_time {};
  34. };
  35. }