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) {
|
||||
nsIGlobalObject* global = GetScopeObject();
|
||||
if (global) {
|
||||
if (nsPIDOMWindowInner* window = global->AsInnerWindow()) {
|
||||
if (nsPIDOMWindowInner* window = global->GetAsInnerWindow()) {
|
||||
nsGlobalWindowInner::Cast(window)
|
||||
->RegisterDataDocumentForMemoryReporting(this);
|
||||
}
|
||||
|
|
@ -7579,7 +7579,7 @@ void Document::SetScopeObject(nsIGlobalObject* aGlobal) {
|
|||
if (aGlobal) {
|
||||
mHasHadScriptHandlingObject = true;
|
||||
|
||||
nsPIDOMWindowInner* window = aGlobal->AsInnerWindow();
|
||||
nsPIDOMWindowInner* window = aGlobal->GetAsInnerWindow();
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -18712,7 +18712,7 @@ void Document::UnregisterFromMemoryReportingForDataDocument() {
|
|||
mAddedToMemoryReportingAsDataDocument = false;
|
||||
nsIGlobalObject* global = GetScopeObject();
|
||||
if (global) {
|
||||
if (nsPIDOMWindowInner* win = global->AsInnerWindow()) {
|
||||
if (nsPIDOMWindowInner* win = global->GetAsInnerWindow()) {
|
||||
nsGlobalWindowInner::Cast(win)->UnregisterDataDocumentForMemoryReporting(
|
||||
this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ bool StructuredCloneCallbacksSharedArrayBuffer(JSContext* cx, bool aReceiving,
|
|||
|
||||
nsPIDOMWindowInner* innerWindow = nullptr;
|
||||
if (global) {
|
||||
innerWindow = global->AsInnerWindow();
|
||||
innerWindow = global->GetAsInnerWindow();
|
||||
}
|
||||
|
||||
DocGroup* docGroup = nullptr;
|
||||
|
|
|
|||
|
|
@ -10882,7 +10882,7 @@ bool nsContentUtils::
|
|||
static nsGlobalWindowInner* GetInnerWindowForGlobal(nsIGlobalObject* aGlobal) {
|
||||
NS_ENSURE_TRUE(aGlobal, nullptr);
|
||||
|
||||
if (auto* window = aGlobal->AsInnerWindow()) {
|
||||
if (auto* window = aGlobal->GetAsInnerWindow()) {
|
||||
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
|
||||
// pointer.
|
||||
return nsGlobalWindowInner::Cast(aGlobal->AsInnerWindow());
|
||||
return nsGlobalWindowInner::Cast(aGlobal->GetAsInnerWindow());
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ mozilla::StorageAccess nsIGlobalObject::GetStorageAccess() {
|
|||
return mozilla::StorageAccess::eDeny;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* nsIGlobalObject::AsInnerWindow() {
|
||||
nsPIDOMWindowInner* nsIGlobalObject::GetAsInnerWindow() {
|
||||
if (MOZ_LIKELY(mIsInnerWindow)) {
|
||||
return static_cast<nsPIDOMWindowInner*>(
|
||||
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
|
||||
// nullptr otherwise.
|
||||
nsPIDOMWindowInner* AsInnerWindow();
|
||||
nsPIDOMWindowInner* GetAsInnerWindow();
|
||||
|
||||
void QueueMicrotask(mozilla::dom::VoidFunction& aCallback);
|
||||
|
||||
|
|
|
|||
|
|
@ -2548,7 +2548,7 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
|
|||
ErrorResult& aRv) {
|
||||
if (StaticPrefs::dom_security_sanitizer_logging()) {
|
||||
mLogRemovals = true;
|
||||
if (nsPIDOMWindowInner* win = aGlobal->AsInnerWindow()) {
|
||||
if (nsPIDOMWindowInner* win = aGlobal->GetAsInnerWindow()) {
|
||||
mInnerWindowID = win->WindowID();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ already_AddRefed<Document> Event::GetDocument() const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* win = global->AsInnerWindow();
|
||||
nsPIDOMWindowInner* win = global->GetAsInnerWindow();
|
||||
if (!win) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -321,7 +321,7 @@ bool Event::ShouldIgnoreChromeEventTargetListener() const {
|
|||
if (NS_WARN_IF(!global)) {
|
||||
return false;
|
||||
}
|
||||
nsPIDOMWindowInner* win = global->AsInnerWindow();
|
||||
nsPIDOMWindowInner* win = global->GetAsInnerWindow();
|
||||
if (NS_WARN_IF(!win)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -418,7 +418,7 @@ void Event::PreventDefaultInternal(bool aCalledByDefaultHandler,
|
|||
return;
|
||||
}
|
||||
if (mEvent->mFlags.mInPassiveListener) {
|
||||
if (nsPIDOMWindowInner* win = mOwner->AsInnerWindow()) {
|
||||
if (nsPIDOMWindowInner* win = mOwner->GetAsInnerWindow()) {
|
||||
if (Document* doc = win->GetExtantDoc()) {
|
||||
if (!doc->HasWarnedAbout(
|
||||
Document::ePreventDefaultFromPassiveListener)) {
|
||||
|
|
@ -762,7 +762,7 @@ double Event::TimeStamp() {
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* win = mOwner->AsInnerWindow();
|
||||
nsPIDOMWindowInner* win = mOwner->GetAsInnerWindow();
|
||||
if (NS_WARN_IF(!win)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1425,7 +1425,7 @@ already_AddRefed<nsPIDOMWindowInner> EventListenerManager::WindowFromListener(
|
|||
global = callback->IncumbentGlobalOrNull();
|
||||
}
|
||||
if (global) {
|
||||
innerWindow = global->AsInnerWindow(); // Can be nullptr
|
||||
innerWindow = global->GetAsInnerWindow(); // Can be nullptr
|
||||
}
|
||||
} else {
|
||||
// This ensures `window.event` can be set properly for
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ void DOMLocalization::ReportL10nOverlaysErrors(
|
|||
u"Unknown error happened while translating an element.");
|
||||
break;
|
||||
}
|
||||
nsPIDOMWindowInner* innerWindow = GetParentObject()->AsInnerWindow();
|
||||
nsPIDOMWindowInner* innerWindow = GetParentObject()->GetAsInnerWindow();
|
||||
Document* doc = innerWindow ? innerWindow->GetExtantDoc() : nullptr;
|
||||
if (doc) {
|
||||
nsContentUtils::ReportToConsoleNonLocalized(
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ Document* L10nMutations::GetDocument() const {
|
|||
if (!mDOMLocalization) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* innerWindow = mDOMLocalization->GetParentObject()->AsInnerWindow();
|
||||
auto* innerWindow = mDOMLocalization->GetParentObject()->GetAsInnerWindow();
|
||||
if (!innerWindow) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void LockManagerChild::NotifyRequestDestroy() const { NotifyToWindow(false); }
|
|||
|
||||
void LockManagerChild::NotifyToWindow(bool aCreated) const {
|
||||
if (NS_IsMainThread()) {
|
||||
NotifyBFCacheOnMainThread(GetParentObject()->AsInnerWindow(), aCreated);
|
||||
NotifyBFCacheOnMainThread(GetParentObject()->GetAsInnerWindow(), aCreated);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1489,7 +1489,7 @@ NotificationPermission Notification::GetPermission(const GlobalObject& aGlobal,
|
|||
NotificationPermission Notification::GetPermission(nsIGlobalObject* aGlobal,
|
||||
ErrorResult& aRv) {
|
||||
if (NS_IsMainThread()) {
|
||||
return GetPermissionInternal(aGlobal->AsInnerWindow(), aRv);
|
||||
return GetPermissionInternal(aGlobal->GetAsInnerWindow(), aRv);
|
||||
} else {
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(worker);
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ mozilla::PresShell* PerformanceMainThread::GetPresShell() {
|
|||
if (!ownerGlobal) {
|
||||
return nullptr;
|
||||
}
|
||||
if (Document* doc = ownerGlobal->AsInnerWindow()->GetExtantDoc()) {
|
||||
if (Document* doc = ownerGlobal->GetAsInnerWindow()->GetExtantDoc()) {
|
||||
return doc->GetPresShell();
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ MOZ_CAN_RUN_SCRIPT void reportCompilationMessagesToConsole(
|
|||
|
||||
ErrorResult rv;
|
||||
RefPtr<dom::Console> console =
|
||||
nsGlobalWindowInner::Cast(global->AsInnerWindow())->GetConsole(cx, rv);
|
||||
nsGlobalWindowInner::Cast(global->GetAsInnerWindow())->GetConsole(cx, rv);
|
||||
if (rv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ nsresult WebTaskSchedulerMainThread::SetTimeoutForDelayedTask(WebTask* aTask,
|
|||
int32_t delay = aDelay > INT32_MAX ? INT32_MAX : (int32_t)aDelay;
|
||||
|
||||
int32_t handle;
|
||||
return global->AsInnerWindow()->TimeoutManager().SetTimeout(
|
||||
return global->GetAsInnerWindow()->TimeoutManager().SetTimeout(
|
||||
handler, delay, /* aIsInterval */ false,
|
||||
Timeout::Reason::eDelayedWebTaskTimeout, &handle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,7 +926,7 @@ class BFCacheNotifyWTRunnable final : public WorkerProxyToMainThreadRunnable {
|
|||
|
||||
void WebTransport::NotifyToWindow(bool aCreated) const {
|
||||
if (NS_IsMainThread()) {
|
||||
NotifyBFCacheOnMainThread(GetParentObject()->AsInnerWindow(), aCreated);
|
||||
NotifyBFCacheOnMainThread(GetParentObject()->GetAsInnerWindow(), aCreated);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ AutoRequestJSThreadExecution::AutoRequestJSThreadExecution(
|
|||
|
||||
nsPIDOMWindowInner* innerWindow = nullptr;
|
||||
if (aGlobalObject) {
|
||||
innerWindow = aGlobalObject->AsInnerWindow();
|
||||
innerWindow = aGlobalObject->GetAsInnerWindow();
|
||||
}
|
||||
|
||||
DocGroup* docGroup = nullptr;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ already_AddRefed<Worker> Worker::Constructor(const GlobalObject& aGlobal,
|
|||
nsCOMPtr<nsIGlobalObject> globalObject =
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
if (globalObject->AsInnerWindow() &&
|
||||
!globalObject->AsInnerWindow()->IsCurrentInnerWindow()) {
|
||||
if (globalObject->GetAsInnerWindow() &&
|
||||
!globalObject->GetAsInnerWindow()->IsCurrentInnerWindow()) {
|
||||
aRv.ThrowInvalidStateError(
|
||||
"Cannot create worker for a going to be discarded document");
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace intl {
|
|||
#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) || defined(DEBUG)
|
||||
dom::Document* doc = nullptr;
|
||||
if (aGlobal) {
|
||||
nsPIDOMWindowInner* innerWindow = aGlobal->AsInnerWindow();
|
||||
nsPIDOMWindowInner* innerWindow = aGlobal->GetAsInnerWindow();
|
||||
if (innerWindow) {
|
||||
doc = innerWindow->GetExtantDoc();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ nsFormFillController::HandleEvent(Event* aEvent) {
|
|||
|
||||
nsIGlobalObject* global = target->GetOwnerGlobal();
|
||||
NS_ENSURE_STATE(global);
|
||||
nsPIDOMWindowInner* inner = global->AsInnerWindow();
|
||||
nsPIDOMWindowInner* inner = global->GetAsInnerWindow();
|
||||
NS_ENSURE_STATE(inner);
|
||||
|
||||
if (!inner->GetBrowsingContext()->IsContent()) {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ SessionStoreChangeListener::HandleEvent(dom::Event* aEvent) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* inner = global->AsInnerWindow();
|
||||
nsPIDOMWindowInner* inner = global->GetAsInnerWindow();
|
||||
if (!inner) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -502,9 +502,10 @@ nsWindowWatcher::OpenWindowWithRemoteTab(nsIRemoteTab* aRemoteTab,
|
|||
if (parentBC) {
|
||||
RefPtr<Element> browserElement = parentBC->Top()->GetEmbedderElement();
|
||||
if (browserElement && browserElement->GetOwnerGlobal() &&
|
||||
browserElement->GetOwnerGlobal()->AsInnerWindow()) {
|
||||
parentWindowOuter =
|
||||
browserElement->GetOwnerGlobal()->AsInnerWindow()->GetOuterWindow();
|
||||
browserElement->GetOwnerGlobal()->GetAsInnerWindow()) {
|
||||
parentWindowOuter = browserElement->GetOwnerGlobal()
|
||||
->GetAsInnerWindow()
|
||||
->GetOuterWindow();
|
||||
}
|
||||
|
||||
isFissionWindow = parentBC->UseRemoteSubframes();
|
||||
|
|
|
|||
Loading…
Reference in a new issue