Skip to content

Commit

Permalink
Bug 1216401: Eviscerate nsIDOMWindow, move still needed methods to ns…
Browse files Browse the repository at this point in the history
…PIDOMWindow. r=bz
  • Loading branch information
khuey committed Oct 26, 2015
1 parent 8bb8104 commit c7d3c4e
Show file tree
Hide file tree
Showing 83 changed files with 726 additions and 2,108 deletions.
8 changes: 4 additions & 4 deletions accessible/base/DocManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ DocManager::OnStateChange(nsIWebProgress* aWebProgress,
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow));
NS_ENSURE_STATE(DOMWindow);

nsCOMPtr<nsIDOMDocument> DOMDocument;
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
NS_ENSURE_STATE(DOMDocument);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(DOMWindow);
MOZ_ASSERT(piWindow);

nsCOMPtr<nsIDocument> document(do_QueryInterface(DOMDocument));
nsCOMPtr<nsIDocument> document = piWindow->GetDoc();
NS_ENSURE_STATE(document);

// Document was loaded.
if (aStateFlags & STATE_STOP) {
Expand Down
12 changes: 5 additions & 7 deletions accessible/generic/ApplicationAccessible.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -193,12 +193,10 @@ ApplicationAccessible::CacheChildren()
while (hasMore) {
nsCOMPtr<nsISupports> window;
windowEnumerator->GetNext(getter_AddRefs(window));
nsCOMPtr<nsIDOMWindow> DOMWindow = do_QueryInterface(window);
nsCOMPtr<nsPIDOMWindow> DOMWindow = do_QueryInterface(window);
if (DOMWindow) {
nsCOMPtr<nsIDOMDocument> DOMDocument;
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
if (DOMDocument) {
nsCOMPtr<nsIDocument> docNode(do_QueryInterface(DOMDocument));
nsCOMPtr<nsIDocument> docNode = DOMWindow->GetDoc();
if (docNode) {
GetAccService()->GetDocAccessible(docNode); // ensure creation
}
}
Expand Down
9 changes: 4 additions & 5 deletions accessible/generic/ImageAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,12 @@ ImageAccessible::DoAction(uint8_t aIndex)

nsIDocument* document = mContent->OwnerDoc();
nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(piWindow);
if (!win)
if (!piWindow)
return false;

nsCOMPtr<nsIDOMWindow> tmp;
return NS_SUCCEEDED(win->Open(spec, EmptyString(), EmptyString(),
getter_AddRefs(tmp)));
nsCOMPtr<nsPIDOMWindow> tmp;
return NS_SUCCEEDED(piWindow->Open(spec, EmptyString(), EmptyString(),
getter_AddRefs(tmp)));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 3 additions & 5 deletions accessible/generic/RootAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,9 @@ RootAccessible::RelationByType(RelationType aType)
nsPIDOMWindow* rootWindow = mDocumentNode->GetWindow();
if (rootWindow) {
nsCOMPtr<nsIDOMWindow> contentWindow = nsGlobalWindow::Cast(rootWindow)->GetContent();
if (contentWindow) {
nsCOMPtr<nsIDOMDocument> contentDOMDocument;
contentWindow->GetDocument(getter_AddRefs(contentDOMDocument));
nsCOMPtr<nsIDocument> contentDocumentNode =
do_QueryInterface(contentDOMDocument);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(contentWindow);
if (piWindow) {
nsCOMPtr<nsIDocument> contentDocumentNode = piWindow->GetDoc();
if (contentDocumentNode) {
DocAccessible* contentDocument =
GetAccService()->GetDocAccessible(contentDocumentNode);
Expand Down
1 change: 1 addition & 0 deletions accessible/windows/msaa/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ LOCAL_INCLUDES += [
'/accessible/xpcom',
'/accessible/xul',
'/dom/base',
'/layout/style',
]

include('/ipc/chromium/chromium-config.mozbuild')
Expand Down
17 changes: 11 additions & 6 deletions accessible/windows/msaa/nsWinUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
#include "mozilla/Preferences.h"
#include "nsArrayUtils.h"
#include "nsIArray.h"
#include "nsICSSDeclaration.h"
#include "nsIDocument.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMElement.h"
#include "mozilla/dom/Element.h"
#include "nsXULAppAPI.h"

using namespace mozilla;
using namespace mozilla::a11y;
using mozilla::dom::Element;

// Window property used by ipc related code in identifying accessible
// tab windows.
Expand All @@ -43,15 +45,18 @@ nsWinUtils::GetComputedStyleDeclaration(nsIContent* aContent)
return nullptr;

// Returns number of items in style declaration
nsCOMPtr<nsIDOMWindow> window =
nsCOMPtr<nsPIDOMWindow> window =
do_QueryInterface(elm->OwnerDoc()->GetWindow());
if (!window)
return nullptr;

nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(elm));
window->GetComputedStyle(domElement, EmptyString(), getter_AddRefs(cssDecl));
return cssDecl.forget();
ErrorResult dummy;
nsCOMPtr<nsICSSDeclaration> cssDecl;
nsCOMPtr<Element> domElement(do_QueryInterface(elm));
cssDecl = window->GetComputedStyle(*domElement, EmptyString(), dummy);
nsCOMPtr<nsIDOMCSSStyleDeclaration> domDecl = do_QueryInterface(cssDecl);
dummy.SuppressException();
return domDecl.forget();
}

bool
Expand Down
1 change: 1 addition & 0 deletions chrome/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ GENERATED_INCLUDES += [
]

LOCAL_INCLUDES += [
'/dom/base',
'/netwerk/base',
'/netwerk/protocol/res',
'/xpcom/components'
Expand Down
37 changes: 13 additions & 24 deletions chrome/nsChromeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,10 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult)
// theme stuff


static void FlushSkinBindingsForWindow(nsIDOMWindow* aWindow)
static void FlushSkinBindingsForWindow(nsPIDOMWindow* aWindow)
{
// Get the DOM document.
nsCOMPtr<nsIDOMDocument> domDocument;
aWindow->GetDocument(getter_AddRefs(domDocument));
if (!domDocument)
return;

nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
// Get the document.
nsCOMPtr<nsIDocument> document = aWindow->GetDoc();
if (!document)
return;

Expand All @@ -345,7 +340,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
if (domWindow)
FlushSkinBindingsForWindow(domWindow);
}
Expand All @@ -360,7 +355,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
nsCOMPtr<nsISupports> protoWindow;
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (protoWindow) {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
if (domWindow)
RefreshWindow(domWindow);
}
Expand All @@ -382,28 +377,23 @@ nsChromeRegistry::FlushSkinCaches()
}

// XXXbsmedberg: move this to windowmediator
nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
{
// Deal with our subframes first.
nsCOMPtr<nsIDOMWindowCollection> frames;
aWindow->GetFrames(getter_AddRefs(frames));
nsCOMPtr<nsIDOMWindowCollection> frames = aWindow->GetFrames();
uint32_t length;
frames->GetLength(&length);
uint32_t j;
for (j = 0; j < length; j++) {
nsCOMPtr<nsIDOMWindow> childWin;
frames->Item(j, getter_AddRefs(childWin));
RefreshWindow(childWin);
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(childWin);
RefreshWindow(piWindow);
}

nsresult rv;
// Get the DOM document.
nsCOMPtr<nsIDOMDocument> domDocument;
aWindow->GetDocument(getter_AddRefs(domDocument));
if (!domDocument)
return NS_OK;

nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
// Get the document.
nsCOMPtr<nsIDocument> document = aWindow->GetDoc();
if (!document)
return NS_OK;

Expand Down Expand Up @@ -521,10 +511,9 @@ nsChromeRegistry::ReloadChrome()
nsCOMPtr<nsISupports> protoWindow;
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(protoWindow);
if (domWindow) {
nsCOMPtr<nsIDOMLocation> location;
domWindow->GetLocation(getter_AddRefs(location));
nsIDOMLocation* location = domWindow->GetLocation();
if (location) {
rv = location->Reload(false);
if (NS_FAILED(rv)) return rv;
Expand Down
4 changes: 2 additions & 2 deletions chrome/nsChromeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "mozilla/FileLocation.h"

class nsIDOMWindow;
class nsPIDOMWindow;
class nsIPrefBranch;
class nsIURL;

Expand Down Expand Up @@ -95,7 +95,7 @@ class nsChromeRegistry : public nsIToolkitChromeRegistry,

nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);

static nsresult RefreshWindow(nsIDOMWindow* aWindow);
static nsresult RefreshWindow(nsPIDOMWindow* aWindow);
static nsresult GetProviderAndPath(nsIURL* aChromeURL,
nsACString& aProvider, nsACString& aPath);

Expand Down
9 changes: 4 additions & 5 deletions docshell/base/nsDSURIContentListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType,
}

if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsCOMPtr<nsPIDOMWindow> domWindow = do_QueryInterface(
mDocShell ? mDocShell->GetWindow() : nullptr);
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus();
}
Expand Down Expand Up @@ -294,16 +294,15 @@ nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
// document must be same-origin with top window. X-F-O: DENY requires that
// the document must never be framed.
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
nsCOMPtr<nsPIDOMWindow> thisWindow = mDocShell->GetWindow();
// If we don't have DOMWindow there is no risk of clickjacking
if (!thisWindow) {
return true;
}

// GetScriptableTop, not GetTop, because we want this to respect
// <iframe mozbrowser> boundaries.
nsCOMPtr<nsIDOMWindow> topWindow;
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> topWindow = thisWindow->GetScriptableTop();

// if the document is in the top window, it's not in a frame.
if (thisWindow == topWindow) {
Expand Down
25 changes: 10 additions & 15 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3503,14 +3503,13 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
return false;
}

nsCOMPtr<nsIDOMWindow> targetWindow = aTargetItem->GetWindow();
nsCOMPtr<nsPIDOMWindow> targetWindow = aTargetItem->GetWindow();
if (!targetWindow) {
NS_ERROR("This should not happen, really");
return false;
}

nsCOMPtr<nsIDOMWindow> targetOpener;
targetWindow->GetOpener(getter_AddRefs(targetOpener));
nsCOMPtr<nsIDOMWindow> targetOpener = targetWindow->GetOpener();
nsCOMPtr<nsIWebNavigation> openerWebNav(do_GetInterface(targetOpener));
nsCOMPtr<nsIDocShellTreeItem> openerItem(do_QueryInterface(openerWebNav));

Expand Down Expand Up @@ -7490,7 +7489,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
return NS_OK;
}

thisWindow->GetFrameElement(getter_AddRefs(frameElement));
frameElement = thisWindow->GetFrameElement();
if (!frameElement) {
return NS_OK;
}
Expand Down Expand Up @@ -9739,8 +9738,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// So, the best we can do, is to tear down the new window
// that was just created!
//
nsCOMPtr<nsIDOMWindow> domWin = targetDocShell->GetWindow();
if (domWin) {
if (nsCOMPtr<nsPIDOMWindow> domWin = targetDocShell->GetWindow()) {
domWin->Close();
}
}
Expand Down Expand Up @@ -13006,34 +13004,31 @@ nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
NS_IMETHODIMP
nsDocShell::GetTopWindow(nsIDOMWindow** aWindow)
{
nsCOMPtr<nsIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (win) {
win->GetTop(aWindow);
win = win->GetTop();
}
win.forget(aWindow);
return NS_OK;
}

NS_IMETHODIMP
nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
{
*aElement = nullptr;
nsCOMPtr<nsIDOMWindow> win = GetWindow();
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (!win) {
return NS_OK;
}

nsCOMPtr<nsIDOMWindow> top;
win->GetScriptableTop(getter_AddRefs(top));
nsCOMPtr<nsPIDOMWindow> top = win->GetScriptableTop();
NS_ENSURE_TRUE(top, NS_ERROR_FAILURE);

nsCOMPtr<nsPIDOMWindow> piTop = do_QueryInterface(top);
NS_ENSURE_TRUE(piTop, NS_ERROR_FAILURE);

// GetFrameElementInternal, /not/ GetScriptableFrameElement -- if |top| is
// inside <iframe mozbrowser>, we want to return the iframe, not null.
// And we want to cross the content/chrome boundary.
nsCOMPtr<nsIDOMElement> elt =
do_QueryInterface(piTop->GetFrameElementInternal());
do_QueryInterface(top->GetFrameElementInternal());
elt.forget(aElement);
return NS_OK;
}
Expand Down
12 changes: 6 additions & 6 deletions docshell/base/nsDocShellEditorData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ nsDocShellEditorData::DetachFromWindow()
mDetachedMakeEditable = mMakeEditable;
mMakeEditable = false;

nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
mDetachedEditingState = htmlDoc->GetEditingState();
}
Expand All @@ -183,9 +183,9 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
mIsDetached = false;
mMakeEditable = mDetachedMakeEditable;

nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow);
nsCOMPtr<nsIDocument> doc = window->GetDoc();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
htmlDoc->SetEditingState(mDetachedEditingState);
}
Expand Down
3 changes: 1 addition & 2 deletions dom/audiochannel/AudioChannelAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
MOZ_ASSERT(pInnerWindow->IsInnerWindow());
mInnerWindowID = pInnerWindow->WindowID();

nsCOMPtr<nsIDOMWindow> topWindow;
aWindow->GetScriptableTop(getter_AddRefs(topWindow));
nsCOMPtr<nsPIDOMWindow> topWindow = pInnerWindow->GetScriptableTop();
if (NS_WARN_IF(!topWindow)) {
return NS_OK;
}
Expand Down
Loading

0 comments on commit c7d3c4e

Please sign in to comment.