diff options
author | marmeladema <xademax@gmail.com> | 2019-07-27 17:45:17 +0100 |
---|---|---|
committer | marmeladema <xademax@gmail.com> | 2019-08-09 00:02:10 +0100 |
commit | 6d444afd9e3ff4bdfb8a814ecee1d6d39f283439 (patch) | |
tree | b535b4f9e05526f5042b89cadcf9c7e6d7350c01 /components/script/script_thread.rs | |
parent | b18fa8b8a78a32eb578bb53e7a48de8d371702a1 (diff) | |
download | servo-6d444afd9e3ff4bdfb8a814ecee1d6d39f283439.tar.gz servo-6d444afd9e3ff4bdfb8a814ecee1d6d39f283439.zip |
Use safe JSContext in MicrotaskQueue
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index da5d8f2e7aa..06442d3042a 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -910,16 +910,13 @@ impl ScriptThread { } // https://html.spec.whatwg.org/multipage/#await-a-stable-state - #[allow(unsafe_code)] pub fn await_stable_state(task: Microtask) { SCRIPT_THREAD_ROOT.with(|root| { if let Some(script_thread) = root.get() { - unsafe { - let script_thread = &*script_thread; - script_thread - .microtask_queue - .enqueue(task, *script_thread.get_cx()); - } + let script_thread = unsafe { &*script_thread }; + script_thread + .microtask_queue + .enqueue(task, script_thread.get_cx()); } }); } @@ -3776,17 +3773,15 @@ impl ScriptThread { } } - #[allow(unsafe_code)] pub fn enqueue_microtask(job: Microtask) { - SCRIPT_THREAD_ROOT.with(|root| unsafe { - let script_thread = &*root.get().unwrap(); + SCRIPT_THREAD_ROOT.with(|root| { + let script_thread = unsafe { &*root.get().unwrap() }; script_thread .microtask_queue - .enqueue(job, *script_thread.get_cx()); + .enqueue(job, script_thread.get_cx()); }); } - #[allow(unsafe_code)] fn perform_a_microtask_checkpoint(&self) { let globals = self .documents @@ -3795,13 +3790,11 @@ impl ScriptThread { .map(|(_id, document)| document.global()) .collect(); - unsafe { - self.microtask_queue.checkpoint( - *self.get_cx(), - |id| self.documents.borrow().find_global(id), - globals, - ) - } + self.microtask_queue.checkpoint( + self.get_cx(), + |id| self.documents.borrow().find_global(id), + globals, + ) } } |