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/microtask.rs | |
parent | b18fa8b8a78a32eb578bb53e7a48de8d371702a1 (diff) | |
download | servo-6d444afd9e3ff4bdfb8a814ecee1d6d39f283439.tar.gz servo-6d444afd9e3ff4bdfb8a814ecee1d6d39f283439.zip |
Use safe JSContext in MicrotaskQueue
Diffstat (limited to 'components/script/microtask.rs')
-rw-r--r-- | components/script/microtask.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/components/script/microtask.rs b/components/script/microtask.rs index db420e20eaa..001262c05e1 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -14,9 +14,9 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::htmlimageelement::ImageElementMicrotask; use crate::dom::htmlmediaelement::MediaElementMicrotask; use crate::dom::mutationobserver::MutationObserver; -use crate::script_runtime::notify_about_rejected_promises; +use crate::script_runtime::{notify_about_rejected_promises, JSContext}; use crate::script_thread::ScriptThread; -use js::jsapi::{JSContext, JobQueueIsEmpty, JobQueueMayNotBeEmpty}; +use js::jsapi::{JobQueueIsEmpty, JobQueueMayNotBeEmpty}; use msg::constellation_msg::PipelineId; use std::cell::Cell; use std::mem; @@ -56,17 +56,17 @@ impl MicrotaskQueue { /// Add a new microtask to this queue. It will be invoked as part of the next /// microtask checkpoint. #[allow(unsafe_code)] - pub unsafe fn enqueue(&self, job: Microtask, cx: *mut JSContext) { + pub fn enqueue(&self, job: Microtask, cx: JSContext) { self.microtask_queue.borrow_mut().push(job); - JobQueueMayNotBeEmpty(cx); + unsafe { JobQueueMayNotBeEmpty(*cx) }; } /// <https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint> /// Perform a microtask checkpoint, executing all queued microtasks until the queue is empty. #[allow(unsafe_code)] - pub unsafe fn checkpoint<F>( + pub fn checkpoint<F>( &self, - cx: *mut JSContext, + cx: JSContext, target_provider: F, globalscopes: Vec<DomRoot<GlobalScope>>, ) where @@ -86,7 +86,7 @@ impl MicrotaskQueue { for (idx, job) in pending_queue.iter().enumerate() { if idx == pending_queue.len() - 1 && self.microtask_queue.borrow().is_empty() { - JobQueueIsEmpty(cx); + unsafe { JobQueueIsEmpty(*cx) }; } match *job { |