From 8e78f18d2d282e651c5a8a20b2fe28cb015b264a Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 17 Sep 2017 10:46:00 +0200 Subject: Introduce MainThreadScriptMsg::DispatchJobQueue This removes the last remaining use of Task::run_with_script_thread --- components/script/script_thread.rs | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 2f7698ff960..21989316864 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -244,12 +244,6 @@ impl Task for CancellableTask where T: Send + Task, { - fn run_with_script_thread(self: Box>, script_thread: &ScriptThread) { - if !self.is_cancelled() { - self.inner.run_with_script_thread(script_thread); - } - } - fn run(self: Box) { if !self.is_cancelled() { self.inner.run() @@ -259,12 +253,7 @@ where pub trait Task { fn name(&self) -> &'static str { unsafe { intrinsics::type_name::() } } - fn run(self: Box) { - panic!("This should probably be redefined.") - } - fn run_with_script_thread(self: Box, _script_thread: &ScriptThread) { - self.run(); - } + fn run(self: Box); } impl fmt::Debug for Task + Send { @@ -304,8 +293,8 @@ pub enum MainThreadScriptMsg { properties: Vec, painter: Box }, - /// Runs a Task in the main thread. - MainThreadTask(ScriptThreadEventCategory, Box), + /// Dispatches a job queue. + DispatchJobQueue { scope_url: ServoUrl }, } impl OpaqueSender for Box { @@ -718,11 +707,11 @@ impl ScriptThread { } #[allow(unrooted_must_root)] - pub fn schedule_job(job: Job, global: &GlobalScope) { + pub fn schedule_job(job: Job) { SCRIPT_THREAD_ROOT.with(|root| { let script_thread = unsafe { &*root.get().unwrap() }; let job_queue = &*script_thread.job_queue_map; - job_queue.schedule_job(job, global, &script_thread); + job_queue.schedule_job(job, &script_thread); }); } @@ -1192,8 +1181,9 @@ impl ScriptThread { MixedMessage::FromImageCache(_) => ScriptThreadEventCategory::ImageCacheMsg, MixedMessage::FromScript(ref inner_msg) => { match *inner_msg { - MainThreadScriptMsg::Common(CommonScriptMsg::Task(category, _)) | - MainThreadScriptMsg::MainThreadTask(category, _) => category, + MainThreadScriptMsg::Common(CommonScriptMsg::Task(category, _)) => { + category + }, MainThreadScriptMsg::RegisterPaintWorklet { .. } => { ScriptThreadEventCategory::WorkletEvent }, @@ -1348,9 +1338,9 @@ impl ScriptThread { painter, ) }, - MainThreadScriptMsg::MainThreadTask(_, task) => { - task.run_with_script_thread(self) - }, + MainThreadScriptMsg::DispatchJobQueue { scope_url } => { + self.job_queue_map.run_job(scope_url, self) + } } } @@ -1787,8 +1777,8 @@ impl ScriptThread { let _ = self.script_sender.send((pipeline_id, ScriptMsg::RegisterServiceWorker(scope_things, scope.clone()))); } - pub fn dispatch_job_queue(&self, scope_url: ServoUrl) { - self.job_queue_map.run_job(scope_url, self); + pub fn schedule_job_queue(&self, scope_url: ServoUrl) { + let _ = self.chan.0.send(MainThreadScriptMsg::DispatchJobQueue { scope_url }); } pub fn dom_manipulation_task_source(&self) -> &DOMManipulationTaskSource { -- cgit v1.2.3