зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
383f32fa9f
Коммит
8a446dd113
|
@ -2195,7 +2195,6 @@ typedef nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>
|
||||||
class NS_STACK_CLASS nsCxPusher
|
class NS_STACK_CLASS nsCxPusher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum PushBehavior { ALWAYS_PUSH, REQUIRE_SCRIPT_CONTEXT, ASSERT_SCRIPT_CONTEXT };
|
|
||||||
nsCxPusher();
|
nsCxPusher();
|
||||||
~nsCxPusher(); // Calls Pop();
|
~nsCxPusher(); // Calls Pop();
|
||||||
|
|
||||||
|
@ -2206,7 +2205,7 @@ public:
|
||||||
bool RePush(nsIDOMEventTarget *aCurrentTarget);
|
bool RePush(nsIDOMEventTarget *aCurrentTarget);
|
||||||
// If a null JSContext is passed to Push(), that will cause no
|
// If a null JSContext is passed to Push(), that will cause no
|
||||||
// push to happen and false to be returned.
|
// 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
|
// Explicitly push a null JSContext on the the stack
|
||||||
bool PushNull();
|
bool PushNull();
|
||||||
|
|
||||||
|
|
|
@ -3021,7 +3021,7 @@ nsCxPusher::Push(nsIDOMEventTarget *aCurrentTarget)
|
||||||
// in the process or being torn down. We don't want to notify the
|
// in the process or being torn down. We don't want to notify the
|
||||||
// script context about scripts having been evaluated in such a
|
// script context about scripts having been evaluated in such a
|
||||||
// case, calling with a null cx is fine in that case.
|
// case, calling with a null cx is fine in that case.
|
||||||
return Push(cx, ASSERT_SCRIPT_CONTEXT);
|
return Push(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -3053,7 +3053,7 @@ nsCxPusher::RePush(nsIDOMEventTarget *aCurrentTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsCxPusher::Push(JSContext *cx, PushBehavior behavior)
|
nsCxPusher::Push(JSContext *cx)
|
||||||
{
|
{
|
||||||
if (mPushedSomething) {
|
if (mPushedSomething) {
|
||||||
NS_ERROR("Whaaa! No double pushing with nsCxPusher::Push()!");
|
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
|
// 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|?
|
// that really a problem? Or do we need to do this to effectively root |cx|?
|
||||||
mScx = GetScriptContextFromJSContext(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);
|
return DoPush(cx);
|
||||||
}
|
}
|
||||||
|
@ -6855,7 +6850,7 @@ AutoJSContext::Init(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||||
|
|
||||||
if (!mCx) {
|
if (!mCx) {
|
||||||
mCx = nsContentUtils::GetSafeJSContext();
|
mCx = nsContentUtils::GetSafeJSContext();
|
||||||
bool result = mPusher.Push(mCx, nsCxPusher::ALWAYS_PUSH);
|
bool result = mPusher.Push(mCx);
|
||||||
if (!result || !mCx) {
|
if (!result || !mCx) {
|
||||||
MOZ_CRASH();
|
MOZ_CRASH();
|
||||||
}
|
}
|
||||||
|
|
|
@ -651,7 +651,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
NS_ENSURE_STATE(pusher.Push(ctx, nsCxPusher::ALWAYS_PUSH));
|
NS_ENSURE_STATE(pusher.Push(ctx));
|
||||||
|
|
||||||
JSAutoRequest ar(ctx);
|
JSAutoRequest ar(ctx);
|
||||||
JSAutoCompartment ac(ctx, object);
|
JSAutoCompartment ac(ctx, object);
|
||||||
|
|
|
@ -2577,7 +2577,7 @@ nsObjectLoadingContent::NotifyContentObjectWrapper()
|
||||||
|
|
||||||
JSContext *cx = scx->GetNativeContext();
|
JSContext *cx = scx->GetNativeContext();
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
|
pusher.Push(cx);
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||||
nsContentUtils::XPConnect()->
|
nsContentUtils::XPConnect()->
|
||||||
|
|
|
@ -818,7 +818,7 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
if (aNeedsCxPush && !pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) {
|
if (aNeedsCxPush && !pusher.Push(cx)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -943,7 +943,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
|
||||||
JSContext *cx = context->GetNativeContext();
|
JSContext *cx = context->GetNativeContext();
|
||||||
|
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
|
pusher.Push(cx);
|
||||||
|
|
||||||
JSObject* scriptObject = mBoundElement->GetWrapper();
|
JSObject* scriptObject = mBoundElement->GetWrapper();
|
||||||
if (scriptObject) {
|
if (scriptObject) {
|
||||||
|
|
|
@ -10206,7 +10206,7 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
if (!cx) {
|
if (!cx) {
|
||||||
cx = nsContentUtils::GetContextFromDocument(document);
|
cx = nsContentUtils::GetContextFromDocument(document);
|
||||||
pusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT);
|
pusher.Push(cx);
|
||||||
}
|
}
|
||||||
rv = scContainer->InitFromVariant(aData, cx);
|
rv = scContainer->InitFromVariant(aData, cx);
|
||||||
|
|
||||||
|
|
|
@ -4765,7 +4765,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
NS_ENSURE_STATE(pusher.Push(cx, nsCxPusher::ALWAYS_PUSH));
|
NS_ENSURE_STATE(pusher.Push(cx));
|
||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
JSAutoCompartment ac(cx, object);
|
JSAutoCompartment ac(cx, object);
|
||||||
|
@ -8513,7 +8513,7 @@ public:
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
JSContext* cx = mContext ? mContext->GetNativeContext()
|
JSContext* cx = mContext ? mContext->GetNativeContext()
|
||||||
: nsContentUtils::GetSafeJSContext();
|
: nsContentUtils::GetSafeJSContext();
|
||||||
pusher.Push(cx, nsCxPusher::ALWAYS_PUSH);
|
pusher.Push(cx);
|
||||||
|
|
||||||
JSObject* obj = nullptr;
|
JSObject* obj = nullptr;
|
||||||
mWrapper->GetJSObject(&obj);
|
mWrapper->GetJSObject(&obj);
|
||||||
|
|
|
@ -2085,7 +2085,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||||
bool thisChrome = IsChromeWindow();
|
bool thisChrome = IsChromeWindow();
|
||||||
|
|
||||||
nsCxPusher cxPusher;
|
nsCxPusher cxPusher;
|
||||||
if (!cxPusher.Push(cx, nsCxPusher::ASSERT_SCRIPT_CONTEXT)) {
|
if (!cxPusher.Push(cx)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1260,7 +1260,7 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
if (!pusher.Push(mContext, nsCxPusher::ASSERT_SCRIPT_CONTEXT))
|
if (!pusher.Push(mContext))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
xpc_UnmarkGrayObject(&aScopeObject);
|
xpc_UnmarkGrayObject(&aScopeObject);
|
||||||
|
@ -1515,7 +1515,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope,
|
||||||
// all now, and never were in some cases.
|
// all now, and never were in some cases.
|
||||||
|
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
if (!pusher.Push(mContext, nsCxPusher::ASSERT_SCRIPT_CONTEXT))
|
if (!pusher.Push(mContext))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// check if the event handler can be run on the object in question
|
// check if the event handler can be run on the object in question
|
||||||
|
|
|
@ -87,7 +87,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback)
|
||||||
mAr.construct(cx);
|
mAr.construct(cx);
|
||||||
|
|
||||||
// Make sure our JSContext is pushed on the stack.
|
// Make sure our JSContext is pushed on the stack.
|
||||||
if (!mCxPusher.Push(cx, nsCxPusher::ALWAYS_PUSH)) {
|
if (!mCxPusher.Push(cx)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -523,7 +523,7 @@ SmsRequest::NotifyThreadList(const InfallibleTArray<ThreadListItem>& aItems)
|
||||||
NS_ENSURE_TRUE_VOID(ownerObj);
|
NS_ENSURE_TRUE_VOID(ownerObj);
|
||||||
|
|
||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
NS_ENSURE_TRUE_VOID(pusher.Push(cx, nsCxPusher::ALWAYS_PUSH));
|
NS_ENSURE_TRUE_VOID(pusher.Push(cx));
|
||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
JSAutoCompartment ac(cx, ownerObj);
|
JSAutoCompartment ac(cx, ownerObj);
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace {
|
||||||
JSOPTION_DONT_REPORT_UNCAUGHT)))
|
JSOPTION_DONT_REPORT_UNCAUGHT)))
|
||||||
{
|
{
|
||||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||||
mStack.Push(cx, nsCxPusher::ALWAYS_PUSH);
|
mStack.Push(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoContextPusher() {
|
~AutoContextPusher() {
|
||||||
|
|
|
@ -428,7 +428,7 @@ def write_cpp(iface, fd):
|
||||||
" }\n\n"
|
" }\n\n"
|
||||||
" JSObject* obj = &aVal->toObject();\n"
|
" JSObject* obj = &aVal->toObject();\n"
|
||||||
" nsCxPusher pusher;\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"
|
" JSAutoRequest ar(aCx);\n"
|
||||||
" JSAutoCompartment ac(aCx, obj);\n")
|
" JSAutoCompartment ac(aCx, obj);\n")
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче