bug 331376 - merge nsIDocShellTreeNode into nsIDocShellTreeItem r=smaug

This commit is contained in:
Trevor Saunders 2014-01-06 17:34:15 -05:00
parent 7bdb8095bb
commit ff0491aef6
30 changed files with 153 additions and 228 deletions

View File

@ -21,7 +21,6 @@
#include "nsIScrollPositionListener.h"
#include "nsITimer.h"
#include "nsIWeakReference.h"
#include "nsIDocShellTreeNode.h"
class nsAccessiblePivot;

View File

@ -9,7 +9,7 @@ const gXPInstallObserver = {
if (aDocShell == aSoughtShell)
return aDocShell;
var node = aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeNode);
var node = aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeItem);
for (var i = 0; i < node.childCount; ++i) {
var docShell = node.getChildAt(i);
docShell = this._findChildShell(docShell, aSoughtShell);

View File

@ -391,7 +391,7 @@ function findChildShell(aDocument, aDocShell, aSoughtURI) {
(aSoughtURI && aSoughtURI.spec == aDocShell.currentURI.spec))
return aDocShell;
var node = aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeNode);
var node = aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeItem);
for (var i = 0; i < node.childCount; ++i) {
var docShell = node.getChildAt(i);
docShell = findChildShell(aDocument, docShell, aSoughtURI);

View File

@ -223,7 +223,7 @@ MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
}
}
void MarkDocShell(nsIDocShellTreeNode* aNode, bool aCleanupJS,
void MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS,
bool aPrepareForCC);
void
@ -256,7 +256,7 @@ MarkSHEntry(nsISHEntry* aSHEntry, bool aCleanupJS, bool aPrepareForCC)
}
void
MarkDocShell(nsIDocShellTreeNode* aNode, bool aCleanupJS, bool aPrepareForCC)
MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS, bool aPrepareForCC)
{
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(aNode);
if (!shell) {
@ -299,8 +299,7 @@ MarkWindowList(nsISimpleEnumerator* aWindowList, bool aCleanupJS,
iter) {
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(iter);
if (window) {
nsCOMPtr<nsIDocShellTreeNode> rootDocShell =
do_QueryInterface(window->GetDocShell());
nsCOMPtr<nsIDocShell> rootDocShell = window->GetDocShell();
MarkDocShell(rootDocShell, aCleanupJS, aPrepareForCC);
}
@ -379,8 +378,7 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
if (hw) {
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeNode> shellTreeNode = do_QueryInterface(shell);
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
MarkDocShell(shell, cleanupJS, prepareForCC);
}
bool hasHiddenPrivateWindow = false;
appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow);
@ -389,8 +387,7 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
if (hw) {
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeNode> shellTreeNode = do_QueryInterface(shell);
MarkDocShell(shellTreeNode, cleanupJS, prepareForCC);
MarkDocShell(shell, cleanupJS, prepareForCC);
}
}
}

View File

@ -5881,14 +5881,13 @@ nsContentUtils::FlushLayoutForTree(nsIDOMWindow* aWindow)
doc->FlushPendingNotifications(Flush_Layout);
}
nsCOMPtr<nsIDocShellTreeNode> node =
do_QueryInterface(piWin->GetDocShell());
if (node) {
nsCOMPtr<nsIDocShell> docShell = piWin->GetDocShell();
if (docShell) {
int32_t i = 0, i_end;
node->GetChildCount(&i_end);
docShell->GetChildCount(&i_end);
for (; i < i_end; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
node->GetChildAt(i, getter_AddRefs(item));
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(item);
if (win) {
FlushLayoutForTree(win);

View File

@ -713,7 +713,7 @@ bool
nsFrameLoader::AddTreeItemToTreeOwner(nsIDocShellTreeItem* aItem,
nsIDocShellTreeOwner* aOwner,
int32_t aParentType,
nsIDocShellTreeNode* aParentNode)
nsIDocShell* aParentNode)
{
NS_PRECONDITION(aItem, "Must have docshell treeitem");
NS_PRECONDITION(mOwnerContent, "Must have owning content");
@ -1571,9 +1571,8 @@ nsFrameLoader::MaybeCreateDocShell()
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsISupports> container =
doc->GetContainer();
nsCOMPtr<nsIWebNavigation> parentAsWebNav = do_QueryInterface(container);
nsCOMPtr<nsIDocShell> docShell = doc->GetDocShell();
nsCOMPtr<nsIWebNavigation> parentAsWebNav = do_QueryInterface(docShell);
NS_ENSURE_STATE(parentAsWebNav);
// Create the docshell...
@ -1615,53 +1614,41 @@ nsFrameLoader::MaybeCreateDocShell()
mDocShell->SetName(frameName);
}
// If our container is a web-shell, inform it that it has a new
// child. If it's not a web-shell then some things will not operate
// properly.
// Inform our docShell that it has a new child.
// Note: This logic duplicates a lot of logic in
// nsSubDocumentFrame::AttributeChanged. We should fix that.
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(parentAsWebNav));
if (parentAsNode) {
// Note: This logic duplicates a lot of logic in
// nsSubDocumentFrame::AttributeChanged. We should fix that.
int32_t parentType;
docShell->GetItemType(&parentType);
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
do_QueryInterface(parentAsNode);
// XXXbz why is this in content code, exactly? We should handle
// this some other way..... Not sure how yet.
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
docShell->GetTreeOwner(getter_AddRefs(parentTreeOwner));
NS_ENSURE_STATE(parentTreeOwner);
mIsTopLevelContent =
AddTreeItemToTreeOwner(mDocShell, parentTreeOwner, parentType, docShell);
int32_t parentType;
parentAsItem->GetItemType(&parentType);
// Make sure all shells have links back to the content element
// in the nearest enclosing chrome shell.
nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
// XXXbz why is this in content code, exactly? We should handle
// this some other way..... Not sure how yet.
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
NS_ENSURE_STATE(parentTreeOwner);
mIsTopLevelContent =
AddTreeItemToTreeOwner(mDocShell, parentTreeOwner, parentType,
parentAsNode);
if (parentType == nsIDocShellTreeItem::typeChrome) {
// Our parent shell is a chrome shell. It is therefore our nearest
// enclosing chrome shell.
// Make sure all shells have links back to the content element
// in the nearest enclosing chrome shell.
nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
chromeEventHandler = do_QueryInterface(mOwnerContent);
NS_ASSERTION(chromeEventHandler,
"This mContent should implement this.");
} else {
// Our parent shell is a content shell. Get the chrome event
// handler from it and use that for our shell as well.
if (parentType == nsIDocShellTreeItem::typeChrome) {
// Our parent shell is a chrome shell. It is therefore our nearest
// enclosing chrome shell.
chromeEventHandler = do_QueryInterface(mOwnerContent);
NS_ASSERTION(chromeEventHandler,
"This mContent should implement this.");
} else {
nsCOMPtr<nsIDocShell> parentShell(do_QueryInterface(parentAsNode));
// Our parent shell is a content shell. Get the chrome event
// handler from it and use that for our shell as well.
parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
}
mDocShell->SetChromeEventHandler(chromeEventHandler);
docShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
}
mDocShell->SetChromeEventHandler(chromeEventHandler);
// This is nasty, this code (the do_GetInterface(mDocShell) below)
// *must* come *after* the above call to
// mDocShell->SetChromeEventHandler() for the global window to get

View File

@ -32,7 +32,6 @@ class AutoResetInShow;
class nsITabParent;
class nsIDocShellTreeItem;
class nsIDocShellTreeOwner;
class nsIDocShellTreeNode;
class mozIApplication;
namespace mozilla {
@ -388,7 +387,7 @@ private:
bool AddTreeItemToTreeOwner(nsIDocShellTreeItem* aItem,
nsIDocShellTreeOwner* aOwner,
int32_t aParentType,
nsIDocShellTreeNode* aParentNode);
nsIDocShell* aParentNode);
nsIAtom* TypeAttrName() const {
return mOwnerContent->IsXUL() ? nsGkAtoms::type : nsGkAtoms::mozframetype;

View File

@ -642,8 +642,7 @@ test(function test_FrameAncestor_ignores_userpass_bug779918() {
.createInstance(Ci.nsIDocShell);
docshellparent.setCurrentURI(aParentUri);
docshellchild.setCurrentURI(aChildUri);
docshellparent.QueryInterface(Ci.nsIDocShellTreeNode)
.addChild(docshellchild);
docshellparent.addChild(docshellchild);
return cspObj.permitsAncestry(docshellchild);
};

View File

@ -1490,11 +1490,11 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
ProcessingAccessKeyState aAccessKeyState,
int32_t aModifierMask)
{
nsCOMPtr<nsISupports> pcContainer = aPresContext->GetContainerWeak();
nsCOMPtr<nsIDocShell> docShell = aPresContext->GetDocShell();
// Alt or other accesskey modifier is down, we may need to do an accesskey
if (mAccessKeys.Count() > 0 &&
aModifierMask == GetAccessModifierMaskFor(pcContainer)) {
aModifierMask == GetAccessModifierMaskFor(docShell)) {
// Someone registered an accesskey. Find and activate it.
nsAutoTArray<uint32_t, 10> accessCharCodes;
nsContentUtils::GetAccessKeyCandidates(aEvent, accessCharCodes);
@ -1508,7 +1508,6 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
if (nsEventStatus_eConsumeNoDefault != *aStatus) {
// checking all sub docshells
nsCOMPtr<nsIDocShellTreeNode> docShell(do_QueryInterface(pcContainer));
if (!docShell) {
NS_WARNING("no docShellTreeNode for presContext");
return;
@ -1552,7 +1551,6 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
// bubble up the process to the parent docshell if necessary
if (eAccessKeyProcessingDown != aAccessKeyState && nsEventStatus_eConsumeNoDefault != *aStatus) {
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(pcContainer));
if (!docShell) {
NS_WARNING("no docShellTreeItem for presContext");
return;

View File

@ -22,7 +22,6 @@ class nsFrameLoader;
class nsIContent;
class nsIDocument;
class nsIDocShell;
class nsIDocShellTreeNode;
class nsIDocShellTreeItem;
class imgIContainer;
class nsDOMDataTransfer;

View File

@ -15,7 +15,6 @@ XPIDL_SOURCES += [
'nsIDocShell.idl',
'nsIDocShellLoadInfo.idl',
'nsIDocShellTreeItem.idl',
'nsIDocShellTreeNode.idl',
'nsIDocShellTreeOwner.idl',
'nsIDocumentLoaderFactory.idl',
'nsIDownloadHistory.idl',

View File

@ -974,7 +974,6 @@ NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIDocShell)
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeNode)
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
@ -3608,10 +3607,6 @@ nsDocShell::GetIsInUnload(bool* aIsInUnload)
return NS_OK;
}
//*****************************************************************************
// nsDocShell::nsIDocShellTreeNode
//*****************************************************************************
NS_IMETHODIMP
nsDocShell::GetChildCount(int32_t * aChildCount)
{

View File

@ -11,7 +11,6 @@
#include "nsITimer.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIBaseWindow.h"
#include "nsIScrollable.h"
#include "nsITextScroll.h"
@ -155,7 +154,6 @@ public:
NS_DECL_NSIDOCSHELL
NS_DECL_NSIDOCSHELLTREEITEM
NS_DECL_NSIDOCSHELLTREENODE
NS_DECL_NSIWEBNAVIGATION
NS_DECL_NSIBASEWINDOW
NS_DECL_NSISCROLLABLE

View File

@ -8,7 +8,6 @@
#include "nsDocShellEnumerator.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
nsDocShellEnumerator::nsDocShellEnumerator(int32_t inEnumerationDirection)
: mRootItem(nullptr)
@ -123,8 +122,6 @@ nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArr
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
{
nsresult rv;
nsCOMPtr<nsIDocShellTreeNode> itemAsNode = do_QueryInterface(inItem, &rv);
if (NS_FAILED(rv)) return rv;
int32_t itemType;
// add this item to the array
@ -136,13 +133,13 @@ nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem*
}
int32_t numChildren;
rv = itemAsNode->GetChildCount(&numChildren);
rv = inItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) return rv;
for (int32_t i = 0; i < numChildren; ++i)
{
nsCOMPtr<nsIDocShellTreeItem> curChild;
rv = itemAsNode->GetChildAt(i, getter_AddRefs(curChild));
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) return rv;
rv = BuildArrayRecursive(curChild, inItemArray);
@ -156,17 +153,15 @@ nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem*
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
{
nsresult rv;
nsCOMPtr<nsIDocShellTreeNode> itemAsNode = do_QueryInterface(inItem, &rv);
if (NS_FAILED(rv)) return rv;
int32_t numChildren;
rv = itemAsNode->GetChildCount(&numChildren);
rv = inItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) return rv;
for (int32_t i = numChildren - 1; i >= 0; --i)
{
nsCOMPtr<nsIDocShellTreeItem> curChild;
rv = itemAsNode->GetChildAt(i, getter_AddRefs(curChild));
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) return rv;
rv = BuildArrayRecursive(curChild, inItemArray);

View File

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDocShellTreeNode.idl"
#include "nsISupports.idl"
interface nsIDocShellTreeOwner;
@ -15,8 +15,8 @@ interface nsIDocShellTreeOwner;
* node or a leaf.
*/
[scriptable, uuid(e35bbb39-985b-4d62-81da-73c330222e5f)]
interface nsIDocShellTreeItem : nsIDocShellTreeNode
[scriptable, uuid(cb16a98d-a9e4-4ee2-a450-709b92ad8a89)]
interface nsIDocShellTreeItem : nsISupports
{
/*
name of the DocShellTreeItem
@ -125,5 +125,54 @@ interface nsIDocShellTreeItem : nsIDocShellTreeNode
*/
readonly attribute nsIDocShellTreeOwner treeOwner;
[noscript] void setTreeOwner(in nsIDocShellTreeOwner treeOwner);
/*
The current number of DocShells which are immediate children of the
this object.
*/
readonly attribute long childCount;
/*
Add a new child DocShellTreeItem. Adds to the end of the list.
Note that this does NOT take a reference to the child. The child stays
alive only as long as it's referenced from outside the docshell tree.
@throws NS_ERROR_ILLEGAL_VALUE if child corresponds to the same
object as this treenode or an ancestor of this treenode
@throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree.
*/
void addChild(in nsIDocShellTreeItem child);
/*
Removes a child DocShellTreeItem.
@throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree.
*/
void removeChild(in nsIDocShellTreeItem child);
/**
* Return the child at the index requested. This is 0-based.
*
* @throws NS_ERROR_UNEXPECTED if the index is out of range
*/
nsIDocShellTreeItem getChildAt(in long index);
/*
Return the child DocShellTreeItem with the specified name.
aName - This is the name of the item that is trying to be found.
aRecurse - Is used to tell the function to recurse through children.
Note, recursion will only happen through items of the same type.
aSameType - If this is set only children of the same type will be returned.
aRequestor - This is the docshellTreeItem that is requesting the find. This
parameter is used when recursion is being used to avoid searching the same
tree again when a child has asked a parent to search for children.
aOriginalRequestor - The original treeitem that made the request, if any.
This is used to ensure that we don't run into cross-site issues.
Note the search is depth first when recursing.
*/
nsIDocShellTreeItem findChildWithName(in wstring aName,
in boolean aRecurse,
in boolean aSameType,
in nsIDocShellTreeItem aRequestor,
in nsIDocShellTreeItem aOriginalRequestor);
};

View File

@ -1,75 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIDocShellTreeItem;
/**
* The nsIDocShellTreeNode supplies the methods for interacting with children
* of a docshell. These are essentially the methods that turn a single docshell
* into a docshell tree.
*/
/*
* Long-term, we probably want to merge this interface into
* nsIDocShellTreeItem. Need to eliminate uses of this interface
* first.
*/
[scriptable, uuid(37f1ab73-f224-44b1-82f0-d2834ab1cec0)]
interface nsIDocShellTreeNode : nsISupports
{
/*
The current number of DocShells which are immediate children of the
this object.
*/
readonly attribute long childCount;
/*
Add a new child DocShellTreeItem. Adds to the end of the list.
Note that this does NOT take a reference to the child. The child stays
alive only as long as it's referenced from outside the docshell tree.
@throws NS_ERROR_ILLEGAL_VALUE if child corresponds to the same
object as this treenode or an ancestor of this treenode
@throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree.
*/
void addChild(in nsIDocShellTreeItem child);
/*
Removes a child DocShellTreeItem.
@throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree.
*/
void removeChild(in nsIDocShellTreeItem child);
/**
* Return the child at the index requested. This is 0-based.
*
* @throws NS_ERROR_UNEXPECTED if the index is out of range
*/
nsIDocShellTreeItem getChildAt(in long index);
/*
Return the child DocShellTreeItem with the specified name.
aName - This is the name of the item that is trying to be found.
aRecurse - Is used to tell the function to recurse through children.
Note, recursion will only happen through items of the same type.
aSameType - If this is set only children of the same type will be returned.
aRequestor - This is the docshellTreeItem that is requesting the find. This
parameter is used when recursion is being used to avoid searching the same
tree again when a child has asked a parent to search for children.
aOriginalRequestor - The original treeitem that made the request, if any.
This is used to ensure that we don't run into cross-site issues.
Note the search is depth first when recursing.
*/
nsIDocShellTreeItem findChildWithName(in wstring aName,
in boolean aRecurse,
in boolean aSameType,
in nsIDocShellTreeItem aRequestor,
in nsIDocShellTreeItem aOriginalRequestor);
};

View File

@ -17,7 +17,6 @@
#include "nsIDocShellLoadInfo.h"
#include "nsISHContainer.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIURI.h"
#include "nsIContentViewer.h"
#include "nsICacheService.h"
@ -1636,22 +1635,21 @@ nsSHistory::CompareFrames(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsID
int32_t pcnt=0, ncnt=0, dsCount=0;
nsCOMPtr<nsISHContainer> prevContainer(do_QueryInterface(aPrevEntry));
nsCOMPtr<nsISHContainer> nextContainer(do_QueryInterface(aNextEntry));
nsCOMPtr<nsIDocShellTreeNode> dsTreeNode(do_QueryInterface(aParent));
if (!dsTreeNode)
if (!aParent)
return NS_ERROR_FAILURE;
if (!prevContainer || !nextContainer)
return NS_ERROR_FAILURE;
prevContainer->GetChildCount(&pcnt);
nextContainer->GetChildCount(&ncnt);
dsTreeNode->GetChildCount(&dsCount);
aParent->GetChildCount(&dsCount);
// Create an array for child docshells.
nsCOMArray<nsIDocShell> docshells;
for (int32_t i = 0; i < dsCount; ++i) {
nsCOMPtr<nsIDocShellTreeItem> treeItem;
dsTreeNode->GetChildAt(i, getter_AddRefs(treeItem));
aParent->GetChildAt(i, getter_AddRefs(treeItem));
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(treeItem);
if (shell) {
docshells.AppendObject(shell);

View File

@ -111,7 +111,7 @@ function xpcEnumerateContentWindows(callback) {
if (/ChromeWindow/.exec(win)) {
var docshellTreeNode = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeNode);
.QueryInterface(Ci.nsIDocShellTreeItem);
var childCount = docshellTreeNode.childCount;
for (var i = 0; i < childCount; ++i) {
var childTreeNode = docshellTreeNode.getChildAt(i);

View File

@ -38,8 +38,7 @@ NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsDOMWindowList::SetDocShell(nsIDocShell* aDocShell)
{
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
mDocShellNode = docShellAsNode; // Weak Reference
mDocShellNode = aDocShell; // Weak Reference
return NS_OK;
}

View File

@ -8,7 +8,7 @@
#include "nsCOMPtr.h"
#include "nsIDOMWindowCollection.h"
#include <stdint.h>
#include "nsIDocShellTreeItem.h"
#include "nsIDocShell.h"
class nsIDocShell;
class nsIDOMWindow;
@ -41,7 +41,7 @@ protected:
// Note: this function may flush and cause mDocShellNode to become null.
void EnsureFresh();
nsIDocShellTreeNode* mDocShellNode; //Weak Reference
nsIDocShell* mDocShellNode; //Weak Reference
};
#endif // nsDOMWindowList_h___

View File

@ -5468,13 +5468,13 @@ nsGlobalWindow::GetLength(uint32_t* aLength)
already_AddRefed<nsIDOMWindow>
nsGlobalWindow::GetChildWindow(const nsAString& aName)
{
nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(GetDocShell()));
NS_ENSURE_TRUE(dsn, nullptr);
nsCOMPtr<nsIDocShell> docShell(GetDocShell());
NS_ENSURE_TRUE(docShell, nullptr);
nsCOMPtr<nsIDocShellTreeItem> child;
dsn->FindChildWithName(PromiseFlatString(aName).get(),
false, true, nullptr, nullptr,
getter_AddRefs(child));
docShell->FindChildWithName(PromiseFlatString(aName).get(),
false, true, nullptr, nullptr,
getter_AddRefs(child));
nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
return child_win.forget();

View File

@ -1848,14 +1848,13 @@ MediaManager::MediaCaptureWindowStateInternal(nsIDOMWindow* aWindow, bool* aVide
}
// iterate any children of *this* window (iframes, etc)
nsCOMPtr<nsIDocShellTreeNode> node =
do_QueryInterface(piWin->GetDocShell());
if (node) {
nsCOMPtr<nsIDocShell> docShell = piWin->GetDocShell();
if (docShell) {
int32_t i, count;
node->GetChildCount(&count);
docShell->GetChildCount(&count);
for (i = 0; i < count; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
node->GetChildAt(i, getter_AddRefs(item));
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(item);
MediaCaptureWindowStateInternal(win, aVideo, aAudio);

View File

@ -136,7 +136,6 @@ NS_INTERFACE_MAP_BEGIN(nsWebBrowser)
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
NS_INTERFACE_MAP_ENTRY(nsITextScroll)
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeNode)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserSetup)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPersist)

View File

@ -18,7 +18,6 @@
#include "nsIBaseWindow.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIScrollable.h"
@ -96,7 +95,6 @@ public:
NS_DECL_NSIBASEWINDOW
NS_DECL_NSIDOCSHELLTREEITEM
NS_DECL_NSIDOCSHELLTREENODE
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSISCROLLABLE
NS_DECL_NSITEXTSCROLL

View File

@ -322,7 +322,7 @@ private:
#ifdef NS_PRINTING
// Called when the DocViewer is notified that the state
// of Printing or PP has changed
void SetIsPrintingInDocShellTree(nsIDocShellTreeNode* aParentNode,
void SetIsPrintingInDocShellTree(nsIDocShellTreeItem* aParentNode,
bool aIsPrintingOrPP,
bool aStartAtTop);
#endif // NS_PRINTING
@ -1147,14 +1147,14 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
}
}
nsCOMPtr<nsIDocShellTreeNode> docShellNode(mContainer);
nsCOMPtr<nsIDocShell> docShell(mContainer);
nsAutoString text;
beforeUnload->GetReturnValue(text);
if (*aShouldPrompt && (event->GetInternalNSEvent()->mFlags.mDefaultPrevented ||
!text.IsEmpty())) {
// Ask the user if it's ok to unload the current page
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(docShellNode);
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(docShell);
if (prompt) {
nsXPIDLString title, message, stayLabel, leaveLabel;
@ -1211,13 +1211,13 @@ nsDocumentViewer::PermitUnloadInternal(bool aCallerClosesWindow,
}
}
if (docShellNode) {
if (docShell) {
int32_t childCount;
docShellNode->GetChildCount(&childCount);
docShell->GetChildCount(&childCount);
for (int32_t i = 0; i < childCount && *aPermitUnload; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
docShellNode->GetChildAt(i, getter_AddRefs(item));
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(item));
@ -1244,14 +1244,14 @@ nsDocumentViewer::ResetCloseWindow()
{
mCallerIsClosingWindow = false;
nsCOMPtr<nsIDocShellTreeNode> docShellNode(mContainer);
if (docShellNode) {
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell) {
int32_t childCount;
docShellNode->GetChildCount(&childCount);
docShell->GetChildCount(&childCount);
for (int32_t i = 0; i < childCount; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
docShellNode->GetChildAt(i, getter_AddRefs(item));
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(item));
@ -1770,7 +1770,7 @@ nsDocumentViewer::SetDocumentInternal(nsIDocument* aDocument,
// Clear the list of old child docshells. Child docshells for the new
// document will be constructed as frames are created.
if (!aDocument->IsStaticDocument()) {
nsCOMPtr<nsIDocShellTreeNode> node(mContainer);
nsCOMPtr<nsIDocShell> node(mContainer);
if (node) {
int32_t count;
node->GetChildCount(&count);
@ -2690,16 +2690,16 @@ NS_IMETHODIMP nsDocumentViewer::ScrollToNode(nsIDOMNode* aNode)
void
nsDocumentViewer::CallChildren(CallChildFunc aFunc, void* aClosure)
{
nsCOMPtr<nsIDocShellTreeNode> docShellNode(mContainer);
if (docShellNode)
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell)
{
int32_t i;
int32_t n;
docShellNode->GetChildCount(&n);
docShell->GetChildCount(&n);
for (i=0; i < n; i++)
{
nsCOMPtr<nsIDocShellTreeItem> child;
docShellNode->GetChildAt(i, getter_AddRefs(child));
docShell->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
@ -3961,7 +3961,7 @@ nsDocumentViewer::GetIsRangeSelection(bool *aIsRangeSelection)
//----------------------------------------------------------------------------------
// Walks the document tree and tells each DocShell whether Printing/PP is happening
void
nsDocumentViewer::SetIsPrintingInDocShellTree(nsIDocShellTreeNode* aParentNode,
nsDocumentViewer::SetIsPrintingInDocShellTree(nsIDocShellTreeItem* aParentNode,
bool aIsPrintingOrPP,
bool aStartAtTop)
{
@ -4000,10 +4000,9 @@ nsDocumentViewer::SetIsPrintingInDocShellTree(nsIDocShellTreeNode* aParentNode,
for (int32_t i=0; i < n; i++) {
nsCOMPtr<nsIDocShellTreeItem> child;
aParentNode->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIDocShellTreeNode> childAsNode(do_QueryInterface(child));
NS_ASSERTION(childAsNode, "child isn't nsIDocShellTreeNode");
if (childAsNode) {
SetIsPrintingInDocShellTree(childAsNode, aIsPrintingOrPP, false);
NS_ASSERTION(child, "child isn't nsIDocShell");
if (child) {
SetIsPrintingInDocShellTree(child, aIsPrintingOrPP, false);
}
}
@ -4084,9 +4083,9 @@ nsDocumentViewer::SetIsPrinting(bool aIsPrinting)
#ifdef NS_PRINTING
// Set all the docShells in the docshell tree to be printing.
// that way if anyone of them tries to "navigate" it can't
nsCOMPtr<nsIDocShellTreeNode> docShellTreeNode(mContainer);
if (docShellTreeNode || !aIsPrinting) {
SetIsPrintingInDocShellTree(docShellTreeNode, aIsPrinting, true);
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell || !aIsPrinting) {
SetIsPrintingInDocShellTree(docShell, aIsPrinting, true);
} else {
NS_WARNING("Did you close a window before printing?");
}
@ -4120,9 +4119,9 @@ nsDocumentViewer::SetIsPrintPreview(bool aIsPrintPreview)
#ifdef NS_PRINTING
// Set all the docShells in the docshell tree to be printing.
// that way if anyone of them tries to "navigate" it can't
nsCOMPtr<nsIDocShellTreeNode> docShellTreeNode(mContainer);
if (docShellTreeNode || !aIsPrintPreview) {
SetIsPrintingInDocShellTree(docShellTreeNode, aIsPrintPreview, true);
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell || !aIsPrintPreview) {
SetIsPrintingInDocShellTree(docShell, aIsPrintPreview, true);
}
if (!aIsPrintPreview) {
mBeforeAndAfterPrint = nullptr;

View File

@ -1159,7 +1159,7 @@ nsPrintEngine::IsParentAFrameSet(nsIDocShell * aParent)
// Recursively build a list of sub documents to be printed
// that mirrors the document tree
void
nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
nsPrintEngine::BuildDocTree(nsIDocShell * aParentNode,
nsTArray<nsPrintObject*> * aDocList,
nsPrintObject * aPO)
{
@ -1180,17 +1180,15 @@ nsPrintEngine::BuildDocTree(nsIDocShellTreeNode * aParentNode,
if (viewer) {
nsCOMPtr<nsIContentViewerFile> viewerFile(do_QueryInterface(viewer));
if (viewerFile) {
nsCOMPtr<nsIDocShell> childDocShell(do_QueryInterface(child));
nsCOMPtr<nsIDocShellTreeNode> childNode(do_QueryInterface(child));
nsCOMPtr<nsIDOMDocument> doc = do_GetInterface(childDocShell);
nsCOMPtr<nsIDOMDocument> doc = do_GetInterface(childAsShell);
nsPrintObject * po = new nsPrintObject();
po->mParent = aPO;
nsresult rv = po->Init(childDocShell, doc, aPO->mPrintPreview);
nsresult rv = po->Init(childAsShell, doc, aPO->mPrintPreview);
if (NS_FAILED(rv))
NS_NOTREACHED("Init failed?");
aPO->mKids.AppendElement(po);
aDocList->AppendElement(po);
BuildDocTree(childNode, aDocList, po);
BuildDocTree(childAsShell, aDocList, po);
}
}
}
@ -3757,11 +3755,10 @@ DumpViews(nsIDocShell* aDocShell, FILE* out)
// dump the views of the sub documents
int32_t i, n;
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
docShellAsNode->GetChildCount(&n);
aDocShell->GetChildCount(&n);
for (i = 0; i < n; i++) {
nsCOMPtr<nsIDocShellTreeItem> child;
docShellAsNode->GetChildAt(i, getter_AddRefs(child));
aDocShell->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
if (childAsShell) {
DumpViews(childAsShell, out);

View File

@ -24,7 +24,7 @@
// Classes
class nsPagePrintTimer;
class nsIDocShellTreeNode;
class nsIDocShell;
class nsDeviceContext;
class nsIDocument;
class nsIDocumentViewerPrint;
@ -116,7 +116,7 @@ public:
bool DonePrintingPages(nsPrintObject* aPO, nsresult aResult);
//---------------------------------------------------------------------
void BuildDocTree(nsIDocShellTreeNode * aParentNode,
void BuildDocTree(nsIDocShell * aParentNode,
nsTArray<nsPrintObject*> * aDocList,
nsPrintObject * aPO);
nsresult ReflowDocList(nsPrintObject * aPO, bool aSetPixelScale);

View File

@ -320,11 +320,10 @@ static void DumpAWebShell(nsIDocShellTreeItem* aShellItem, FILE* out, int32_t aI
fprintf(out, "' parent=%p <\n", static_cast<void*>(parent));
++aIndent;
nsCOMPtr<nsIDocShellTreeNode> shellAsNode(do_QueryInterface(aShellItem));
shellAsNode->GetChildCount(&n);
aShellItem->GetChildCount(&n);
for (i = 0; i < n; ++i) {
nsCOMPtr<nsIDocShellTreeItem> child;
shellAsNode->GetChildAt(i, getter_AddRefs(child));
aShellItem->GetChildAt(i, getter_AddRefs(child));
if (child) {
DumpAWebShell(child, out, aIndent);
}

View File

@ -511,7 +511,7 @@
.currentURI.spec == aSoughtURI.spec)
return aDocShell;
var node = aDocShell.QueryInterface(
Components.interfaces.nsIDocShellTreeNode);
Components.interfaces.nsIDocShellTreeItem);
for (var i = 0; i < node.childCount; ++i) {
var docShell = node.getChildAt(i);
docShell = this.findChildShell(docShell, aSoughtURI);

View File

@ -65,7 +65,6 @@
#include "nsIBaseWindow.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIMarkupDocumentViewer.h"
#include "mozilla/Attributes.h"