mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibWeb: Implement the HTMLMediaElement currentSrc attribute
This commit is contained in:
parent
74a6f50c91
commit
1a67b86b76
3 changed files with 11 additions and 1 deletions
|
@ -378,6 +378,8 @@ enum class SelectMode {
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#concept-media-load-algorithm
|
// https://html.spec.whatwg.org/multipage/media.html#concept-media-load-algorithm
|
||||||
WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
|
WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
|
||||||
{
|
{
|
||||||
|
auto& vm = this->vm();
|
||||||
|
|
||||||
// 1. Set the element's networkState attribute to the NETWORK_NO_SOURCE value.
|
// 1. Set the element's networkState attribute to the NETWORK_NO_SOURCE value.
|
||||||
m_network_state = NetworkState::NoSource;
|
m_network_state = NetworkState::NoSource;
|
||||||
|
|
||||||
|
@ -463,7 +465,9 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
|
||||||
// the URL specified by the src attribute's value relative to the media element's node document when the src attribute was last changed.
|
// the URL specified by the src attribute's value relative to the media element's node document when the src attribute was last changed.
|
||||||
auto url_record = document().parse_url(source);
|
auto url_record = document().parse_url(source);
|
||||||
|
|
||||||
// FIXME: 3. ⌛ If urlString was obtained successfully, set the currentSrc attribute to urlString.
|
// 3. ⌛ If urlString was obtained successfully, set the currentSrc attribute to urlString.
|
||||||
|
if (url_record.is_valid())
|
||||||
|
m_current_src = TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url_record.to_deprecated_string()));
|
||||||
|
|
||||||
// 4. End the synchronous section, continuing the remaining steps in parallel.
|
// 4. End the synchronous section, continuing the remaining steps in parallel.
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
|
|
||||||
void queue_a_media_element_task(JS::SafeFunction<void()> steps);
|
void queue_a_media_element_task(JS::SafeFunction<void()> steps);
|
||||||
|
|
||||||
|
String const& current_src() const { return m_current_src; }
|
||||||
|
|
||||||
enum class NetworkState : u16 {
|
enum class NetworkState : u16 {
|
||||||
Empty,
|
Empty,
|
||||||
Idle,
|
Idle,
|
||||||
|
@ -142,6 +144,9 @@ private:
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#dom-media-crossorigin
|
// https://html.spec.whatwg.org/multipage/media.html#dom-media-crossorigin
|
||||||
CORSSettingAttribute m_crossorigin { CORSSettingAttribute::NoCORS };
|
CORSSettingAttribute m_crossorigin { CORSSettingAttribute::NoCORS };
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/media.html#dom-media-currentsrc
|
||||||
|
String m_current_src;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
|
// https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
|
||||||
NetworkState m_network_state { NetworkState::Empty };
|
NetworkState m_network_state { NetworkState::Empty };
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ interface HTMLMediaElement : HTMLElement {
|
||||||
|
|
||||||
// network state
|
// network state
|
||||||
[Reflect, CEReactions] attribute DOMString src;
|
[Reflect, CEReactions] attribute DOMString src;
|
||||||
|
readonly attribute USVString currentSrc;
|
||||||
[Reflect=crossorigin, CEReactions] attribute DOMString? crossOrigin;
|
[Reflect=crossorigin, CEReactions] attribute DOMString? crossOrigin;
|
||||||
const unsigned short NETWORK_EMPTY = 0;
|
const unsigned short NETWORK_EMPTY = 0;
|
||||||
const unsigned short NETWORK_IDLE = 1;
|
const unsigned short NETWORK_IDLE = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue