TextTrackCue.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGC/RootVector.h>
  8. #include <LibWeb/DOM/EventTarget.h>
  9. #include <LibWeb/HTML/TextTrack.h>
  10. namespace Web::HTML {
  11. // https://html.spec.whatwg.org/multipage/media.html#texttrackcue
  12. class TextTrackCue : public DOM::EventTarget {
  13. WEB_PLATFORM_OBJECT(TextTrackCue, DOM::EventTarget);
  14. GC_DECLARE_ALLOCATOR(TextTrackCue);
  15. public:
  16. virtual ~TextTrackCue() override;
  17. GC::Ptr<TextTrack> track() { return m_track; }
  18. String const& id() const { return m_identifier; }
  19. void set_id(String const& id) { m_identifier = id; }
  20. double start_time() const { return m_start_time; }
  21. void set_start_time(double start_time);
  22. double end_time() const { return m_end_time; }
  23. WebIDL::ExceptionOr<void> set_end_time(double end_time);
  24. bool pause_on_exit() const { return m_pause_on_exit; }
  25. void set_pause_on_exit(bool pause_on_exit) { m_pause_on_exit = pause_on_exit; }
  26. WebIDL::CallbackType* onenter();
  27. void set_onenter(WebIDL::CallbackType*);
  28. WebIDL::CallbackType* onexit();
  29. void set_onexit(WebIDL::CallbackType*);
  30. protected:
  31. TextTrackCue(JS::Realm&, GC::Ptr<TextTrack>);
  32. virtual void initialize(JS::Realm&) override;
  33. virtual void visit_edges(Visitor&) override;
  34. GC::Ptr<TextTrack> m_track;
  35. // https://html.spec.whatwg.org/multipage/media.html#text-track-cue-identifier
  36. String m_identifier;
  37. // https://html.spec.whatwg.org/multipage/media.html#text-track-cue-start-time
  38. double m_start_time;
  39. // https://html.spec.whatwg.org/multipage/media.html#text-track-cue-end-time
  40. double m_end_time;
  41. // https://html.spec.whatwg.org/multipage/media.html#text-track-cue-pause-on-exit-flag
  42. bool m_pause_on_exit;
  43. };
  44. }