diff options
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r-- | components/script/dom/htmlmediaelement.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 824aadd1ee2..2d89abaa7b7 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -6,6 +6,7 @@ use std::cell::Cell; use std::collections::VecDeque; use std::rc::Rc; use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; use std::{f64, mem}; use dom_struct::dom_struct; @@ -33,7 +34,6 @@ use servo_media::player::video::{VideoFrame, VideoFrameRenderer}; use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, SeekLock, StreamType}; use servo_media::{ClientContextId, ServoMedia, SupportsMediaType}; use servo_url::ServoUrl; -use time::{self, Duration, Timespec}; use webrender_api::{ ExternalImageData, ExternalImageId, ExternalImageType, ImageBufferKind, ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey, @@ -377,9 +377,8 @@ pub struct HTMLMediaElement { /// https://html.spec.whatwg.org/multipage/#dom-media-texttracks text_tracks_list: MutNullableDom<TextTrackList>, /// Time of last timeupdate notification. - #[ignore_malloc_size_of = "Defined in time"] - #[no_trace] - next_timeupdate_event: Cell<Timespec>, + #[ignore_malloc_size_of = "Defined in std::time"] + next_timeupdate_event: Cell<Instant>, /// Latest fetch request context. current_fetch_context: DomRefCell<Option<HTMLMediaElementFetchContext>>, /// Player Id reported the player thread @@ -452,7 +451,7 @@ impl HTMLMediaElement { audio_tracks_list: Default::default(), video_tracks_list: Default::default(), text_tracks_list: Default::default(), - next_timeupdate_event: Cell::new(time::get_time() + Duration::milliseconds(250)), + next_timeupdate_event: Cell::new(Instant::now() + Duration::from_millis(250)), current_fetch_context: DomRefCell::new(None), id: Cell::new(0), media_controls_id: DomRefCell::new(None), @@ -502,14 +501,14 @@ impl HTMLMediaElement { /// https://html.spec.whatwg.org/multipage/#time-marches-on fn time_marches_on(&self) { // Step 6. - if time::get_time() > self.next_timeupdate_event.get() { + if Instant::now() > 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)); + .set(Instant::now() + Duration::from_millis(350)); } } @@ -2602,7 +2601,7 @@ struct HTMLMediaElementFetchListener { /// The generation of the media element when this fetch started. generation_id: u32, /// Time of last progress notification. - next_progress_event: Timespec, + next_progress_event: Instant, /// Timing data for this resource. resource_timing: ResourceFetchTiming, /// Url for the resource. @@ -2751,13 +2750,13 @@ impl FetchResponseListener for HTMLMediaElementFetchListener { // https://html.spec.whatwg.org/multipage/#concept-media-load-resource step 4, // => "If mode is remote" step 2 - if time::get_time() > self.next_progress_event { + if Instant::now() > self.next_progress_event { let window = window_from_node(&*elem); window .task_manager() .media_element_task_source() .queue_simple_event(elem.upcast(), atom!("progress"), &window); - self.next_progress_event = time::get_time() + Duration::milliseconds(350); + self.next_progress_event = Instant::now() + Duration::from_millis(350); } } @@ -2886,7 +2885,7 @@ impl HTMLMediaElementFetchListener { elem: Trusted::new(elem), metadata: None, generation_id: elem.generation_id.get(), - next_progress_event: time::get_time() + Duration::milliseconds(350), + next_progress_event: Instant::now() + Duration::from_millis(350), resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource), url, expected_content_length: None, |