AnimationEvent.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2024, 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::CSS {
  10. // https://www.w3.org/TR/css-animations-1/#dictdef-animationeventinit
  11. struct AnimationEventInit : public DOM::EventInit {
  12. FlyString animation_name { ""_fly_string };
  13. double elapsed_time { 0.0 };
  14. FlyString pseudo_element { ""_fly_string };
  15. };
  16. // https://www.w3.org/TR/css-animations-1/#animationevent
  17. class AnimationEvent : public DOM::Event {
  18. WEB_PLATFORM_OBJECT(AnimationEvent, DOM::Event);
  19. public:
  20. [[nodiscard]] static JS::NonnullGCPtr<AnimationEvent> create(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init = {});
  21. static WebIDL::ExceptionOr<JS::NonnullGCPtr<AnimationEvent>> construct_impl(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
  22. virtual ~AnimationEvent() override = default;
  23. FlyString const& animation_name() const { return m_animation_name; }
  24. double elapsed_time() const { return m_elapsed_time; }
  25. FlyString const& pseudo_element() const { return m_pseudo_element; }
  26. private:
  27. AnimationEvent(JS::Realm&, FlyString const& type, AnimationEventInit const& event_init);
  28. virtual void initialize(JS::Realm&) override;
  29. // https://www.w3.org/TR/css-animations-1/#dom-animationevent-animationname
  30. FlyString m_animation_name {};
  31. // https://www.w3.org/TR/css-animations-1/#dom-animationevent-elapsedtime
  32. double m_elapsed_time { 0.0 };
  33. // https://www.w3.org/TR/css-animations-1/#dom-animationevent-pseudoelement
  34. FlyString m_pseudo_element {};
  35. };
  36. }