LibWeb: Consider playback ended when loop is set after ending playback

This allows playback to restart when playing is requested after the end
of playback was reached while loop was disabled, regardless of whether
loop is then subsequently enabled.

This matches other browsers' implementations, but differs from the spec
in how the ended attribute is handled.

See: https://github.com/whatwg/html/issues/11775
This commit is contained in:
Zaggy1024 2025-10-09 16:55:03 -05:00 committed by Jelle Raaijmakers
parent 3be6b957f8
commit 4471e8c0ec
Notes: github-actions[bot] 2025-10-28 00:31:04 +00:00
2 changed files with 37 additions and 4 deletions

View file

@ -211,6 +211,7 @@ private:
void set_show_poster(bool);
void set_paused(bool);
void set_duration(double);
void set_ended(bool);
void volume_or_muted_attribute_changed();
void update_volume();
@ -224,6 +225,7 @@ private:
PlaybackDirection direction_of_playback() const;
bool has_ended_playback() const;
void upon_has_ended_playback_possibly_changed();
void reached_end_of_media_playback();
void dispatch_time_update_event();
@ -291,6 +293,9 @@ private:
// https://html.spec.whatwg.org/multipage/media.html#dom-media-paused
bool m_paused { true };
// https://html.spec.whatwg.org/multipage/media.html#dom-media-ended
bool m_ended { false };
// https://html.spec.whatwg.org/multipage/media.html#dom-media-defaultplaybackrate
double m_default_playback_rate { 1.0 };
@ -334,6 +339,8 @@ private:
GC::Ptr<VideoTrack> m_selected_video_track;
RefPtr<Media::DisplayingVideoSink> m_selected_video_track_sink;
bool m_loop_was_specified_when_reaching_end_of_media_resource { false };
// Cached state for layout.
Optional<MediaComponent> m_mouse_tracking_component;
Optional<MediaComponent> m_hovered_component;