mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement step 6 of media element 'time marches on' algoritm
This commit is contained in:
parent
9223d6248d
commit
6c2c3f75b9
5 changed files with 19 additions and 8 deletions
|
@ -130,7 +130,7 @@ use style::values::specified::Length;
|
|||
use tendril::fmt::UTF8;
|
||||
use tendril::stream::LossyDecoder;
|
||||
use tendril::{StrTendril, TendrilSink};
|
||||
use time::Duration;
|
||||
use time::{Duration, Timespec};
|
||||
use uuid::Uuid;
|
||||
use webrender_api::{DocumentId, ImageKey, RenderApiSender};
|
||||
use webvr_traits::WebVRGamepadHand;
|
||||
|
@ -488,6 +488,7 @@ unsafe_no_jsmanaged_fields!(dyn Player<Error = ServoMediaError>);
|
|||
unsafe_no_jsmanaged_fields!(Mutex<MediaFrameRenderer>);
|
||||
unsafe_no_jsmanaged_fields!(RenderApiSender);
|
||||
unsafe_no_jsmanaged_fields!(ResourceFetchTiming);
|
||||
unsafe_no_jsmanaged_fields!(Timespec);
|
||||
|
||||
unsafe impl<'a> JSTraceable for &'a str {
|
||||
#[inline]
|
||||
|
|
|
@ -204,6 +204,9 @@ pub struct HTMLMediaElement {
|
|||
text_tracks_list: MutNullableDom<TextTrackList>,
|
||||
/// Expected content length of the media asset being fetched or played.
|
||||
content_length: Cell<Option<u64>>,
|
||||
/// Time of last timeupdate notification.
|
||||
#[ignore_malloc_size_of = "Defined in time"]
|
||||
next_timeupdate_event: Cell<Timespec>,
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate>
|
||||
|
@ -261,6 +264,7 @@ impl HTMLMediaElement {
|
|||
played: Rc::new(DomRefCell::new(TimeRangesContainer::new())),
|
||||
text_tracks_list: Default::default(),
|
||||
content_length: Cell::new(None),
|
||||
next_timeupdate_event: Cell::new(time::get_time() + Duration::milliseconds(250)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,7 +307,15 @@ impl HTMLMediaElement {
|
|||
|
||||
/// https://html.spec.whatwg.org/multipage/#time-marches-on
|
||||
fn time_marches_on(&self) {
|
||||
// TODO: implement this.
|
||||
// Step 6.
|
||||
if time::get_time() > self.next_timeupdate_event.get() {
|
||||
let window = window_from_node(self);
|
||||
window
|
||||
.task_manager()
|
||||
.media_element_task_source()
|
||||
.queue_simple_event(self.upcast(), atom!("timeupdate"), &window);
|
||||
self.next_timeupdate_event.set(time::get_time() + Duration::milliseconds(350));
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#internal-pause-steps>
|
||||
|
@ -1173,6 +1185,7 @@ impl HTMLMediaElement {
|
|||
.borrow_mut()
|
||||
.add(self.playback_position.get(), position);
|
||||
self.playback_position.set(position);
|
||||
self.time_marches_on();
|
||||
},
|
||||
PlayerEvent::StateChanged(ref state) => match *state {
|
||||
PlaybackState::Paused => {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
[autoplay-with-broken-track.html]
|
||||
expected: TIMEOUT
|
||||
[<video autoplay> with <track> child]
|
||||
expected: TIMEOUT
|
||||
expected:
|
||||
if debug and (os == "mac") and (version == "OS X 10.14.1") and (processor == "x86_64") and (bits == 64): PASS
|
||||
TIMEOUT
|
||||
|
||||
[<video autoplay> with <track src=\"invalid://url\" default=\"\"> child]
|
||||
expected: TIMEOUT
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
type: testharness
|
||||
disabled: Until https://github.com/servo/servo/pull/22477 is merged
|
||||
expected: TIMEOUT
|
||||
[setting src attribute on a sufficiently long autoplay audio should trigger timeupdate event]
|
||||
expected: NOTRUN
|
||||
|
||||
[setting src attribute on a sufficiently long autoplay video should trigger timeupdate event]
|
||||
expected: NOTRUN
|
||||
|
||||
|
|
|
@ -5,6 +5,4 @@
|
|||
[calling play() on a sufficiently long audio should trigger timeupdate event]
|
||||
expected: NOTRUN
|
||||
|
||||
[calling play() on a sufficiently long video should trigger timeupdate event]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue