summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-04-04 09:11:58 -0400
committerLinus Groh <mail@linusgroh.de>2023-04-07 16:02:22 +0200
commit9f8da9798a60f897d0afe4f2263a736d133a6547 (patch)
tree1cbedbacb3a20b55d2ef2c66fc526a5a256a9149 /Userland/Libraries
parent0a45554bf4dee5c2e1902f845bc024095a5bcab7 (diff)
downloadserenity-9f8da9798a60f897d0afe4f2263a736d133a6547.zip
LibWeb: Define steps to queue a media element task on a HTMLMediaElement
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp8
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h8
2 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
index 2fea46c39a..a04a1fc6a7 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
@@ -25,6 +25,14 @@ JS::ThrowCompletionOr<void> HTMLMediaElement::initialize(JS::Realm& realm)
return {};
}
+// https://html.spec.whatwg.org/multipage/media.html#queue-a-media-element-task
+void HTMLMediaElement::queue_a_media_element_task(JS::SafeFunction<void()> steps)
+{
+ // To queue a media element task with a media element element and a series of steps steps, queue an element task on the media element's
+ // media element event task source given element and steps.
+ queue_an_element_task(media_element_event_task_source(), move(steps));
+}
+
// https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype
Bindings::CanPlayTypeResult HTMLMediaElement::can_play_type(DeprecatedString const& type) const
{
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h
index 82d4307e1d..cd67e31fbb 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h
@@ -6,6 +6,7 @@
#pragma once
+#include <LibWeb/HTML/EventLoop/Task.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@@ -16,6 +17,8 @@ class HTMLMediaElement : public HTMLElement {
public:
virtual ~HTMLMediaElement() override;
+ void queue_a_media_element_task(JS::SafeFunction<void()> steps);
+
enum class NetworkState : u16 {
Empty,
Idle,
@@ -35,6 +38,11 @@ protected:
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
private:
+ Task::Source media_element_event_task_source() const { return m_media_element_event_task_source.source; }
+
+ // https://html.spec.whatwg.org/multipage/media.html#media-element-event-task-source
+ UniqueTaskSource m_media_element_event_task_source {};
+
// https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
NetworkState m_network_state { NetworkState::Empty };
};