diff options
author | Aron Zwaan <aronzwaan@gmail.com> | 2019-04-24 22:33:16 +0200 |
---|---|---|
committer | Aron Zwaan <aronzwaan@gmail.com> | 2019-04-25 11:37:35 +0200 |
commit | e2e6e2ac9428b9448edb06f7f11b201ce68e7191 (patch) | |
tree | 1ad0b3a8647d2946bf9a0b5ff427f1d8c1e6cf29 /components/script/dom/promise.rs | |
parent | 1b6949d4cf951600efa6db6747b65e2db42a96cd (diff) | |
download | servo-e2e6e2ac9428b9448edb06f7f11b201ce68e7191.tar.gz servo-e2e6e2ac9428b9448edb06f7f11b201ce68e7191.zip |
Pass InCompartment by value
Diffstat (limited to 'components/script/dom/promise.rs')
-rw-r--r-- | components/script/dom/promise.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 52e6dfab56a..b4e3109e789 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -11,7 +11,7 @@ //! native Promise values that refer to the same JS value yet are distinct native objects //! (ie. address equality for the native objects is meaningless). -use crate::compartments::InCompartment; +use crate::compartments::{AlreadyInCompartment, InCompartment}; use crate::dom::bindings::conversions::root_from_object; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; @@ -80,12 +80,13 @@ impl Drop for Promise { } impl Promise { - pub fn new(global: &GlobalScope, comp: &InCompartment) -> Rc<Promise> { - Promise::new_in_current_compartment(global, comp) + pub fn new(global: &GlobalScope) -> Rc<Promise> { + let comp = AlreadyInCompartment::assert(&global); + Promise::new_in_current_compartment(global, InCompartment::Already(&comp)) } #[allow(unsafe_code)] - pub fn new_in_current_compartment(global: &GlobalScope, _comp: &InCompartment) -> Rc<Promise> { + pub fn new_in_current_compartment(global: &GlobalScope, _comp: InCompartment) -> Rc<Promise> { let cx = global.get_cx(); rooted!(in(cx) let mut obj = ptr::null_mut::<JSObject>()); unsafe { |