Skip to content

Commit

Permalink
Bug 1846277 - Untangle nsGlobalWindow*.h includes. r=dom-core,media-p…
Browse files Browse the repository at this point in the history
…layback-reviewers,sessionstore-reviewers,padenot,farre

Differential Revision: https://phabricator.services.mozilla.com/D184978
  • Loading branch information
petervanderbeken committed Aug 2, 2023
1 parent 849c427 commit 3f4ffad
Show file tree
Hide file tree
Showing 54 changed files with 114 additions and 132 deletions.
1 change: 1 addition & 0 deletions docshell/base/BrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "nsDocShell.h"
#include "nsDocShellLoadState.h"
#include "nsFocusManager.h"
#include "nsGlobalWindowInner.h"
#include "nsGlobalWindowOuter.h"
#include "PresShell.h"
#include "nsIObserverService.h"
Expand Down
1 change: 0 additions & 1 deletion docshell/base/nsDSURIContentListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "nsError.h"
#include "nsContentSecurityManager.h"
#include "nsDocShellLoadTypes.h"
#include "nsGlobalWindowOuter.h"
#include "nsIInterfaceRequestor.h"
#include "nsIMultiPartChannel.h"
#include "nsWebNavigationInfo.h"
Expand Down
35 changes: 16 additions & 19 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,9 +1280,8 @@ void nsDocShell::ThawFreezeNonRecursive(bool aThaw) {
return;
}

RefPtr<nsGlobalWindowInner> inner =
mScriptGlobal->GetCurrentInnerWindowInternal();
if (inner) {
if (RefPtr<nsGlobalWindowInner> inner =
nsGlobalWindowInner::Cast(mScriptGlobal->GetCurrentInnerWindow())) {
if (aThaw) {
inner->Thaw(false);
} else {
Expand Down Expand Up @@ -1311,9 +1310,8 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
RefPtr<Document> doc = contentViewer->GetDocument();
if (doc) {
doc->NotifyActivityChanged();
RefPtr<nsGlobalWindowInner> inner =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindowInternal()
: nullptr;
nsCOMPtr<nsPIDOMWindowInner> inner =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindow() : nullptr;
if (mBrowsingContext->IsTop()) {
doc->NotifyPossibleTitleChange(false);
if (inner) {
Expand Down Expand Up @@ -2428,8 +2426,8 @@ nsDocShell::SetCustomUserAgent(const nsAString& aCustomUserAgent) {

NS_IMETHODIMP
nsDocShell::ClearCachedPlatform() {
RefPtr<nsGlobalWindowInner> win =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
nsCOMPtr<nsPIDOMWindowInner> win =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindow() : nullptr;
if (win) {
Navigator* navigator = win->Navigator();
if (navigator) {
Expand All @@ -2442,8 +2440,8 @@ nsDocShell::ClearCachedPlatform() {

NS_IMETHODIMP
nsDocShell::ClearCachedUserAgent() {
RefPtr<nsGlobalWindowInner> win =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
nsCOMPtr<nsPIDOMWindowInner> win =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindow() : nullptr;
if (win) {
Navigator* navigator = win->Navigator();
if (navigator) {
Expand Down Expand Up @@ -2527,11 +2525,10 @@ void nsDocShell::MaybeCreateInitialClientSource(nsIPrincipal* aPrincipal) {

// If there is an existing document then there is no need to create
// a client for a future initial about:blank document.
if (mScriptGlobal && mScriptGlobal->GetCurrentInnerWindowInternal() &&
mScriptGlobal->GetCurrentInnerWindowInternal()->GetExtantDoc()) {
MOZ_DIAGNOSTIC_ASSERT(mScriptGlobal->GetCurrentInnerWindowInternal()
->GetClientInfo()
.isSome());
if (mScriptGlobal && mScriptGlobal->GetCurrentInnerWindow() &&
mScriptGlobal->GetCurrentInnerWindow()->GetExtantDoc()) {
MOZ_DIAGNOSTIC_ASSERT(
mScriptGlobal->GetCurrentInnerWindow()->GetClientInfo().isSome());
MOZ_DIAGNOSTIC_ASSERT(!mInitialClientSource);
return;
}
Expand Down Expand Up @@ -2613,8 +2610,8 @@ Maybe<ClientInfo> nsDocShell::GetInitialClientInfo() const {
return result;
}

nsGlobalWindowInner* innerWindow =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
nsPIDOMWindowInner* innerWindow =
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindow() : nullptr;
Document* doc = innerWindow ? innerWindow->GetExtantDoc() : nullptr;

if (!doc || !doc->IsInitialDocument()) {
Expand Down Expand Up @@ -9148,8 +9145,8 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
CopyFavicon(currentURI, newURI, UsePrivateBrowsing());

RefPtr<nsGlobalWindowOuter> scriptGlobal = mScriptGlobal;
RefPtr<nsGlobalWindowInner> win =
scriptGlobal ? scriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
nsCOMPtr<nsPIDOMWindowInner> win =
scriptGlobal ? scriptGlobal->GetCurrentInnerWindow() : nullptr;

// ScrollToAnchor doesn't necessarily cause us to scroll the window;
// the function decides whether a scroll is appropriate based on the
Expand Down
2 changes: 1 addition & 1 deletion dom/base/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "nsJSUtils.h"
#include "nsContentUtils.h"
#include "nsDocShell.h"
#include "nsGlobalWindowInner.h"
#include "nsGlobalWindowOuter.h"
#include "mozilla/Likely.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/BasePrincipal.h"
Expand Down
3 changes: 2 additions & 1 deletion dom/base/PostMessageEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP PostMessageEvent::Run() {

RefPtr<nsGlobalWindowInner> targetWindow;
if (mTargetWindow->IsClosedOrClosing() ||
!(targetWindow = mTargetWindow->GetCurrentInnerWindowInternal()) ||
!(targetWindow = nsGlobalWindowInner::Cast(
mTargetWindow->GetCurrentInnerWindow())) ||
targetWindow->IsDying())
return NS_OK;

Expand Down
2 changes: 1 addition & 1 deletion dom/base/ThirdPartyUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "nsDebug.h"
#include "nsEffectiveTLDService.h"
#include "nsError.h"
#include "nsGlobalWindowInner.h"
#include "nsGlobalWindowOuter.h"
#include "nsIChannel.h"
#include "nsIClassifiedChannel.h"
#include "nsIContentPolicy.h"
Expand Down
1 change: 0 additions & 1 deletion dom/base/Timeout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "Timeout.h"

#include "mozilla/dom/TimeoutManager.h"
#include "nsGlobalWindowInner.h"
#include "GeckoProfiler.h"

namespace mozilla::dom {
Expand Down
3 changes: 2 additions & 1 deletion dom/base/WindowDestroyedEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ WindowDestroyedEvent::Run() {
} else {
nsGlobalWindowOuter* outer =
nsGlobalWindowOuter::FromSupports(window);
currentInner = outer->GetCurrentInnerWindowInternal();
currentInner =
nsGlobalWindowInner::Cast(outer->GetCurrentInnerWindow());
nukedOuter = outer;
}
NS_ENSURE_TRUE(currentInner, NS_OK);
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsContentPermissionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nsArrayUtils.h"
#include "nsIMutableArray.h"
#include "nsContentPermissionHelper.h"
#include "nsGlobalWindowInner.h"
#include "nsJSUtils.h"
#include "nsISupportsPrimitives.h"
#include "nsServiceManagerUtils.h"
Expand Down
1 change: 0 additions & 1 deletion dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "nsContentList.h"
#include "nsError.h"
#include "nsQueryContentEventResult.h"
#include "nsGlobalWindowInner.h"
#include "nsGlobalWindowOuter.h"
#include "nsFocusManager.h"
#include "nsFrameManager.h"
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "nsIAppWindow.h"
#include "nsIMozBrowserFrame.h"
#include "nsIScriptError.h"
#include "nsGlobalWindowInner.h"
#include "nsGlobalWindowOuter.h"
#include "nsHTMLDocument.h"
#include "nsPIWindowRoot.h"
Expand Down
10 changes: 6 additions & 4 deletions dom/base/nsGlobalWindowInner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5773,7 +5773,8 @@ CallState nsGlobalWindowInner::CallOnInProcessDescendantsInternal(
for (const RefPtr<BrowsingContext>& bc : aBrowsingContext->Children()) {
if (nsCOMPtr<nsPIDOMWindowOuter> pWin = bc->GetDOMWindow()) {
auto* win = nsGlobalWindowOuter::Cast(pWin);
if (nsGlobalWindowInner* inner = win->GetCurrentInnerWindowInternal()) {
if (nsGlobalWindowInner* inner =
nsGlobalWindowInner::Cast(win->GetCurrentInnerWindow())) {
// Call the descendant method using our helper CallDescendant() template
// method. This allows us to handle both void returning methods and
// methods that return CallState explicitly. For void returning methods
Expand Down Expand Up @@ -6100,13 +6101,14 @@ bool WindowScriptTimeoutHandler::Call(const char* aExecutionReason) {
nsGlobalWindowInner* nsGlobalWindowInner::InnerForSetTimeoutOrInterval(
ErrorResult& aError) {
nsGlobalWindowOuter* outer = GetOuterWindowInternal();
nsGlobalWindowInner* currentInner =
outer ? outer->GetCurrentInnerWindowInternal() : this;
nsPIDOMWindowInner* currentInner =
outer ? outer->GetCurrentInnerWindow() : this;

// If forwardTo is not the window with an active document then we want the
// call to setTimeout/Interval to be a noop, so return null but don't set an
// error.
return HasActiveDocument() ? currentInner : nullptr;
return HasActiveDocument() ? nsGlobalWindowInner::Cast(currentInner)
: nullptr;
}

int32_t nsGlobalWindowInner::SetTimeout(JSContext* aCx, Function& aFunction,
Expand Down
Loading

0 comments on commit 3f4ffad

Please sign in to comment.