зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1474273 - Add xpc::CurrentNativeGlobal and use it instead of NativeGlobal(JS::CurrentGlobalOrNull(cx)). r=bz
This commit is contained in:
Родитель
c1bbe21ac6
Коммит
4f7b2378dc
|
@ -378,7 +378,7 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
|
|||
}
|
||||
|
||||
if (aTag == SCTAG_DOM_WEBCRYPTO_KEY || aTag == SCTAG_DOM_URLSEARCHPARAMS) {
|
||||
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -952,7 +952,7 @@ public:
|
|||
if (aDatabase && aDatabase->GetParentObject()) {
|
||||
parent = aDatabase->GetParentObject();
|
||||
} else {
|
||||
parent = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
parent = xpc::CurrentNativeGlobal(aCx);
|
||||
}
|
||||
} else {
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
|
|
|
@ -101,7 +101,7 @@ StructuredCloneData::Read(JSContext* aCx,
|
|||
{
|
||||
MOZ_ASSERT(mInitialized);
|
||||
|
||||
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
ReadFromBuffer(global, aCx, Data(), aValue, aRv);
|
||||
|
|
|
@ -693,8 +693,7 @@ AutoEntryScript::DocshellEntryMonitor::Entry(JSContext* aCx, JSFunction* aFuncti
|
|||
rootedScript = aScript;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)));
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = xpc::CurrentWindowOrNull(aCx);
|
||||
if (!window || !window->GetDocShell() ||
|
||||
!window->GetDocShell()->GetRecordProfileTimelineMarkers()) {
|
||||
return;
|
||||
|
@ -738,8 +737,7 @@ AutoEntryScript::DocshellEntryMonitor::Entry(JSContext* aCx, JSFunction* aFuncti
|
|||
void
|
||||
AutoEntryScript::DocshellEntryMonitor::Exit(JSContext* aCx)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowInner> window =
|
||||
do_QueryInterface(xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)));
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = xpc::CurrentWindowOrNull(aCx);
|
||||
// Not really worth checking GetRecordProfileTimelineMarkers here.
|
||||
if (window && window->GetDocShell()) {
|
||||
nsCOMPtr<nsIDocShell> docShellForJSRunToCompletion = window->GetDocShell();
|
||||
|
|
|
@ -86,8 +86,7 @@ PublicKeyCredential::SetResponse(RefPtr<AuthenticatorResponse> aResponse)
|
|||
/* static */ already_AddRefed<Promise>
|
||||
PublicKeyCredential::IsUserVerifyingPlatformAuthenticatorAvailable(GlobalObject& aGlobal)
|
||||
{
|
||||
nsIGlobalObject* globalObject =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aGlobal.Context()));
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aGlobal.Context());
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -179,8 +179,7 @@ nsThebesFontEnumerator::EnumerateFontsAsync(const char* aLangGroup,
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx);
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
||||
|
||||
ErrorResult errv;
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
|
||||
MOZ_ASSERT(global);
|
||||
|
||||
// RefPtr<File> needs to go out of scope before toObjectOrNull() is called because
|
||||
|
|
|
@ -813,7 +813,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
|
|||
|
||||
case nsXPTType::T_PROMISE:
|
||||
{
|
||||
nsIGlobalObject* glob = NativeGlobal(CurrentGlobalOrNull(cx));
|
||||
nsIGlobalObject* glob = CurrentNativeGlobal(cx);
|
||||
if (!glob) {
|
||||
if (pErr) {
|
||||
*pErr = NS_ERROR_UNEXPECTED;
|
||||
|
|
|
@ -504,6 +504,13 @@ CompilationScope();
|
|||
nsIGlobalObject*
|
||||
NativeGlobal(JSObject* aObj);
|
||||
|
||||
/**
|
||||
* Returns the nsIGlobalObject corresponding to |cx|'s JS global. Must not be
|
||||
* called when |cx| is not in a Realm.
|
||||
*/
|
||||
nsIGlobalObject*
|
||||
CurrentNativeGlobal(JSContext* cx);
|
||||
|
||||
/**
|
||||
* If |aObj| is a window, returns the associated nsGlobalWindow.
|
||||
* Otherwise, returns null.
|
||||
|
@ -519,7 +526,7 @@ nsGlobalWindowInner*
|
|||
WindowGlobalOrNull(JSObject* aObj);
|
||||
|
||||
/**
|
||||
* If |cx| is in a compartment whose global is a window, returns the associated
|
||||
* If |cx| is in a realm whose global is a window, returns the associated
|
||||
* nsGlobalWindow. Otherwise, returns null.
|
||||
*/
|
||||
nsGlobalWindowInner*
|
||||
|
|
|
@ -701,4 +701,10 @@ NativeGlobal(JSObject* obj)
|
|||
return global;
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
CurrentNativeGlobal(JSContext* cx)
|
||||
{
|
||||
return xpc::NativeGlobal(JS::CurrentGlobalOrNull(cx));
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
|
|
@ -310,8 +310,7 @@ nsStyleSheetService::PreloadSheetAsync(nsIURI* aSheetURI, uint32_t aSheetType,
|
|||
nsresult rv = GetParsingMode(aSheetType, &parsingMode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx);
|
||||
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
||||
|
||||
ErrorResult errv;
|
||||
|
|
|
@ -152,9 +152,7 @@ SecretDecoderRing::AsyncEncryptStrings(uint32_t plaintextsCount,
|
|||
NS_ENSURE_ARG_POINTER(plaintexts);
|
||||
NS_ENSURE_ARG_POINTER(aCx);
|
||||
|
||||
nsIGlobalObject* globalObject =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aCx);
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
|
|
@ -848,7 +848,7 @@ NS_IMETHODIMP
|
|||
TelemetryImpl::GetLoadedModules(JSContext *cx, Promise** aPromise)
|
||||
{
|
||||
#if defined(MOZ_GECKO_PROFILER)
|
||||
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(cx));
|
||||
nsIGlobalObject* global = xpc::CurrentNativeGlobal(cx);
|
||||
if (NS_WARN_IF(!global)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -234,9 +234,7 @@ nsProfiler::GetProfileDataAsync(double aSinceTime, JSContext* aCx,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIGlobalObject* globalObject =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aCx);
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -302,9 +300,7 @@ nsProfiler::GetProfileDataAsArrayBuffer(double aSinceTime, JSContext* aCx,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIGlobalObject* globalObject =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aCx);
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -359,9 +355,7 @@ nsProfiler::DumpProfileToFileAsync(const nsACString& aFilename,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIGlobalObject* globalObject =
|
||||
xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aCx);
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -673,4 +667,4 @@ nsProfiler::ClearExpiredExitProfiles()
|
|||
mExitProfiles.RemoveElementsBy([bufferRangeStart](ExitProfile& aExitProfile){
|
||||
return aExitProfile.mBufferPositionAtGatherTime < bufferRangeStart;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче