mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibWeb: Implement the HTMLVideoElement poster attribute
This will fetch the URL indicated by the poster attribute when it's set, changed, or removed. The spec doesn't say how to handle animated poster images, so we just grab the first frame of the image, which seems to match other implementations.
This commit is contained in:
parent
b384f2009d
commit
e0ccba9c85
2 changed files with 110 additions and 0 deletions
|
@ -8,8 +8,10 @@
|
|||
|
||||
#include <AK/Optional.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/HTMLMediaElement.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -37,6 +39,7 @@ public:
|
|||
|
||||
void set_current_frame(Badge<VideoTrack>, RefPtr<Gfx::Bitmap> frame, double position);
|
||||
VideoFrame const& current_frame() const { return m_current_frame; }
|
||||
RefPtr<Gfx::Bitmap> const& poster_frame() const { return m_poster_frame; }
|
||||
|
||||
void set_layout_mouse_position(Badge<Painting::VideoPaintable>, Optional<CSSPixelPoint> mouse_position) { m_mouse_position = move(mouse_position); }
|
||||
Optional<CSSPixelPoint> const& layout_mouse_position(Badge<Painting::VideoPaintable>) const { return m_mouse_position; }
|
||||
|
@ -54,18 +57,27 @@ private:
|
|||
virtual JS::ThrowCompletionOr<void> 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<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
virtual void on_playing() override;
|
||||
virtual void on_paused() override;
|
||||
virtual void on_seek(double, MediaSeekMode) override;
|
||||
|
||||
WebIDL::ExceptionOr<void> determine_element_poster_frame(Optional<StringView> const& poster);
|
||||
|
||||
JS::GCPtr<HTML::VideoTrack> m_video_track;
|
||||
VideoFrame m_current_frame;
|
||||
RefPtr<Gfx::Bitmap> m_poster_frame;
|
||||
|
||||
u32 m_video_width { 0 };
|
||||
u32 m_video_height { 0 };
|
||||
|
||||
JS::GCPtr<Fetch::Infrastructure::FetchController> m_fetch_controller;
|
||||
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
|
||||
|
||||
// Cached state for layout
|
||||
Optional<CSSPixelPoint> m_mouse_position;
|
||||
mutable CachedLayoutBoxes m_layout_boxes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue