mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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.
This commit is contained in:
parent
5f463d3c97
commit
af0f7db909
1 changed files with 22 additions and 3 deletions
|
@ -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));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue