aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmediaelement.rs
diff options
context:
space:
mode:
authorTIN TUN AUNG <62133983+rayguo17@users.noreply.github.com>2025-04-11 14:32:34 +0800
committerGitHub <noreply@github.com>2025-04-11 06:32:34 +0000
commit972ca77ce1bd2c08b809b7d54ec716213519fe1e (patch)
tree2b65e59a4bbe7ffcfbb382612b1c8a32594e55e4 /components/script/dom/htmlmediaelement.rs
parentc8ecb57d97f1b2ac38886452b1aea8a9b1e020a9 (diff)
downloadservo-972ca77ce1bd2c08b809b7d54ec716213519fe1e.tar.gz
servo-972ca77ce1bd2c08b809b7d54ec716213519fe1e.zip
dom: should change media element's currentSrc to children source element's src in resource selection algorithm. (#36408)
Set the `htmlmediaelement`'s `currenSrc` in resource-selection-algorithm. Change the `htmlsourceelement`'s src and srcset to USVString type. According to [Spec](https://html.spec.whatwg.org/multipage/media.html#concept-media-load-algorithm), Step 9.3 for mode is children, should set the `currentSrc` to `src` of children `htmlsourceelement`. Also, In the `htmlsourceelement` [interface definition](https://html.spec.whatwg.org/multipage/embedded-content.html#the-source-element), the `src` and `srcset` attribute should be type `USVString`. Testing: More WPT tests related to resource selection algorithm are passing. Fix: Some spec fix [Try](https://github.com/rayguo17/servo/actions/runs/14347535616) cc @xiaochengh Signed-off-by: rayguo17 <rayguo17@gmail.com>
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r--components/script/dom/htmlmediaelement.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index b16c17f1d79..1c802b38f72 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -52,7 +52,6 @@ use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::{
CanPlayTypeResult, HTMLMediaElementConstants, HTMLMediaElementMethods,
};
-use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElementMethods;
use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*;
use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::Navigator_Binding::NavigatorMethods;
@@ -836,15 +835,20 @@ impl HTMLMediaElement {
Mode::Children(source) => {
// This is only a partial implementation
// FIXME: https://github.com/servo/servo/issues/21481
- let src = source.Src();
+ let src = source
+ .upcast::<Element>()
+ .get_attribute(&ns!(), &local_name!("src"));
// Step 9.attr.2.
- if src.is_empty() {
- source
- .upcast::<EventTarget>()
- .fire_event(atom!("error"), can_gc);
- self.queue_dedicated_media_source_failure_steps();
- return;
- }
+ let src: String = match src {
+ Some(src) if !src.Value().is_empty() => src.Value().into(),
+ _ => {
+ source
+ .upcast::<EventTarget>()
+ .fire_event(atom!("error"), can_gc);
+ self.queue_dedicated_media_source_failure_steps();
+ return;
+ },
+ };
// Step 9.attr.3.
let url_record = match base_url.join(&src) {
Ok(url) => url,
@@ -856,6 +860,8 @@ impl HTMLMediaElement {
return;
},
};
+ // Step 9.attr.7
+ *self.current_src.borrow_mut() = url_record.as_str().into();
// Step 9.attr.8.
self.resource_fetch_algorithm(Resource::Url(url_record));
},