mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Clean up HTMLMediaElement::change_ready_state
This commit is contained in:
parent
23701f8659
commit
e4cd6be831
1 changed files with 58 additions and 80 deletions
|
@ -199,23 +199,19 @@ impl HTMLMediaElement {
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let task_source = window.dom_manipulation_task_source();
|
let task_source = window.dom_manipulation_task_source();
|
||||||
|
|
||||||
// Step 1
|
// Step 1.
|
||||||
match (old_ready_state, ready_state) {
|
match (old_ready_state, ready_state) {
|
||||||
// Previous ready state was ReadyState::HaveNothing,
|
|
||||||
// and the new ready state is ReadyState::HaveMetadata.
|
|
||||||
(ReadyState::HaveNothing, ReadyState::HaveMetadata) => {
|
(ReadyState::HaveNothing, ReadyState::HaveMetadata) => {
|
||||||
task_source.queue_simple_event(
|
task_source.queue_simple_event(
|
||||||
self.upcast(),
|
self.upcast(),
|
||||||
atom!("loadedmetadata"),
|
atom!("loadedmetadata"),
|
||||||
&window,
|
&window,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Previous ready state was ReadyState::HaveMetadata, and the new
|
// No other steps are applicable in this case.
|
||||||
// ready state is ReadyState::HaveCurrentData or greater.
|
return;
|
||||||
(ReadyState::HaveMetadata, ReadyState::HaveCurrentData) |
|
},
|
||||||
(ReadyState::HaveMetadata, ReadyState::HaveFutureData) |
|
(ReadyState::HaveMetadata, new) if new >= ReadyState::HaveCurrentData => {
|
||||||
(ReadyState::HaveMetadata, ReadyState::HaveEnoughData) => {
|
|
||||||
if !self.fired_loadeddata_event.get() {
|
if !self.fired_loadeddata_event.get() {
|
||||||
self.fired_loadeddata_event.set(true);
|
self.fired_loadeddata_event.set(true);
|
||||||
task_source.queue_simple_event(
|
task_source.queue_simple_event(
|
||||||
|
@ -224,86 +220,68 @@ impl HTMLMediaElement {
|
||||||
&window,
|
&window,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// previous ready state was ReadyState::HaveFutureData or more,
|
// Steps for the transition from HaveMetadata to HaveCurrentData
|
||||||
// and the new ready state is ReadyState::HaveCurrentData or less.
|
// or HaveFutureData also apply here, as per the next match
|
||||||
(ReadyState::HaveFutureData, ReadyState::HaveCurrentData) |
|
// expression.
|
||||||
(ReadyState::HaveEnoughData, ReadyState::HaveCurrentData) |
|
},
|
||||||
(ReadyState::HaveFutureData, ReadyState::HaveMetadata) |
|
(ReadyState::HaveFutureData, new) if new <= ReadyState::HaveCurrentData => {
|
||||||
(ReadyState::HaveEnoughData, ReadyState::HaveMetadata) |
|
// FIXME(nox): Queue a task to fire timeupdate and waiting
|
||||||
(ReadyState::HaveFutureData, ReadyState::HaveNothing) |
|
// events if the conditions call from the spec are met.
|
||||||
(ReadyState::HaveEnoughData, ReadyState::HaveNothing) => {
|
|
||||||
// TODO: timeupdate event logic + waiting
|
// No other steps are applicable in this case.
|
||||||
}
|
return;
|
||||||
|
},
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1.
|
if old_ready_state <= ReadyState::HaveCurrentData && ready_state >= ReadyState::HaveFutureData {
|
||||||
// If the new ready state is ReadyState::HaveFutureData or ReadyState::HaveEnoughData,
|
task_source.queue_simple_event(
|
||||||
// then the relevant steps below must then be run also.
|
self.upcast(),
|
||||||
match (old_ready_state, ready_state) {
|
atom!("canplay"),
|
||||||
// Previous ready state was ReadyState::HaveCurrentData or less,
|
&window,
|
||||||
// and the new ready state is ReadyState::HaveFutureData.
|
);
|
||||||
(ReadyState::HaveCurrentData, ReadyState::HaveFutureData) |
|
|
||||||
(ReadyState::HaveMetadata, ReadyState::HaveFutureData) |
|
|
||||||
(ReadyState::HaveNothing, ReadyState::HaveFutureData) => {
|
|
||||||
task_source.queue_simple_event(
|
|
||||||
self.upcast(),
|
|
||||||
atom!("canplay"),
|
|
||||||
&window,
|
|
||||||
);
|
|
||||||
|
|
||||||
if !self.Paused() {
|
if !self.Paused() {
|
||||||
self.notify_about_playing();
|
self.notify_about_playing();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New ready state is ReadyState::HaveEnoughData.
|
|
||||||
(_, ReadyState::HaveEnoughData) => {
|
|
||||||
if old_ready_state <= ReadyState::HaveCurrentData {
|
|
||||||
task_source.queue_simple_event(
|
|
||||||
self.upcast(),
|
|
||||||
atom!("canplay"),
|
|
||||||
&window,
|
|
||||||
);
|
|
||||||
|
|
||||||
if !self.Paused() {
|
|
||||||
self.notify_about_playing();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: check sandboxed automatic features browsing context flag
|
|
||||||
if self.autoplaying.get() &&
|
|
||||||
self.Paused() &&
|
|
||||||
self.Autoplay() {
|
|
||||||
// Step 1
|
|
||||||
self.paused.set(false);
|
|
||||||
// TODO step 2: show poster
|
|
||||||
// Step 3
|
|
||||||
task_source.queue_simple_event(
|
|
||||||
self.upcast(),
|
|
||||||
atom!("play"),
|
|
||||||
&window,
|
|
||||||
);
|
|
||||||
// Step 4
|
|
||||||
self.notify_about_playing();
|
|
||||||
// Step 5
|
|
||||||
self.autoplaying.set(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
task_source.queue_simple_event(
|
|
||||||
self.upcast(),
|
|
||||||
atom!("canplaythrough"),
|
|
||||||
&window,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Step 2: media controller
|
if ready_state == ReadyState::HaveEnoughData {
|
||||||
|
// TODO: Check sandboxed automatic features browsing context flag.
|
||||||
|
// FIXME(nox): I have no idea what this TODO is about.
|
||||||
|
|
||||||
|
// FIXME(nox): Review this block.
|
||||||
|
if self.autoplaying.get() &&
|
||||||
|
self.Paused() &&
|
||||||
|
self.Autoplay() {
|
||||||
|
// Step 1
|
||||||
|
self.paused.set(false);
|
||||||
|
// TODO step 2: show poster
|
||||||
|
// Step 3
|
||||||
|
task_source.queue_simple_event(
|
||||||
|
self.upcast(),
|
||||||
|
atom!("play"),
|
||||||
|
&window,
|
||||||
|
);
|
||||||
|
// Step 4
|
||||||
|
self.notify_about_playing();
|
||||||
|
// Step 5
|
||||||
|
self.autoplaying.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME(nox): According to the spec, this should come *before* the
|
||||||
|
// "play" event.
|
||||||
|
task_source.queue_simple_event(
|
||||||
|
self.upcast(),
|
||||||
|
atom!("canplaythrough"),
|
||||||
|
&window,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Step 2: Media controller.
|
||||||
|
// FIXME(nox): There is no step 2 in the spec.
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#concept-media-load-algorithm
|
// https://html.spec.whatwg.org/multipage/#concept-media-load-algorithm
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue