Auto merge of #18600 - servo:promises, r=<try>

Improve Promise

The elephant 🐘 (not PHP's) still remains in the room: `Rc<Promise>` shouldn't require `#⁠[allow(unrooted_must_root)]`.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18600)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-22 07:36:38 -05:00 committed by GitHub
commit 4af0d9acb3
22 changed files with 184 additions and 245 deletions

View file

@ -788,7 +788,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
$*{exceptionCode}
}
match Promise::Resolve(&promiseGlobal, cx, valueToResolve.handle()) {
match Promise::new_resolved(&promiseGlobal, cx, valueToResolve.handle()) {
Ok(value) => value,
Err(error) => {
throw_dom_exception(cx, &promiseGlobal, error);

View file

@ -29,7 +29,6 @@ use dom::bindings::js::Root;
use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::trace::trace_reflector;
use dom::promise::Promise;
use js::jsapi::JSAutoCompartment;
use js::jsapi::JSTracer;
use libc;
use std::cell::RefCell;
@ -126,10 +125,7 @@ impl TrustedPromise {
let this = self;
task!(reject_promise: move || {
debug!("Rejecting promise.");
let this = this.root();
let cx = this.global().get_cx();
let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get());
this.reject_error(cx, error);
this.root().reject_error(error);
})
}
@ -142,10 +138,7 @@ impl TrustedPromise {
let this = self;
task!(resolve_promise: move || {
debug!("Resolving promise.");
let this = this.root();
let cx = this.global().get_cx();
let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get());
this.resolve_native(cx, &value);
this.root().resolve_native(&value);
})
}
}