/* * Copyright (c) 2020, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Web::HTML { struct VideoFrame { RefPtr frame; double position { 0.0 }; }; class HTMLVideoElement final : public HTMLMediaElement { WEB_PLATFORM_OBJECT(HTMLVideoElement, HTMLMediaElement); public: virtual ~HTMLVideoElement() override; Layout::VideoBox* layout_node(); Layout::VideoBox const* layout_node() const; void set_video_width(u32 video_width) { m_video_width = video_width; } u32 video_width() const; void set_video_height(u32 video_height) { m_video_height = video_height; } u32 video_height() const; void set_video_track(JS::GCPtr); void set_current_frame(Badge, RefPtr frame, double position); VideoFrame const& current_frame() const { return m_current_frame; } RefPtr const& poster_frame() const { return m_poster_frame; } void set_layout_mouse_position(Badge, Optional mouse_position) { m_mouse_position = move(mouse_position); } Optional const& layout_mouse_position(Badge) const { return m_mouse_position; } struct CachedLayoutBoxes { Optional control_box_rect; Optional playback_button_rect; Optional timeline_rect; }; CachedLayoutBoxes& cached_layout_boxes(Badge) const { return m_layout_boxes; } private: HTMLVideoElement(DOM::Document&, DOM::QualifiedName); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; virtual void did_remove_attribute(DeprecatedFlyString const&) override; virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; virtual void on_playing() override; virtual void on_paused() override; virtual void on_seek(double, MediaSeekMode) override; WebIDL::ExceptionOr determine_element_poster_frame(Optional const& poster); JS::GCPtr m_video_track; VideoFrame m_current_frame; RefPtr m_poster_frame; u32 m_video_width { 0 }; u32 m_video_height { 0 }; JS::GCPtr m_fetch_controller; Optional m_load_event_delayer; // Cached state for layout Optional m_mouse_position; mutable CachedLayoutBoxes m_layout_boxes; }; }