| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-04-28 22:46:44 +02:00
										 |  |  |  * Copyright (c) 2020, the SerenityOS developers. | 
					
						
							| 
									
										
										
										
											2023-04-07 10:45:17 -04:00
										 |  |  |  * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  | #include <AK/ByteBuffer.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  | #include <AK/Optional.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-10 09:52:53 -04:00
										 |  |  | #include <AK/Time.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  | #include <AK/Variant.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  | #include <LibGfx/Rect.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  | #include <LibJS/Heap/MarkedVector.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  | #include <LibJS/SafeFunction.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-19 06:48:42 -04:00
										 |  |  | #include <LibWeb/DOM/DocumentLoadEventDelayer.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-18 16:38:54 -04:00
										 |  |  | #include <LibWeb/HTML/CORSSettingAttribute.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-04 09:11:58 -04:00
										 |  |  | #include <LibWeb/HTML/EventLoop/Task.h>
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  | #include <LibWeb/HTML/HTMLElement.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  | #include <LibWeb/PixelUnits.h>
 | 
					
						
							| 
									
										
										
										
											2024-06-06 13:29:08 -06:00
										 |  |  | #include <LibWeb/UIEvents/KeyCode.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  | #include <LibWeb/WebIDL/DOMException.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-04 15:12:40 -04:00
										 |  |  | #include <math.h>
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  | enum class MediaSeekMode { | 
					
						
							|  |  |  |     Accurate, | 
					
						
							|  |  |  |     ApproximateForSpeed, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-12 15:02:37 -04:00
										 |  |  | class SourceElementSelector; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  | class HTMLMediaElement : public HTMLElement { | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     WEB_PLATFORM_OBJECT(HTMLMediaElement, HTMLElement); | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  |     virtual ~HTMLMediaElement() override; | 
					
						
							| 
									
										
										
										
											2022-03-04 18:49:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 21:39:06 -07:00
										 |  |  |     virtual bool is_focusable() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-04 12:06:50 +02:00
										 |  |  |     // NOTE: The function is wrapped in a JS::HeapFunction immediately.
 | 
					
						
							|  |  |  |     void queue_a_media_element_task(Function<void()>); | 
					
						
							| 
									
										
										
										
											2023-04-04 09:11:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-22 14:44:33 -04:00
										 |  |  |     JS::GCPtr<MediaError> error() const { return m_error; } | 
					
						
							| 
									
										
										
										
											2024-04-26 11:51:26 -04:00
										 |  |  |     void set_decoder_error(String error_message); | 
					
						
							| 
									
										
										
										
											2023-04-22 14:44:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-19 06:44:40 -04:00
										 |  |  |     String const& current_src() const { return m_current_src; } | 
					
						
							| 
									
										
										
										
											2023-05-12 15:04:58 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> select_resource(); | 
					
						
							| 
									
										
										
										
											2023-04-19 06:44:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 11:11:18 -04:00
										 |  |  |     enum class NetworkState : u16 { | 
					
						
							|  |  |  |         Empty, | 
					
						
							|  |  |  |         Idle, | 
					
						
							|  |  |  |         Loading, | 
					
						
							|  |  |  |         NoSource, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     NetworkState network_state() const { return m_network_state; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-13 13:05:26 +02:00
										 |  |  |     [[nodiscard]] JS::NonnullGCPtr<TimeRanges> buffered() const; | 
					
						
							| 
									
										
										
										
											2023-04-18 16:22:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-26 11:56:11 -04:00
										 |  |  |     Bindings::CanPlayTypeResult can_play_type(StringView type) const; | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 15:41:09 -04:00
										 |  |  |     enum class ReadyState : u16 { | 
					
						
							|  |  |  |         HaveNothing, | 
					
						
							|  |  |  |         HaveMetadata, | 
					
						
							|  |  |  |         HaveCurrentData, | 
					
						
							|  |  |  |         HaveFutureData, | 
					
						
							|  |  |  |         HaveEnoughData, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     ReadyState ready_state() const { return m_ready_state; } | 
					
						
							| 
									
										
										
										
											2023-08-01 15:26:56 +01:00
										 |  |  |     bool blocked() const; | 
					
						
							|  |  |  |     bool stalled() const; | 
					
						
							| 
									
										
										
										
											2023-04-04 15:41:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  |     bool seeking() const { return m_seeking; } | 
					
						
							| 
									
										
										
										
											2023-08-01 13:04:47 +01:00
										 |  |  |     void set_seeking(bool); | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 10:45:17 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> load(); | 
					
						
							| 
									
										
										
										
											2023-04-10 10:07:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     double current_time() const; | 
					
						
							|  |  |  |     void set_current_time(double); | 
					
						
							| 
									
										
										
										
											2023-04-23 16:17:01 -04:00
										 |  |  |     void fast_seek(double); | 
					
						
							| 
									
										
										
										
											2023-04-20 06:47:48 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     double current_playback_position() const { return m_current_playback_position; } | 
					
						
							| 
									
										
										
										
											2023-04-10 10:07:23 -04:00
										 |  |  |     void set_current_playback_position(double); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 15:12:40 -04:00
										 |  |  |     double duration() const; | 
					
						
							| 
									
										
										
										
											2023-04-20 06:49:06 -04:00
										 |  |  |     bool show_poster() const { return m_show_poster; } | 
					
						
							| 
									
										
										
										
											2023-04-07 11:10:57 -04:00
										 |  |  |     bool paused() const { return m_paused; } | 
					
						
							| 
									
										
										
										
											2023-04-10 20:04:46 -04:00
										 |  |  |     bool ended() const; | 
					
						
							| 
									
										
										
										
											2023-04-20 07:20:42 -04:00
										 |  |  |     bool potentially_playing() const; | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> play(); | 
					
						
							| 
									
										
										
										
											2023-04-07 11:35:11 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> pause(); | 
					
						
							| 
									
										
										
										
											2023-07-02 21:38:11 -07:00
										 |  |  |     WebIDL::ExceptionOr<void> toggle_playback(); | 
					
						
							| 
									
										
										
										
											2022-10-28 15:38:35 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 13:07:09 -04:00
										 |  |  |     double volume() const { return m_volume; } | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> set_volume(double); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool muted() const { return m_muted; } | 
					
						
							|  |  |  |     void set_muted(bool); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-30 09:41:15 -04:00
										 |  |  |     void page_mute_state_changed(Badge<Page>); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 13:07:09 -04:00
										 |  |  |     double effective_media_volume() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-12 13:52:30 -04:00
										 |  |  |     JS::NonnullGCPtr<AudioTrackList> audio_tracks() const { return *m_audio_tracks; } | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     JS::NonnullGCPtr<VideoTrackList> video_tracks() const { return *m_video_tracks; } | 
					
						
							| 
									
										
										
										
											2024-07-05 20:24:41 +01:00
										 |  |  |     JS::NonnullGCPtr<TextTrackList> text_tracks() const { return *m_text_tracks; } | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-25 20:23:15 +01:00
										 |  |  |     JS::NonnullGCPtr<TextTrack> add_text_track(Bindings::TextTrackKind kind, String const& label, String const& language); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-04 04:30:44 +01:00
										 |  |  |     WebIDL::ExceptionOr<bool> handle_keydown(Badge<Web::EventHandler>, UIEvents::KeyCode, u32 modifiers); | 
					
						
							| 
									
										
										
										
											2023-07-02 21:40:46 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 17:08:50 -04:00
										 |  |  |     enum class MouseTrackingComponent { | 
					
						
							|  |  |  |         Timeline, | 
					
						
							|  |  |  |         Volume, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     void set_layout_mouse_tracking_component(Badge<Painting::MediaPaintable>, Optional<MouseTrackingComponent> mouse_tracking_component) { m_mouse_tracking_component = move(mouse_tracking_component); } | 
					
						
							|  |  |  |     Optional<MouseTrackingComponent> const& layout_mouse_tracking_component(Badge<Painting::MediaPaintable>) const { return m_mouse_tracking_component; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  |     void set_layout_mouse_position(Badge<Painting::MediaPaintable>, Optional<CSSPixelPoint> mouse_position) { m_mouse_position = move(mouse_position); } | 
					
						
							|  |  |  |     Optional<CSSPixelPoint> const& layout_mouse_position(Badge<Painting::MediaPaintable>) const { return m_mouse_position; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 17:08:50 -04:00
										 |  |  |     void set_layout_display_time(Badge<Painting::MediaPaintable>, Optional<double> display_time); | 
					
						
							|  |  |  |     double layout_display_time(Badge<Painting::MediaPaintable>) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  |     struct CachedLayoutBoxes { | 
					
						
							|  |  |  |         Optional<CSSPixelRect> control_box_rect; | 
					
						
							|  |  |  |         Optional<CSSPixelRect> playback_button_rect; | 
					
						
							|  |  |  |         Optional<CSSPixelRect> timeline_rect; | 
					
						
							| 
									
										
										
										
											2023-06-15 15:09:47 -04:00
										 |  |  |         Optional<CSSPixelRect> speaker_button_rect; | 
					
						
							| 
									
										
										
										
											2023-06-15 15:46:37 -04:00
										 |  |  |         Optional<CSSPixelRect> volume_rect; | 
					
						
							| 
									
										
										
										
											2023-08-03 17:53:35 -05:00
										 |  |  |         Optional<CSSPixelRect> volume_scrub_rect; | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  |     }; | 
					
						
							|  |  |  |     CachedLayoutBoxes& cached_layout_boxes(Badge<Painting::MediaPaintable>) const { return m_layout_boxes; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | protected: | 
					
						
							|  |  |  |     HTMLMediaElement(DOM::Document&, DOM::QualifiedName); | 
					
						
							| 
									
										
										
										
											2023-01-10 06:28:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-07 08:41:28 +02:00
										 |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2024-03-30 09:38:00 -04:00
										 |  |  |     virtual void finalize() override; | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							| 
									
										
										
										
											2023-04-03 11:11:18 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-09 20:18:41 +01:00
										 |  |  |     virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override; | 
					
						
							| 
									
										
										
										
											2023-04-29 07:41:30 -04:00
										 |  |  |     virtual void removed_from(DOM::Node*) override; | 
					
						
							| 
									
										
										
										
											2023-05-22 07:41:34 -04:00
										 |  |  |     virtual void children_changed() override; | 
					
						
							| 
									
										
										
										
											2023-04-20 06:34:59 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 11:10:57 -04:00
										 |  |  |     // Override in subclasses to handle implementation-specific behavior when the element state changes
 | 
					
						
							|  |  |  |     // to playing or paused, e.g. to start/stop play timers.
 | 
					
						
							|  |  |  |     virtual void on_playing() { } | 
					
						
							|  |  |  |     virtual void on_paused() { } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  |     // Override in subclasses to handle implementation-specific seeking behavior. When seeking is complete,
 | 
					
						
							|  |  |  |     // subclasses must invoke set_current_playback_position() to unblock the user agent.
 | 
					
						
							|  |  |  |     virtual void on_seek(double, MediaSeekMode) { m_seek_in_progress = false; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 13:07:09 -04:00
										 |  |  |     virtual void on_volume_change() { } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 11:11:18 -04:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-05-12 15:02:37 -04:00
										 |  |  |     friend SourceElementSelector; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     struct EntireResource { }; | 
					
						
							|  |  |  |     using ByteRange = Variant<EntireResource>; // FIXME: This will need to include "until end" and an actual byte range.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 09:11:58 -04:00
										 |  |  |     Task::Source media_element_event_task_source() const { return m_media_element_event_task_source.source; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> load_element(); | 
					
						
							| 
									
										
										
										
											2024-05-17 17:14:06 -07:00
										 |  |  |     WebIDL::ExceptionOr<void> fetch_resource(URL::URL const&, ESCAPING Function<void(String)> failure_callback); | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     static bool verify_response(JS::NonnullGCPtr<Fetch::Infrastructure::Response>, ByteRange const&); | 
					
						
							| 
									
										
										
										
											2023-04-22 14:44:33 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> process_media_data(Function<void(String)> failure_callback); | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> handle_media_source_failure(Span<JS::NonnullGCPtr<WebIDL::Promise>> promises, String error_message); | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     void forget_media_resource_specific_tracks(); | 
					
						
							| 
									
										
										
										
											2023-04-04 15:41:09 -04:00
										 |  |  |     void set_ready_state(ReadyState); | 
					
						
							| 
									
										
										
										
											2023-04-07 11:10:57 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> play_element(); | 
					
						
							| 
									
										
										
										
											2023-04-07 11:35:11 -04:00
										 |  |  |     WebIDL::ExceptionOr<void> pause_element(); | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  |     void seek_element(double playback_position, MediaSeekMode = MediaSeekMode::Accurate); | 
					
						
							| 
									
										
										
										
											2023-04-07 11:10:57 -04:00
										 |  |  |     void notify_about_playing(); | 
					
						
							| 
									
										
										
										
											2023-04-20 06:49:06 -04:00
										 |  |  |     void set_show_poster(bool); | 
					
						
							| 
									
										
										
										
											2023-04-07 11:10:57 -04:00
										 |  |  |     void set_paused(bool); | 
					
						
							| 
									
										
										
										
											2023-04-04 15:12:40 -04:00
										 |  |  |     void set_duration(double); | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 13:07:09 -04:00
										 |  |  |     void volume_or_muted_attribute_changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-17 07:24:50 -04:00
										 |  |  |     bool is_eligible_for_autoplay() const; | 
					
						
							| 
									
										
										
										
											2023-04-10 20:04:46 -04:00
										 |  |  |     bool has_ended_playback() const; | 
					
						
							| 
									
										
										
										
											2023-08-13 13:05:26 +02:00
										 |  |  |     void reached_end_of_media_playback(); | 
					
						
							| 
									
										
										
										
											2023-04-10 20:04:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-13 13:05:26 +02:00
										 |  |  |     void dispatch_time_update_event(); | 
					
						
							| 
									
										
										
										
											2023-04-10 09:52:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-10 10:07:23 -04:00
										 |  |  |     enum class TimeMarchesOnReason { | 
					
						
							|  |  |  |         NormalPlayback, | 
					
						
							|  |  |  |         Other, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     void time_marches_on(TimeMarchesOnReason = TimeMarchesOnReason::NormalPlayback); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  |     JS::MarkedVector<JS::NonnullGCPtr<WebIDL::Promise>> take_pending_play_promises(); | 
					
						
							|  |  |  |     void resolve_pending_play_promises(ReadonlySpan<JS::NonnullGCPtr<WebIDL::Promise>> promises); | 
					
						
							|  |  |  |     void reject_pending_play_promises(ReadonlySpan<JS::NonnullGCPtr<WebIDL::Promise>> promises, JS::NonnullGCPtr<WebIDL::DOMException> error); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/media.html#reject-pending-play-promises
 | 
					
						
							|  |  |  |     template<typename ErrorType> | 
					
						
							| 
									
										
										
										
											2024-10-12 20:56:21 +02:00
										 |  |  |     void reject_pending_play_promises(ReadonlySpan<JS::NonnullGCPtr<WebIDL::Promise>> promises, String message) | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         auto& realm = this->realm(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-12 20:56:21 +02:00
										 |  |  |         auto error = ErrorType::create(realm, move(message)); | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  |         reject_pending_play_promises(promises, error); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 09:11:58 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#media-element-event-task-source
 | 
					
						
							|  |  |  |     UniqueTaskSource m_media_element_event_task_source {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-22 14:44:33 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-error
 | 
					
						
							|  |  |  |     JS::GCPtr<MediaError> m_error; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-18 16:38:54 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-crossorigin
 | 
					
						
							|  |  |  |     CORSSettingAttribute m_crossorigin { CORSSettingAttribute::NoCORS }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-19 06:44:40 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-currentsrc
 | 
					
						
							|  |  |  |     String m_current_src; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 11:11:18 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
 | 
					
						
							|  |  |  |     NetworkState m_network_state { NetworkState::Empty }; | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 15:41:09 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-readystate
 | 
					
						
							|  |  |  |     ReadyState m_ready_state { ReadyState::HaveNothing }; | 
					
						
							|  |  |  |     bool m_first_data_load_event_since_load_start { false }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-seeking
 | 
					
						
							|  |  |  |     bool m_seeking { false }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-10 10:07:23 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#current-playback-position
 | 
					
						
							|  |  |  |     double m_current_playback_position { 0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/media.html#official-playback-position
 | 
					
						
							|  |  |  |     double m_official_playback_position { 0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/media.html#default-playback-start-position
 | 
					
						
							|  |  |  |     double m_default_playback_start_position { 0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-20 06:49:06 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#show-poster-flag
 | 
					
						
							|  |  |  |     bool m_show_poster { true }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 15:12:40 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-duration
 | 
					
						
							|  |  |  |     double m_duration { NAN }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#list-of-pending-play-promises
 | 
					
						
							| 
									
										
										
										
											2024-04-01 10:39:25 +02:00
										 |  |  |     Vector<JS::NonnullGCPtr<WebIDL::Promise>> m_pending_play_promises; | 
					
						
							| 
									
										
										
										
											2023-04-07 12:52:41 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-07 11:10:57 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-paused
 | 
					
						
							|  |  |  |     bool m_paused { true }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 13:07:09 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-volume
 | 
					
						
							|  |  |  |     double m_volume { 1.0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-muted
 | 
					
						
							|  |  |  |     bool m_muted { false }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-12 13:52:30 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-audiotracks
 | 
					
						
							|  |  |  |     JS::GCPtr<AudioTrackList> m_audio_tracks; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-videotracks
 | 
					
						
							|  |  |  |     JS::GCPtr<VideoTrackList> m_video_tracks; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-05 20:24:41 +01:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#dom-media-texttracks
 | 
					
						
							|  |  |  |     JS::GCPtr<TextTrackList> m_text_tracks; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#media-data
 | 
					
						
							|  |  |  |     ByteBuffer m_media_data; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-17 07:24:50 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#can-autoplay-flag
 | 
					
						
							|  |  |  |     bool m_can_autoplay { true }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-19 06:48:42 -04:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/media.html#delaying-the-load-event-flag
 | 
					
						
							|  |  |  |     Optional<DOM::DocumentLoadEventDelayer> m_delaying_the_load_event; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-10 09:52:53 -04:00
										 |  |  |     bool m_running_time_update_event_handler { false }; | 
					
						
							| 
									
										
										
										
											2023-03-17 19:50:39 +01:00
										 |  |  |     Optional<MonotonicTime> m_last_time_update_event_time; | 
					
						
							| 
									
										
										
										
											2023-04-10 09:52:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-04 08:50:34 -04:00
										 |  |  |     JS::GCPtr<DOM::DocumentObserver> m_document_observer; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-12 15:02:37 -04:00
										 |  |  |     JS::GCPtr<SourceElementSelector> m_source_element_selector; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-04 14:14:33 -04:00
										 |  |  |     JS::GCPtr<Fetch::Infrastructure::FetchController> m_fetch_controller; | 
					
						
							| 
									
										
										
										
											2023-04-11 18:37:00 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool m_seek_in_progress = false; | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Cached state for layout.
 | 
					
						
							| 
									
										
										
										
											2023-06-21 17:08:50 -04:00
										 |  |  |     Optional<MouseTrackingComponent> m_mouse_tracking_component; | 
					
						
							|  |  |  |     bool m_tracking_mouse_position_while_playing { false }; | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  |     Optional<CSSPixelPoint> m_mouse_position; | 
					
						
							| 
									
										
										
										
											2023-06-21 17:08:50 -04:00
										 |  |  |     Optional<double> m_display_time; | 
					
						
							| 
									
										
										
										
											2023-06-12 08:21:35 -04:00
										 |  |  |     mutable CachedLayoutBoxes m_layout_boxes; | 
					
						
							| 
									
										
										
										
											2020-08-01 03:05:43 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |