HTMLVideoElement.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/Forward.h>
  10. #include <LibWeb/HTML/HTMLMediaElement.h>
  11. namespace Web::HTML {
  12. class HTMLVideoElement final : public HTMLMediaElement {
  13. WEB_PLATFORM_OBJECT(HTMLVideoElement, HTMLMediaElement);
  14. public:
  15. virtual ~HTMLVideoElement() override;
  16. Layout::VideoBox* layout_node();
  17. Layout::VideoBox const* layout_node() const;
  18. void set_video_width(u32 video_width) { m_video_width = video_width; }
  19. u32 video_width() const;
  20. void set_video_height(u32 video_height) { m_video_height = video_height; }
  21. u32 video_height() const;
  22. void set_video_track(JS::GCPtr<VideoTrack>);
  23. void set_current_frame(Badge<VideoTrack>, RefPtr<Gfx::Bitmap> frame);
  24. RefPtr<Gfx::Bitmap> const& current_frame() const { return m_current_frame; }
  25. void set_layout_mouse_position(Badge<Painting::VideoPaintable>, Optional<CSSPixelPoint> mouse_position) { m_mouse_position = move(mouse_position); }
  26. Optional<CSSPixelPoint> const& layout_mouse_position(Badge<Painting::VideoPaintable>) const { return m_mouse_position; }
  27. private:
  28. HTMLVideoElement(DOM::Document&, DOM::QualifiedName);
  29. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  30. virtual void visit_edges(Cell::Visitor&) override;
  31. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  32. virtual void on_playing() override;
  33. virtual void on_paused() override;
  34. JS::GCPtr<HTML::VideoTrack> m_video_track;
  35. RefPtr<Gfx::Bitmap> m_current_frame;
  36. u32 m_video_width { 0 };
  37. u32 m_video_height { 0 };
  38. // Cached state for layout
  39. Optional<CSSPixelPoint> m_mouse_position;
  40. };
  41. }