forked from mirrors/gecko-dev
Bug 1851263 - Rename nsIGlobalObject::AsInnerWindow to GetAsInnerWindow because it can return null. r=smaug
This is also the name that was originally suggested in https://bugzilla.mozilla.org/show_bug.cgi?id=218415#c53 . Differential Revision: https://phabricator.services.mozilla.com/D187340
This commit is contained in:
parent
c9e6139615
commit
fa8bfb6bc7
22 changed files with 32 additions and 31 deletions
|
|
@ -3625,7 +3625,7 @@ void Document::SetLoadedAsData(bool aLoadedAsData,
|
||||||
if (aConsiderForMemoryReporting) {
|
if (aConsiderForMemoryReporting) {
|
||||||
nsIGlobalObject* global = GetScopeObject();
|
nsIGlobalObject* global = GetScopeObject();
|
||||||
if (global) {
|
if (global) {
|
||||||
if (nsPIDOMWindowInner* window = global->AsInnerWindow()) {
|
if (nsPIDOMWindowInner* window = global->GetAsInnerWindow()) {
|
||||||
nsGlobalWindowInner::Cast(window)
|
nsGlobalWindowInner::Cast(window)
|
||||||
->RegisterDataDocumentForMemoryReporting(this);
|
->RegisterDataDocumentForMemoryReporting(this);
|
||||||
}
|
}
|
||||||
|
|
@ -7579,7 +7579,7 @@ void Document::SetScopeObject(nsIGlobalObject* aGlobal) {
|
||||||
if (aGlobal) {
|
if (aGlobal) {
|
||||||
mHasHadScriptHandlingObject = true;
|
mHasHadScriptHandlingObject = true;
|
||||||
|
|
||||||
nsPIDOMWindowInner* window = aGlobal->AsInnerWindow();
|
nsPIDOMWindowInner* window = aGlobal->GetAsInnerWindow();
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -18712,7 +18712,7 @@ void Document::UnregisterFromMemoryReportingForDataDocument() {
|
||||||
mAddedToMemoryReportingAsDataDocument = false;
|
mAddedToMemoryReportingAsDataDocument = false;
|
||||||
nsIGlobalObject* global = GetScopeObject();
|
nsIGlobalObject* global = GetScopeObject();
|
||||||
if (global) {
|
if (global) {
|
||||||
if (nsPIDOMWindowInner* win = global->AsInnerWindow()) {
|
if (nsPIDOMWindowInner* win = global->GetAsInnerWindow()) {
|
||||||
nsGlobalWindowInner::Cast(win)->UnregisterDataDocumentForMemoryReporting(
|
nsGlobalWindowInner::Cast(win)->UnregisterDataDocumentForMemoryReporting(
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ bool StructuredCloneCallbacksSharedArrayBuffer(JSContext* cx, bool aReceiving,
|
||||||
|
|
||||||
nsPIDOMWindowInner* innerWindow = nullptr;
|
nsPIDOMWindowInner* innerWindow = nullptr;
|
||||||
if (global) {
|
if (global) {
|
||||||
innerWindow = global->AsInnerWindow();
|
innerWindow = global->GetAsInnerWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
DocGroup* docGroup = nullptr;
|
DocGroup* docGroup = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -10882,7 +10882,7 @@ bool nsContentUtils::
|
||||||
static nsGlobalWindowInner* GetInnerWindowForGlobal(nsIGlobalObject* aGlobal) {
|
static nsGlobalWindowInner* GetInnerWindowForGlobal(nsIGlobalObject* aGlobal) {
|
||||||
NS_ENSURE_TRUE(aGlobal, nullptr);
|
NS_ENSURE_TRUE(aGlobal, nullptr);
|
||||||
|
|
||||||
if (auto* window = aGlobal->AsInnerWindow()) {
|
if (auto* window = aGlobal->GetAsInnerWindow()) {
|
||||||
return nsGlobalWindowInner::Cast(window);
|
return nsGlobalWindowInner::Cast(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -10906,7 +10906,7 @@ static nsGlobalWindowInner* GetInnerWindowForGlobal(nsIGlobalObject* aGlobal) {
|
||||||
|
|
||||||
// The calling window must be holding a reference, so we can return a weak
|
// The calling window must be holding a reference, so we can return a weak
|
||||||
// pointer.
|
// pointer.
|
||||||
return nsGlobalWindowInner::Cast(aGlobal->AsInnerWindow());
|
return nsGlobalWindowInner::Cast(aGlobal->GetAsInnerWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ mozilla::StorageAccess nsIGlobalObject::GetStorageAccess() {
|
||||||
return mozilla::StorageAccess::eDeny;
|
return mozilla::StorageAccess::eDeny;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPIDOMWindowInner* nsIGlobalObject::AsInnerWindow() {
|
nsPIDOMWindowInner* nsIGlobalObject::GetAsInnerWindow() {
|
||||||
if (MOZ_LIKELY(mIsInnerWindow)) {
|
if (MOZ_LIKELY(mIsInnerWindow)) {
|
||||||
return static_cast<nsPIDOMWindowInner*>(
|
return static_cast<nsPIDOMWindowInner*>(
|
||||||
static_cast<nsGlobalWindowInner*>(this));
|
static_cast<nsGlobalWindowInner*>(this));
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ class nsIGlobalObject : public nsISupports,
|
||||||
|
|
||||||
// Returns a pointer to this object as an inner window if this is one or
|
// Returns a pointer to this object as an inner window if this is one or
|
||||||
// nullptr otherwise.
|
// nullptr otherwise.
|
||||||
nsPIDOMWindowInner* AsInnerWindow();
|
nsPIDOMWindowInner* GetAsInnerWindow();
|
||||||
|
|
||||||
void QueueMicrotask(mozilla::dom::VoidFunction& aCallback);
|
void QueueMicrotask(mozilla::dom::VoidFunction& aCallback);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2548,7 +2548,7 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
|
||||||
ErrorResult& aRv) {
|
ErrorResult& aRv) {
|
||||||
if (StaticPrefs::dom_security_sanitizer_logging()) {
|
if (StaticPrefs::dom_security_sanitizer_logging()) {
|
||||||
mLogRemovals = true;
|
mLogRemovals = true;
|
||||||
if (nsPIDOMWindowInner* win = aGlobal->AsInnerWindow()) {
|
if (nsPIDOMWindowInner* win = aGlobal->GetAsInnerWindow()) {
|
||||||
mInnerWindowID = win->WindowID();
|
mInnerWindowID = win->WindowID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ already_AddRefed<Document> Event::GetDocument() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPIDOMWindowInner* win = global->AsInnerWindow();
|
nsPIDOMWindowInner* win = global->GetAsInnerWindow();
|
||||||
if (!win) {
|
if (!win) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -321,7 +321,7 @@ bool Event::ShouldIgnoreChromeEventTargetListener() const {
|
||||||
if (NS_WARN_IF(!global)) {
|
if (NS_WARN_IF(!global)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nsPIDOMWindowInner* win = global->AsInnerWindow();
|
nsPIDOMWindowInner* win = global->GetAsInnerWindow();
|
||||||
if (NS_WARN_IF(!win)) {
|
if (NS_WARN_IF(!win)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -418,7 +418,7 @@ void Event::PreventDefaultInternal(bool aCalledByDefaultHandler,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mEvent->mFlags.mInPassiveListener) {
|
if (mEvent->mFlags.mInPassiveListener) {
|
||||||
if (nsPIDOMWindowInner* win = mOwner->AsInnerWindow()) {
|
if (nsPIDOMWindowInner* win = mOwner->GetAsInnerWindow()) {
|
||||||
if (Document* doc = win->GetExtantDoc()) {
|
if (Document* doc = win->GetExtantDoc()) {
|
||||||
if (!doc->HasWarnedAbout(
|
if (!doc->HasWarnedAbout(
|
||||||
Document::ePreventDefaultFromPassiveListener)) {
|
Document::ePreventDefaultFromPassiveListener)) {
|
||||||
|
|
@ -762,7 +762,7 @@ double Event::TimeStamp() {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPIDOMWindowInner* win = mOwner->AsInnerWindow();
|
nsPIDOMWindowInner* win = mOwner->GetAsInnerWindow();
|
||||||
if (NS_WARN_IF(!win)) {
|
if (NS_WARN_IF(!win)) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1425,7 +1425,7 @@ already_AddRefed<nsPIDOMWindowInner> EventListenerManager::WindowFromListener(
|
||||||
global = callback->IncumbentGlobalOrNull();
|
global = callback->IncumbentGlobalOrNull();
|
||||||
}
|
}
|
||||||
if (global) {
|
if (global) {
|
||||||
innerWindow = global->AsInnerWindow(); // Can be nullptr
|
innerWindow = global->GetAsInnerWindow(); // Can be nullptr
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This ensures `window.event` can be set properly for
|
// This ensures `window.event` can be set properly for
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ void DOMLocalization::ReportL10nOverlaysErrors(
|
||||||
u"Unknown error happened while translating an element.");
|
u"Unknown error happened while translating an element.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nsPIDOMWindowInner* innerWindow = GetParentObject()->AsInnerWindow();
|
nsPIDOMWindowInner* innerWindow = GetParentObject()->GetAsInnerWindow();
|
||||||
Document* doc = innerWindow ? innerWindow->GetExtantDoc() : nullptr;
|
Document* doc = innerWindow ? innerWindow->GetExtantDoc() : nullptr;
|
||||||
if (doc) {
|
if (doc) {
|
||||||
nsContentUtils::ReportToConsoleNonLocalized(
|
nsContentUtils::ReportToConsoleNonLocalized(
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ Document* L10nMutations::GetDocument() const {
|
||||||
if (!mDOMLocalization) {
|
if (!mDOMLocalization) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* innerWindow = mDOMLocalization->GetParentObject()->AsInnerWindow();
|
auto* innerWindow = mDOMLocalization->GetParentObject()->GetAsInnerWindow();
|
||||||
if (!innerWindow) {
|
if (!innerWindow) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ void LockManagerChild::NotifyRequestDestroy() const { NotifyToWindow(false); }
|
||||||
|
|
||||||
void LockManagerChild::NotifyToWindow(bool aCreated) const {
|
void LockManagerChild::NotifyToWindow(bool aCreated) const {
|
||||||
if (NS_IsMainThread()) {
|
if (NS_IsMainThread()) {
|
||||||
NotifyBFCacheOnMainThread(GetParentObject()->AsInnerWindow(), aCreated);
|
NotifyBFCacheOnMainThread(GetParentObject()->GetAsInnerWindow(), aCreated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1489,7 +1489,7 @@ NotificationPermission Notification::GetPermission(const GlobalObject& aGlobal,
|
||||||
NotificationPermission Notification::GetPermission(nsIGlobalObject* aGlobal,
|
NotificationPermission Notification::GetPermission(nsIGlobalObject* aGlobal,
|
||||||
ErrorResult& aRv) {
|
ErrorResult& aRv) {
|
||||||
if (NS_IsMainThread()) {
|
if (NS_IsMainThread()) {
|
||||||
return GetPermissionInternal(aGlobal->AsInnerWindow(), aRv);
|
return GetPermissionInternal(aGlobal->GetAsInnerWindow(), aRv);
|
||||||
} else {
|
} else {
|
||||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||||
MOZ_ASSERT(worker);
|
MOZ_ASSERT(worker);
|
||||||
|
|
|
||||||
|
|
@ -529,7 +529,7 @@ mozilla::PresShell* PerformanceMainThread::GetPresShell() {
|
||||||
if (!ownerGlobal) {
|
if (!ownerGlobal) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (Document* doc = ownerGlobal->AsInnerWindow()->GetExtantDoc()) {
|
if (Document* doc = ownerGlobal->GetAsInnerWindow()->GetExtantDoc()) {
|
||||||
return doc->GetPresShell();
|
return doc->GetPresShell();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -673,7 +673,7 @@ MOZ_CAN_RUN_SCRIPT void reportCompilationMessagesToConsole(
|
||||||
|
|
||||||
ErrorResult rv;
|
ErrorResult rv;
|
||||||
RefPtr<dom::Console> console =
|
RefPtr<dom::Console> console =
|
||||||
nsGlobalWindowInner::Cast(global->AsInnerWindow())->GetConsole(cx, rv);
|
nsGlobalWindowInner::Cast(global->GetAsInnerWindow())->GetConsole(cx, rv);
|
||||||
if (rv.Failed()) {
|
if (rv.Failed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ nsresult WebTaskSchedulerMainThread::SetTimeoutForDelayedTask(WebTask* aTask,
|
||||||
int32_t delay = aDelay > INT32_MAX ? INT32_MAX : (int32_t)aDelay;
|
int32_t delay = aDelay > INT32_MAX ? INT32_MAX : (int32_t)aDelay;
|
||||||
|
|
||||||
int32_t handle;
|
int32_t handle;
|
||||||
return global->AsInnerWindow()->TimeoutManager().SetTimeout(
|
return global->GetAsInnerWindow()->TimeoutManager().SetTimeout(
|
||||||
handler, delay, /* aIsInterval */ false,
|
handler, delay, /* aIsInterval */ false,
|
||||||
Timeout::Reason::eDelayedWebTaskTimeout, &handle);
|
Timeout::Reason::eDelayedWebTaskTimeout, &handle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -926,7 +926,7 @@ class BFCacheNotifyWTRunnable final : public WorkerProxyToMainThreadRunnable {
|
||||||
|
|
||||||
void WebTransport::NotifyToWindow(bool aCreated) const {
|
void WebTransport::NotifyToWindow(bool aCreated) const {
|
||||||
if (NS_IsMainThread()) {
|
if (NS_IsMainThread()) {
|
||||||
NotifyBFCacheOnMainThread(GetParentObject()->AsInnerWindow(), aCreated);
|
NotifyBFCacheOnMainThread(GetParentObject()->GetAsInnerWindow(), aCreated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ AutoRequestJSThreadExecution::AutoRequestJSThreadExecution(
|
||||||
|
|
||||||
nsPIDOMWindowInner* innerWindow = nullptr;
|
nsPIDOMWindowInner* innerWindow = nullptr;
|
||||||
if (aGlobalObject) {
|
if (aGlobalObject) {
|
||||||
innerWindow = aGlobalObject->AsInnerWindow();
|
innerWindow = aGlobalObject->GetAsInnerWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
DocGroup* docGroup = nullptr;
|
DocGroup* docGroup = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ already_AddRefed<Worker> Worker::Constructor(const GlobalObject& aGlobal,
|
||||||
nsCOMPtr<nsIGlobalObject> globalObject =
|
nsCOMPtr<nsIGlobalObject> globalObject =
|
||||||
do_QueryInterface(aGlobal.GetAsSupports());
|
do_QueryInterface(aGlobal.GetAsSupports());
|
||||||
|
|
||||||
if (globalObject->AsInnerWindow() &&
|
if (globalObject->GetAsInnerWindow() &&
|
||||||
!globalObject->AsInnerWindow()->IsCurrentInnerWindow()) {
|
!globalObject->GetAsInnerWindow()->IsCurrentInnerWindow()) {
|
||||||
aRv.ThrowInvalidStateError(
|
aRv.ThrowInvalidStateError(
|
||||||
"Cannot create worker for a going to be discarded document");
|
"Cannot create worker for a going to be discarded document");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace intl {
|
||||||
#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) || defined(DEBUG)
|
#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) || defined(DEBUG)
|
||||||
dom::Document* doc = nullptr;
|
dom::Document* doc = nullptr;
|
||||||
if (aGlobal) {
|
if (aGlobal) {
|
||||||
nsPIDOMWindowInner* innerWindow = aGlobal->AsInnerWindow();
|
nsPIDOMWindowInner* innerWindow = aGlobal->GetAsInnerWindow();
|
||||||
if (innerWindow) {
|
if (innerWindow) {
|
||||||
doc = innerWindow->GetExtantDoc();
|
doc = innerWindow->GetExtantDoc();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -856,7 +856,7 @@ nsFormFillController::HandleEvent(Event* aEvent) {
|
||||||
|
|
||||||
nsIGlobalObject* global = target->GetOwnerGlobal();
|
nsIGlobalObject* global = target->GetOwnerGlobal();
|
||||||
NS_ENSURE_STATE(global);
|
NS_ENSURE_STATE(global);
|
||||||
nsPIDOMWindowInner* inner = global->AsInnerWindow();
|
nsPIDOMWindowInner* inner = global->GetAsInnerWindow();
|
||||||
NS_ENSURE_STATE(inner);
|
NS_ENSURE_STATE(inner);
|
||||||
|
|
||||||
if (!inner->GetBrowsingContext()->IsContent()) {
|
if (!inner->GetBrowsingContext()->IsContent()) {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ SessionStoreChangeListener::HandleEvent(dom::Event* aEvent) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPIDOMWindowInner* inner = global->AsInnerWindow();
|
nsPIDOMWindowInner* inner = global->GetAsInnerWindow();
|
||||||
if (!inner) {
|
if (!inner) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -502,9 +502,10 @@ nsWindowWatcher::OpenWindowWithRemoteTab(nsIRemoteTab* aRemoteTab,
|
||||||
if (parentBC) {
|
if (parentBC) {
|
||||||
RefPtr<Element> browserElement = parentBC->Top()->GetEmbedderElement();
|
RefPtr<Element> browserElement = parentBC->Top()->GetEmbedderElement();
|
||||||
if (browserElement && browserElement->GetOwnerGlobal() &&
|
if (browserElement && browserElement->GetOwnerGlobal() &&
|
||||||
browserElement->GetOwnerGlobal()->AsInnerWindow()) {
|
browserElement->GetOwnerGlobal()->GetAsInnerWindow()) {
|
||||||
parentWindowOuter =
|
parentWindowOuter = browserElement->GetOwnerGlobal()
|
||||||
browserElement->GetOwnerGlobal()->AsInnerWindow()->GetOuterWindow();
|
->GetAsInnerWindow()
|
||||||
|
->GetOuterWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
isFissionWindow = parentBC->UseRemoteSubframes();
|
isFissionWindow = parentBC->UseRemoteSubframes();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue