summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-04-29 07:41:30 -0400
committerAndreas Kling <kling@serenityos.org>2023-05-04 16:48:10 +0200
commit88b89694433760da56a3e1e0684dc463fbfa76d5 (patch)
treee5b24a6cf682a34bbd646d3b0029db3b1cd4c8a7
parent344785ae3a513f0fc253575b3009f38dc6535e9e (diff)
downloadserenity-88b89694433760da56a3e1e0684dc463fbfa76d5.zip
LibWeb: Implement steps for removing an HTMLMediaElement from a document
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp19
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
index db2e59b2f4..a1c5e935e7 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
@@ -84,6 +84,25 @@ void HTMLMediaElement::did_remove_attribute(DeprecatedFlyString const& name)
m_crossorigin = cors_setting_attribute_from_keyword({});
}
+// https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:media-element-83
+void HTMLMediaElement::removed_from(DOM::Node* node)
+{
+ Base::removed_from(node);
+
+ // When a media element is removed from a Document, the user agent must run the following steps:
+
+ // FIXME: 1. Await a stable state, allowing the task that removed the media element from the Document to continue. The
+ // synchronous section consists of all the remaining steps of this algorithm. (Steps in the synchronous section
+ // are marked with ⌛.)
+
+ // 2. ⌛ If the media element is in a document, return.
+ if (in_a_document_tree())
+ return;
+
+ // 3. ⌛ Run the internal pause steps for the media element.
+ pause_element().release_value_but_fixme_should_propagate_errors();
+}
+
// https://html.spec.whatwg.org/multipage/media.html#fatal-decode-error
WebIDL::ExceptionOr<void> HTMLMediaElement::set_decoder_error(String error_message)
{
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h
index 4c262f6c68..74109250f5 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h
@@ -89,6 +89,7 @@ protected:
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
virtual void did_remove_attribute(DeprecatedFlyString const&) override;
+ virtual void removed_from(DOM::Node*) override;
// Override in subclasses to handle implementation-specific behavior when the element state changes
// to playing or paused, e.g. to start/stop play timers.