mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add proof parameter to Promise::new_in_current_compartment
This commit is contained in:
parent
7b293ee8cb
commit
1b6949d4cf
25 changed files with 263 additions and 95 deletions
|
@ -11,6 +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::dom::bindings::conversions::root_from_object;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
|
||||
|
@ -79,17 +80,18 @@ impl Drop for Promise {
|
|||
}
|
||||
|
||||
impl Promise {
|
||||
#[allow(unsafe_code)]
|
||||
pub fn new(global: &GlobalScope, _comp: &JSAutoCompartment) -> Rc<Promise> {
|
||||
unsafe { Promise::new_in_current_compartment(global) }
|
||||
pub fn new(global: &GlobalScope, comp: &InCompartment) -> Rc<Promise> {
|
||||
Promise::new_in_current_compartment(global, comp)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn new_in_current_compartment(global: &GlobalScope) -> 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>());
|
||||
Promise::create_js_promise(cx, HandleObject::null(), obj.handle_mut());
|
||||
Promise::new_with_js_promise(obj.handle(), cx)
|
||||
unsafe {
|
||||
Promise::create_js_promise(cx, HandleObject::null(), obj.handle_mut());
|
||||
Promise::new_with_js_promise(obj.handle(), cx)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue