bug 966059 - add nsIDocShell::GetWindow and GetDocument r=smaug

This commit is contained in:
Trevor Saunders 2014-01-09 21:03:47 -05:00
Родитель 0eae897026
Коммит 78966cf36b
43 изменённых файлов: 406 добавлений и 301 удалений

Просмотреть файл

@ -408,8 +408,7 @@ logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
LogDocInfo(documentNode, document);
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
printf("\n ");
LogShellLoadType(docShell);
printf("\n");

Просмотреть файл

@ -406,8 +406,7 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
// if set, serialize the content under this node
nsCOMPtr<nsIContent> nodeToSerialize;
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(mWindow);
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
nsCOMPtr<nsIDocShellTreeItem> dsti = mWindow->GetDocShell();
const bool isChromeShell =
dsti && dsti->ItemType() == nsIDocShellTreeItem::typeChrome;

Просмотреть файл

@ -5056,8 +5056,12 @@ nsContentUtils::CheckForSubFrameDrop(nsIDragSession* aDragSession,
}
nsIDocument* targetDoc = target->OwnerDoc();
nsCOMPtr<nsIWebNavigation> twebnav = do_GetInterface(targetDoc->GetWindow());
nsCOMPtr<nsIDocShellTreeItem> tdsti = do_QueryInterface(twebnav);
nsPIDOMWindow* targetWin = targetDoc->GetWindow();
if (!targetWin) {
return true;
}
nsCOMPtr<nsIDocShellTreeItem> tdsti = targetWin->GetDocShell();
if (!tdsti) {
return true;
}
@ -5899,7 +5903,7 @@ nsContentUtils::FlushLayoutForTree(nsIDOMWindow* aWindow)
for (; i < i_end; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(item);
nsCOMPtr<nsIDOMWindow> win = item->GetWindow();
if (win) {
FlushLayoutForTree(win);
}

Просмотреть файл

@ -637,7 +637,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
if (!nsContentUtils::IsSafeToRunScript())
return false;
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(piWindow);
nsCOMPtr<nsIDocShell> docShell = piWindow->GetDocShell();
const bool chromeShell =
docShell && docShell->ItemType() == nsIDocShellTreeItem::typeChrome;

Просмотреть файл

@ -4572,10 +4572,10 @@ nsDocument::GetWindowInternal() const
// the docshell, the outer window might be still obtainable from the it.
nsCOMPtr<nsPIDOMWindow> win;
if (mRemovedFromDocShell) {
nsCOMPtr<nsIInterfaceRequestor> requestor(mDocumentContainer);
if (requestor) {
// The docshell returns the outer window we are done.
win = do_GetInterface(requestor);
// The docshell returns the outer window we are done.
nsCOMPtr<nsIDocShell> kungfuDeathGrip(mDocumentContainer);
if (mDocumentContainer) {
win = mDocumentContainer->GetWindow();
}
} else {
win = do_QueryInterface(mScriptGlobalObject);
@ -10986,7 +10986,7 @@ IsInActiveTab(nsIDocument* aDoc)
if (!rootItem) {
return false;
}
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
nsCOMPtr<nsIDOMWindow> rootWin = rootItem->GetWindow();
if (!rootWin) {
return false;
}

Просмотреть файл

@ -653,9 +653,9 @@ static void
FirePageHideEvent(nsIDocShellTreeItem* aItem,
EventTarget* aChromeEventHandler)
{
nsCOMPtr<nsIDocument> internalDoc = do_GetInterface(aItem);
NS_ASSERTION(internalDoc, "What happened here?");
internalDoc->OnPageHide(true, aChromeEventHandler);
nsCOMPtr<nsIDocument> doc = aItem->GetDocument();
NS_ASSERTION(doc, "What happened here?");
doc->OnPageHide(true, aChromeEventHandler);
int32_t childCount = 0;
aItem->GetChildCount(&childCount);
@ -695,10 +695,10 @@ FirePageShowEvent(nsIDocShellTreeItem* aItem,
}
}
nsCOMPtr<nsIDocument> internalDoc = do_GetInterface(aItem);
NS_ASSERTION(internalDoc, "What happened here?");
if (internalDoc->IsShowing() == aFireIfShowing) {
internalDoc->OnPageShow(true, aChromeEventHandler);
nsCOMPtr<nsIDocument> doc = aItem->GetDocument();
NS_ASSERTION(doc, "What happened here?");
if (doc->IsShowing() == aFireIfShowing) {
doc->OnPageShow(true, aChromeEventHandler);
}
}
@ -1156,8 +1156,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
return NS_ERROR_NOT_IMPLEMENTED;
}
nsCOMPtr<nsPIDOMWindow> ourWindow = do_GetInterface(ourDocshell);
nsCOMPtr<nsPIDOMWindow> otherWindow = do_GetInterface(otherDocshell);
nsCOMPtr<nsPIDOMWindow> ourWindow = ourDocshell->GetWindow();
nsCOMPtr<nsPIDOMWindow> otherWindow = otherDocshell->GetWindow();
nsCOMPtr<Element> ourFrameElement =
ourWindow->GetFrameElementInternal();
@ -1411,9 +1411,11 @@ nsFrameLoader::Destroy()
}
// Let our window know that we are gone
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
if (win_private) {
win_private->SetFrameElementInternal(nullptr);
if (mDocShell) {
nsCOMPtr<nsPIDOMWindow> win_private(mDocShell->GetWindow());
if (win_private) {
win_private->SetFrameElementInternal(nullptr);
}
}
if ((mNeedsAsyncDestroy || !doc ||
@ -1677,7 +1679,7 @@ nsFrameLoader::MaybeCreateDocShell()
mDocShell->SetChromeEventHandler(chromeEventHandler);
// This is nasty, this code (the do_GetInterface(mDocShell) below)
// This is nasty, this code (the mDocShell->GetWindow() below)
// *must* come *after* the above call to
// mDocShell->SetChromeEventHandler() for the global window to get
// the right chrome event handler.
@ -1686,7 +1688,7 @@ nsFrameLoader::MaybeCreateDocShell()
nsCOMPtr<Element> frame_element = mOwnerContent;
NS_ASSERTION(frame_element, "frame loader owner element not a DOM element!");
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
nsCOMPtr<nsPIDOMWindow> win_private(mDocShell->GetWindow());
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
if (win_private) {
win_private->SetFrameElementInternal(frame_element);
@ -1878,14 +1880,15 @@ nsFrameLoader::GetWindowDimensions(nsRect& aRect)
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIWebNavigation> parentAsWebNav =
do_GetInterface(doc->GetWindow());
if (!parentAsWebNav) {
nsCOMPtr<nsPIDOMWindow> win = doc->GetWindow();
if (!win) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsWebNav));
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(win->GetDocShell());
if (!parentAsItem) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocShellTreeOwner> parentOwner;
if (NS_FAILED(parentAsItem->GetTreeOwner(getter_AddRefs(parentOwner))) ||
@ -2052,14 +2055,15 @@ nsFrameLoader::TryRemoteBrowser()
return false;
}
nsCOMPtr<nsIWebNavigation> parentAsWebNav =
do_GetInterface(doc->GetWindow());
if (!parentAsWebNav) {
nsCOMPtr<nsPIDOMWindow> parentWin = doc->GetWindow();
if (!parentWin) {
return false;
}
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsWebNav));
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(parentWin->GetDocShell());
if (!parentAsItem) {
return false;
}
// <iframe mozbrowser> gets to skip these checks.
if (!OwnerIsBrowserOrAppFrame()) {
@ -2127,7 +2131,7 @@ nsFrameLoader::TryRemoteBrowser()
mChildID = mRemoteBrowser->Manager()->ChildID();
nsCOMPtr<nsIDocShellTreeItem> rootItem;
parentAsItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
nsCOMPtr<nsIDOMWindow> rootWin = rootItem->GetWindow();
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
NS_ABORT_IF_FALSE(rootChromeWin, "How did we not get a chrome window here?");
@ -2222,15 +2226,18 @@ nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
dest->MaybeCreateDocShell();
NS_ENSURE_STATE(dest->mDocShell);
nsCOMPtr<nsIDocument> dummy = do_GetInterface(dest->mDocShell);
nsCOMPtr<nsIDocument> dummy = dest->mDocShell->GetDocument();
nsCOMPtr<nsIContentViewer> viewer;
dest->mDocShell->GetContentViewer(getter_AddRefs(viewer));
NS_ENSURE_STATE(viewer);
nsCOMPtr<nsIDocShell> origDocShell;
GetDocShell(getter_AddRefs(origDocShell));
nsCOMPtr<nsIDocument> doc = do_GetInterface(origDocShell);
NS_ENSURE_STATE(origDocShell);
nsCOMPtr<nsIDocument> doc = origDocShell->GetDocument();
NS_ENSURE_STATE(doc);
nsCOMPtr<nsIDocument> clonedDoc = doc->CreateStaticClone(dest->mDocShell);
nsCOMPtr<nsIDOMDocument> clonedDOMDoc = do_QueryInterface(clonedDoc);

Просмотреть файл

@ -167,7 +167,11 @@ NS_IMETHODIMP
nsInProcessTabChildGlobal::GetContent(nsIDOMWindow** aContent)
{
*aContent = nullptr;
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
if (!mDocShell) {
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> window = mDocShell->GetWindow();
window.swap(*aContent);
return NS_OK;
}
@ -220,10 +224,12 @@ nsInProcessTabChildGlobal::DelayedDisconnect()
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
// Continue with the Disconnect cleanup
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(mDocShell);
if (win) {
MOZ_ASSERT(win->IsOuterWindow());
win->SetChromeEventHandler(win->GetChromeEventHandler());
if (mDocShell) {
nsCOMPtr<nsPIDOMWindow> win = mDocShell->GetWindow();
if (win) {
MOZ_ASSERT(win->IsOuterWindow());
win->SetChromeEventHandler(win->GetChromeEventHandler());
}
}
mDocShell = nullptr;
mChromeMessageManager = nullptr;

Просмотреть файл

@ -3727,8 +3727,13 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsXULElement& elem,
PBrowserParent *child = frameloader->GetRemoteBrowser();
if (!child) {
nsCOMPtr<nsIDOMWindow> window =
do_GetInterface(frameloader->GetExistingDocShell());
nsIDocShell* docShell = frameLoader->GetExistingDocShell();
if (!docShell) {
error.Throw(NS_ERROR_FAILURE);
return;
}
nsCOMPtr<nsIDOMWindow> window = docShell->GetWindow();
if (!window) {
error.Throw(NS_ERROR_FAILURE);
return;

Просмотреть файл

@ -4700,9 +4700,11 @@ XULDocument::ParserObserver::OnStopRequest(nsIRequest *request,
already_AddRefed<nsPIWindowRoot>
XULDocument::GetWindowRoot()
{
nsCOMPtr<nsIInterfaceRequestor> ir(mDocumentContainer);
nsCOMPtr<nsIDOMWindow> window(do_GetInterface(ir));
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(window));
if (!mDocumentContainer) {
return nullptr;
}
nsCOMPtr<nsPIDOMWindow> piWin = mDocumentContainer->GetWindow();
return piWin ? piWin->GetTopWindowRoot() : nullptr;
}

Просмотреть файл

@ -134,7 +134,8 @@ nsDSURIContentListener::DoContent(const char* aContentType,
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
nsCOMPtr<nsIDOMWindow> domWindow = mDocShell ? mDocShell->GetWindow()
: nullptr;
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus();
}
@ -286,7 +287,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// 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 = do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
// If we don't have DOMWindow there is no risk of clickjacking
if (!thisWindow)
return true;
@ -328,7 +329,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
}
bool system = false;
topDoc = do_GetInterface(parentDocShellItem);
topDoc = parentDocShellItem->GetDocument();
if (topDoc) {
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(),
&system)) && system) {
@ -355,7 +356,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
return false;
}
topDoc = do_GetInterface(curDocShellItem);
topDoc = curDocShellItem->GetDocument();
nsCOMPtr<nsIURI> topUri;
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
@ -452,9 +453,9 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
nsIURI* aThisURI,
XFOHeader aHeader)
{
nsresult rv = NS_OK;
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
nsCOMPtr<nsPIDOMWindow> topOuterWindow = do_GetInterface(aTopDocShellItem);
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
if (!topOuterWindow)
return;
@ -465,10 +466,8 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
nsCOMPtr<nsIURI> topURI;
nsCOMPtr<nsIDocument> document;
document = do_GetInterface(aTopDocShellItem);
rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
if (NS_FAILED(rv))
return;

Просмотреть файл

@ -1125,8 +1125,7 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
tabChild->
GetMessageManager(getter_AddRefs(mm));
} else {
nsCOMPtr<nsPIDOMWindow> win =
do_GetInterface(static_cast<nsIDocShell*>(this));
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (win) {
mm = do_QueryInterface(win->GetParentTarget());
}
@ -1748,12 +1747,14 @@ nsDocShell::ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
return true;
}
MOZ_ASSERT(aOriginTreeItem && aTargetTreeItem, "need two docshells");
// Get origin document principal
nsCOMPtr<nsIDocument> originDocument(do_GetInterface(aOriginTreeItem));
nsCOMPtr<nsIDocument> originDocument = aOriginTreeItem->GetDocument();
NS_ENSURE_TRUE(originDocument, false);
// Get target principal
nsCOMPtr<nsIDocument> targetDocument(do_GetInterface(aTargetTreeItem));
nsCOMPtr<nsIDocument> targetDocument = aTargetTreeItem->GetDocument();
NS_ENSURE_TRUE(targetDocument, false);
bool equal;
@ -2093,7 +2094,7 @@ nsDocShell::GetChannelIsUnsafe(bool *aUnsafe)
NS_IMETHODIMP
nsDocShell::GetHasMixedActiveContentLoaded(bool* aHasMixedActiveContentLoaded)
{
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
nsCOMPtr<nsIDocument> doc(GetDocument());
*aHasMixedActiveContentLoaded = doc && doc->GetHasMixedActiveContentLoaded();
return NS_OK;
}
@ -2101,7 +2102,7 @@ nsDocShell::GetHasMixedActiveContentLoaded(bool* aHasMixedActiveContentLoaded)
NS_IMETHODIMP
nsDocShell::GetHasMixedActiveContentBlocked(bool* aHasMixedActiveContentBlocked)
{
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
nsCOMPtr<nsIDocument> doc(GetDocument());
*aHasMixedActiveContentBlocked = doc && doc->GetHasMixedActiveContentBlocked();
return NS_OK;
}
@ -2109,7 +2110,7 @@ nsDocShell::GetHasMixedActiveContentBlocked(bool* aHasMixedActiveContentBlocked)
NS_IMETHODIMP
nsDocShell::GetHasMixedDisplayContentLoaded(bool* aHasMixedDisplayContentLoaded)
{
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
nsCOMPtr<nsIDocument> doc(GetDocument());
*aHasMixedDisplayContentLoaded = doc && doc->GetHasMixedDisplayContentLoaded();
return NS_OK;
}
@ -2117,7 +2118,7 @@ nsDocShell::GetHasMixedDisplayContentLoaded(bool* aHasMixedDisplayContentLoaded)
NS_IMETHODIMP
nsDocShell::GetHasMixedDisplayContentBlocked(bool* aHasMixedDisplayContentBlocked)
{
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
nsCOMPtr<nsIDocument> doc(GetDocument());
*aHasMixedDisplayContentBlocked = doc && doc->GetHasMixedDisplayContentBlocked();
return NS_OK;
}
@ -2451,7 +2452,7 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
// has the allowfullscreen attribute set to true. If any ancestor
// iframe does not have mozallowfullscreen=true, then fullscreen is
// prohibited.
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
if (!win) {
return NS_OK;
}
@ -2466,11 +2467,8 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
// If we have no parent then we're the root docshell; no ancestor of the
// original docshell doesn't have a allowfullscreen attribute, so
// report fullscreen as allowed.
nsCOMPtr<nsIDocShellTreeItem> dsti = do_GetInterface(GetAsSupports(this));
NS_ENSURE_TRUE(dsti, NS_OK);
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
dsti->GetParent(getter_AddRefs(parentTreeItem));
GetParent(getter_AddRefs(parentTreeItem));
if (!parentTreeItem) {
*aFullscreenAllowed = true;
return NS_OK;
@ -3248,7 +3246,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
return false;
}
nsCOMPtr<nsIDOMWindow> targetWindow = do_GetInterface(aTargetItem);
nsCOMPtr<nsIDOMWindow> targetWindow = aTargetItem->GetWindow();
if (!targetWindow) {
NS_ERROR("This should not happen, really");
return false;
@ -3269,7 +3267,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
static bool
ItemIsActive(nsIDocShellTreeItem *aItem)
{
nsCOMPtr<nsIDOMWindow> window(do_GetInterface(aItem));
nsCOMPtr<nsIDOMWindow> window = aItem->GetWindow();
if (window) {
bool isClosed;
@ -4126,6 +4124,20 @@ nsDocShell::GetScriptGlobalObject()
return mScriptGlobal;
}
nsIDocument*
nsDocShell::GetDocument()
{
NS_ENSURE_SUCCESS(EnsureContentViewer(), nullptr);
return mContentViewer->GetDocument();
}
nsPIDOMWindow*
nsDocShell::GetWindow()
{
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
return mScriptGlobal;
}
NS_IMETHODIMP
nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
{
@ -4925,7 +4937,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
rv = LoadHistoryEntry(mLSHE, loadType);
}
else {
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
nsCOMPtr<nsIDocument> doc(GetDocument());
// Do not inherit owner from document
uint32_t flags = INTERNAL_LOAD_FLAGS_NONE;
@ -5769,7 +5781,7 @@ nsDocShell::GetAllowMixedContentAndConnectionData(bool* aRootHasSecureConnection
*aIsRootDocShell = sameTypeRoot.get() == static_cast<nsIDocShellTreeItem *>(this);
// now get the document from sameTypeRoot
nsCOMPtr<nsIDocument> rootDoc = do_GetInterface(sameTypeRoot);
nsCOMPtr<nsIDocument> rootDoc = sameTypeRoot->GetDocument();
if (rootDoc) {
nsCOMPtr<nsIPrincipal> rootPrincipal = rootDoc->NodePrincipal();
@ -7215,7 +7227,7 @@ nsDocShell::EnsureContentViewer()
nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {
nsCOMPtr<nsPIDOMWindow> domWin = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsPIDOMWindow> domWin = GetWindow();
if (domWin) {
nsCOMPtr<nsIContent> parentContent =
do_QueryInterface(domWin->GetFrameElementInternal());
@ -7228,7 +7240,7 @@ nsDocShell::EnsureContentViewer()
nsresult rv = CreateAboutBlankContentViewer(principal, baseURI);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
nsCOMPtr<nsIDocument> doc(GetDocument());
NS_ASSERTION(doc,
"Should have doc if CreateAboutBlankContentViewer "
"succeeded!");
@ -7618,7 +7630,7 @@ nsDocShell::FinishRestore()
ReattachEditorToWindow(mOSHE);
}
nsCOMPtr<nsIDocument> doc = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> doc = GetDocument();
if (doc) {
// Finally, we remove the request from the loadgroup. This will
// cause onStateChange(STATE_STOP) to fire, which will fire the
@ -7981,8 +7993,9 @@ nsDocShell::RestoreFromHistory()
if (document) {
nsCOMPtr<nsIDocShellTreeItem> parent;
GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIDocument> d = do_GetInterface(parent);
if (d) {
if (parent) {
nsCOMPtr<nsIDocument> d = parent->GetDocument();
if (d) {
if (d->EventHandlingSuppressed()) {
document->SuppressEventHandling(nsIDocument::eEvents,
d->EventHandlingSuppressed());
@ -7996,8 +8009,9 @@ nsDocShell::RestoreFromHistory()
nsCOMPtr<nsPIDOMWindow> parentWindow = d->GetWindow();
if (parentWindow) {
parentSuspendCount = parentWindow->TimeoutSuspendCount();
parentSuspendCount = parentWindow->TimeoutSuspendCount();
}
}
}
// Use the uri from the mLSHE we had when we entered this function
@ -8013,8 +8027,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 =
do_GetInterface(static_cast<nsIInterfaceRequestor*>(this));
nsCOMPtr<nsPIDOMWindow> privWin = GetWindow();
NS_ASSERTION(privWin, "could not get nsPIDOMWindow interface");
rv = privWin->RestoreWindowState(windowState);
@ -8604,7 +8617,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
nsresult
nsDocShell::SetDocCurrentStateObj(nsISHEntry *shEntry)
{
nsCOMPtr<nsIDocument> document = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> document = GetDocument();
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
nsCOMPtr<nsIStructuredCloneContainer> scContainer;
@ -8650,7 +8663,7 @@ nsDocShell::CheckLoadingPermissions()
// or any of its ancestors.
nsCOMPtr<nsIDocShellTreeItem> item(this);
do {
nsCOMPtr<nsIScriptGlobalObject> sgo(do_GetInterface(item));
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(item);
nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(sgo));
nsIPrincipal *p;
@ -9037,8 +9050,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
}
}
nsCOMPtr<nsPIDOMWindow> win =
do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
nsDependentString name(aWindowTarget);
@ -9099,8 +9111,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 =
do_GetInterface(targetDocShell);
nsCOMPtr<nsIDOMWindow> domWin = targetDocShell->GetWindow();
if (domWin) {
domWin->Close();
}
@ -9411,8 +9422,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
}
// Set the doc's URI according to the new history entry's URI.
nsCOMPtr<nsIDocument> doc =
do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> doc = GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
doc->SetDocumentURI(aURI);
@ -9623,7 +9633,7 @@ nsDocShell::GetInheritedPrincipal(bool aConsiderCurrentDocument)
nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {
document = do_GetInterface(parentItem);
document = parentItem->GetDocument();
}
}
@ -9710,15 +9720,17 @@ nsDocShell::DoURILoad(nsIURI * aURI,
nsCOMPtr<nsIContentSecurityPolicy> csp;
nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetSameTypeParent(getter_AddRefs(parentItem));
nsCOMPtr<nsIDocument> doc = do_GetInterface(parentItem);
if (doc) {
if (parentItem) {
nsCOMPtr<nsIDocument> doc = parentItem->GetDocument();
if (doc) {
rv = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
NS_ENSURE_SUCCESS(rv, rv);
if (csp) {
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
channelPolicy->SetContentSecurityPolicy(csp);
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_SUBDOCUMENT);
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
channelPolicy->SetContentSecurityPolicy(csp);
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_SUBDOCUMENT);
}
}
}
// Only allow view-source scheme in top-level docshells. view-source is
@ -10631,7 +10643,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
aReplace = true;
}
nsCOMPtr<nsIDocument> document = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> document = GetDocument();
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
// Step 1: Serialize aData using structured clone.
@ -10642,8 +10654,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
// 634834) To protect against this, we abort if our principal changes due
// to the InitFromJSVal() call.
{
nsCOMPtr<nsIDocument> origDocument =
do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> origDocument = GetDocument();
if (!origDocument)
return NS_ERROR_DOM_SECURITY_ERR;
nsCOMPtr<nsIPrincipal> origPrincipal = origDocument->NodePrincipal();
@ -10664,8 +10675,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
}
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> newDocument =
do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDocument> newDocument = GetDocument();
if (!newDocument)
return NS_ERROR_DOM_SECURITY_ERR;
nsCOMPtr<nsIPrincipal> newPrincipal = newDocument->NodePrincipal();
@ -12216,7 +12226,7 @@ nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
NS_IMETHODIMP
nsDocShell::GetTopWindow(nsIDOMWindow** aWindow)
{
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDOMWindow> win = GetWindow();
if (win) {
win->GetTop(aWindow);
}
@ -12227,7 +12237,7 @@ NS_IMETHODIMP
nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
{
*aElement = nullptr;
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(GetAsSupports(this));
nsCOMPtr<nsIDOMWindow> win = GetWindow();
if (!win) {
return NS_OK;
}
@ -12345,9 +12355,7 @@ nsDocShell::EnsureCommandHandler()
do_CreateInstance("@mozilla.org/embedcomp/command-manager;1");
if (!commandUpdater) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDOMWindow> domWindow =
do_GetInterface(static_cast<nsIInterfaceRequestor *>(this));
nsCOMPtr<nsIDOMWindow> domWindow = GetWindow();
nsresult rv = commandUpdater->Init(domWindow);
if (NS_SUCCEEDED(rv))
mCommandManager = do_QueryInterface(commandUpdater);

Просмотреть файл

@ -8,7 +8,7 @@
#include "nsDocShellEditorData.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsIDOMWindow.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIEditor.h"
#include "nsIEditingSession.h"
@ -102,8 +102,9 @@ nsDocShellEditorData::CreateEditor()
nsCOMPtr<nsIEditingSession> editingSession;
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
rv = editingSession->SetupEditorOnWindow(domWindow);
if (NS_FAILED(rv)) return rv;
@ -201,7 +202,8 @@ nsDocShellEditorData::DetachFromWindow()
NS_ASSERTION(mEditingSession,
"Can't detach when we don't have a session to detach!");
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsresult rv = mEditingSession->DetachFromWindow(domWindow);
NS_ENSURE_SUCCESS(rv, rv);
@ -225,7 +227,8 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
{
mDocShell = aDocShell;
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsresult rv = mEditingSession->ReattachToWindow(domWindow);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -45,7 +45,7 @@ interface nsIScrollObserver;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(e46d924d-c20f-4add-8cf5-1e1c817b2181)]
[scriptable, builtinclass, uuid(3ca96c12-b69d-4b54-83c5-25a18d32a22b)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**

Просмотреть файл

@ -7,6 +7,8 @@
#include "nsISupports.idl"
interface nsIDocShellTreeOwner;
interface nsIDocument;
interface nsPIDOMWindow;
/**
@ -15,7 +17,7 @@ interface nsIDocShellTreeOwner;
* node or a leaf.
*/
[scriptable, uuid(f897f4af-f67e-4115-9d37-ce09f71122e2)]
[scriptable, uuid(edb99640-8378-4106-8673-e701a086eb1c)]
interface nsIDocShellTreeItem : nsISupports
{
/*
@ -175,5 +177,8 @@ interface nsIDocShellTreeItem : nsISupports
in boolean aSameType,
in nsIDocShellTreeItem aRequestor,
in nsIDocShellTreeItem aOriginalRequestor);
[noscript,nostdcall,notxpcom] nsIDocument getDocument();
[noscript,nostdcall,notxpcom] nsPIDOMWindow getWindow();
};

Просмотреть файл

@ -91,7 +91,7 @@ nsDOMWindowList::IndexedGetter(uint32_t aIndex, bool& aFound)
return nullptr;
}
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(item);
nsCOMPtr<nsIDOMWindow> window = item->GetWindow();
MOZ_ASSERT(window);
aFound = true;

Просмотреть файл

@ -662,8 +662,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow)
if (mActiveWindow)
WindowLowered(mActiveWindow);
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(aWindow));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(webnav));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = window->GetDocShell();
// If there's no docShellAsItem, this window must have been closed,
// in that case there is no tree owner.
NS_ENSURE_TRUE(docShellAsItem, NS_OK);
@ -805,10 +804,12 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
// so that no element is focused.
nsIDocument* subdoc = aDocument->GetSubDocumentFor(content);
if (subdoc) {
nsCOMPtr<nsISupports> container = subdoc->GetContainer();
nsCOMPtr<nsPIDOMWindow> childWindow = do_GetInterface(container);
if (childWindow && IsSameOrAncestor(childWindow, mFocusedWindow)) {
ClearFocus(mActiveWindow);
nsCOMPtr<nsIDocShell> docShell = subdoc->GetDocShell();
if (docShell) {
nsCOMPtr<nsPIDOMWindow> childWindow = docShell->GetWindow();
if (childWindow && IsSameOrAncestor(childWindow, mFocusedWindow)) {
ClearFocus(mActiveWindow);
}
}
}
}
@ -968,14 +969,16 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow)
// ensures that the focused window isn't in a chain of frames that doesn't
// exist any more.
if (window != mFocusedWindow) {
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(mFocusedWindow));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
nsCOMPtr<nsIDocShellTreeItem> dsti =
mFocusedWindow ? mFocusedWindow->GetDocShell() : nullptr;
if (dsti) {
nsCOMPtr<nsIDocShellTreeItem> parentDsti;
dsti->GetParent(getter_AddRefs(parentDsti));
nsCOMPtr<nsPIDOMWindow> parentWindow = do_GetInterface(parentDsti);
if (parentWindow)
parentWindow->SetFocusedNode(nullptr);
if (parentDsti) {
nsCOMPtr<nsPIDOMWindow> parentWindow = parentDsti->GetWindow();
if (parentWindow)
parentWindow->SetFocusedNode(nullptr);
}
}
SetFocusedWindowInternal(window);
@ -1144,13 +1147,12 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
// new root docshell for the new element with the active window's docshell.
bool isElementInActiveWindow = false;
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(newWindow);
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
nsCOMPtr<nsIDocShellTreeItem> dsti = newWindow->GetDocShell();
nsCOMPtr<nsPIDOMWindow> newRootWindow;
if (dsti) {
nsCOMPtr<nsIDocShellTreeItem> root;
dsti->GetRootTreeItem(getter_AddRefs(root));
newRootWindow = do_GetInterface(root);
newRootWindow = root ? root->GetWindow() : nullptr;
isElementInActiveWindow = (mActiveWindow && newRootWindow == mActiveWindow);
}
@ -1276,11 +1278,12 @@ bool
nsFocusManager::IsSameOrAncestor(nsPIDOMWindow* aPossibleAncestor,
nsPIDOMWindow* aWindow)
{
nsCOMPtr<nsIWebNavigation> awebnav(do_GetInterface(aPossibleAncestor));
nsCOMPtr<nsIDocShellTreeItem> ancestordsti = do_QueryInterface(awebnav);
if (!aWindow || !aPossibleAncestor) {
return false;
}
nsCOMPtr<nsIWebNavigation> fwebnav(do_GetInterface(aWindow));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(fwebnav);
nsCOMPtr<nsIDocShellTreeItem> ancestordsti = aPossibleAncestor->GetDocShell();
nsCOMPtr<nsIDocShellTreeItem> dsti = aWindow->GetDocShell();
while (dsti) {
if (dsti == ancestordsti)
return true;
@ -1296,12 +1299,12 @@ already_AddRefed<nsPIDOMWindow>
nsFocusManager::GetCommonAncestor(nsPIDOMWindow* aWindow1,
nsPIDOMWindow* aWindow2)
{
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(aWindow1));
nsCOMPtr<nsIDocShellTreeItem> dsti1 = do_QueryInterface(webnav);
NS_ENSURE_TRUE(aWindow1 && aWindow2, nullptr);
nsCOMPtr<nsIDocShellTreeItem> dsti1 = aWindow1->GetDocShell();
NS_ENSURE_TRUE(dsti1, nullptr);
webnav = do_GetInterface(aWindow2);
nsCOMPtr<nsIDocShellTreeItem> dsti2 = do_QueryInterface(webnav);
nsCOMPtr<nsIDocShellTreeItem> dsti2 = aWindow2->GetDocShell();
NS_ENSURE_TRUE(dsti2, nullptr);
nsAutoTArray<nsIDocShellTreeItem*, 30> parents1, parents2;
@ -1331,7 +1334,7 @@ nsFocusManager::GetCommonAncestor(nsPIDOMWindow* aWindow1,
parent = child1;
}
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(parent);
nsCOMPtr<nsPIDOMWindow> window = parent ? parent->GetWindow() : nullptr;
return window.forget();
}
@ -1348,14 +1351,16 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindow* aWindow,
nsCOMPtr<nsIContent> frameContent =
do_QueryInterface(window->GetFrameElementInternal());
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(window));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
nsCOMPtr<nsIDocShellTreeItem> dsti = window->GetDocShell();
if (!dsti)
return;
nsCOMPtr<nsIDocShellTreeItem> parentDsti;
dsti->GetParent(getter_AddRefs(parentDsti));
if (!parentDsti) {
return;
}
window = do_GetInterface(parentDsti);
window = parentDsti->GetWindow();
if (window) {
// if the parent window is visible but aWindow was not, then we have
// likely moved up and out from a hidden tab to the browser window, or a
@ -2005,8 +2010,8 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow)
widget->SetFocus(true);
}
#else
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(aWindow);
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = do_QueryInterface(webnav);
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin =
do_QueryInterface(aWindow->GetDocShell());
if (treeOwnerAsWin) {
nsCOMPtr<nsIWidget> widget;
treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
@ -2581,14 +2586,14 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
// move up to the parent shell and try again from there.
// first, get the frame element this window is inside.
nsCOMPtr<nsPIDOMWindow> piWindow = do_GetInterface(docShell);
nsCOMPtr<nsPIDOMWindow> piWindow = docShell->GetWindow();
NS_ENSURE_TRUE(piWindow, NS_ERROR_FAILURE);
// Next, retrieve the parent docshell, document and presshell.
docShell = do_QueryInterface(docShellParent);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> piParentWindow = do_GetInterface(docShellParent);
nsCOMPtr<nsPIDOMWindow> piParentWindow = docShellParent->GetWindow();
NS_ENSURE_TRUE(piParentWindow, NS_ERROR_FAILURE);
doc = piParentWindow->GetExtantDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
@ -2632,7 +2637,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
docShell->TabToTreeOwner(forward, &tookFocus);
// if the tree owner, took the focus, blur the current content
if (tookFocus) {
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell);
nsCOMPtr<nsPIDOMWindow> window = docShell->GetWindow();
if (window->GetFocusedNode() == mFocusedContent)
Blur(mFocusedWindow, nullptr, true, true);
else
@ -3184,14 +3189,9 @@ nsFocusManager::GetNextTabbableDocument(nsIContent* aStartContent, bool aForward
else if (mFocusedWindow) {
startDocShell = mFocusedWindow->GetDocShell();
doc = mFocusedWindow->GetExtantDoc();
}
else {
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(mActiveWindow);
startDocShell = do_QueryInterface(webnav);
if (mActiveWindow) {
doc = mActiveWindow->GetExtantDoc();
}
} else if (mActiveWindow) {
startDocShell = mActiveWindow->GetDocShell();
doc = mActiveWindow->GetExtantDoc();
}
if (!startDocShell)
@ -3251,7 +3251,7 @@ nsFocusManager::GetNextTabbableDocument(nsIContent* aStartContent, bool aForward
}
curItem = nextItem;
nextFrame = do_GetInterface(nextItem);
nextFrame = nextItem ? nextItem->GetWindow() : nullptr;
}
if (!nextFrame)

Просмотреть файл

@ -3378,7 +3378,7 @@ nsPIDOMWindow::MaybeCreateDoc()
// Note that |document| here is the same thing as our mDoc, but we
// don't have to explicitly set the member variable because the docshell
// has already called SetNewDocument().
nsCOMPtr<nsIDocument> document = do_GetInterface(docShell);
nsCOMPtr<nsIDocument> document = docShell->GetDocument();
}
}
@ -3801,9 +3801,8 @@ nsGlobalWindow::GetRealParent(nsIDOMWindow** aParent)
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
if (parent) {
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(parent));
NS_ENSURE_SUCCESS(CallQueryInterface(globalObject.get(), aParent),
NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> win = parent->GetWindow();
win.forget(aParent);
}
else {
*aParent = static_cast<nsIDOMWindow*>(this);
@ -3968,7 +3967,11 @@ nsGlobalWindow::GetContentInternal(ErrorResult& aError)
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
}
domWindow = do_GetInterface(primaryContent);
if (!primaryContent) {
return nullptr;
}
domWindow = primaryContent->GetWindow();
return domWindow.forget();
}
@ -5709,7 +5712,7 @@ nsGlobalWindow::GetLength(uint32_t* aLength)
return NS_OK;
}
already_AddRefed<nsIDOMWindow>
nsPIDOMWindow*
nsGlobalWindow::GetChildWindow(const nsAString& aName)
{
nsCOMPtr<nsIDocShell> docShell(GetDocShell());
@ -5720,8 +5723,7 @@ nsGlobalWindow::GetChildWindow(const nsAString& aName)
false, true, nullptr, nullptr,
getter_AddRefs(child));
nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
return child_win.forget();
return child ? child->GetWindow() : nullptr;
}
bool
@ -5888,7 +5890,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
// call SetFullScreen on that window instead.
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(rootItem);
nsCOMPtr<nsPIDOMWindow> window = rootItem ? rootItem->GetWindow() : nullptr;
if (!window)
return NS_ERROR_FAILURE;
if (rootItem != mDocShell)
@ -5972,7 +5974,7 @@ nsGlobalWindow::GetFullScreen(ErrorResult& aError)
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
if (rootItem != mDocShell) {
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(rootItem);
nsCOMPtr<nsIDOMWindow> window = rootItem->GetWindow();
if (window) {
bool fullScreen = false;
aError = window->GetFullScreen(&fullScreen);
@ -6445,7 +6447,7 @@ nsGlobalWindow::Focus(ErrorResult& aError)
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
nsCOMPtr<nsIDOMWindow> rootWin = rootItem ? rootItem->GetWindow() : nullptr;
bool isActive = (rootWin == activeWindow);
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
@ -6488,7 +6490,8 @@ nsGlobalWindow::Focus(ErrorResult& aError)
mDocShell->GetParent(getter_AddRefs(parentDsti));
// set the parent's current focus to the frame containing this window.
nsCOMPtr<nsPIDOMWindow> parent = do_GetInterface(parentDsti);
nsCOMPtr<nsPIDOMWindow> parent =
parentDsti ? parentDsti->GetWindow() : nullptr;
if (parent) {
nsCOMPtr<nsIDocument> parentdoc = parent->GetDoc();
if (!parentdoc) {
@ -8419,7 +8422,8 @@ nsGlobalWindow::ReallyCloseWindow()
nsCOMPtr<nsIBrowserDOMWindow> bwin;
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin(do_GetInterface(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin =
rootItem ? rootItem->GetWindow() : nullptr;
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(rootWin));
if (chromeWin)
chromeWin->GetBrowserDOMWindow(getter_AddRefs(bwin));
@ -9784,7 +9788,11 @@ nsGlobalWindow::SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
for (int32_t i = 0; i < childCount; ++i) {
nsCOMPtr<nsIDocShellTreeItem> childShell;
docShell->GetChildAt(i, getter_AddRefs(childShell));
nsCOMPtr<nsPIDOMWindow> childWindow = do_GetInterface(childShell);
if (!childShell) {
continue;
}
nsCOMPtr<nsPIDOMWindow> childWindow = childShell->GetWindow();
if (childWindow) {
childWindow->SetKeyboardIndicators(aShowAccelerators, aShowFocusRings);
}
@ -11378,7 +11386,7 @@ nsGlobalWindow::FireDelayedDOMEvents()
docShell->GetChildAt(i, getter_AddRefs(childShell));
NS_ASSERTION(childShell, "null child shell");
nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
nsCOMPtr<nsPIDOMWindow> pWin = childShell->GetWindow();
if (pWin) {
nsGlobalWindow *win =
static_cast<nsGlobalWindow*>
@ -12748,7 +12756,7 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease,
docShell->GetChildAt(i, getter_AddRefs(childShell));
NS_ASSERTION(childShell, "null child shell");
nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
nsCOMPtr<nsPIDOMWindow> pWin = childShell->GetWindow();
if (pWin) {
nsGlobalWindow *win =
static_cast<nsGlobalWindow*>
@ -12856,7 +12864,7 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
docShell->GetChildAt(i, getter_AddRefs(childShell));
NS_ASSERTION(childShell, "null child shell");
nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
nsCOMPtr<nsPIDOMWindow> pWin = childShell->GetWindow();
if (pWin) {
nsGlobalWindow *win =
static_cast<nsGlobalWindow*>

Просмотреть файл

@ -546,7 +546,7 @@ public:
return static_cast<nsGlobalWindow *>(top.get());
}
already_AddRefed<nsIDOMWindow> GetChildWindow(const nsAString& aName);
nsPIDOMWindow* GetChildWindow(const nsAString& aName);
// These return true if we've reached the state in this top level window
// where we ask the user if further dialogs should be blocked.

Просмотреть файл

@ -153,7 +153,10 @@ nsHistory::Go(int32_t aDelta, ErrorResult& aRv)
}
if (!aDelta) {
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(GetDocShell()));
nsCOMPtr<nsPIDOMWindow> window;
if (nsIDocShell* docShell = GetDocShell()) {
window = docShell->GetWindow();
}
if (window && window->IsHandlingResizeEvent()) {
// history.go(0) (aka location.reload()) was called on a window

Просмотреть файл

@ -54,8 +54,10 @@ GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
nsLocation::nsLocation(nsIDocShell *aDocShell)
{
MOZ_ASSERT(aDocShell);
mDocShell = do_GetWeakReference(aDocShell);
nsCOMPtr<nsIDOMWindow> outer = do_GetInterface(aDocShell);
nsCOMPtr<nsIDOMWindow> outer = aDocShell->GetWindow();
mOuter = do_GetWeakReference(outer);
}
@ -535,7 +537,8 @@ nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
// Now check to make sure that the script is running in our window,
// since we only want to replace if the location is set by a
// <script> tag in the same window. See bug 178729.
nsCOMPtr<nsIScriptGlobalObject> ourGlobal(do_GetInterface(docShell));
nsCOMPtr<nsIScriptGlobalObject> ourGlobal =
docShell ? docShell->GetScriptGlobalObject() : nullptr;
inScriptTag = (ourGlobal == scriptContext->GetGlobalObject());
}
}
@ -786,7 +789,7 @@ nsLocation::Reload(bool aForceget)
nsresult rv;
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(docShell));
nsCOMPtr<nsPIDOMWindow> window = docShell ? docShell->GetWindow() : nullptr;
if (window && window->IsHandlingResizeEvent()) {
// location.reload() was called on a window that is handling a
@ -901,7 +904,7 @@ nsLocation::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
// the docshell. If that fails, just return null and hope that the caller passed
// an absolute URI.
if (!sgo && GetDocShell()) {
sgo = do_GetInterface(GetDocShell());
sgo = GetDocShell()->GetScriptGlobalObject();
}
NS_ENSURE_TRUE(sgo, NS_OK);
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(sgo);

Просмотреть файл

@ -270,7 +270,7 @@ nsPluginArray::Observe(nsISupports *aSubject, const char *aTopic,
bool
nsPluginArray::AllowPlugins() const
{
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWindow);
nsCOMPtr<nsIDocShell> docShell = mWindow ? mWindow->GetDocShell() : nullptr;
return docShell && docShell->PluginsAllowedInCurrentDoc();
}

Просмотреть файл

@ -283,7 +283,7 @@ BrowserElementParent::OpenWindowInProcess(nsIDOMWindow* aOpenerWindow,
frameLoader->GetDocShell(getter_AddRefs(docshell));
NS_ENSURE_TRUE(docshell, BrowserElementParent::OPEN_WINDOW_IGNORED);
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(docshell);
nsCOMPtr<nsIDOMWindow> window = docshell->GetWindow();
window.forget(aReturnWindow);
return !!*aReturnWindow ? opened : BrowserElementParent::OPEN_WINDOW_CANCELLED;

Просмотреть файл

@ -15,6 +15,7 @@
#include "nsContentUtils.h"
#include "nsIContent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDocShell.h"
#include "nsIDOMWindow.h"
#include "nsIDOMNode.h"
#include "nsIFrame.h"
@ -68,12 +69,10 @@ UIEvent::UIEvent(EventTarget* aOwner,
mView = nullptr;
if (mPresContext)
{
nsISupports* container = mPresContext->GetContainerWeak();
if (container)
nsIDocShell* docShell = mPresContext->GetDocShell();
if (docShell)
{
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
if (window)
mView = do_QueryInterface(window);
mView = docShell->GetWindow();
}
}
}

Просмотреть файл

@ -1986,7 +1986,7 @@ MediaManager::MediaCaptureWindowStateInternal(nsIDOMWindow* aWindow, bool* aVide
for (i = 0; i < count; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(item);
nsCOMPtr<nsPIDOMWindow> win = item ? item->GetWindow() : nullptr;
MediaCaptureWindowStateInternal(win, aVideo, aAudio);
if (*aAudio && *aVideo) {

Просмотреть файл

@ -5,6 +5,7 @@
#include "mozilla/dom/TimeEvent.h"
#include "mozilla/BasicEvents.h"
#include "nsIDocShell.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsPresContext.h"
@ -34,12 +35,9 @@ TimeEvent::TimeEvent(EventTarget* aOwner,
mEvent->mFlags.mCancelable = false;
if (mPresContext) {
nsISupports* container = mPresContext->GetContainerWeak();
if (container) {
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
if (window) {
mView = do_QueryInterface(window);
}
nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
if (docShell) {
mView = docShell->GetWindow();
}
}
}

Просмотреть файл

@ -363,13 +363,9 @@ NS_IMETHODIMP nsWebBrowser::SetParentURIContentListener(nsIURIContentListener*
NS_IMETHODIMP nsWebBrowser::GetContentDOMWindow(nsIDOMWindow **_retval)
{
NS_ENSURE_STATE(mDocShell);
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMWindow> retval = do_GetInterface(mDocShell, &rv);
if (NS_FAILED(rv)) return rv;
*_retval = retval;
NS_ADDREF(*_retval);
return rv;
nsCOMPtr<nsIDOMWindow> retval = mDocShell->GetWindow();
retval.forget(_retval);
return *_retval ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsWebBrowser::GetIsActive(bool *rv)
@ -512,6 +508,18 @@ NS_IMETHODIMP nsWebBrowser::FindItemWithName(const char16_t *aName,
aOriginalRequestor, _retval);
}
nsIDocument*
nsWebBrowser::GetDocument()
{
return mDocShell ? mDocShell->GetDocument() : nullptr;
}
nsPIDOMWindow*
nsWebBrowser::GetWindow()
{
return mDocShell ? mDocShell->GetWindow() : nullptr;
}
NS_IMETHODIMP nsWebBrowser::GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner)
{
NS_ENSURE_ARG_POINTER(aTreeOwner);
@ -1482,7 +1490,7 @@ NS_IMETHODIMP nsWebBrowser::GetMainWidget(nsIWidget** mainWidget)
NS_IMETHODIMP nsWebBrowser::SetFocus()
{
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> window = GetWindow();
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
@ -1647,9 +1655,9 @@ static void DrawThebesLayer(ThebesLayer* aLayer,
void nsWebBrowser::WindowRaised(nsIWidget* aWidget)
{
#if defined(DEBUG_smaug)
nsCOMPtr<nsIDOMDocument> domDocument = do_GetInterface(mDocShell);
nsCOMPtr<nsIDocument> document = mDocShell->GetDocument();
nsAutoString documentURI;
domDocument->GetDocumentURI(documentURI);
document->GetDocumentURI(documentURI);
printf("nsWebBrowser::NS_ACTIVATE %p %s\n", (void*)this,
NS_ConvertUTF16toUTF8(documentURI).get());
#endif
@ -1659,9 +1667,9 @@ void nsWebBrowser::WindowRaised(nsIWidget* aWidget)
void nsWebBrowser::WindowLowered(nsIWidget* aWidget)
{
#if defined(DEBUG_smaug)
nsCOMPtr<nsIDOMDocument> domDocument = do_GetInterface(mDocShell);
nsCOMPtr<nsIDocument> document = mDocShell->GetDocument();
nsAutoString documentURI;
domDocument->GetDocumentURI(documentURI);
document->GetDocumentURI(documentURI);
printf("nsWebBrowser::NS_DEACTIVATE %p %s\n", (void*)this,
NS_ConvertUTF16toUTF8(documentURI).get());
#endif
@ -1698,7 +1706,7 @@ NS_IMETHODIMP nsWebBrowser::GetPrimaryContentWindow(nsIDOMWindow** aDOMWindow)
docShell = do_QueryInterface(item);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(docShell);
nsCOMPtr<nsIDOMWindow> domWindow = docShell->GetWindow();
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
*aDOMWindow = domWindow;
@ -1714,7 +1722,7 @@ NS_IMETHODIMP nsWebBrowser::GetPrimaryContentWindow(nsIDOMWindow** aDOMWindow)
NS_IMETHODIMP nsWebBrowser::Activate(void)
{
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> window = GetWindow();
if (fm && window)
return fm->WindowRaised(window);
return NS_OK;
@ -1724,7 +1732,7 @@ NS_IMETHODIMP nsWebBrowser::Activate(void)
NS_IMETHODIMP nsWebBrowser::Deactivate(void)
{
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> window = GetWindow();
if (fm && window)
return fm->WindowLowered(window);
return NS_OK;
@ -1748,7 +1756,9 @@ NS_IMETHODIMP nsWebBrowser::GetFocusedWindow(nsIDOMWindow * *aFocusedWindow)
NS_ENSURE_ARG_POINTER(aFocusedWindow);
*aFocusedWindow = nullptr;
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> window = mDocShell->GetWindow();
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMElement> focusedElement;
@ -1767,8 +1777,9 @@ NS_IMETHODIMP nsWebBrowser::SetFocusedWindow(nsIDOMWindow * aFocusedWindow)
NS_IMETHODIMP nsWebBrowser::GetFocusedElement(nsIDOMElement * *aFocusedElement)
{
NS_ENSURE_ARG_POINTER(aFocusedElement);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> window = mDocShell->GetWindow();
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);

Просмотреть файл

@ -156,8 +156,10 @@ NS_IMETHODIMP nsWebBrowserFind::FindNext(bool *outDidFind)
if (doFind)
{
searchFrame = do_GetInterface(curItem, &rv);
if (NS_FAILED(rv)) break;
searchFrame = curItem->GetWindow();
if (!searchFrame) {
break;
}
OnStartSearchFrame(searchFrame);
@ -201,8 +203,11 @@ NS_IMETHODIMP nsWebBrowserFind::FindNext(bool *outDidFind)
curItem = do_QueryInterface(curSupports, &rv);
if (NS_FAILED(rv)) break;
searchFrame = do_GetInterface(curItem, &rv);
if (NS_FAILED(rv)) break;
searchFrame = curItem->GetWindow();
if (!searchFrame) {
rv = NS_ERROR_FAILURE;
break;
}
if (curItem.get() == startingItem.get())
{

Просмотреть файл

@ -801,10 +801,8 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
// cases we do _not_ set the parent window principal as the owner of the
// load--since we really don't know who the owner is, just leave it null.
nsCOMPtr<nsPIDOMWindow> newWindow = do_QueryInterface(*_retval);
#ifdef DEBUG
nsCOMPtr<nsPIDOMWindow> newDebugWindow = do_GetInterface(newDocShell);
NS_ASSERTION(newWindow == newDebugWindow, "Different windows??");
#endif
NS_ASSERTION(newWindow == newDocShell->GetWindow(), "Different windows??");
// The principal of the initial about:blank document gets set up in
// nsWindowWatcher::AddWindow. Make sure to call it. In the common case
// this call already happened when the window was created, but
@ -1312,8 +1310,10 @@ nsWindowWatcher::GetWindowByName(const char16_t *aTargetName,
FindItemWithName(aTargetName, nullptr, nullptr, getter_AddRefs(treeItem));
}
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(treeItem);
domWindow.swap(*aResult);
if (treeItem) {
nsCOMPtr<nsIDOMWindow> domWindow = treeItem->GetWindow();
domWindow.forget(aResult);
}
return NS_OK;
}
@ -1734,7 +1734,7 @@ nsWindowWatcher::GetCallerTreeItem(nsIDocShellTreeItem* aParentItem)
return callerItem.forget();
}
already_AddRefed<nsIDOMWindow>
nsPIDOMWindow*
nsWindowWatcher::SafeGetWindowByName(const nsAString& aName,
nsIDOMWindow* aCurrentWindow)
{
@ -1755,8 +1755,7 @@ nsWindowWatcher::SafeGetWindowByName(const nsAString& aName,
getter_AddRefs(foundItem));
}
nsCOMPtr<nsIDOMWindow> foundWin = do_GetInterface(foundItem);
return foundWin.forget();
return foundItem ? foundItem->GetWindow() : nullptr;
}
/* Fetch the nsIDOMWindow corresponding to the given nsIDocShellTreeItem.
@ -1772,8 +1771,10 @@ nsWindowWatcher::ReadyOpenedDocShellItem(nsIDocShellTreeItem *aOpenedItem,
{
nsresult rv = NS_ERROR_FAILURE;
NS_ENSURE_ARG(aOpenedWindow);
*aOpenedWindow = 0;
nsCOMPtr<nsPIDOMWindow> piOpenedWindow(do_GetInterface(aOpenedItem));
nsCOMPtr<nsPIDOMWindow> piOpenedWindow = aOpenedItem->GetWindow();
if (piOpenedWindow) {
if (aParent) {
piOpenedWindow->SetOpenerWindow(aParent, aWindowIsNew); // damnit

Просмотреть файл

@ -22,6 +22,7 @@
class nsIURI;
class nsIDocShellTreeItem;
class nsIDocShellTreeOwner;
class nsPIDOMWindow;
class nsIWebBrowserChrome;
class nsString;
class nsWatcherWindowEnumerator;
@ -64,7 +65,7 @@ protected:
// Unlike GetWindowByName this will look for a caller on the JS
// stack, and then fall back on aCurrentWindow if it can't find one.
already_AddRefed<nsIDOMWindow>
nsPIDOMWindow*
SafeGetWindowByName(const nsAString& aName, nsIDOMWindow* aCurrentWindow);
// Just like OpenWindowJS, but knows whether it got called via OpenWindowJS

Просмотреть файл

@ -566,8 +566,12 @@ nsDocumentViewer::LoadStart(nsIDocument* aDocument)
nsresult
nsDocumentViewer::SyncParentSubDocMap()
{
nsCOMPtr<nsIDocShellTreeItem> item(mContainer);
nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(item));
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (!docShell) {
return NS_OK;
}
nsCOMPtr<nsPIDOMWindow> pwin(docShell->GetWindow());
nsCOMPtr<nsIContent> content;
if (mDocument && pwin) {
@ -576,9 +580,9 @@ nsDocumentViewer::SyncParentSubDocMap()
if (content) {
nsCOMPtr<nsIDocShellTreeItem> parent;
item->GetParent(getter_AddRefs(parent));
docShell->GetParent(getter_AddRefs(parent));
nsCOMPtr<nsIDOMWindow> parent_win(do_GetInterface(parent));
nsCOMPtr<nsIDOMWindow> parent_win = parent ? parent->GetWindow() : nullptr;
if (parent_win) {
nsCOMPtr<nsIDOMDocument> dom_doc;
@ -1795,7 +1799,7 @@ nsDocumentViewer::SetDocumentInternal(nsIDocument* aDocument,
// Set the script global object on the new document
nsCOMPtr<nsPIDOMWindow> window =
do_GetInterface(static_cast<nsIDocShell*>(mContainer.get()));
mContainer ? mContainer->GetWindow() : nullptr;
if (window) {
window->SetNewDocument(aDocument, nullptr, aForceReuseInnerWindow);
}
@ -2453,21 +2457,19 @@ nsDocumentViewer::FindContainerView()
nsView* containerView = nullptr;
if (mContainer) {
nsCOMPtr<nsIDocShellTreeItem> docShellItem(mContainer);
nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(docShellItem));
nsCOMPtr<nsIDocShell> docShell(mContainer);
nsCOMPtr<nsPIDOMWindow> pwin(docShell->GetWindow());
if (pwin) {
nsCOMPtr<nsIContent> containerElement = do_QueryInterface(pwin->GetFrameElementInternal());
if (!containerElement) {
return nullptr;
}
nsCOMPtr<nsIPresShell> parentPresShell;
if (docShellItem) {
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
docShellItem->GetParent(getter_AddRefs(parentDocShellItem));
if (parentDocShellItem) {
nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
parentPresShell = parentDocShell->GetPresShell();
}
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
docShell->GetParent(getter_AddRefs(parentDocShellItem));
if (parentDocShellItem) {
nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
parentPresShell = parentDocShell->GetPresShell();
}
if (!parentPresShell) {
nsCOMPtr<nsIDocument> parentDoc = containerElement->GetCurrentDoc();
@ -4330,10 +4332,11 @@ nsDocumentViewer::OnDonePrinting()
// We are done printing, now cleanup
if (mDeferredWindowClose) {
mDeferredWindowClose = false;
nsCOMPtr<nsIDOMWindow> win =
do_GetInterface(static_cast<nsIDocShell*>(mContainer));
if (win)
win->Close();
if (mContainer) {
nsCOMPtr<nsIDOMWindow> win = mContainer->GetWindow();
if (win)
win->Close();
}
} else if (mClosingWhilePrinting) {
if (mDocument) {
mDocument->SetScriptGlobalObject(nullptr);

Просмотреть файл

@ -5392,7 +5392,7 @@ nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow)
// context does the right thing on multi-monitor systems when we return it to
// the caller. It will also make sure that our prescontext has been created,
// if we're supposed to have one.
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(docShell);
nsCOMPtr<nsPIDOMWindow> win = docShell->GetWindow();
if (!win) {
// No reason to go on
return nullptr;

Просмотреть файл

@ -1642,7 +1642,11 @@ nsPresContext::IsTopLevelWindowInactive()
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsPIDOMWindow> domWindow(do_GetInterface(rootItem));
if (!rootItem) {
return false;
}
nsCOMPtr<nsPIDOMWindow> domWindow = rootItem->GetWindow();
return domWindow && !domWindow->IsActive();
}

Просмотреть файл

@ -5151,8 +5151,12 @@ PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
static bool IsTransparentContainerElement(nsPresContext* aPresContext)
{
nsCOMPtr<nsIDocShellTreeItem> docShellItem = aPresContext->GetDocShell();
nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(docShellItem));
nsCOMPtr<nsIDocShell> docShell = aPresContext->GetDocShell();
if (!docShell) {
return false;
}
nsCOMPtr<nsPIDOMWindow> pwin = docShell->GetWindow();
if (!pwin)
return false;
nsCOMPtr<nsIContent> containerElement =
@ -7067,8 +7071,11 @@ PresShell::GetTouchEventTargetDocument()
nsCOMPtr<nsIDocShellTreeItem> item;
owner->GetPrimaryContentShell(getter_AddRefs(item));
nsCOMPtr<nsIDocShell> childDocShell = do_QueryInterface(item);
nsCOMPtr<nsIDocument> result = do_GetInterface(childDocShell);
return result;
if (!childDocShell) {
return nullptr;
}
return childDocShell->GetDocument();
}
#endif

Просмотреть файл

@ -343,7 +343,11 @@ nsPrintEngine::InstallPrintPreviewListener()
{
if (!mPrt->mPPEventListeners) {
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mContainer);
nsCOMPtr<nsPIDOMWindow> win(do_GetInterface(docShell));
if (!docShell) {
return;
}
nsCOMPtr<nsPIDOMWindow> win(docShell->GetWindow());
if (win) {
nsCOMPtr<EventTarget> target = do_QueryInterface(win->GetFrameElementInternal());
mPrt->mPPEventListeners = new nsPrintPreviewListener(target);
@ -1141,8 +1145,7 @@ nsPrintEngine::IsParentAFrameSet(nsIDocShell * aParent)
bool isFrameSet = false;
// only check to see if there is a frameset if there is
// NO parent doc for this doc. meaning this parent is the root doc
nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(aParent);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCOMPtr<nsIDocument> doc = aParent->GetDocument();
if (doc) {
nsIContent *rootElement = doc->GetRootElement();
if (rootElement) {
@ -1392,7 +1395,8 @@ nsPrintEngine::IsThereAnIFrameSelected(nsIDocShell* aDocShell,
if (aDOMWin) {
// Get the main docshell's DOMWin to see if it matches
// the frame that is selected
nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(aDocShell);
nsCOMPtr<nsIDOMWindow> domWin =
aDocShell ? aDocShell->GetWindow() : nullptr;
if (domWin != aDOMWin) {
iFrameIsSelected = true; // we have a selected IFRAME
}
@ -3300,7 +3304,7 @@ nsPrintEngine::EnablePOsForPrinting()
for (uint32_t i=0;i<mPrt->mPrintDocList.Length();i++) {
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsCOMPtr<nsIDOMWindow> domWin = do_GetInterface(po->mDocShell);
nsCOMPtr<nsIDOMWindow> domWin = po->mDocShell->GetWindow();
if (IsThereARangeSelection(domWin)) {
mPrt->mCurrentFocusWin = domWin;
SetPrintPO(po, true);

Просмотреть файл

@ -851,8 +851,12 @@ nsSVGOuterSVGFrame::IsRootOfReplacedElementSubDoc(nsIFrame **aEmbeddingFrame)
{
if (!mContent->GetParent()) {
// Our content is the document element
nsCOMPtr<nsISupports> container = PresContext()->GetContainerWeak();
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
nsCOMPtr<nsIDocShell> docShell = PresContext()->GetDocShell();
nsCOMPtr<nsIDOMWindow> window;
if (docShell) {
window = docShell->GetWindow();
}
if (window) {
nsCOMPtr<nsIDOMElement> frameElement;
window->GetFrameElement(getter_AddRefs(frameElement));

Просмотреть файл

@ -1572,7 +1572,11 @@ nsXULPopupManager::MayShowPopup(nsMenuPopupFrame* aPopup)
// only allow popups in active windows
nsCOMPtr<nsIDocShellTreeItem> root;
dsti->GetRootTreeItem(getter_AddRefs(root));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(root);
if (!root) {
return false;
}
nsCOMPtr<nsIDOMWindow> rootWin = root->GetWindow();
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm || !rootWin)

Просмотреть файл

@ -1148,14 +1148,13 @@ nsFormFillController::StopControllingInput()
nsIDocShell *
nsFormFillController::GetDocShellForInput(nsIDOMHTMLInputElement *aInput)
{
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aInput);
element->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
NS_ENSURE_TRUE(doc, nullptr);
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(doc->GetWindow());
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
return docShell;
nsCOMPtr<nsINode> node = do_QueryInterface(aInput);
NS_ENSURE_TRUE(node, nullptr);
nsCOMPtr<nsPIDOMWindow> win = node->OwnerDoc()->GetWindow();
NS_ENSURE_TRUE(win, nullptr);
return win->GetDocShell();
}
nsIDOMWindow *

Просмотреть файл

@ -1484,7 +1484,8 @@ nsNativeAppSupportWin::OpenBrowserWindow()
if ( navItem ) {
nsCOMPtr<nsIDocShellTreeItem> rootItem;
navItem->GetRootTreeItem( getter_AddRefs( rootItem ) );
nsCOMPtr<nsIDOMWindow> rootWin( do_GetInterface( rootItem ) );
nsCOMPtr<nsIDOMWindow> rootWin =
rootItem ? rootItem->GetWindow() : nullptr;
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(rootWin));
if ( chromeWin )
chromeWin->GetBrowserDOMWindow( getter_AddRefs ( bwin ) );

Просмотреть файл

@ -656,13 +656,11 @@ nsAppShellService::GetHiddenDOMWindow(nsIDOMWindow **aWindow)
rv = mHiddenWindow->GetDocShell(getter_AddRefs(docShell));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> hiddenDOMWindow(do_GetInterface(docShell, &rv));
NS_ENSURE_SUCCESS(rv, rv);
*aWindow = hiddenDOMWindow;
NS_IF_ADDREF(*aWindow);
return NS_OK;
nsCOMPtr<nsIDOMWindow> hiddenDOMWindow(docShell->GetWindow());
hiddenDOMWindow.forget(aWindow);
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -688,13 +686,11 @@ nsAppShellService::GetHiddenPrivateDOMWindow(nsIDOMWindow **aWindow)
rv = mHiddenPrivateWindow->GetDocShell(getter_AddRefs(docShell));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindow> hiddenPrivateDOMWindow(do_GetInterface(docShell, &rv));
NS_ENSURE_SUCCESS(rv, rv);
*aWindow = hiddenPrivateDOMWindow;
NS_IF_ADDREF(*aWindow);
return NS_OK;
nsCOMPtr<nsIDOMWindow> hiddenPrivateDOMWindow(docShell->GetWindow());
hiddenPrivateDOMWindow.forget(aWindow);
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -722,14 +718,16 @@ nsAppShellService::GetHiddenWindowAndJSContext(nsIDOMWindow **aWindow,
nsCOMPtr<nsIDocShell> docShell;
rv = mHiddenWindow->GetDocShell(getter_AddRefs(docShell));
if (NS_FAILED(rv)) break;
if (!docShell) {
break;
}
// 2. Convert that to an nsIDOMWindow.
nsCOMPtr<nsIDOMWindow> hiddenDOMWindow(do_GetInterface(docShell));
nsCOMPtr<nsIDOMWindow> hiddenDOMWindow(docShell->GetWindow());
if(!hiddenDOMWindow) break;
// 3. Get script global object for the window.
nsCOMPtr<nsIScriptGlobalObject> sgo;
sgo = do_QueryInterface( hiddenDOMWindow );
nsCOMPtr<nsIScriptGlobalObject> sgo = docShell->GetScriptGlobalObject();
if (!sgo) { rv = NS_ERROR_FAILURE; break; }
// 4. Get script context from that.
@ -771,7 +769,9 @@ nsAppShellService::RegisterTopLevelWindow(nsIXULWindow* aWindow)
nsCOMPtr<nsIDocShell> docShell;
aWindow->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsPIDOMWindow> domWindow(do_GetInterface(docShell));
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsPIDOMWindow> domWindow(docShell->GetWindow());
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->SetInitialPrincipalToSubject();
@ -843,7 +843,7 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow)
nsCOMPtr<nsIDocShell> docShell;
aWindow->GetDocShell(getter_AddRefs(docShell));
if (docShell) {
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docShell));
nsCOMPtr<nsIDOMWindow> domWindow(docShell->GetWindow());
if (domWindow)
wwatcher->RemoveWindow(domWindow);
}

Просмотреть файл

@ -754,8 +754,8 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const char16_t* aTitle)
//
nsCOMPtr<nsIDocShellTreeItem> dsitem;
GetPrimaryContentShell(getter_AddRefs(dsitem));
nsCOMPtr<nsIDOMDocument> domdoc(do_GetInterface(dsitem));
nsCOMPtr<nsIScriptObjectPrincipal> doc(do_QueryInterface(domdoc));
nsCOMPtr<nsIScriptObjectPrincipal> doc =
do_QueryInterface(dsitem ? dsitem->GetDocument() : nullptr);
if (doc) {
nsCOMPtr<nsIURI> uri;
nsIPrincipal* principal = doc->GetPrincipal();
@ -1078,9 +1078,11 @@ nsSiteWindow::SetFocus(void)
if (window) {
nsCOMPtr<nsIDocShell> docshell;
window->GetDocShell(getter_AddRefs(docshell));
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docshell));
if (domWindow)
domWindow->Focus();
if (docShell) {
nsCOMPtr<nsIDOMWindow> domWindow(docShell->GetWindow());
if (domWindow)
domWindow->Focus();
}
}
#endif
return NS_OK;
@ -1140,7 +1142,11 @@ nsSiteWindow::Blur(void)
if (xulWindow) {
nsCOMPtr<nsIDocShell> docshell;
xulWindow->GetDocShell(getter_AddRefs(docshell));
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docshell));
if (!docshell) {
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> domWindow(docshell->GetWindow());
if (domWindow)
domWindow->Focus();
}

Просмотреть файл

@ -212,7 +212,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
if (nsContentUtils::IsInitialized()) { // Sometimes this happens really early See bug 793370.
rv = mDocShell->CreateAboutBlankContentViewer(nsContentUtils::SubjectPrincipal());
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_GetInterface(mDocShell);
nsCOMPtr<nsIDocument> doc = mDocShell ? mDocShell->GetDocument() : nullptr;
NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE);
doc->SetIsInitialDocument(true);
}
@ -251,7 +251,8 @@ nsWebShellWindow::WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y)
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsPIDOMWindow> window =
mDocShell ? mDocShell->GetWindow() : nullptr;
pm->AdjustPopupsOnWindowChange(window);
}
@ -281,11 +282,10 @@ nsWebShellWindow::RequestWindowClose(nsIWidget* aWidget)
// Maintain a reference to this as it is about to get destroyed.
nsCOMPtr<nsIXULWindow> xulWindow(this);
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(mDocShell));
nsCOMPtr<nsPIDOMWindow> window(mDocShell ? mDocShell->GetWindow() : nullptr);
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(window);
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
if (!presShell) {
mozilla::DebugOnly<bool> dying;
MOZ_ASSERT(NS_SUCCEEDED(mDocShell->IsBeingDestroyed(&dying)) && dying,
@ -324,7 +324,8 @@ nsWebShellWindow::SizeModeChanged(nsSizeMode sizeMode)
// cases this will merge with the similar call in NS_SIZE and
// write the attribute values only once.
SetPersistenceTimer(PAD_MISC);
nsCOMPtr<nsPIDOMWindow> ourWindow = do_GetInterface(mDocShell);
nsCOMPtr<nsPIDOMWindow> ourWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
if (ourWindow) {
// Let the application know if it's in fullscreen mode so it
// can update its UI.
@ -388,7 +389,7 @@ nsWebShellWindow::WindowActivated()
nsCOMPtr<nsIXULWindow> xulWindow(this);
// focusing the window could cause it to close, so keep a reference to it
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsIDOMWindow> window = mDocShell ? mDocShell->GetWindow() : nullptr;
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
if (fm && window)
fm->WindowRaised(window);
@ -404,7 +405,8 @@ nsWebShellWindow::WindowDeactivated()
{
nsCOMPtr<nsIXULWindow> xulWindow(this);
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mDocShell);
nsCOMPtr<nsPIDOMWindow> window =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
if (fm && window)
fm->WindowLowered(window);
@ -671,8 +673,10 @@ bool nsWebShellWindow::ExecuteCloseHandler()
than it otherwise would.) */
nsCOMPtr<nsIXULWindow> kungFuDeathGrip(this);
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(mDocShell));
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(window);
nsCOMPtr<EventTarget> eventTarget;
if (mDocShell) {
eventTarget = do_QueryInterface(mDocShell->GetWindow());
}
if (eventTarget) {
nsCOMPtr<nsIContentViewer> contentViewer;

Просмотреть файл

@ -43,8 +43,11 @@ nsWindowMediator::GetDOMWindow(nsIXULWindow* inWindow,
{
nsCOMPtr<nsIDocShell> docShell;
outDOMWindow = nullptr;
inWindow->GetDocShell(getter_AddRefs(docShell));
outDOMWindow = do_GetInterface(docShell);
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
outDOMWindow = docShell->GetWindow();
return outDOMWindow ? NS_OK : NS_ERROR_FAILURE;
}

Просмотреть файл

@ -1547,7 +1547,7 @@ NS_IMETHODIMP nsXULWindow::GetWindowDOMWindow(nsIDOMWindow** aDOMWindow)
NS_ENSURE_STATE(mDocShell);
if (!mDOMWindow)
mDOMWindow = do_GetInterface(mDocShell);
mDOMWindow = mDocShell->GetWindow();
NS_ENSURE_TRUE(mDOMWindow, NS_ERROR_FAILURE);
*aDOMWindow = mDOMWindow;