Bug 1241764: Replace nsPIDOMWindow with nsPIDOMWindowInner/Outer. r=mrbkap,smaug

This commit is contained in:
Kyle Huey
2016-01-30 09:05:36 -08:00
parent 366da70c9f
commit e95edb30a9
806 changed files with 4709 additions and 5300 deletions

View File

@@ -964,7 +964,8 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
*aSink = mContentListener;
} else if ((aIID.Equals(NS_GET_IID(nsIScriptGlobalObject)) ||
aIID.Equals(NS_GET_IID(nsIGlobalObject)) ||
aIID.Equals(NS_GET_IID(nsPIDOMWindow)) ||
aIID.Equals(NS_GET_IID(nsPIDOMWindowOuter)) ||
aIID.Equals(NS_GET_IID(mozIDOMWindowProxy)) ||
aIID.Equals(NS_GET_IID(nsIDOMWindow)) ||
aIID.Equals(NS_GET_IID(nsIDOMWindowInternal))) &&
NS_SUCCEEDED(EnsureScriptEnvironment())) {
@@ -1012,7 +1013,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
// Get the an auth prompter for our window so that the parenting
// of the dialogs works as it should when using tabs.
nsIPrompt* prompt;
rv = wwatch->GetNewPrompter(mScriptGlobal, &prompt);
rv = wwatch->GetNewPrompter(mScriptGlobal->AsOuter(), &prompt);
NS_ENSURE_SUCCESS(rv, rv);
*aSink = prompt;
@@ -1080,8 +1081,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
if (tabChild) {
tabChild->GetMessageManager(getter_AddRefs(mm));
} else {
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (win) {
if (nsPIDOMWindowOuter* win = GetWindow()) {
mm = do_QueryInterface(win->GetParentTarget());
}
}
@@ -1717,7 +1717,8 @@ nsDocShell::MaybeInitTiming()
}
if (mScriptGlobal && mBlankTiming) {
nsPIDOMWindow* innerWin = mScriptGlobal->GetCurrentInnerWindow();
nsPIDOMWindowInner* innerWin =
mScriptGlobal->AsOuter()->GetCurrentInnerWindow();
if (innerWin && innerWin->GetPerformance()) {
mTiming = innerWin->GetPerformance()->GetDOMTiming();
mBlankTiming = false;
@@ -2430,8 +2431,8 @@ nsDocShell::SetAllowMedia(bool aAllowMedia)
// Mute or unmute audio contexts attached to the inner window.
if (mScriptGlobal) {
nsPIDOMWindow* innerWin = mScriptGlobal->GetCurrentInnerWindow();
if (innerWin) {
if (nsPIDOMWindowInner* innerWin =
mScriptGlobal->AsOuter()->GetCurrentInnerWindow()) {
if (aAllowMedia) {
innerWin->UnmuteAudioContexts();
} else {
@@ -2517,7 +2518,7 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
// Assume false until we determine otherwise...
*aFullscreenAllowed = false;
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
if (!win) {
return NS_OK;
}
@@ -2972,14 +2973,15 @@ nsDocShell::GetSessionStorageForPrincipal(nsIPrincipal* aPrincipal,
return NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsPIDOMWindowOuter> domWin = do_GetInterface(GetAsSupports(this));
if (aCreate) {
return manager->CreateStorage(domWin, aPrincipal, aDocumentURI,
mInPrivateBrowsing, aStorage);
return manager->CreateStorage(domWin->GetCurrentInnerWindow(), aPrincipal,
aDocumentURI, mInPrivateBrowsing, aStorage);
}
return manager->GetStorage(domWin, aPrincipal, mInPrivateBrowsing, aStorage);
return manager->GetStorage(domWin->GetCurrentInnerWindow(), aPrincipal,
mInPrivateBrowsing, aStorage);
}
nsresult
@@ -3545,13 +3547,13 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
return false;
}
nsCOMPtr<nsPIDOMWindow> targetWindow = aTargetItem->GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> targetWindow = aTargetItem->GetWindow();
if (!targetWindow) {
NS_ERROR("This should not happen, really");
return false;
}
nsCOMPtr<nsIDOMWindow> targetOpener = targetWindow->GetOpener();
nsCOMPtr<mozIDOMWindowProxy> targetOpener = targetWindow->GetOpener();
nsCOMPtr<nsIWebNavigation> openerWebNav(do_GetInterface(targetOpener));
nsCOMPtr<nsIDocShellTreeItem> openerItem(do_QueryInterface(openerWebNav));
@@ -3565,8 +3567,8 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
static bool
ItemIsActive(nsIDocShellTreeItem* aItem)
{
if (nsCOMPtr<nsIDOMWindow> window = aItem->GetWindow()) {
auto* win = static_cast<nsGlobalWindow*>(window.get());
if (nsCOMPtr<nsPIDOMWindowOuter> window = aItem->GetWindow()) {
auto* win = nsGlobalWindow::Cast(window);
MOZ_ASSERT(win->IsOuterWindow());
if (!win->GetClosedOuter()) {
return true;
@@ -3823,7 +3825,7 @@ PrintDocTree(nsIDocShellTreeItem* aParentNode, int aLevel)
parentAsDocShell->GetPresContext(getter_AddRefs(presContext));
nsIDocument* doc = presShell->GetDocument();
nsCOMPtr<nsIDOMWindow> domwin(doc->GetWindow());
nsCOMPtr<nsPIDOMWindowOuter> domwin(doc->GetWindow());
nsCOMPtr<nsIWidget> widget;
nsViewManager* vm = presShell->GetViewManager();
@@ -4442,13 +4444,13 @@ nsDocShell::GetDocument()
return mContentViewer->GetDocument();
}
nsPIDOMWindow*
nsPIDOMWindowOuter*
nsDocShell::GetWindow()
{
if (NS_FAILED(EnsureScriptEnvironment())) {
return nullptr;
}
return mScriptGlobal;
return mScriptGlobal->AsOuter();
}
NS_IMETHODIMP
@@ -7575,7 +7577,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
if (isTopFrame == false && aStatus == NS_ERROR_TRACKING_URI) {
// frameElement is our nsIContent to be annotated
nsCOMPtr<nsIDOMElement> frameElement;
nsPIDOMWindow* thisWindow = GetWindow();
nsPIDOMWindowOuter* thisWindow = GetWindow();
if (!thisWindow) {
return NS_OK;
}
@@ -7814,8 +7816,7 @@ nsDocShell::EnsureContentViewer()
nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {
nsCOMPtr<nsPIDOMWindow> domWin = GetWindow();
if (domWin) {
if (nsCOMPtr<nsPIDOMWindowOuter> domWin = GetWindow()) {
nsCOMPtr<Element> parentElement = domWin->GetFrameElementInternal();
if (parentElement) {
baseURI = parentElement->GetBaseURI();
@@ -8668,8 +8669,7 @@ nsDocShell::RestoreFromHistory()
d->AnimationsPaused());
}
nsCOMPtr<nsPIDOMWindow> parentWindow = d->GetWindow();
if (parentWindow) {
if (nsCOMPtr<nsPIDOMWindowOuter> parentWindow = d->GetWindow()) {
parentSuspendCount = parentWindow->TimeoutSuspendCount();
}
}
@@ -8688,7 +8688,7 @@ nsDocShell::RestoreFromHistory()
// This is the end of our CreateContentViewer() replacement.
// Now we simulate a load. First, we restore the state of the javascript
// window object.
nsCOMPtr<nsPIDOMWindow> privWin = GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> privWin = GetWindow();
NS_ASSERTION(privWin, "could not get nsPIDOMWindow interface");
rv = privWin->RestoreWindowState(windowState);
@@ -9608,7 +9608,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsCOMPtr<Element> requestingElement;
// Use nsPIDOMWindow since we _want_ to cross the chrome boundary if needed
if (mScriptGlobal) {
requestingElement = mScriptGlobal->GetFrameElementInternal();
requestingElement = mScriptGlobal->AsOuter()->GetFrameElementInternal();
}
RefPtr<nsGlobalWindow> MMADeathGrip = mScriptGlobal;
@@ -9762,11 +9762,11 @@ nsDocShell::InternalLoad(nsIURI* aURI,
}
}
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
nsDependentString name(aWindowTarget);
nsCOMPtr<nsIDOMWindow> newWin;
nsCOMPtr<nsPIDOMWindowOuter> newWin;
nsAutoCString spec;
if (aURI) {
aURI->GetSpec(spec);
@@ -9779,7 +9779,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// In some cases the Open call doesn't actually result in a new
// window being opened. We can detect these cases by examining the
// document in |newWin|, if any.
nsCOMPtr<nsPIDOMWindow> piNewWin = do_QueryInterface(newWin);
nsCOMPtr<nsPIDOMWindowOuter> piNewWin = do_QueryInterface(newWin);
if (piNewWin) {
nsCOMPtr<nsIDocument> newDoc = piNewWin->GetExtantDoc();
if (!newDoc || newDoc->IsInitialDocument()) {
@@ -9832,7 +9832,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// So, the best we can do, is to tear down the new window
// that was just created!
//
if (nsCOMPtr<nsPIDOMWindow> domWin = targetDocShell->GetWindow()) {
if (nsCOMPtr<nsPIDOMWindowOuter> domWin = targetDocShell->GetWindow()) {
domWin->Close();
}
}
@@ -10187,7 +10187,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
win->DispatchSyncPopState();
}
if (needsScrollPosUpdate && win->HasActiveDocument()) {
if (needsScrollPosUpdate && win->AsInner()->HasActiveDocument()) {
SetCurScrollPosEx(bx, by);
}
@@ -10530,7 +10530,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
rv = aURI->SchemeIs("about", &isAbout);
if (NS_SUCCEEDED(rv) && !isAbout &&
nsIDocShell::GetIsApp()) {
nsCOMPtr<Element> frameElement = mScriptGlobal->GetFrameElementInternal();
nsCOMPtr<Element> frameElement = mScriptGlobal->AsOuter()->GetFrameElementInternal();
if (frameElement) {
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(frameElement);
// |GetReallyIsApp| indicates the browser frame is a valid app or widget.
@@ -10554,7 +10554,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
nsCOMPtr<nsINode> requestingNode;
if (mScriptGlobal) {
requestingNode = mScriptGlobal->GetFrameElementInternal();
requestingNode = mScriptGlobal->AsOuter()->GetFrameElementInternal();
if (!requestingNode) {
requestingNode = mScriptGlobal->GetExtantDoc();
}
@@ -12964,8 +12964,8 @@ nsDocShell::EnsureFind()
NS_ENSURE_TRUE(scriptGO, NS_ERROR_UNEXPECTED);
// default to our window
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(scriptGO);
nsCOMPtr<nsPIDOMWindow> windowToSearch;
nsCOMPtr<nsPIDOMWindowOuter> ourWindow = do_QueryInterface(scriptGO);
nsCOMPtr<nsPIDOMWindowOuter> windowToSearch;
nsFocusManager::GetFocusedDescendant(ourWindow, true,
getter_AddRefs(windowToSearch));
@@ -13138,7 +13138,7 @@ nsDocShell::GetAuthPrompt(uint32_t aPromptReason, const nsIID& aIID,
// Get the an auth prompter for our window so that the parenting
// of the dialogs works as it should when using tabs.
return wwatch->GetPrompt(mScriptGlobal, aIID,
return wwatch->GetPrompt(mScriptGlobal->AsOuter(), aIID,
reinterpret_cast<void**>(aResult));
}
@@ -13147,16 +13147,16 @@ nsDocShell::GetAuthPrompt(uint32_t aPromptReason, const nsIID& aIID,
//*****************************************************************************
NS_IMETHODIMP
nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
nsDocShell::GetAssociatedWindow(mozIDOMWindowProxy** aWindow)
{
CallGetInterface(this, aWindow);
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetTopWindow(nsIDOMWindow** aWindow)
nsDocShell::GetTopWindow(mozIDOMWindowProxy** aWindow)
{
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
if (win) {
win = win->GetTop();
}
@@ -13168,12 +13168,12 @@ NS_IMETHODIMP
nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
{
*aElement = nullptr;
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindow();
if (!win) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindow> top = win->GetScriptableTop();
nsCOMPtr<nsPIDOMWindowOuter> top = win->GetScriptableTop();
NS_ENSURE_TRUE(top, NS_ERROR_FAILURE);
// GetFrameElementInternal, /not/ GetScriptableFrameElement -- if |top| is
@@ -13295,7 +13295,7 @@ nsDocShell::EnsureCommandHandler()
return NS_ERROR_OUT_OF_MEMORY;
}
nsCOMPtr<nsIDOMWindow> domWindow = GetWindow();
nsCOMPtr<nsPIDOMWindowOuter> domWindow = GetWindow();
nsresult rv = commandUpdater->Init(domWindow);
if (NS_SUCCEEDED(rv)) {
mCommandManager = do_QueryInterface(commandUpdater);
@@ -13584,10 +13584,10 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
// Now check that the refererDoc's inner window is the current inner
// window for mScriptGlobal. If it's not, then we don't want to
// follow this link.
nsPIDOMWindow* refererInner = refererDoc->GetInnerWindow();
nsPIDOMWindowInner* refererInner = refererDoc->GetInnerWindow();
NS_ENSURE_TRUE(refererInner, NS_ERROR_UNEXPECTED);
if (!mScriptGlobal ||
mScriptGlobal->GetCurrentInnerWindow() != refererInner) {
mScriptGlobal->AsOuter()->GetCurrentInnerWindow() != refererInner) {
// We're no longer the current inner window
return NS_OK;
}