HTMLVideoElement.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Optional.h>
  8. #include <LibGfx/Forward.h>
  9. #include <LibWeb/DOM/DocumentLoadEventDelayer.h>
  10. #include <LibWeb/Forward.h>
  11. #include <LibWeb/HTML/HTMLMediaElement.h>
  12. #include <LibWeb/WebIDL/ExceptionOr.h>
  13. namespace Web::HTML {
  14. struct VideoFrame {
  15. RefPtr<Gfx::Bitmap> frame;
  16. double position { 0.0 };
  17. };
  18. class HTMLVideoElement final : public HTMLMediaElement {
  19. WEB_PLATFORM_OBJECT(HTMLVideoElement, HTMLMediaElement);
  20. JS_DECLARE_ALLOCATOR(HTMLVideoElement);
  21. public:
  22. virtual ~HTMLVideoElement() override;
  23. Layout::VideoBox* layout_node();
  24. Layout::VideoBox const* layout_node() const;
  25. void set_video_width(u32 video_width) { m_video_width = video_width; }
  26. u32 video_width() const;
  27. void set_video_height(u32 video_height) { m_video_height = video_height; }
  28. u32 video_height() const;
  29. void set_video_track(JS::GCPtr<VideoTrack>);
  30. void set_current_frame(Badge<VideoTrack>, RefPtr<Gfx::Bitmap> frame, double position);
  31. VideoFrame const& current_frame() const { return m_current_frame; }
  32. RefPtr<Gfx::Bitmap> const& poster_frame() const { return m_poster_frame; }
  33. private:
  34. HTMLVideoElement(DOM::Document&, DOM::QualifiedName);
  35. virtual void initialize(JS::Realm&) override;
  36. virtual void visit_edges(Cell::Visitor&) override;
  37. virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  38. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  39. virtual void on_playing() override;
  40. virtual void on_paused() override;
  41. virtual void on_seek(double, MediaSeekMode) override;
  42. WebIDL::ExceptionOr<void> determine_element_poster_frame(Optional<String> const& poster);
  43. JS::GCPtr<HTML::VideoTrack> m_video_track;
  44. VideoFrame m_current_frame;
  45. RefPtr<Gfx::Bitmap> m_poster_frame;
  46. u32 m_video_width { 0 };
  47. u32 m_video_height { 0 };
  48. JS::GCPtr<Fetch::Infrastructure::FetchController> m_fetch_controller;
  49. Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
  50. };
  51. }