mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 10:27:03 +00:00
Bug 1276276 part 5. Change AutoCxPusher to not worry about nsIScriptContext, since its JSContext never has one anymore. r=smaug
This commit is contained in:
parent
30b1d353e7
commit
718461c894
@ -764,12 +764,6 @@ danger::AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
|
||||
{
|
||||
MOZ_ASSERT_IF(!allowNull, cx);
|
||||
|
||||
// Hold a strong ref to the nsIScriptContext, if any. This ensures that we
|
||||
// only destroy the mContext of an nsJSContext when it is not on the cx stack
|
||||
// (and therefore not in use). See nsJSContext::DestroyJSContext().
|
||||
if (cx)
|
||||
mScx = GetScriptContextFromJSContext(cx);
|
||||
|
||||
XPCJSContextStack *stack = XPCJSRuntime::Get()->GetJSContextStack();
|
||||
stack->Push(cx);
|
||||
mStackDepthAfterPush = stack->Count();
|
||||
@ -801,7 +795,6 @@ danger::AutoCxPusher::~AutoCxPusher()
|
||||
DebugOnly<JSContext*> stackTop;
|
||||
MOZ_ASSERT(mPushedContext == nsXPConnect::XPConnect()->GetCurrentJSContext());
|
||||
XPCJSRuntime::Get()->GetJSContextStack()->Pop();
|
||||
mScx = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -40,15 +40,12 @@ public:
|
||||
explicit AutoCxPusher(JSContext *aCx, bool aAllowNull = false);
|
||||
~AutoCxPusher();
|
||||
|
||||
nsIScriptContext* GetScriptContext() { return mScx; }
|
||||
|
||||
// Returns true if this AutoCxPusher performed the push that is currently at
|
||||
// the top of the cx stack.
|
||||
bool IsStackTop() const;
|
||||
|
||||
private:
|
||||
mozilla::Maybe<JSAutoRequest> mAutoRequest;
|
||||
nsCOMPtr<nsIScriptContext> mScx;
|
||||
uint32_t mStackDepthAfterPush;
|
||||
#ifdef DEBUG
|
||||
JSContext* mPushedContext;
|
||||
|
@ -12,24 +12,6 @@
|
||||
|
||||
class nsIJSArgArray;
|
||||
|
||||
// seems like overkill for just this 1 function - but let's see what else
|
||||
// falls out first.
|
||||
inline nsIScriptContext *
|
||||
GetScriptContextFromJSContext(JSContext *cx)
|
||||
{
|
||||
if (!(JS::ContextOptionsRef(cx).privateIsNSISupports())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptContext> scx =
|
||||
do_QueryInterface(static_cast<nsISupports *>
|
||||
(::JS_GetContextPrivate(cx)));
|
||||
|
||||
// This will return a pointer to something that's about to be
|
||||
// released, but that's ok here.
|
||||
return scx;
|
||||
}
|
||||
|
||||
// A factory function for turning a JS::Value argv into an nsIArray
|
||||
// but also supports an effecient way of extracting the original argv.
|
||||
// The resulting object will take a copy of the array, and ensure each
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsDOMJSUtils.h" // for GetScriptContextFromJSContext
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -102,8 +101,6 @@ nsJSUtils::CompileFunction(AutoJSAPI& jsapi,
|
||||
MOZ_ASSERT_IF(aScopeChain.length() != 0,
|
||||
js::IsObjectInContextCompartment(aScopeChain[0], cx));
|
||||
MOZ_ASSERT_IF(aOptions.versionSet, aOptions.version != JSVERSION_UNKNOWN);
|
||||
mozilla::DebugOnly<nsIScriptContext*> ctx = GetScriptContextFromJSContext(cx);
|
||||
MOZ_ASSERT_IF(ctx, ctx->IsContextInitialized());
|
||||
|
||||
// Do the junk Gecko is supposed to do before calling into JSAPI.
|
||||
for (size_t i = 0; i < aScopeChain.length(); ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user