зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1147215 - Add a helper to get the current window with a null check. r=smaug
This commit is contained in:
Родитель
7c855a15e6
Коммит
125cbceb13
|
@ -483,7 +483,7 @@ WarningOnlyErrorReporter(JSContext* aCx, const char* aMessage, JSErrorReport* aR
|
|||
{
|
||||
MOZ_ASSERT(JSREPORT_IS_WARNING(aRep->flags));
|
||||
nsRefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
|
||||
nsPIDOMWindow* win = xpc::WindowGlobalOrNull(JS::CurrentGlobalOrNull(aCx));
|
||||
nsPIDOMWindow* win = xpc::CurrentWindowOrNull(aCx);
|
||||
xpcReport->Init(aRep, aMessage, nsContentUtils::IsCallerChrome(),
|
||||
win ? win->WindowID() : 0);
|
||||
xpcReport->LogToConsole();
|
||||
|
|
|
@ -597,6 +597,13 @@ AddonWindowOrNull(JSObject *aObj)
|
|||
return WindowOrNull(mainGlobal);
|
||||
}
|
||||
|
||||
nsGlobalWindow*
|
||||
CurrentWindowOrNull(JSContext *cx)
|
||||
{
|
||||
JSObject *glob = JS::CurrentGlobalOrNull(cx);
|
||||
return glob ? WindowOrNull(glob) : nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -469,6 +469,13 @@ WindowGlobalOrNull(JSObject *aObj);
|
|||
nsGlobalWindow*
|
||||
AddonWindowOrNull(JSObject *aObj);
|
||||
|
||||
/**
|
||||
* If |cx| is in a compartment whose global is a window, returns the associated
|
||||
* nsGlobalWindow. Otherwise, returns null.
|
||||
*/
|
||||
nsGlobalWindow*
|
||||
CurrentWindowOrNull(JSContext *cx);
|
||||
|
||||
// Error reporter used when there is no associated DOM window on to which to
|
||||
// report errors and warnings.
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче