aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmediaelement.rs
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2018-10-11 21:42:51 +0200
committerest31 <MTest31@outlook.com>2018-10-12 15:29:57 +0200
commitaf0f7db909058e125f48b0580c7f5d7c95de36ab (patch)
tree59f050ca2548600b6feb6aa70c040852108e72dc /components/script/dom/htmlmediaelement.rs
parent5f463d3c97e1ebb7436b611cd62ff6edcc61daa7 (diff)
downloadservo-af0f7db909058e125f48b0580c7f5d7c95de36ab.tar.gz
servo-af0f7db909058e125f48b0580c7f5d7c95de36ab.zip
Implement basic <source> support for HtmlMediaElement
The spec has a complicated algorithm for selecting a <source> element among multiple <source> children of a HtmlMediaElement where it loops over all of them, tries each and takes the first where "everything works out". This commit implements a much simpler and restricted approach by just taking the first <source> child, and if that fails, failing altogether, without looking at any further children. This is an improvement over the current status and makes gifv items on imgur playable, although it doesn't mean full <source> support.
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r--components/script/dom/htmlmediaelement.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 3a1d439168c..6756e6838b0 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -9,6 +9,7 @@ use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::CanPlayTypeResult;
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementConstants;
use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods;
+use dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElementMethods;
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorConstants::*;
use dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods;
use dom::bindings::codegen::InheritTypes::{ElementTypeId, HTMLElementTypeId};
@@ -633,10 +634,28 @@ impl HTMLMediaElement {
// of the cleanup in case of failure itself.
self.resource_fetch_algorithm(Resource::Url(url_record));
},
- Mode::Children(_source) => {
- // Step 9.children.
+ // Step 9.children.
+ Mode::Children(source) => {
+ // This is only a partial implementation
// FIXME: https://github.com/servo/servo/issues/21481
- self.queue_dedicated_media_source_failure_steps()
+ let src = source.Src();
+ // Step 9.attr.2.
+ if src.is_empty() {
+ source.upcast::<EventTarget>().fire_event(atom!("error"));
+ self.queue_dedicated_media_source_failure_steps();
+ return;
+ }
+ // Step 9.attr.3.
+ let url_record = match base_url.join(&src) {
+ Ok(url) => url,
+ Err(_) => {
+ source.upcast::<EventTarget>().fire_event(atom!("error"));
+ self.queue_dedicated_media_source_failure_steps();
+ return;
+ },
+ };
+ // Step 9.attr.8.
+ self.resource_fetch_algorithm(Resource::Url(url_record));
},
}
}