mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 841312 - Remove the termination function API. r=bz
\o/
This commit is contained in:
parent
83b50e7905
commit
0bda6fb49c
@ -27,11 +27,9 @@ class nsIScriptObjectPrincipal;
|
|||||||
class nsIDOMWindow;
|
class nsIDOMWindow;
|
||||||
class nsIURI;
|
class nsIURI;
|
||||||
|
|
||||||
typedef void (*nsScriptTerminationFunc)(nsISupports* aRef);
|
|
||||||
|
|
||||||
#define NS_ISCRIPTCONTEXT_IID \
|
#define NS_ISCRIPTCONTEXT_IID \
|
||||||
{ 0x821c5be9, 0xbf9e, 0x4041, \
|
{ 0xef0c91ce, 0x14f6, 0x41c9, \
|
||||||
{ 0x9f, 0xf2, 0x1f, 0xca, 0x39, 0xf7, 0x89, 0xf3 } }
|
{ 0xa5, 0x77, 0xa6, 0xeb, 0xdc, 0x6d, 0x44, 0x7b } }
|
||||||
|
|
||||||
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
|
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
|
||||||
know what language we have is a little silly... */
|
know what language we have is a little silly... */
|
||||||
@ -179,11 +177,10 @@ public:
|
|||||||
* A GC may be done if "necessary."
|
* A GC may be done if "necessary."
|
||||||
* This call is necessary if script evaluation is done
|
* This call is necessary if script evaluation is done
|
||||||
* without using the EvaluateScript method.
|
* without using the EvaluateScript method.
|
||||||
* @param aTerminated If true then call termination function if it was
|
* @param aTerminated If true then do script termination handling. Within DOM
|
||||||
* previously set. Within DOM this will always be true, but outside
|
* this will always be true, but outside callers (such as xpconnect) who
|
||||||
* callers (such as xpconnect) who may do script evaluations nested
|
* may do script evaluations nested inside inside DOM script evaluations
|
||||||
* inside DOM script evaluations can pass false to avoid premature
|
* can pass false to avoid premature termination handling.
|
||||||
* calls to the termination function.
|
|
||||||
* @return NS_OK if the method is successful
|
* @return NS_OK if the method is successful
|
||||||
*/
|
*/
|
||||||
virtual void ScriptEvaluated(bool aTerminated) = 0;
|
virtual void ScriptEvaluated(bool aTerminated) = 0;
|
||||||
@ -196,19 +193,6 @@ public:
|
|||||||
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
||||||
JS::MutableHandle<JSScript*> aResult) = 0;
|
JS::MutableHandle<JSScript*> aResult) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* JS only - this function need not be implemented by languages other
|
|
||||||
* than JS (ie, this should be moved to a private interface!)
|
|
||||||
* Called to specify a function that should be called when the current
|
|
||||||
* script (if there is one) terminates. Generally used if breakdown
|
|
||||||
* of script state needs to happen, but should be deferred till
|
|
||||||
* the end of script evaluation.
|
|
||||||
*
|
|
||||||
* @throws NS_ERROR_OUT_OF_MEMORY if that happens
|
|
||||||
*/
|
|
||||||
virtual void SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
|
||||||
nsIDOMWindow* aRef) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to disable/enable script execution in this context.
|
* Called to disable/enable script execution in this context.
|
||||||
*/
|
*/
|
||||||
|
@ -1141,7 +1141,6 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime, bool aGCOnDestruction,
|
|||||||
::JS_SetOperationCallback(mContext, DOMOperationCallback);
|
::JS_SetOperationCallback(mContext, DOMOperationCallback);
|
||||||
}
|
}
|
||||||
mIsInitialized = false;
|
mIsInitialized = false;
|
||||||
mTerminations = nullptr;
|
|
||||||
mScriptsEnabled = true;
|
mScriptsEnabled = true;
|
||||||
mOperationCallbackTime = 0;
|
mOperationCallbackTime = 0;
|
||||||
mModalStateTime = 0;
|
mModalStateTime = 0;
|
||||||
@ -1156,11 +1155,6 @@ nsJSContext::~nsJSContext()
|
|||||||
mNext->mPrev = mPrev;
|
mNext->mPrev = mPrev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may still have pending termination functions if the context is destroyed
|
|
||||||
// before they could be executed. In this case, free the references to their
|
|
||||||
// parameters, but don't execute the functions (see bug 622326).
|
|
||||||
delete mTerminations;
|
|
||||||
|
|
||||||
mGlobalObjectRef = nullptr;
|
mGlobalObjectRef = nullptr;
|
||||||
|
|
||||||
DestroyJSContext();
|
DestroyJSContext();
|
||||||
@ -1289,8 +1283,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_TRUE(ok, NS_OK);
|
NS_ENSURE_TRUE(ok, NS_OK);
|
||||||
|
|
||||||
nsJSContext::TerminationFuncHolder holder(this);
|
|
||||||
|
|
||||||
// Scope the JSAutoCompartment so that it gets destroyed before we pop the
|
// Scope the JSAutoCompartment so that it gets destroyed before we pop the
|
||||||
// cx and potentially call JS_RestoreFrameChain.
|
// cx and potentially call JS_RestoreFrameChain.
|
||||||
XPCAutoRequest ar(mContext);
|
XPCAutoRequest ar(mContext);
|
||||||
@ -1414,7 +1406,6 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject_,
|
|||||||
nsCxPusher pusher;
|
nsCxPusher pusher;
|
||||||
pusher.Push(mContext);
|
pusher.Push(mContext);
|
||||||
|
|
||||||
nsJSContext::TerminationFuncHolder holder(this);
|
|
||||||
XPCAutoRequest ar(mContext);
|
XPCAutoRequest ar(mContext);
|
||||||
|
|
||||||
// Scope the JSAutoCompartment so that it gets destroyed before we pop the
|
// Scope the JSAutoCompartment so that it gets destroyed before we pop the
|
||||||
@ -2361,20 +2352,6 @@ nsJSContext::IsContextInitialized()
|
|||||||
void
|
void
|
||||||
nsJSContext::ScriptEvaluated(bool aTerminated)
|
nsJSContext::ScriptEvaluated(bool aTerminated)
|
||||||
{
|
{
|
||||||
if (aTerminated && mTerminations) {
|
|
||||||
// Make sure to null out mTerminations before doing anything that
|
|
||||||
// might cause new termination funcs to be added!
|
|
||||||
nsJSContext::TerminationFuncClosure* start = mTerminations;
|
|
||||||
mTerminations = nullptr;
|
|
||||||
|
|
||||||
for (nsJSContext::TerminationFuncClosure* cur = start;
|
|
||||||
cur;
|
|
||||||
cur = cur->mNext) {
|
|
||||||
(*(cur->mTerminationFunc))(cur->mTerminationFuncArg);
|
|
||||||
}
|
|
||||||
delete start;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_MaybeGC(mContext);
|
JS_MaybeGC(mContext);
|
||||||
|
|
||||||
if (aTerminated) {
|
if (aTerminated) {
|
||||||
@ -2384,17 +2361,6 @@ nsJSContext::ScriptEvaluated(bool aTerminated)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
nsJSContext::SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
|
||||||
nsIDOMWindow* aRef)
|
|
||||||
{
|
|
||||||
NS_PRECONDITION(GetExecutingScript(), "should be executing script");
|
|
||||||
|
|
||||||
nsJSContext::TerminationFuncClosure* newClosure =
|
|
||||||
new nsJSContext::TerminationFuncClosure(aFunc, aRef, mTerminations);
|
|
||||||
mTerminations = newClosure;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsJSContext::GetScriptsEnabled()
|
nsJSContext::GetScriptsEnabled()
|
||||||
{
|
{
|
||||||
|
@ -75,8 +75,6 @@ public:
|
|||||||
virtual bool IsContextInitialized();
|
virtual bool IsContextInitialized();
|
||||||
|
|
||||||
virtual void ScriptEvaluated(bool aTerminated);
|
virtual void ScriptEvaluated(bool aTerminated);
|
||||||
virtual void SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
|
||||||
nsIDOMWindow* aRef);
|
|
||||||
virtual bool GetScriptsEnabled();
|
virtual bool GetScriptsEnabled();
|
||||||
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
|
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
|
||||||
|
|
||||||
@ -186,66 +184,6 @@ private:
|
|||||||
JSContext *mContext;
|
JSContext *mContext;
|
||||||
bool mActive;
|
bool mActive;
|
||||||
|
|
||||||
// Public so we can use it from CallbackFunction
|
|
||||||
public:
|
|
||||||
struct TerminationFuncHolder;
|
|
||||||
protected:
|
|
||||||
friend struct TerminationFuncHolder;
|
|
||||||
|
|
||||||
struct TerminationFuncClosure
|
|
||||||
{
|
|
||||||
TerminationFuncClosure(nsScriptTerminationFunc aFunc,
|
|
||||||
nsISupports* aArg,
|
|
||||||
TerminationFuncClosure* aNext) :
|
|
||||||
mTerminationFunc(aFunc),
|
|
||||||
mTerminationFuncArg(aArg),
|
|
||||||
mNext(aNext)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
~TerminationFuncClosure()
|
|
||||||
{
|
|
||||||
delete mNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsScriptTerminationFunc mTerminationFunc;
|
|
||||||
nsCOMPtr<nsISupports> mTerminationFuncArg;
|
|
||||||
TerminationFuncClosure* mNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Public so we can use it from CallbackFunction
|
|
||||||
public:
|
|
||||||
struct TerminationFuncHolder
|
|
||||||
{
|
|
||||||
TerminationFuncHolder(nsJSContext* aContext)
|
|
||||||
: mContext(aContext),
|
|
||||||
mTerminations(aContext->mTerminations)
|
|
||||||
{
|
|
||||||
aContext->mTerminations = nullptr;
|
|
||||||
}
|
|
||||||
~TerminationFuncHolder()
|
|
||||||
{
|
|
||||||
// Have to be careful here. mContext might have picked up new
|
|
||||||
// termination funcs while the script was evaluating. Prepend whatever
|
|
||||||
// we have to the current termination funcs on the context (since our
|
|
||||||
// termination funcs were posted first).
|
|
||||||
if (mTerminations) {
|
|
||||||
TerminationFuncClosure* cur = mTerminations;
|
|
||||||
while (cur->mNext) {
|
|
||||||
cur = cur->mNext;
|
|
||||||
}
|
|
||||||
cur->mNext = mContext->mTerminations;
|
|
||||||
mContext->mTerminations = mTerminations;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsJSContext* mContext;
|
|
||||||
TerminationFuncClosure* mTerminations;
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TerminationFuncClosure* mTerminations;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool mIsInitialized;
|
bool mIsInitialized;
|
||||||
bool mScriptsEnabled;
|
bool mScriptsEnabled;
|
||||||
bool mGCOnDestruction;
|
bool mGCOnDestruction;
|
||||||
|
@ -109,14 +109,6 @@ CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
|
|||||||
nsresult rv = nsContentUtils::GetSecurityManager()->
|
nsresult rv = nsContentUtils::GetSecurityManager()->
|
||||||
CheckFunctionAccess(cx, js::UncheckedUnwrap(aCallback), nullptr);
|
CheckFunctionAccess(cx, js::UncheckedUnwrap(aCallback), nullptr);
|
||||||
|
|
||||||
// Construct a termination func holder even if we're not planning to
|
|
||||||
// run any script. We need this because we're going to call
|
|
||||||
// ScriptEvaluated even if we don't run the script... See XXX
|
|
||||||
// comment above.
|
|
||||||
if (ctx) {
|
|
||||||
mTerminationFuncHolder.construct(static_cast<nsJSContext*>(ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
// Security check failed. We're done here.
|
// Security check failed. We're done here.
|
||||||
return;
|
return;
|
||||||
|
@ -148,10 +148,6 @@ protected:
|
|||||||
// this needs to be a Maybe.
|
// this needs to be a Maybe.
|
||||||
Maybe<XPCAutoRequest> mAr;
|
Maybe<XPCAutoRequest> mAr;
|
||||||
|
|
||||||
// Can't construct a TerminationFuncHolder without an nsJSContext. But we
|
|
||||||
// generally want its destructor to come after the destructor of mCxPusher.
|
|
||||||
Maybe<nsJSContext::TerminationFuncHolder> mTerminationFuncHolder;
|
|
||||||
|
|
||||||
nsCxPusher mCxPusher;
|
nsCxPusher mCxPusher;
|
||||||
|
|
||||||
// Can't construct a JSAutoCompartment without a JSContext either. Also,
|
// Can't construct a JSAutoCompartment without a JSContext either. Also,
|
||||||
|
Loading…
Reference in New Issue
Block a user