mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1292892 part 5 - Replace most nsContentUtils::RootingCx calls with dom::RootingCx. r=bz,terrence
This commit is contained in:
parent
4ec9b6fc7e
commit
c33bac8363
@ -1845,7 +1845,7 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
||||
const nsAString& aURL,
|
||||
bool aRunInGlobalScope)
|
||||
{
|
||||
JS::Rooted<JSScript*> script(nsContentUtils::RootingCx());
|
||||
JS::Rooted<JSScript*> script(RootingCx());
|
||||
TryCacheLoadAndCompileScript(aURL, aRunInGlobalScope, true, &script);
|
||||
}
|
||||
|
||||
|
@ -2262,7 +2262,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(WindowStateHolder, WINDOWSTATEHOLDER_IID)
|
||||
|
||||
WindowStateHolder::WindowStateHolder(nsGlobalWindow* aWindow)
|
||||
: mInnerWindow(aWindow),
|
||||
mInnerWindowReflector(nsContentUtils::RootingCx(), aWindow->GetWrapper())
|
||||
mInnerWindowReflector(RootingCx(), aWindow->GetWrapper())
|
||||
{
|
||||
NS_PRECONDITION(aWindow, "null window");
|
||||
NS_PRECONDITION(aWindow->IsInnerWindow(), "Saving an outer window");
|
||||
@ -3532,8 +3532,7 @@ nsGlobalWindow::DefineArgumentsProperty(nsIArray *aArguments)
|
||||
nsIScriptContext *ctx = GetOuterWindowInternal()->mContext;
|
||||
NS_ENSURE_TRUE(aArguments && ctx, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
JS::Rooted<JSObject*> obj(nsContentUtils::RootingCx(),
|
||||
GetWrapperPreserveColor());
|
||||
JS::Rooted<JSObject*> obj(RootingCx(), GetWrapperPreserveColor());
|
||||
return ctx->SetProperty(obj, "arguments", aArguments);
|
||||
}
|
||||
|
||||
@ -8946,7 +8945,7 @@ nsGlobalWindow::NotifyDOMWindowThawed(nsGlobalWindow* aWindow) {
|
||||
JSObject*
|
||||
nsGlobalWindow::GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey)
|
||||
{
|
||||
JS::Rooted<JSObject*> handler(nsContentUtils::RootingCx());
|
||||
JS::Rooted<JSObject*> handler(RootingCx());
|
||||
if (mCachedXBLPrototypeHandlers) {
|
||||
mCachedXBLPrototypeHandlers->Get(aKey, handler.address());
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public:
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
// First, notify the DOM that we have a script error, but only if
|
||||
// our window is still the current inner.
|
||||
JSContext* rootingCx = nsContentUtils::RootingCx();
|
||||
JS::RootingContext* rootingCx = RootingCx();
|
||||
if (win->IsCurrentInnerWindow() && win->GetDocShell() && !sHandlingScriptError) {
|
||||
AutoRestore<bool> recursionGuard(sHandlingScriptError);
|
||||
sHandlingScriptError = true;
|
||||
|
@ -19,7 +19,8 @@ class MOZ_RAII RootedDictionary final : public T,
|
||||
private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
explicit RootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
template <typename CX>
|
||||
explicit RootedDictionary(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
T(),
|
||||
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
@ -36,7 +37,8 @@ class MOZ_RAII NullableRootedDictionary final : public Nullable<T>,
|
||||
private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
explicit NullableRootedDictionary(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
template <typename CX>
|
||||
explicit NullableRootedDictionary(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
Nullable<T>(),
|
||||
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ SimpleGlobalObject::Create(GlobalType globalType, JS::Handle<JS::Value> proto)
|
||||
// We can't root our return value with our AutoJSAPI because the rooting
|
||||
// analysis thinks ~AutoJSAPI can GC. So we need to root in a scope outside
|
||||
// the lifetime of the AutoJSAPI.
|
||||
JS::Rooted<JSObject*> global(nsContentUtils::RootingCx());
|
||||
JS::Rooted<JSObject*> global(RootingCx());
|
||||
|
||||
{ // Scope to ensure the AutoJSAPI destructor runs before we end up returning
|
||||
AutoJSAPI jsapi;
|
||||
|
@ -369,7 +369,8 @@ template<typename ArrayType>
|
||||
class MOZ_RAII TypedArrayRooter : private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
TypedArrayRooter(JSContext* cx,
|
||||
template <typename CX>
|
||||
TypedArrayRooter(const CX& cx,
|
||||
ArrayType* aArray MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
|
||||
mArray(aArray)
|
||||
@ -392,7 +393,8 @@ class MOZ_RAII TypedArrayRooter<Nullable<ArrayType> > :
|
||||
private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
TypedArrayRooter(JSContext* cx,
|
||||
template <typename CX>
|
||||
TypedArrayRooter(const CX& cx,
|
||||
Nullable<ArrayType>* aArray MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
|
||||
mArray(aArray)
|
||||
@ -416,14 +418,16 @@ class MOZ_RAII RootedTypedArray final : public ArrayType,
|
||||
private TypedArrayRooter<ArrayType>
|
||||
{
|
||||
public:
|
||||
explicit RootedTypedArray(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
template <typename CX>
|
||||
explicit RootedTypedArray(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
ArrayType(),
|
||||
TypedArrayRooter<ArrayType>(cx, this
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
}
|
||||
|
||||
RootedTypedArray(JSContext* cx, JSObject* obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
template <typename CX>
|
||||
RootedTypedArray(const CX& cx, JSObject* obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
ArrayType(obj),
|
||||
TypedArrayRooter<ArrayType>(cx, this
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
|
@ -5494,7 +5494,7 @@ void
|
||||
CanvasRenderingContext2D::PutImageData(ImageData& aImageData, double aDx,
|
||||
double aDy, ErrorResult& aError)
|
||||
{
|
||||
RootedTypedArray<Uint8ClampedArray> arr(nsContentUtils::RootingCx());
|
||||
RootedTypedArray<Uint8ClampedArray> arr(RootingCx());
|
||||
DebugOnly<bool> inited = arr.Init(aImageData.GetDataObject());
|
||||
MOZ_ASSERT(inited);
|
||||
|
||||
@ -5510,7 +5510,7 @@ CanvasRenderingContext2D::PutImageData(ImageData& aImageData, double aDx,
|
||||
double aDirtyHeight,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
RootedTypedArray<Uint8ClampedArray> arr(nsContentUtils::RootingCx());
|
||||
RootedTypedArray<Uint8ClampedArray> arr(RootingCx());
|
||||
DebugOnly<bool> inited = arr.Init(aImageData.GetDataObject());
|
||||
MOZ_ASSERT(inited);
|
||||
|
||||
|
@ -388,7 +388,7 @@ WebGLTexture::TexOrSubImage(bool isSubImage, const char* funcName, TexImageTarge
|
||||
const uint32_t height = imageData->Height();
|
||||
const uint32_t depth = 1;
|
||||
|
||||
dom::RootedTypedArray<dom::Uint8ClampedArray> scopedArr(nsContentUtils::RootingCx());
|
||||
dom::RootedTypedArray<dom::Uint8ClampedArray> scopedArr(dom::RootingCx());
|
||||
const RefPtr<gfx::DataSourceSurface> surf = FromImageData(mContext, funcName,
|
||||
unpackType, imageData,
|
||||
&scopedArr);
|
||||
|
@ -822,7 +822,7 @@ nsGeolocationService::HandleMozsettingChanged(nsISupports* aSubject)
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"gelocation.enabled","value":true}
|
||||
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
RootedDictionary<SettingChangeNotification> setting(RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ Icc::NotifyEvent(const nsAString& aName)
|
||||
nsresult
|
||||
Icc::NotifyStkEvent(const nsAString& aName, nsIStkProactiveCmd* aStkProactiveCmd)
|
||||
{
|
||||
JSContext* cx = nsContentUtils::RootingCx();
|
||||
JS::RootingContext* cx = RootingCx();
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
|
||||
nsCOMPtr<nsIStkCmdFactory> cmdFactory =
|
||||
|
@ -489,7 +489,7 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor,
|
||||
error->GetName(errorName);
|
||||
}
|
||||
|
||||
RootedDictionary<ErrorEventInit> init(nsContentUtils::RootingCx());
|
||||
RootedDictionary<ErrorEventInit> init(RootingCx());
|
||||
request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno);
|
||||
|
||||
init.mMessage = errorName;
|
||||
|
@ -508,7 +508,7 @@ SpeechRecognition::NotifyFinalResult(SpeechEvent* aEvent)
|
||||
{
|
||||
ResetAndEnd();
|
||||
|
||||
RootedDictionary<SpeechRecognitionEventInit> init(nsContentUtils::RootingCx());
|
||||
RootedDictionary<SpeechRecognitionEventInit> init(RootingCx());
|
||||
init.mBubbles = true;
|
||||
init.mCancelable = false;
|
||||
// init.mResultIndex = 0;
|
||||
|
@ -1073,7 +1073,7 @@ Notification::ConstructFromFields(
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
|
||||
RootedDictionary<NotificationOptions> options(nsContentUtils::RootingCx());
|
||||
RootedDictionary<NotificationOptions> options(RootingCx());
|
||||
options.mDir = Notification::StringToDirection(nsString(aDir));
|
||||
options.mLang = aLang;
|
||||
options.mBody = aBody;
|
||||
|
@ -1062,7 +1062,7 @@ _getwindowobject(NPP npp)
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outer = doc->GetWindow();
|
||||
NS_ENSURE_TRUE(outer, nullptr);
|
||||
|
||||
JS::Rooted<JSObject*> global(nsContentUtils::RootingCx(),
|
||||
JS::Rooted<JSObject*> global(dom::RootingCx(),
|
||||
nsGlobalWindow::Cast(outer)->GetGlobalJSObject());
|
||||
return nsJSObjWrapper::GetNewOrUsed(npp, global);
|
||||
}
|
||||
|
@ -2460,7 +2460,7 @@ XMLHttpRequestMainThread::Send(nsIVariant* aVariant)
|
||||
}
|
||||
|
||||
// ArrayBuffer?
|
||||
JSContext* rootingCx = nsContentUtils::RootingCx();
|
||||
JS::RootingContext* rootingCx = RootingCx();
|
||||
JS::Rooted<JS::Value> realVal(rootingCx);
|
||||
|
||||
nsresult rv = aVariant->GetAsJSVal(&realVal);
|
||||
|
@ -2720,7 +2720,7 @@ NotifyOffThreadScriptCompletedRunnable::Run()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
JS::Rooted<JSScript*> script(nsContentUtils::RootingCx());
|
||||
JS::Rooted<JSScript*> script(RootingCx());
|
||||
{
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(xpc::CompilationScope())) {
|
||||
|
@ -6444,15 +6444,10 @@ JS_CallOnce(JSCallOnceType* once, JSInitCallback func)
|
||||
}
|
||||
|
||||
AutoGCRooter::AutoGCRooter(JSContext* cx, ptrdiff_t tag)
|
||||
: down(ContextFriendFields::get(cx)->roots.autoGCRooters_),
|
||||
tag_(tag),
|
||||
stackTop(&ContextFriendFields::get(cx)->roots.autoGCRooters_)
|
||||
{
|
||||
MOZ_ASSERT(this != *stackTop);
|
||||
*stackTop = this;
|
||||
}
|
||||
: AutoGCRooter(JS::RootingContext::get(cx), tag)
|
||||
{}
|
||||
|
||||
AutoGCRooter::AutoGCRooter(ContextFriendFields* cx, ptrdiff_t tag)
|
||||
AutoGCRooter::AutoGCRooter(JS::RootingContext* cx, ptrdiff_t tag)
|
||||
: down(cx->roots.autoGCRooters_),
|
||||
tag_(tag),
|
||||
stackTop(&cx->roots.autoGCRooters_)
|
||||
|
@ -457,7 +457,7 @@ class MOZ_RAII JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
explicit CustomAutoRooter(CX* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
explicit CustomAutoRooter(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, CUSTOM)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
@ -42,13 +42,13 @@ class JS_FRIEND_API(OwningCompileOptions);
|
||||
class JS_FRIEND_API(TransitiveCompileOptions);
|
||||
class JS_PUBLIC_API(CompartmentOptions);
|
||||
|
||||
struct RootingContext;
|
||||
class Value;
|
||||
struct Zone;
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
namespace js {
|
||||
struct ContextFriendFields;
|
||||
class RootLists;
|
||||
} // namespace js
|
||||
|
||||
@ -184,7 +184,7 @@ class JS_PUBLIC_API(AutoGCRooter)
|
||||
{
|
||||
public:
|
||||
AutoGCRooter(JSContext* cx, ptrdiff_t tag);
|
||||
AutoGCRooter(js::ContextFriendFields* cx, ptrdiff_t tag);
|
||||
AutoGCRooter(JS::RootingContext* cx, ptrdiff_t tag);
|
||||
|
||||
~AutoGCRooter() {
|
||||
MOZ_ASSERT(this == *stackTop);
|
||||
|
@ -395,7 +395,7 @@ mozJSSubScriptLoader::ReadScriptAsync(nsIURI* uri, JSObject* targetObjArg,
|
||||
nsIIOService* serv, bool reuseGlobal,
|
||||
bool cache, MutableHandleValue retval)
|
||||
{
|
||||
RootedObject target_obj(nsContentUtils::RootingCx(), targetObjArg);
|
||||
RootedObject target_obj(RootingCx(), targetObjArg);
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = xpc::NativeGlobal(target_obj);
|
||||
ErrorResult result;
|
||||
|
@ -550,7 +550,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (info && NS_SUCCEEDED(info->IsFunction(&isFunc)) && isFunc) {
|
||||
RefPtr<nsXPCWrappedJS> wrapper;
|
||||
RootedObject obj(nsContentUtils::RootingCx(), self->GetJSObject());
|
||||
RootedObject obj(RootingCx(), self->GetJSObject());
|
||||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(obj, aIID, getter_AddRefs(wrapper));
|
||||
|
||||
// Do the same thing we do for the "check for any existing wrapper" case above.
|
||||
|
Loading…
Reference in New Issue
Block a user