Bug 1260417 - Part c: Stop mentioning requests around CallSetup::mRootedCallable; r=bz
Rooted used to only work when the JSContext was in a request. This has long
been rectified, so the comments referring to that constraint are confusing at
best.
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -130,22 +130,19 @@ CallbackObject::CallSetup::CallSetup(Cal
mAutoIncumbentScript.emplace(incumbent);
}
cx = mAutoEntryScript->cx();
// Unmark the callable (by invoking Callback() and not the CallbackPreserveColor()
// variant), and stick it in a Rooted before it can go gray again.
// Nothing before us in this function can trigger a CC, so it's safe to wait
- // until here it do the unmark. This allows us to order the following two
- // operations _after_ the Push() above, which lets us take advantage of the
- // JSAutoRequest embedded in the pusher.
- //
- // We can do this even though we're not in the right compartment yet, because
- // Rooted<> does not care about compartments.
+ // until here it do the unmark. This allows us to construct mRootedCallable
+ // with the cx from mAutoEntryScript, avoiding the cost of finding another
+ // JSContext. (Rooted<> does not care about requests or compartments.)
mRootedCallable.emplace(cx, aCallback->Callback());
}
// JS-implemented WebIDL is always OK to run, since it runs with Chrome
// privileges anyway.
if (mIsMainThread && !aIsJSImplementedWebIDL) {
// Check that it's ok to run this callback at all.
// Make sure to use realCallback to get the global of the callback object,
--- a/dom/bindings/CallbackObject.h
+++ b/dom/bindings/CallbackObject.h
@@ -250,18 +250,16 @@ protected:
// Caller's compartment. This will only have a sensible value if
// mExceptionHandling == eRethrowContentExceptions or eRethrowExceptions.
JSCompartment* mCompartment;
// And now members whose construction/destruction order we need to control.
Maybe<AutoEntryScript> mAutoEntryScript;
Maybe<AutoIncumbentScript> mAutoIncumbentScript;
- // Constructed the rooter within the scope of mCxPusher above, so that it's
- // always within a request during its lifetime.
Maybe<JS::Rooted<JSObject*> > mRootedCallable;
// Members which are used to set the async stack.
Maybe<JS::Rooted<JSObject*>> mAsyncStack;
Maybe<JS::AutoSetAsyncStackForNewCalls> mAsyncStackSetter;
// Can't construct a JSAutoCompartment without a JSContext either. Also,
// Put mAc after mAutoEntryScript so that we exit the compartment before