Bug 834732 - Remove PushBehavior. r=mrbkap

Now that we only have ALWAYS_PUSH and ASSERT_SCRIPT_CONTEXT, we have uniform
release-mode behavior everywhere. Remove the crap.
This commit is contained in:
Bobby Holley 2013-02-26 11:04:11 -08:00
parent 99fefbe87b
commit 784a476fb8
14 changed files with 18 additions and 24 deletions

View File

@ -2195,7 +2195,6 @@ typedef nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>
class NS_STACK_CLASS nsCxPusher
{
public:
enum PushBehavior { ALWAYS_PUSH, REQUIRE_SCRIPT_CONTEXT, ASSERT_SCRIPT_CONTEXT };
nsCxPusher();
~nsCxPusher(); // Calls Pop();
@ -2206,7 +2205,7 @@ public:
bool RePush(nsIDOMEventTarget *aCurrentTarget);
// If a null JSContext is passed to Push(), that will cause no
// push to happen and false to be returned.
bool Push(JSContext *cx, PushBehavior behavior);
bool Push(JSContext *cx);
// Explicitly push a null JSContext on the the stack
bool PushNull();

View File

@ -3021,7 +3021,7 @@ nsCxPusher::Push(nsIDOMEventTarget *aCurrentTarget)
// in the process or being torn down. We don't want to notify the
// script context about scripts having been evaluated in such a
// case, calling with a null cx is fine in that case.
return Push(cx, ASSERT_SCRIPT_CONTEXT);
return Push(cx);
}
bool
@ -3053,7 +3053,7 @@ nsCxPusher::RePush(nsIDOMEventTarget *aCurrentTarget)
}
bool
nsCxPusher::Push(JSContext *cx, PushBehavior behavior)
nsCxPusher::Push(JSContext *cx)
{
if (mPushedSomething) {
NS_ERROR("Whaaa! No double pushing with nsCxPusher::Push()!");
@ -3069,11 +3069,6 @@ nsCxPusher::Push(JSContext *cx, PushBehavior behavior)
// 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);
MOZ_ASSERT_IF(behavior == ASSERT_SCRIPT_CONTEXT, mScx);
if (!mScx && behavior == REQUIRE_SCRIPT_CONTEXT) {
// Should probably return false. See bug 416916.
return true;
}
return DoPush(cx);
}
@ -6833,7 +6828,7 @@ AutoJSContext::Init(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
if (!mCx) {
mCx = nsContentUtils::GetSafeJSContext();
bool result = mPusher.Push(mCx, nsCxPusher::ALWAYS_PUSH);
bool result = mPusher.Push(mCx);
if (!result || !mCx) {
MOZ_CRASH();
}

View File

@ -651,7 +651,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
continue;
}
nsCxPusher pusher;
NS_ENSURE_STATE(pusher.Push(ctx, nsCxPusher::ALWAYS_PUSH));
NS_ENSURE_STATE(pusher.Push(ctx));
JSAutoRequest ar(ctx);
JSAutoCompartment ac(ctx, object);

View File

@ -2571,7 +2571,7 @@ nsObjectLoadingContent::NotifyContentObjectWrapper()
JSContext *cx = scx->GetNativeContext();
nsCxPusher pusher;
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
pusher.Push(cx);
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsContentUtils::XPConnect()->

View File

@ -818,7 +818,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
}
nsCxPusher pusher;
if (aNeedsCxPush && !pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) {
if (aNeedsCxPush && !pusher.Push(cx)) {
return NS_ERROR_FAILURE;
}

View File

@ -943,7 +943,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
JSContext *cx = context->GetNativeContext();
nsCxPusher pusher;
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
pusher.Push(cx);
JSObject* scriptObject = mBoundElement->GetWrapper();
if (scriptObject) {

View File

@ -10202,7 +10202,7 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
nsCxPusher pusher;
if (!cx) {
cx = nsContentUtils::GetContextFromDocument(document);
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
pusher.Push(cx);
}
rv = scContainer->InitFromVariant(aData, cx);

View File

@ -4082,7 +4082,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
}
nsCxPusher pusher;
NS_ENSURE_STATE(pusher.Push(cx, nsCxPusher::ALWAYS_PUSH));
NS_ENSURE_STATE(pusher.Push(cx));
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, object);
@ -7776,7 +7776,7 @@ public:
nsCxPusher pusher;
JSContext* cx = mContext ? mContext->GetNativeContext()
: nsContentUtils::GetSafeJSContext();
pusher.Push(cx, nsCxPusher::ALWAYS_PUSH);
pusher.Push(cx);
JSObject* obj = nullptr;
mWrapper->GetJSObject(&obj);

View File

@ -2077,7 +2077,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
bool thisChrome = IsChromeWindow();
nsCxPusher cxPusher;
if (!cxPusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) {
if (!cxPusher.Push(cx)) {
return NS_ERROR_FAILURE;
}

View File

@ -1260,7 +1260,7 @@ nsJSContext::EvaluateString(const nsAString& aScript,
}
nsCxPusher pusher;
if (!pusher.Push(mContext, nsCxPusher::ASSERT_SCRIPT_CONTEXT))
if (!pusher.Push(mContext))
return NS_ERROR_FAILURE;
xpc_UnmarkGrayObject(&aScopeObject);
@ -1515,7 +1515,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope,
// all now, and never were in some cases.
nsCxPusher pusher;
if (!pusher.Push(mContext, nsCxPusher::ASSERT_SCRIPT_CONTEXT))
if (!pusher.Push(mContext))
return NS_ERROR_FAILURE;
// check if the event handler can be run on the object in question

View File

@ -91,7 +91,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback,
mAr.construct(cx);
// Make sure our JSContext is pushed on the stack.
if (!mCxPusher.Push(cx, nsCxPusher::ALWAYS_PUSH)) {
if (!mCxPusher.Push(cx)) {
return;
}

View File

@ -523,7 +523,7 @@ SmsRequest::NotifyThreadList(const InfallibleTArray<ThreadListItem>& aItems)
NS_ENSURE_TRUE_VOID(ownerObj);
nsCxPusher pusher;
NS_ENSURE_TRUE_VOID(pusher.Push(cx, nsCxPusher::ALWAYS_PUSH));
NS_ENSURE_TRUE_VOID(pusher.Push(cx));
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, ownerObj);

View File

@ -42,7 +42,7 @@ namespace {
JSOPTION_DONT_REPORT_UNCAUGHT)))
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
mStack.Push(cx, nsCxPusher::ALWAYS_PUSH);
mStack.Push(cx);
}
~AutoContextPusher() {

View File

@ -406,7 +406,7 @@ def write_cpp(iface, fd):
" }\n\n"
" JSObject* obj = &aVal->toObject();\n"
" nsCxPusher pusher;\n"
" NS_ENSURE_STATE(pusher.Push(aCx, nsCxPusher::ALWAYS_PUSH));\n"
" NS_ENSURE_STATE(pusher.Push(aCx));\n"
" JSAutoRequest ar(aCx);\n"
" JSAutoCompartment ac(aCx, obj);\n")