Bug 888104 - Move nsCxPusher's mScx grabbing code into the common helper method. r=gabor

This function is called by Push and PushNull, so with the added null check this
is equivalent. This facilitates the refactoring in the next patch.
This commit is contained in:
Bobby Holley 2013-07-02 14:39:02 -06:00
parent 37bbfefcec
commit 8536bd9ae6

View File

@ -106,17 +106,18 @@ nsCxPusher::Push(JSContext *cx)
MOZ_ASSERT(!mPushedSomething, "No double pushing with nsCxPusher::Push()!"); MOZ_ASSERT(!mPushedSomething, "No double pushing with nsCxPusher::Push()!");
MOZ_ASSERT(cx); MOZ_ASSERT(cx);
// Hold a strong ref to the nsIScriptContext, just in case
// XXXbz do we really need to? If we don't get one of these in Pop(), is
// that really a problem? Or do we need to do this to effectively root |cx|?
mScx = GetScriptContextFromJSContext(cx);
DoPush(cx); DoPush(cx);
} }
void void
nsCxPusher::DoPush(JSContext* cx) nsCxPusher::DoPush(JSContext* cx)
{ {
// If we have a cx, hold a strong ref to the nsIScriptContext, just in case.
// XXXbz do we really need to? If we don't get one of these in Pop(), is
// that really a problem? Or do we need to do this to effectively root |cx|?
if (cx)
mScx = GetScriptContextFromJSContext(cx);
// NB: The GetDynamicScriptContext is historical and might not be sane. // NB: The GetDynamicScriptContext is historical and might not be sane.
if (cx && nsJSUtils::GetDynamicScriptContext(cx) && if (cx && nsJSUtils::GetDynamicScriptContext(cx) &&
xpc::IsJSContextOnStack(cx)) xpc::IsJSContextOnStack(cx))