diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-10-16 01:23:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-16 01:23:08 -0400 |
commit | 1652fe2a91e43d27350a8230363da8d28dfbf678 (patch) | |
tree | d4c1123b09b9ab7e24205b352e02718a74fea587 /components/script | |
parent | f88f3122249c5284d43caeac8580012189645bfc (diff) | |
parent | af0f7db909058e125f48b0580c7f5d7c95de36ab (diff) | |
download | servo-1652fe2a91e43d27350a8230363da8d28dfbf678.tar.gz servo-1652fe2a91e43d27350a8230363da8d28dfbf678.zip |
Auto merge of #21923 - est31:master, r=ferjm
πππ Implement basic <source> take-first-then-fail algo 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 PR 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.
See it in action: https://i.imgur.com/WoEhYj3.gifv
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change isβ[<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21923)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/htmlmediaelement.rs | 25 |
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)); }, } } |