mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968335 - Make Auto{Entry,Incumbent}Global inherit ScriptSettingsStackEntry. r=bz
This will allow us to downcast from a stack entry to an AutoEntryGlobal, and thereby get at the AutoCxPusher.
This commit is contained in:
parent
36891c136e
commit
6c95fae0b3
@ -158,8 +158,8 @@ GetIncumbentGlobal()
|
||||
AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
bool aIsMainThread,
|
||||
JSContext* aCx)
|
||||
: mStack(ScriptSettingsStack::Ref())
|
||||
, mEntry(aGlobalObject, /* aCandidate = */ true)
|
||||
: ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ true)
|
||||
, mStack(ScriptSettingsStack::Ref())
|
||||
{
|
||||
MOZ_ASSERT(aGlobalObject);
|
||||
if (!aCx) {
|
||||
@ -180,26 +180,26 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
mCxPusher.construct(aCx);
|
||||
}
|
||||
mAc.construct(aCx, aGlobalObject->GetGlobalJSObject());
|
||||
mStack.Push(&mEntry);
|
||||
mStack.Push(this);
|
||||
}
|
||||
|
||||
AutoEntryScript::~AutoEntryScript()
|
||||
{
|
||||
MOZ_ASSERT(mStack.Incumbent() == &mEntry);
|
||||
MOZ_ASSERT(mStack.Incumbent() == this);
|
||||
mStack.Pop();
|
||||
}
|
||||
|
||||
AutoIncumbentScript::AutoIncumbentScript(nsIGlobalObject* aGlobalObject)
|
||||
: mStack(ScriptSettingsStack::Ref())
|
||||
, mEntry(aGlobalObject, /* aCandidate = */ false)
|
||||
: ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ false)
|
||||
, mStack(ScriptSettingsStack::Ref())
|
||||
, mCallerOverride(nsContentUtils::GetCurrentJSContextForThread())
|
||||
{
|
||||
mStack.Push(&mEntry);
|
||||
mStack.Push(this);
|
||||
}
|
||||
|
||||
AutoIncumbentScript::~AutoIncumbentScript()
|
||||
{
|
||||
MOZ_ASSERT(mStack.Incumbent() == &mEntry);
|
||||
MOZ_ASSERT(mStack.Incumbent() == this);
|
||||
mStack.Pop();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
/*
|
||||
* A class that represents a new script entry point.
|
||||
*/
|
||||
class AutoEntryScript {
|
||||
class AutoEntryScript : protected ScriptSettingsStackEntry {
|
||||
public:
|
||||
AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
bool aIsMainThread = NS_IsMainThread(),
|
||||
@ -81,7 +81,6 @@ public:
|
||||
|
||||
private:
|
||||
dom::ScriptSettingsStack& mStack;
|
||||
dom::ScriptSettingsStackEntry mEntry;
|
||||
mozilla::Maybe<AutoCxPusher> mCxPusher;
|
||||
mozilla::Maybe<JSAutoCompartment> mAc; // This can de-Maybe-fy when mCxPusher
|
||||
// goes away.
|
||||
@ -90,13 +89,12 @@ private:
|
||||
/*
|
||||
* A class that can be used to force a particular incumbent script on the stack.
|
||||
*/
|
||||
class AutoIncumbentScript {
|
||||
class AutoIncumbentScript : protected ScriptSettingsStackEntry {
|
||||
public:
|
||||
AutoIncumbentScript(nsIGlobalObject* aGlobalObject);
|
||||
~AutoIncumbentScript();
|
||||
private:
|
||||
dom::ScriptSettingsStack& mStack;
|
||||
dom::ScriptSettingsStackEntry mEntry;
|
||||
JS::AutoHideScriptedCaller mCallerOverride;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user