diff options
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 50 |
1 files changed, 2 insertions, 48 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 87e7a5ffc1c..d45556cad56 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -60,7 +60,7 @@ use script_traits::{ PortMessageTask, ScriptMsg, ScriptToConstellationChan, }; use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; -use timers::{BoxedTimerCallback, TimerEvent, TimerEventId, TimerEventRequest, TimerSource}; +use timers::{TimerEventId, TimerEventRequest, TimerSource}; use uuid::Uuid; #[cfg(feature = "webgpu")] use webgpu::{DeviceLostReason, WebGPUDevice}; @@ -386,13 +386,6 @@ struct BroadcastListener { context: Trusted<GlobalScope>, } -/// A wrapper between timer events coming in over IPC, and the event-loop. -#[derive(Clone)] -pub(crate) struct TimerListener { - task_source: TaskSource, - context: Trusted<GlobalScope>, -} - type FileListenerCallback = Box<dyn Fn(Rc<Promise>, Fallible<Vec<u8>>) + Send>; /// A wrapper for the handling of file data received by the ipc router @@ -525,37 +518,6 @@ impl BroadcastListener { } } -impl TimerListener { - /// Handle a timer-event coming from the [`timers::TimerScheduler`] - /// by queuing the appropriate task on the relevant event-loop. - fn handle(&self, event: TimerEvent) { - let context = self.context.clone(); - // Step 18, queue a task, - // https://html.spec.whatwg.org/multipage/#timer-initialisation-steps - let _ = self.task_source.queue( - task!(timer_event: move || { - let global = context.root(); - let TimerEvent(source, id) = event; - match source { - TimerSource::FromWorker => { - global.downcast::<WorkerGlobalScope>().expect("Window timer delivered to worker"); - }, - TimerSource::FromWindow(pipeline) => { - assert_eq!(pipeline, global.pipeline_id()); - global.downcast::<Window>().expect("Worker timer delivered to window"); - }, - }; - // Step 7, substeps run in a task. - global.fire_timer(id, CanGc::note()); - }) - ); - } - - pub fn into_callback(self) -> BoxedTimerCallback { - Box::new(move |timer_event| self.handle(timer_event)) - } -} - impl MessageListener { /// A new message came in, handle it via a task enqueued on the event-loop. /// A task is required, since we are using a trusted globalscope, @@ -825,15 +787,7 @@ impl GlobalScope { } fn timers(&self) -> &OneshotTimers { - self.timers.get_or_init(|| { - OneshotTimers::new( - self, - TimerListener { - context: Trusted::new(self), - task_source: self.task_manager().timer_task_source(), - }, - ) - }) + self.timers.get_or_init(|| OneshotTimers::new(self)) } /// <https://w3c.github.io/ServiceWorker/#get-the-service-worker-registration-object> |