Bug 1473865 part 4 - Use xpc::WindowOrNull instead of xpc::WindowGlobalOrNull in a few places. r=bz

This commit is contained in:
Jan de Mooij 2018-07-12 16:17:44 +02:00
parent 1fb564174b
commit 7967870e29
7 changed files with 14 additions and 11 deletions

View File

@ -9655,7 +9655,8 @@ nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri)
MOZ_ASSERT(strncmp(aUri, "about:", 6) == 0);
// Make sure the global is a window
nsGlobalWindowInner* win = xpc::WindowGlobalOrNull(aGlobal);
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
nsGlobalWindowInner* win = xpc::WindowOrNull(aGlobal);
if (!win) {
return false;
}

View File

@ -2599,9 +2599,10 @@ nsIDocument::IsSynthesized() {
}
bool
nsDocument::IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject)
nsDocument::IsShadowDOMEnabled(JSContext* aCx, JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindowInner> window = xpc::WindowGlobalOrNull(aObject);
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
nsCOMPtr<nsPIDOMWindowInner> window = xpc::WindowOrNull(aGlobal);
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
if (!doc) {

View File

@ -194,8 +194,8 @@ public:
nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const;
nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName);
// Check whether shadow DOM is enabled for the global of aObject.
static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject);
// Check whether shadow DOM is enabled for aGlobal.
static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aGlobal);
// Check whether shadow DOM is enabled for the document this node belongs to.
static bool IsShadowDOMEnabled(const nsINode* aNode);

View File

@ -568,6 +568,7 @@ AutoJSAPI::ReportException()
errorGlobal = GetCurrentThreadWorkerGlobal();
}
}
MOZ_ASSERT(JS_IsGlobalObject(errorGlobal));
JSAutoRealm ar(cx(), errorGlobal);
JS::Rooted<JS::Value> exn(cx());
js::ErrorReport jsReport(cx());
@ -576,7 +577,7 @@ AutoJSAPI::ReportException()
if (mIsMainThread) {
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
RefPtr<nsGlobalWindowInner> win = xpc::WindowGlobalOrNull(errorGlobal);
RefPtr<nsGlobalWindowInner> win = xpc::WindowOrNull(errorGlobal);
nsPIDOMWindowInner* inner = win ? win->AsInner() : nullptr;
bool isChrome = nsContentUtils::IsSystemPrincipal(
nsContentUtils::ObjectPrincipal(errorGlobal));

View File

@ -233,8 +233,7 @@ ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type, const ch
// Compute the current window id if any.
uint64_t windowId = 0;
nsGlobalWindowInner* win = WindowGlobalOrNull(CurrentGlobalOrNull(cx));
if (win)
if (nsGlobalWindowInner* win = CurrentWindowOrNull(cx))
windowId = win->WindowID();

View File

@ -92,9 +92,10 @@ AddonManagerWebAPI::IsValidSite(nsIURI* uri)
}
bool
AddonManagerWebAPI::IsAPIEnabled(JSContext* cx, JSObject* obj)
AddonManagerWebAPI::IsAPIEnabled(JSContext* aCx, JSObject* aGlobal)
{
nsGlobalWindowInner* global = xpc::WindowGlobalOrNull(obj);
MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
nsGlobalWindowInner* global = xpc::WindowOrNull(aGlobal);
if (!global) {
return false;
}

View File

@ -13,7 +13,7 @@ namespace mozilla {
class AddonManagerWebAPI {
public:
static bool IsAPIEnabled(JSContext* cx, JSObject* obj);
static bool IsAPIEnabled(JSContext* aCx, JSObject* aGlobal);
static bool IsValidSite(nsIURI* uri);
};