mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Implement the error path for source children of media elements
This removes some test timeout.
This commit is contained in:
parent
49dd04cd8b
commit
5245931dc2
8 changed files with 54 additions and 24 deletions
|
@ -85,7 +85,7 @@ pub struct HTMLMediaElement {
|
|||
/// https://html.spec.whatwg.org/multipage/#dom-media-networkstate
|
||||
#[derive(Clone, Copy, HeapSizeOf, JSTraceable, PartialEq)]
|
||||
#[repr(u8)]
|
||||
enum NetworkState {
|
||||
pub enum NetworkState {
|
||||
Empty = HTMLMediaElementConstants::NETWORK_EMPTY as u8,
|
||||
Idle = HTMLMediaElementConstants::NETWORK_IDLE as u8,
|
||||
Loading = HTMLMediaElementConstants::NETWORK_LOADING as u8,
|
||||
|
@ -443,12 +443,23 @@ impl HTMLMediaElement {
|
|||
#[allow(dead_code)]
|
||||
Object,
|
||||
Attribute(String),
|
||||
// FIXME(nox): Support source element child.
|
||||
#[allow(dead_code)]
|
||||
Children(Root<HTMLSourceElement>),
|
||||
}
|
||||
let mode = if let Some(attr) = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("src")) {
|
||||
Mode::Attribute(attr.Value().into())
|
||||
fn mode(media: &HTMLMediaElement) -> Option<Mode> {
|
||||
if let Some(attr) = media.upcast::<Element>().get_attribute(&ns!(), &local_name!("src")) {
|
||||
return Some(Mode::Attribute(attr.Value().into()));
|
||||
}
|
||||
let source_child_element = media.upcast::<Node>()
|
||||
.children()
|
||||
.filter_map(Root::downcast::<HTMLSourceElement>)
|
||||
.next();
|
||||
if let Some(element) = source_child_element {
|
||||
return Some(Mode::Children(element));
|
||||
}
|
||||
None
|
||||
}
|
||||
let mode = if let Some(mode) = mode(self) {
|
||||
mode
|
||||
} else {
|
||||
self.network_state.set(NetworkState::Empty);
|
||||
return;
|
||||
|
@ -775,6 +786,19 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles insertion of `source` children.
|
||||
///
|
||||
/// https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted
|
||||
pub fn handle_source_child_insertion(&self) {
|
||||
if self.upcast::<Element>().has_attribute(&local_name!("src")) {
|
||||
return;
|
||||
}
|
||||
if self.network_state.get() != NetworkState::Empty {
|
||||
return;
|
||||
}
|
||||
self.media_element_load_algorithm();
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue