Bug 1543564 part 2. Get rid of pointless nsPIDOMWindowInner::AsInner methods. r=farre
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 11 Apr 2019 14:12:43 +0000
changeset 469191 27a7ba7282164c8806cb8ed93d3353677371c7b4
parent 469190 a1b827eab86fd647764e3ce220617bbfa046e6f0
child 469192 abafb9533234acd5cb0cd687163143d35aa6a00c
push id35858
push usershindli@mozilla.com
push dateFri, 12 Apr 2019 09:34:00 +0000
treeherdermozilla-central@a632dfa60af6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1543564
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1543564 part 2. Get rid of pointless nsPIDOMWindowInner::AsInner methods. r=farre Differential Revision: https://phabricator.services.mozilla.com/D27027
docshell/base/nsDocShell.cpp
dom/base/BarProps.cpp
dom/base/PostMessageEvent.cpp
dom/base/TimeoutManager.cpp
dom/base/WindowOrientationObserver.cpp
dom/base/nsCCUncollectableMarker.cpp
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsGlobalWindowOuter.h
dom/base/nsINode.cpp
dom/base/nsPIDOMWindow.h
dom/base/nsPIDOMWindowInlines.h
dom/bindings/CallbackObject.cpp
dom/canvas/CanvasRenderingContext2D.cpp
dom/gamepad/GamepadManager.cpp
dom/media/MediaManager.cpp
dom/presentation/PresentationSessionInfo.cpp
dom/presentation/ipc/PresentationBuilderChild.cpp
dom/presentation/ipc/PresentationIPCService.cpp
dom/promise/Promise.cpp
dom/script/ScriptSettings.cpp
dom/vr/VREventObserver.cpp
dom/xbl/nsXBLPrototypeHandler.cpp
js/xpconnect/src/XPCComponents.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
xpfe/appshell/nsWindowMediator.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -9088,17 +9088,17 @@ nsresult nsDocShell::MaybeHandleSameDocu
     // Fire a hashchange event URIs differ, and only in their hashes.
     bool doHashchange = sameExceptHashes && (curURIHasRef != newURIHasRef ||
                                              !curHash.Equals(newHash));
 
     if (historyNavBetweenSameDoc || doHashchange) {
       win->DispatchSyncPopState();
     }
 
-    if (needsScrollPosUpdate && win->AsInner()->HasActiveDocument()) {
+    if (needsScrollPosUpdate && win->HasActiveDocument()) {
       SetCurScrollPosEx(bx, by);
     }
 
     if (doHashchange) {
       // Note that currentURI hasn't changed because it's on the
       // stack, so we can just use it directly as the old URI.
       win->DispatchAsyncHashchange(currentURI, aLoadState->URI());
     }
--- a/dom/base/BarProps.cpp
+++ b/dom/base/BarProps.cpp
@@ -17,19 +17,17 @@ namespace dom {
 
 //
 //  Basic (virtual) BarProp class implementation
 //
 BarProp::BarProp(nsGlobalWindowInner* aWindow) : mDOMWindow(aWindow) {}
 
 BarProp::~BarProp() {}
 
-nsPIDOMWindowInner* BarProp::GetParentObject() const {
-  return mDOMWindow->AsInner();
-}
+nsPIDOMWindowInner* BarProp::GetParentObject() const { return mDOMWindow; }
 
 JSObject* BarProp::WrapObject(JSContext* aCx,
                               JS::Handle<JSObject*> aGivenProto) {
   return BarProp_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(BarProp, mDOMWindow)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(BarProp)
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -152,17 +152,17 @@ PostMessageEvent::Run() {
 
   IgnoredErrorResult rv;
   JS::Rooted<JS::Value> messageData(cx);
   nsCOMPtr<mozilla::dom::EventTarget> eventTarget =
       do_QueryObject(targetWindow);
 
   StructuredCloneHolder* holder;
   if (mHolder.constructed<StructuredCloneHolder>()) {
-    mHolder.ref<StructuredCloneHolder>().Read(targetWindow->AsInner(), cx,
+    mHolder.ref<StructuredCloneHolder>().Read(ToSupports(targetWindow), cx,
                                               &messageData, rv);
     holder = &mHolder.ref<StructuredCloneHolder>();
   } else {
     MOZ_ASSERT(mHolder.constructed<ipc::StructuredCloneData>());
     mHolder.ref<ipc::StructuredCloneData>().Read(cx, &messageData, rv);
     holder = &mHolder.ref<ipc::StructuredCloneData>();
   }
   if (NS_WARN_IF(rv.Failed())) {
@@ -218,14 +218,14 @@ void PostMessageEvent::Dispatch(nsGlobal
 
   RefPtr<nsPresContext> presContext =
       aTargetWindow->GetExtantDoc()->GetPresContext();
 
   aEvent->SetTrusted(true);
   WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
 
   nsEventStatus status = nsEventStatus_eIgnore;
-  EventDispatcher::Dispatch(aTargetWindow->AsInner(), presContext,
+  EventDispatcher::Dispatch(ToSupports(aTargetWindow), presContext,
                             internalEvent, aEvent, &status);
 }
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -117,17 +117,17 @@ bool TimeoutManager::IsActive() const {
   // Note that a window can be considered active if it is either in the
   // foreground or in the background.
 
   if (mWindow.IsChromeWindow()) {
     return true;
   }
 
   // Check if we're playing audio
-  if (mWindow.AsInner()->IsPlayingAudio()) {
+  if (mWindow.IsPlayingAudio()) {
     return true;
   }
 
   return false;
 }
 
 void TimeoutManager::SetLoading(bool value) {
   // When moving from loading to non-loading, we may need to
@@ -1222,17 +1222,17 @@ void TimeoutManager::Suspend() {
 }
 
 void TimeoutManager::Resume() {
   MOZ_LOG(gTimeoutLog, LogLevel::Debug, ("Resume(TimeoutManager=%p)\n", this));
 
   // When Suspend() has been called after IsDocumentLoaded(), but the
   // throttle tracking timer never managed to fire, start the timer
   // again.
-  if (mWindow.AsInner()->IsDocumentLoaded() && !mThrottleTimeouts) {
+  if (mWindow.IsDocumentLoaded() && !mThrottleTimeouts) {
     MaybeStartThrottleTimeout();
   }
 
   Timeout* nextTimeout = mTimeouts.GetFirst();
   if (nextTimeout) {
     MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
   }
   nextTimeout = mIdleTimeouts.GetFirst();
@@ -1323,17 +1323,17 @@ class ThrottleTimeoutsCallback final : p
   // object itself alive.
   RefPtr<nsGlobalWindowInner> mWindow;
 };
 
 NS_IMPL_ISUPPORTS(ThrottleTimeoutsCallback, nsITimerCallback, nsINamed)
 
 NS_IMETHODIMP
 ThrottleTimeoutsCallback::Notify(nsITimer* aTimer) {
-  mWindow->AsInner()->TimeoutManager().StartThrottlingTimeouts();
+  mWindow->TimeoutManager().StartThrottlingTimeouts();
   mWindow = nullptr;
   return NS_OK;
 }
 
 }  // namespace
 
 bool TimeoutManager::BudgetThrottlingEnabled(bool aIsBackground) const {
   // A window can be throttled using budget if
@@ -1350,26 +1350,26 @@ bool TimeoutManager::BudgetThrottlingEna
     return false;
   }
 
   if (!mBudgetThrottleTimeouts || IsActive()) {
     return false;
   }
 
   // Check if there are any active IndexedDB databases
-  if (mWindow.AsInner()->HasActiveIndexedDBDatabases()) {
+  if (mWindow.HasActiveIndexedDBDatabases()) {
     return false;
   }
 
   // Check if we have active PeerConnection
-  if (mWindow.AsInner()->HasActivePeerConnections()) {
+  if (mWindow.HasActivePeerConnections()) {
     return false;
   }
 
-  if (mWindow.AsInner()->HasOpenWebSockets()) {
+  if (mWindow.HasOpenWebSockets()) {
     return false;
   }
 
   return true;
 }
 
 void TimeoutManager::StartThrottlingTimeouts() {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/base/WindowOrientationObserver.cpp
+++ b/dom/base/WindowOrientationObserver.cpp
@@ -30,17 +30,17 @@ WindowOrientationObserver::WindowOrienta
 
 WindowOrientationObserver::~WindowOrientationObserver() {
   hal::UnregisterScreenConfigurationObserver(this);
 }
 
 void WindowOrientationObserver::Notify(
     const mozilla::hal::ScreenConfiguration& aConfiguration) {
   uint16_t currentAngle = aConfiguration.angle();
-  if (mAngle != currentAngle && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mAngle != currentAngle && mWindow->IsCurrentInnerWindow()) {
     mAngle = currentAngle;
     mWindow->GetOuterWindow()->DispatchCustomEvent(
         NS_LITERAL_STRING("orientationchange"));
   }
 }
 
 /* static */
 int16_t WindowOrientationObserver::OrientationAngle() {
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -178,26 +178,24 @@ void MarkContentViewer(nsIContentViewer*
   if (doc &&
       doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
     doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
     if (aCleanupJS) {
       EventListenerManager* elm = doc->GetExistingListenerManager();
       if (elm) {
         elm->MarkForCC();
       }
-      nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow());
+      RefPtr<nsGlobalWindowInner> win =
+          nsGlobalWindowInner::Cast(doc->GetInnerWindow());
       if (win) {
         elm = win->GetExistingListenerManager();
         if (elm) {
           elm->MarkForCC();
         }
-        static_cast<nsGlobalWindowInner*>(win.get())
-            ->AsInner()
-            ->TimeoutManager()
-            .UnmarkGrayTimers();
+        win->TimeoutManager().UnmarkGrayTimers();
       }
     }
   }
   if (doc) {
     if (nsPIDOMWindowInner* inner = doc->GetInnerWindow()) {
       inner->MarkUncollectableForCCGeneration(
           nsCCUncollectableMarker::sGeneration);
     }
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -1807,17 +1807,17 @@ nsresult nsGlobalWindowInner::EnsureClie
 
   return NS_OK;
 }
 
 nsresult nsGlobalWindowInner::ExecutionReady() {
   nsresult rv = EnsureClientSource();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = mClientSource->WindowExecutionReady(AsInner());
+  rv = mClientSource->WindowExecutionReady(this);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 void nsGlobalWindowInner::UpdateParentTarget() {
   // NOTE: This method is identical to
   // nsGlobalWindowOuter::UpdateParentTarget(). IF YOU UPDATE THIS METHOD,
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -2066,17 +2066,17 @@ nsresult nsGlobalWindowOuter::SetNewDocu
     if (currentInner && currentInner->GetWrapperPreserveColor()) {
       // Don't free objects on our current inner window if it's going to be
       // held in the bfcache.
       if (!currentInner->IsFrozen()) {
         doomCurrentInner = true;
       }
     }
 
-    mInnerWindow = newInnerWindow->AsInner();
+    mInnerWindow = newInnerWindow;
     MOZ_ASSERT(mInnerWindow);
     mInnerWindow->TryToCacheTopInnerWindow();
 
     if (!GetWrapperPreserveColor()) {
       JS::Rooted<JSObject*> outer(
           cx, NewOuterWindowProxy(cx, newInnerGlobal, thisChrome));
       NS_ENSURE_TRUE(outer, NS_ERROR_FAILURE);
 
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -1203,14 +1203,14 @@ inline bool nsGlobalWindowOuter::IsTopLe
 inline bool nsGlobalWindowOuter::IsPopupSpamWindow() { return mIsPopupSpam; }
 
 inline bool nsGlobalWindowOuter::IsFrame() {
   return GetParentInternal() != nullptr;
 }
 
 inline void nsGlobalWindowOuter::MaybeClearInnerWindow(
     nsGlobalWindowInner* aExpectedInner) {
-  if (mInnerWindow == aExpectedInner->AsInner()) {
+  if (mInnerWindow == aExpectedInner) {
     mInnerWindow = nullptr;
   }
 }
 
 #endif /* nsGlobalWindowOuter_h___ */
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1040,20 +1040,21 @@ EventListenerManager* nsINode::GetOrCrea
 }
 
 EventListenerManager* nsINode::GetExistingListenerManager() const {
   return nsContentUtils::GetExistingListenerManagerForNode(this);
 }
 
 nsPIDOMWindowOuter* nsINode::GetOwnerGlobalForBindingsInternal() {
   bool dummy;
+  // FIXME(bz): This cast is a bit bogus.  See
+  // https://bugzilla.mozilla.org/show_bug.cgi?id=1515709
   auto* window = static_cast<nsGlobalWindowInner*>(
       OwnerDoc()->GetScriptHandlingObject(dummy));
-  return window ? nsPIDOMWindowOuter::GetFromCurrentInner(window->AsInner())
-                : nullptr;
+  return window ? nsPIDOMWindowOuter::GetFromCurrentInner(window) : nullptr;
 }
 
 nsIGlobalObject* nsINode::GetOwnerGlobal() const {
   bool dummy;
   return OwnerDoc()->GetScriptHandlingObject(dummy);
 }
 
 bool nsINode::UnoptimizableCCNode() const {
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -140,19 +140,16 @@ class nsPIDOMWindowInner : public mozIDO
 
   explicit nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow);
 
   ~nsPIDOMWindowInner();
 
  public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOWINNER_IID)
 
-  nsPIDOMWindowInner* AsInner() { return this; }
-  const nsPIDOMWindowInner* AsInner() const { return this; }
-
   nsIGlobalObject* AsGlobal();
   const nsIGlobalObject* AsGlobal() const;
 
   nsPIDOMWindowOuter* GetOuterWindow() const { return mOuterWindow; }
 
   static nsPIDOMWindowInner* From(mozIDOMWindow* aFrom) {
     return static_cast<nsPIDOMWindowInner*>(aFrom);
   }
--- a/dom/base/nsPIDOMWindowInlines.h
+++ b/dom/base/nsPIDOMWindowInlines.h
@@ -44,17 +44,17 @@ bool nsPIDOMWindowInner::IsHandlingResiz
 
     return false;
   }
 
   return mIsHandlingResizeEvent;
 }
 
 bool nsPIDOMWindowInner::IsCurrentInnerWindow() const {
-  return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == AsInner();
+  return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this;
 }
 
 bool nsPIDOMWindowInner::HasActiveDocument() {
   return IsCurrentInnerWindow() ||
          (mOuterWindow && mOuterWindow->GetCurrentInnerWindow() &&
           mOuterWindow->GetCurrentInnerWindow()->GetDoc() == mDoc);
 }
 
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -183,17 +183,17 @@ CallbackObject::CallSetup::CallSetup(Cal
     // Now get the global for this callback. Note that for the case of
     // JS-implemented WebIDL we never have a window here.
     nsGlobalWindowInner* win = mIsMainThread && !aIsJSImplementedWebIDL
                                    ? xpc::WindowGlobalOrNull(realCallback)
                                    : nullptr;
     if (win) {
       // We don't want to run script in windows that have been navigated away
       // from.
-      if (!win->AsInner()->HasActiveDocument()) {
+      if (!win->HasActiveDocument()) {
         aRv.ThrowDOMException(
             NS_ERROR_DOM_NOT_SUPPORTED_ERR,
             NS_LITERAL_CSTRING("Refusing to execute function from window "
                                "whose document is no longer active."));
         return;
       }
       globalObject = win;
     } else {
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4621,17 +4621,17 @@ void CanvasRenderingContext2D::DrawWindo
   // or overflow issues
   if (!Factory::CheckSurfaceSize(IntSize(int32_t(aW), int32_t(aH)), 0xffff)) {
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   // Flush layout updates
   if (!(aFlags & CanvasRenderingContext2D_Binding::DRAWWINDOW_DO_NOT_FLUSH)) {
-    nsContentUtils::FlushLayoutForTree(aWindow.AsInner()->GetOuterWindow());
+    nsContentUtils::FlushLayoutForTree(aWindow.GetOuterWindow());
   }
 
   CompositionOp op = UsedOperation();
   bool discardContent =
       GlobalAlpha() == 1.0f &&
       (op == CompositionOp::OP_OVER || op == CompositionOp::OP_SOURCE);
   const gfx::Rect drawRect(aX, aY, aW, aH);
   EnsureTarget(discardContent ? &drawRect : nullptr);
--- a/dom/gamepad/GamepadManager.cpp
+++ b/dom/gamepad/GamepadManager.cpp
@@ -307,17 +307,17 @@ void GamepadManager::NewConnectionEvent(
       // Do not fire gamepadconnected and gamepaddisconnected events when
       // privacy.resistFingerprinting is true.
       if (nsContentUtils::ShouldResistFingerprinting(
               listeners[i]->GetExtantDoc())) {
         continue;
       }
 
       // Only send events to non-background windows
-      if (!listeners[i]->AsInner()->IsCurrentInnerWindow() ||
+      if (!listeners[i]->IsCurrentInnerWindow() ||
           listeners[i]->GetOuterWindow()->IsBackground()) {
         continue;
       }
 
       // We don't fire a connected event here unless the window
       // has seen input from at least one device.
       if (!listeners[i]->HasSeenGamepadInput()) {
         continue;
@@ -484,17 +484,17 @@ void GamepadManager::Update(const Gamepa
   }
 
   // Hold on to listeners in a separate array because firing events
   // can mutate the mListeners array.
   nsTArray<RefPtr<nsGlobalWindowInner>> listeners(mListeners);
 
   for (uint32_t i = 0; i < listeners.Length(); i++) {
     // Only send events to non-background windows
-    if (!listeners[i]->AsInner()->IsCurrentInnerWindow() ||
+    if (!listeners[i]->IsCurrentInnerWindow() ||
         listeners[i]->GetOuterWindow()->IsBackground()) {
       continue;
     }
 
     SetGamepadByEvent(aEvent, listeners[i]);
     MaybeConvertToNonstandardGamepadEvent(aEvent, listeners[i]);
   }
 }
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -531,17 +531,17 @@ class GetUserMediaWindowListener {
     GetUserMediaWindowListener* windowListener =
         mgr->GetWindowListener(mWindowID);
 
     if (!windowListener) {
       nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
       auto* globalWindow = nsGlobalWindowInner::GetInnerWindowWithId(mWindowID);
       if (globalWindow) {
         auto req = MakeRefPtr<GetUserMediaRequest>(
-            globalWindow->AsInner(), VoidString(), VoidString(),
+            globalWindow, VoidString(), VoidString(),
             EventStateManager::IsHandlingUserInput());
         obs->NotifyObservers(req, "recording-device-stopped", nullptr);
       }
       return;
     }
 
     MOZ_ASSERT(windowListener == this,
                "There should only be one window listener per window ID");
@@ -582,19 +582,17 @@ class GetUserMediaWindowListener {
             revokeVideoPermission = false;
             break;
           }
         }
       }
 
       if (revokeVideoPermission) {
         nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-        auto* globalWindow =
-            nsGlobalWindowInner::GetInnerWindowWithId(mWindowID);
-        auto* window = globalWindow ? globalWindow->AsInner() : nullptr;
+        auto* window = nsGlobalWindowInner::GetInnerWindowWithId(mWindowID);
         auto req = MakeRefPtr<GetUserMediaRequest>(
             window, removedRawId, removedSourceType,
             EventStateManager::IsHandlingUserInput());
         obs->NotifyObservers(req, "recording-device-stopped", nullptr);
       }
     }
 
     if (MediaDevice* removedDevice = aListener->GetAudioDevice()) {
@@ -611,20 +609,17 @@ class GetUserMediaWindowListener {
             revokeAudioPermission = false;
             break;
           }
         }
       }
 
       if (revokeAudioPermission) {
         nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-        auto* globalWindow =
-            nsGlobalWindowInner::GetInnerWindowWithId(mWindowID);
-        nsPIDOMWindowInner* window =
-            globalWindow ? globalWindow->AsInner() : nullptr;
+        auto* window = nsGlobalWindowInner::GetInnerWindowWithId(mWindowID);
         auto req = MakeRefPtr<GetUserMediaRequest>(
             window, removedRawId, removedSourceType,
             EventStateManager::IsHandlingUserInput());
         obs->NotifyObservers(req, "recording-device-stopped", nullptr);
       }
     }
 
     if (mInactiveListeners.Length() == 0 && mActiveListeners.Length() == 0) {
@@ -1097,20 +1092,18 @@ class GetUserMediaStreamRunnable : publi
     // Graph thread only.
     bool mDispatchedTracksCreated = false;
   };
 
   NS_IMETHOD
   Run() override {
     MOZ_ASSERT(NS_IsMainThread());
     LOG("GetUserMediaStreamRunnable::Run()");
-    nsGlobalWindowInner* globalWindow =
+    nsGlobalWindowInner* window =
         nsGlobalWindowInner::GetInnerWindowWithId(mWindowID);
-    nsPIDOMWindowInner* window =
-        globalWindow ? globalWindow->AsInner() : nullptr;
 
     // We're on main-thread, and the windowlist can only
     // be invalidated from the main-thread (see OnNavigation)
     if (!mManager->IsWindowListenerStillActive(mWindowListener)) {
       // This window is no longer live. mListener has already been removed.
       return NS_OK;
     }
 
@@ -2212,17 +2205,17 @@ void MediaManager::OnDeviceChange() {
                     if (!windowsById) {
                       continue;
                     }
 
                     for (auto iter = windowsById->Iter(); !iter.Done();
                          iter.Next()) {
                       nsGlobalWindowInner* window = iter.Data();
                       self->IterateWindowListeners(
-                          window->AsInner(),
+                          window,
                           [&id](const RefPtr<GetUserMediaWindowListener>&
                                     aListener) { aListener->StopRawID(id); });
                     }
                   }
 
                   self->mDeviceIDs = deviceIDs;
                 },
                 [](RefPtr<MediaMgrError>&& reason) {});
@@ -2743,20 +2736,18 @@ RefPtr<MediaManager::StreamPromise> Medi
                               MediaSinkEnum::Other, videoEnumerationType,
                               audioEnumerationType, true, devices)
       ->Then(
           GetCurrentThreadSerialEventTarget(), __func__,
           [self, windowID, c, windowListener, isChrome, devices](bool) {
             LOG("GetUserMedia: post enumeration promise success callback "
                 "starting");
             // Ensure that our windowID is still good.
-            auto* globalWindow =
+            RefPtr<nsPIDOMWindowInner> window =
                 nsGlobalWindowInner::GetInnerWindowWithId(windowID);
-            RefPtr<nsPIDOMWindowInner> window =
-                globalWindow ? globalWindow->AsInner() : nullptr;
             if (!window || !self->IsWindowListenerStillActive(windowListener)) {
               LOG("GetUserMedia: bad window (%" PRIu64
                   ") in post enumeration success callback!",
                   windowID);
               return BadConstraintsPromise::CreateAndReject(
                   MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
                   __func__);
             }
@@ -2773,20 +2764,18 @@ RefPtr<MediaManager::StreamPromise> Medi
           GetCurrentThreadSerialEventTarget(), __func__,
           [self, windowID, c, windowListener, sourceListener, askPermission,
            prefs, isHTTPS, isHandlingUserInput, callID, principalInfo, isChrome,
            devices, resistFingerprinting](const char* badConstraint) mutable {
             LOG("GetUserMedia: starting post enumeration promise2 success "
                 "callback!");
 
             // Ensure that the window is still good.
-            auto* globalWindow =
+            RefPtr<nsPIDOMWindowInner> window =
                 nsGlobalWindowInner::GetInnerWindowWithId(windowID);
-            RefPtr<nsPIDOMWindowInner> window =
-                globalWindow ? globalWindow->AsInner() : nullptr;
             if (!window || !self->IsWindowListenerStillActive(windowListener)) {
               LOG("GetUserMedia: bad window (%" PRIu64
                   ") in post enumeration success callback 2!",
                   windowID);
               return StreamPromise::CreateAndReject(
                   MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
                   __func__);
             }
@@ -3079,18 +3068,17 @@ RefPtr<MediaManager::MgrPromise> MediaMa
 
   LOG("%s: aWindowId=%" PRIu64 ", aVideoInputType=%" PRIu8
       ", aAudioInputType=%" PRIu8 ", aVideoInputEnumType=%" PRIu8
       ", aAudioInputEnumType=%" PRIu8,
       __func__, aWindowId, static_cast<uint8_t>(aVideoInputType),
       static_cast<uint8_t>(aAudioInputType),
       static_cast<uint8_t>(aVideoInputEnumType),
       static_cast<uint8_t>(aAudioInputEnumType));
-  auto* window =
-      nsGlobalWindowInner::GetInnerWindowWithId(aWindowId)->AsInner();
+  auto* window = nsGlobalWindowInner::GetInnerWindowWithId(aWindowId);
 
   // To get a device list anonymized for a particular origin, we must:
   // 1. Get an origin-key (for either regular or private browsing)
   // 2. Get the raw devices list
   // 3. Anonymize the raw list with the origin-key.
 
   nsCOMPtr<nsIPrincipal> principal =
       nsGlobalWindowInner::Cast(window)->GetPrincipal();
@@ -3394,20 +3382,19 @@ void MediaManager::OnNavigation(uint64_t
     mCallIds.Remove(aWindowID);
   }
 
   // This is safe since we're on main-thread, and the windowlist can only
   // be added to from the main-thread
   auto* window = nsGlobalWindowInner::GetInnerWindowWithId(aWindowID);
   if (window) {
     IterateWindowListeners(
-        window->AsInner(),
-        [self = RefPtr<MediaManager>(this),
-         windowID = DebugOnly<decltype(aWindowID)>(aWindowID)](
-            const RefPtr<GetUserMediaWindowListener>& aListener) {
+        window, [self = RefPtr<MediaManager>(this),
+                 windowID = DebugOnly<decltype(aWindowID)>(aWindowID)](
+                    const RefPtr<GetUserMediaWindowListener>& aListener) {
           aListener->RemoveAll();
           MOZ_ASSERT(!self->GetWindowListener(windowID));
         });
   } else {
     RemoveWindowID(aWindowID);
   }
   MOZ_ASSERT(!GetWindowListener(aWindowID));
 
@@ -3450,17 +3437,17 @@ void MediaManager::RemoveWindowID(uint64
 
   // get outer windowID
   auto* window = nsGlobalWindowInner::GetInnerWindowWithId(aWindowId);
   if (!window) {
     LOG("No inner window for %" PRIu64, aWindowId);
     return;
   }
 
-  auto* outer = window->AsInner()->GetOuterWindow();
+  auto* outer = window->GetOuterWindow();
   if (!outer) {
     LOG("No outer window for inner %" PRIu64, aWindowId);
     return;
   }
 
   uint64_t outerID = outer->WindowID();
 
   // Notify the UI that this window no longer has gUM active
@@ -3827,25 +3814,25 @@ nsresult MediaManager::GetActiveMediaCap
 
   for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) {
     const uint64_t& id = iter.Key();
     RefPtr<GetUserMediaWindowListener> winListener = iter.UserData();
     if (!winListener) {
       continue;
     }
 
-    auto* window = nsGlobalWindowInner::GetInnerWindowWithId(id)->AsInner();
+    auto* window = nsGlobalWindowInner::GetInnerWindowWithId(id);
     MOZ_ASSERT(window);
     // XXXkhuey ...
     if (!window) {
       continue;
     }
 
     if (winListener->CapturingVideo() || winListener->CapturingAudio()) {
-      array->AppendElement(window);
+      array->AppendElement(ToSupports(window));
     }
   }
 
   array.forget(aArray);
   return NS_OK;
 }
 
 struct CaptureWindowStateData {
@@ -3932,18 +3919,17 @@ void MediaManager::StopScreensharing(uin
   // We need to stop window/screensharing for all streams in all innerwindows
   // that correspond to that outerwindow.
 
   auto* window = nsGlobalWindowInner::GetInnerWindowWithId(aWindowID);
   if (!window) {
     return;
   }
   IterateWindowListeners(
-      window->AsInner(),
-      [](const RefPtr<GetUserMediaWindowListener>& aListener) {
+      window, [](const RefPtr<GetUserMediaWindowListener>& aListener) {
         aListener->StopSharing();
       });
 }
 
 template <typename FunctionType>
 void MediaManager::IterateWindowListeners(nsPIDOMWindowInner* aWindow,
                                           const FunctionType& aCallback) {
   // Iterate the docshell tree to find all the child windows, and for each
@@ -4472,18 +4458,17 @@ void SourceListener::StopSharing() {
     // We want to stop the whole stream if there's no audio;
     // just the video track if we have both.
     // StopTrack figures this out for us.
     StopTrack(kVideoTrack);
   }
   if (mAudioDeviceState && mAudioDeviceState->mDevice->GetMediaSource() ==
                                MediaSourceEnum::AudioCapture) {
     uint64_t windowID = mWindowListener->WindowID();
-    auto* window =
-        nsGlobalWindowInner::GetInnerWindowWithId(windowID)->AsInner();
+    auto* window = nsGlobalWindowInner::GetInnerWindowWithId(windowID);
     MOZ_RELEASE_ASSERT(window);
     window->SetAudioCapture(false);
     MediaStreamGraph* graph = mStream->Graph();
     graph->UnregisterCaptureStreamForWindow(windowID);
     mStream->Destroy();
   }
 }
 
@@ -4671,18 +4656,17 @@ void GetUserMediaWindowListener::NotifyC
   NS_DispatchToMainThread(NS_NewRunnableFunction(
       "MediaManager::NotifyChrome", [windowID = mWindowID]() {
         auto* window = nsGlobalWindowInner::GetInnerWindowWithId(windowID);
         if (!window) {
           MOZ_ASSERT_UNREACHABLE("Should have window");
           return;
         }
 
-        nsresult rv =
-            MediaManager::NotifyRecordingStatusChange(window->AsInner());
+        nsresult rv = MediaManager::NotifyRecordingStatusChange(window);
         if (NS_FAILED(rv)) {
           MOZ_ASSERT_UNREACHABLE("Should be able to notify chrome");
           return;
         }
       }));
 }
 
 }  // namespace mozilla
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -360,22 +360,17 @@ nsPIDOMWindowInner* PresentationSessionI
     return nullptr;
   }
   uint64_t windowId = 0;
   if (NS_WARN_IF(NS_FAILED(
           service->GetWindowIdBySessionId(mSessionId, mRole, &windowId)))) {
     return nullptr;
   }
 
-  auto window = nsGlobalWindowInner::GetInnerWindowWithId(windowId);
-  if (!window) {
-    return nullptr;
-  }
-
-  return window->AsInner();
+  return nsGlobalWindowInner::GetInnerWindowWithId(windowId);
 }
 
 /* virtual */
 bool PresentationSessionInfo::IsAccessible(base::ProcessId aProcessId) {
   // No restriction by default.
   return true;
 }
 
--- a/dom/presentation/ipc/PresentationBuilderChild.cpp
+++ b/dom/presentation/ipc/PresentationBuilderChild.cpp
@@ -38,17 +38,17 @@ nsresult PresentationBuilderChild::Init(
   }
 
   if (NS_WARN_IF(NS_FAILED(
           service->GetWindowIdBySessionId(mSessionId, mRole, &windowId)))) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsPIDOMWindowInner* window =
-      nsGlobalWindowInner::GetInnerWindowWithId(windowId)->AsInner();
+      nsGlobalWindowInner::GetInnerWindowWithId(windowId);
   if (NS_WARN_IF(!window)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return mBuilder->BuildDataChannelTransport(mRole, window, this);
 }
 
 void PresentationBuilderChild::ActorDestroy(ActorDestroyReason aWhy) {
--- a/dom/presentation/ipc/PresentationIPCService.cpp
+++ b/dom/presentation/ipc/PresentationIPCService.cpp
@@ -59,17 +59,17 @@ PresentationIPCService::StartSession(
     nsIPresentationServiceCallback* aCallback,
     nsIPresentationTransportBuilderConstructor* aBuilderConstructor) {
   if (aWindowId != 0) {
     AddRespondingSessionId(aWindowId, aSessionId,
                            nsIPresentationService::ROLE_CONTROLLER);
   }
 
   nsPIDOMWindowInner* window =
-      nsGlobalWindowInner::GetInnerWindowWithId(aWindowId)->AsInner();
+      nsGlobalWindowInner::GetInnerWindowWithId(aWindowId);
   TabId tabId = TabParent::GetTabIdFrom(window->GetDocShell());
 
   return SendRequest(
       aCallback,
       StartSessionRequest(aUrls, nsString(aSessionId), nsString(aOrigin),
                           nsString(aDeviceId), aWindowId, tabId,
                           IPC::Principal(aPrincipal)));
 }
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -521,25 +521,25 @@ void Promise::ReportRejectedPromise(JSCo
                                      nsContentUtils::ObjectPrincipal(aPromise))
                                : IsCurrentThreadRunningChromeWorker();
   nsGlobalWindowInner* win =
       isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
 
   js::ErrorReport report(aCx);
   if (report.init(aCx, result, js::ErrorReport::NoSideEffects)) {
     xpcReport->Init(report.report(), report.toStringResult().c_str(), isChrome,
-                    win ? win->AsInner()->WindowID() : 0);
+                    win ? win->WindowID() : 0);
   } else {
     JS_ClearPendingException(aCx);
 
     RefPtr<Exception> exn;
     if (result.isObject() &&
         (NS_SUCCEEDED(UNWRAP_OBJECT(DOMException, &result, exn)) ||
          NS_SUCCEEDED(UNWRAP_OBJECT(Exception, &result, exn)))) {
-      xpcReport->Init(aCx, exn, isChrome, win ? win->AsInner()->WindowID() : 0);
+      xpcReport->Init(aCx, exn, isChrome, win ? win->WindowID() : 0);
     } else {
       return;
     }
   }
 
   // Now post an event to do the real reporting async
   RefPtr<nsIRunnable> event = new AsyncErrorReporter(xpcReport);
   if (win) {
--- a/dom/script/ScriptSettings.cpp
+++ b/dom/script/ScriptSettings.cpp
@@ -460,17 +460,17 @@ void WarningOnlyErrorReporter(JSContext*
 
     worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep);
     return;
   }
 
   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
   nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aCx);
   xpcReport->Init(aRep, nullptr, nsContentUtils::IsSystemCaller(aCx),
-                  win ? win->AsInner()->WindowID() : 0);
+                  win ? win->WindowID() : 0);
   xpcReport->LogToConsole();
 }
 
 void AutoJSAPI::ReportException() {
   if (!HasException()) {
     return;
   }
 
@@ -496,18 +496,17 @@ void AutoJSAPI::ReportException() {
   JS::Rooted<JS::Value> exn(cx());
   JS::Rooted<JSObject*> exnStack(cx());
   js::ErrorReport jsReport(cx());
   if (StealExceptionAndStack(&exn, &exnStack) &&
       jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects)) {
     if (mIsMainThread) {
       RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
 
-      RefPtr<nsGlobalWindowInner> win = xpc::WindowOrNull(errorGlobal);
-      nsPIDOMWindowInner* inner = win ? win->AsInner() : nullptr;
+      RefPtr<nsGlobalWindowInner> inner = xpc::WindowOrNull(errorGlobal);
       bool isChrome = nsContentUtils::IsSystemPrincipal(
           nsContentUtils::ObjectPrincipal(errorGlobal));
       xpcReport->Init(jsReport.report(), jsReport.toStringResult().c_str(),
                       isChrome, inner ? inner->WindowID() : 0);
       if (inner && jsReport.report()->errorNumber != JSMSG_OUT_OF_MEMORY) {
         JS::RootingContext* rcx = JS::RootingContext::get(cx());
         DispatchScriptErrorEvent(inner, rcx, xpcReport, exn, exnStack);
       } else {
--- a/dom/vr/VREventObserver.cpp
+++ b/dom/vr/VREventObserver.cpp
@@ -88,80 +88,80 @@ bool VREventObserver::GetStopActivitySta
 void VREventObserver::NotifyAfterLoad() {
   if (VRManagerChild::IsCreated()) {
     VRManagerChild* vmc = VRManagerChild::Get();
     vmc->FireDOMVRDisplayConnectEventsForLoad(this);
   }
 }
 
 void VREventObserver::NotifyVRDisplayMounted(uint32_t aDisplayID) {
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayActivate(aDisplayID,
                                        VRDisplayEventReason::Mounted);
   }
 }
 
 void VREventObserver::NotifyVRDisplayNavigation(uint32_t aDisplayID) {
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayActivate(aDisplayID,
                                        VRDisplayEventReason::Navigation);
   }
 }
 
 void VREventObserver::NotifyVRDisplayRequested(uint32_t aDisplayID) {
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayActivate(aDisplayID,
                                        VRDisplayEventReason::Requested);
   }
 }
 
 void VREventObserver::NotifyVRDisplayUnmounted(uint32_t aDisplayID) {
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayDeactivate(aDisplayID,
                                          VRDisplayEventReason::Unmounted);
   }
 }
 
 void VREventObserver::NotifyVRDisplayConnect(uint32_t aDisplayID) {
   /**
    * We do not call nsGlobalWindow::NotifyActiveVRDisplaysChanged here, as we
    * can assume that a newly enumerated display is not presenting WebVR
    * content.
    */
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayConnect(aDisplayID);
   }
 }
 
 void VREventObserver::NotifyVRDisplayDisconnect(uint32_t aDisplayID) {
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     mWindow->NotifyActiveVRDisplaysChanged();
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayDisconnect(aDisplayID);
   }
 }
 
 void VREventObserver::NotifyVRDisplayPresentChange(uint32_t aDisplayID) {
   // When switching to HMD present mode, it is no longer
   // to be a 2D view.
   mIs2DView = false;
 
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     mWindow->NotifyActiveVRDisplaysChanged();
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
     mWindow->DispatchVRDisplayPresentChange(aDisplayID);
   }
 }
 
 void VREventObserver::NotifyPresentationGenerationChanged(uint32_t aDisplayID) {
-  if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {
+  if (mWindow && mWindow->IsCurrentInnerWindow()) {
     mWindow->NotifyPresentationGenerationChanged(aDisplayID);
     MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
   }
 }
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -381,18 +381,17 @@ nsresult nsXBLPrototypeHandler::ExecuteH
 }
 
 nsresult nsXBLPrototypeHandler::EnsureEventHandler(
     AutoJSAPI& jsapi, nsAtom* aName, JS::MutableHandle<JSObject*> aHandler) {
   JSContext* cx = jsapi.cx();
 
   // Check to see if we've already compiled this
   JS::Rooted<JSObject*> globalObject(cx, JS::CurrentGlobalOrNull(cx));
-  nsCOMPtr<nsPIDOMWindowInner> pWindow =
-      xpc::WindowOrNull(globalObject)->AsInner();
+  nsCOMPtr<nsPIDOMWindowInner> pWindow = xpc::WindowOrNull(globalObject);
   if (pWindow) {
     JS::Rooted<JSObject*> cachedHandler(
         cx, pWindow->GetCachedXBLPrototypeHandler(this));
     if (cachedHandler) {
       JS::ExposeObjectToActiveJS(cachedHandler);
       aHandler.set(cachedHandler);
       NS_ENSURE_TRUE(aHandler, NS_ERROR_FAILURE);
       return NS_OK;
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -1331,18 +1331,17 @@ nsXPCComponents_Utils::ReportError(Handl
   // This function shall never fail! Silently eat any failure conditions.
 
   nsCOMPtr<nsIConsoleService> console(
       do_GetService(NS_CONSOLESERVICE_CONTRACTID));
   if (!console) {
     return NS_OK;
   }
 
-  nsGlobalWindowInner* globalWin = CurrentWindowOrNull(cx);
-  nsPIDOMWindowInner* win = globalWin ? globalWin->AsInner() : nullptr;
+  nsGlobalWindowInner* win = CurrentWindowOrNull(cx);
   const uint64_t innerWindowID = win ? win->WindowID() : 0;
 
   RootedObject errorObj(cx, error.isObject() ? &error.toObject() : nullptr);
   JSErrorReport* err = errorObj ? JS_ErrorFromException(cx, errorObj) : nullptr;
 
   nsCOMPtr<nsIScriptError> scripterr;
 
   if (errorObj) {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -421,17 +421,17 @@ nsresult PeerConnectionImpl::Initialize(
     NS_ENSURE_SUCCESS(res, res);
   } else {
     NS_ENSURE_SUCCESS(res = InitNSSInContent(), res);
   }
 
   // Currently no standalone unit tests for DataChannel,
   // which is the user of mWindow
   MOZ_ASSERT(aWindow);
-  mWindow = aWindow->AsInner();
+  mWindow = aWindow;
   NS_ENSURE_STATE(mWindow);
 
   PRTime timestamp = PR_Now();
   // Ok if we truncate this.
   char temp[128];
 
   nsAutoCString locationCStr;
 
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
@@ -70,22 +70,17 @@ bool AddonManagerWebAPI::IsValidSite(nsI
     return false;
   }
 
   return IsValidHost(host);
 }
 
 bool AddonManagerWebAPI::IsAPIEnabled(JSContext* aCx, JSObject* aGlobal) {
   MOZ_DIAGNOSTIC_ASSERT(JS_IsGlobalObject(aGlobal));
-  nsGlobalWindowInner* global = xpc::WindowOrNull(aGlobal);
-  if (!global) {
-    return false;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> win = global->AsInner();
+  nsCOMPtr<nsPIDOMWindowInner> win = xpc::WindowOrNull(aGlobal);
   if (!win) {
     return false;
   }
 
   // Check that the current window and all parent frames are allowed access to
   // the API.
   while (win) {
     nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(win);
--- a/xpfe/appshell/nsWindowMediator.cpp
+++ b/xpfe/appshell/nsWindowMediator.cpp
@@ -329,24 +329,23 @@ NS_IMETHODIMP
 nsWindowMediator::GetCurrentInnerWindowWithId(uint64_t aWindowID,
                                               mozIDOMWindow** aWindow) {
   RefPtr<nsGlobalWindowInner> window =
       nsGlobalWindowInner::GetInnerWindowWithId(aWindowID);
 
   // not found
   if (!window) return NS_OK;
 
-  nsCOMPtr<nsPIDOMWindowInner> inner = window->AsInner();
-  nsCOMPtr<nsPIDOMWindowOuter> outer = inner->GetOuterWindow();
+  nsCOMPtr<nsPIDOMWindowOuter> outer = window->GetOuterWindow();
   NS_ENSURE_TRUE(outer, NS_ERROR_UNEXPECTED);
 
   // outer is already using another inner, so it's same as not found
-  if (outer->GetCurrentInnerWindow() != inner) return NS_OK;
+  if (outer->GetCurrentInnerWindow() != window) return NS_OK;
 
-  inner.forget(aWindow);
+  window.forget(aWindow);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindowMediator::UpdateWindowTimeStamp(nsIXULWindow* inWindow) {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   NS_ENSURE_STATE(mReady);
   nsWindowInfo* info = GetInfoFor(inWindow);