зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1591655 - Remove the unnecessary |proto| argument from |JS::NewPromiseObject| and its callers, seeing as all callers pass |nullptr| (and therefore uniformly request the default prototype). r=jandem,bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D50695 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b0b2bb1db1
Коммит
3e64c882fe
|
@ -28,7 +28,7 @@ PlayPromise::~PlayPromise() {
|
|||
already_AddRefed<PlayPromise> PlayPromise::Create(nsIGlobalObject* aGlobal,
|
||||
ErrorResult& aRv) {
|
||||
RefPtr<PlayPromise> promise = new PlayPromise(aGlobal);
|
||||
promise->CreateWrapper(nullptr, aRv);
|
||||
promise->CreateWrapper(aRv);
|
||||
return aRv.Failed() ? nullptr : promise.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void DetailedPromise::MaybeReject(ErrorResult& aArg,
|
|||
already_AddRefed<DetailedPromise> DetailedPromise::Create(
|
||||
nsIGlobalObject* aGlobal, ErrorResult& aRv, const nsACString& aName) {
|
||||
RefPtr<DetailedPromise> promise = new DetailedPromise(aGlobal, aName);
|
||||
promise->CreateWrapper(nullptr, aRv);
|
||||
promise->CreateWrapper(aRv);
|
||||
return aRv.Failed() ? nullptr : promise.forget();
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ already_AddRefed<DetailedPromise> DetailedPromise::Create(
|
|||
Telemetry::HistogramID aFailureLatencyProbe) {
|
||||
RefPtr<DetailedPromise> promise = new DetailedPromise(
|
||||
aGlobal, aName, aSuccessLatencyProbe, aFailureLatencyProbe);
|
||||
promise->CreateWrapper(nullptr, aRv);
|
||||
promise->CreateWrapper(aRv);
|
||||
return aRv.Failed() ? nullptr : promise.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ already_AddRefed<Promise> Promise::Create(
|
|||
return nullptr;
|
||||
}
|
||||
RefPtr<Promise> p = new Promise(aGlobal);
|
||||
p->CreateWrapper(nullptr, aRv, aPropagateUserInteraction);
|
||||
p->CreateWrapper(aRv, aPropagateUserInteraction);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -273,15 +273,14 @@ Result<RefPtr<Promise>, nsresult> Promise::ThenWithoutCycleCollection(
|
|||
}
|
||||
|
||||
void Promise::CreateWrapper(
|
||||
JS::Handle<JSObject*> aDesiredProto, ErrorResult& aRv,
|
||||
PropagateUserInteraction aPropagateUserInteraction) {
|
||||
ErrorResult& aRv, PropagateUserInteraction aPropagateUserInteraction) {
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(mGlobal)) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
mPromiseObj = JS::NewPromiseObject(cx, nullptr, aDesiredProto);
|
||||
mPromiseObj = JS::NewPromiseObject(cx, nullptr);
|
||||
if (!mPromiseObj) {
|
||||
JS_ClearPendingException(cx);
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
|
|
@ -274,12 +274,11 @@ class Promise : public nsISupports, public SupportsWeakPtr<Promise> {
|
|||
|
||||
virtual ~Promise();
|
||||
|
||||
// Do JS-wrapping after Promise creation. Passing null for aDesiredProto will
|
||||
// use the default prototype for the sort of Promise we have.
|
||||
// Do JS-wrapping after Promise creation.
|
||||
// Pass ePropagateUserInteraction for aPropagateUserInteraction if you want
|
||||
// the promise resolve handler to be called as if we were handling user
|
||||
// input events in case we are currently handling user input events.
|
||||
void CreateWrapper(JS::Handle<JSObject*> aDesiredProto, ErrorResult& aRv,
|
||||
void CreateWrapper(ErrorResult& aRv,
|
||||
PropagateUserInteraction aPropagateUserInteraction =
|
||||
eDontPropagateUserInteraction);
|
||||
|
||||
|
|
|
@ -305,12 +305,9 @@ extern JS_PUBLIC_API void JobQueueMayNotBeEmpty(JSContext* cx);
|
|||
* The `executor` can be a `nullptr`. In that case, the only way to resolve or
|
||||
* reject the returned promise is via the `JS::ResolvePromise` and
|
||||
* `JS::RejectPromise` JSAPI functions.
|
||||
*
|
||||
* If a `proto` is passed, that gets set as the instance's [[Prototype]]
|
||||
* instead of the original value of `Promise.prototype`.
|
||||
*/
|
||||
extern JS_PUBLIC_API JSObject* NewPromiseObject(
|
||||
JSContext* cx, JS::HandleObject executor, JS::HandleObject proto = nullptr);
|
||||
extern JS_PUBLIC_API JSObject* NewPromiseObject(JSContext* cx,
|
||||
JS::HandleObject executor);
|
||||
|
||||
/**
|
||||
* Returns true if the given object is an unwrapped PromiseObject, false
|
||||
|
|
|
@ -3839,19 +3839,19 @@ extern JS_PUBLIC_API void JS::JobQueueMayNotBeEmpty(JSContext* cx) {
|
|||
cx->canSkipEnqueuingJobs = false;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::NewPromiseObject(
|
||||
JSContext* cx, HandleObject executor, HandleObject proto /* = nullptr */) {
|
||||
JS_PUBLIC_API JSObject* JS::NewPromiseObject(JSContext* cx,
|
||||
HandleObject executor) {
|
||||
MOZ_ASSERT(!cx->zone()->isAtomsZone());
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
cx->check(executor, proto);
|
||||
cx->check(executor);
|
||||
|
||||
if (!executor) {
|
||||
return PromiseObject::createSkippingExecutor(cx);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(IsCallable(executor));
|
||||
return PromiseObject::create(cx, executor, proto);
|
||||
return PromiseObject::create(cx, executor);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::IsPromiseObject(JS::HandleObject obj) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче