Make nsIDocShellTreeItem inherit from nsIDocShellTreeNode. Bug 377303,r=bsmedberg, sr=biesi

This commit is contained in:
bzbarsky@mit.edu 2007-05-06 14:06:28 -07:00
Родитель 24dfe682ac
Коммит 7e3d62ddea
7 изменённых файлов: 85 добавлений и 46 удалений

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

@ -2080,16 +2080,15 @@ nsDocShell::GetTreeOwner(nsIDocShellTreeOwner ** aTreeOwner)
#ifdef DEBUG_DOCSHELL_FOCUS
static void
PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel)
PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel)
{
for (PRInt32 i=0;i<aLevel;i++) printf(" ");
PRInt32 childWebshellCount;
aParentNode->GetChildCount(&childWebshellCount);
nsCOMPtr<nsIDocShell> parentAsDocShell(do_QueryInterface(aParentNode));
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(aParentNode));
PRInt32 type;
parentAsItem->GetItemType(&type);
aParentNode->GetItemType(&type);
nsCOMPtr<nsIPresShell> presShell;
parentAsDocShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsPresContext> presContext;
@ -2115,20 +2114,18 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel)
for (PRInt32 i=0;i<childWebshellCount;i++) {
nsCOMPtr<nsIDocShellTreeItem> child;
aParentNode->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIDocShellTreeNode> childAsNode(do_QueryInterface(child));
PrintDocTree(childAsNode, aLevel+1);
PrintDocTree(child, aLevel+1);
}
}
}
static void
PrintDocTree(nsIDocShellTreeNode * aParentNode)
PrintDocTree(nsIDocShellTreeItem * aParentNode)
{
NS_ASSERTION(aParentNode, "Pointer is null!");
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(aParentNode));
nsCOMPtr<nsIDocShellTreeItem> parentItem;
item->GetParent(getter_AddRefs(parentItem));
aParentNode->GetParent(getter_AddRefs(parentItem));
while (parentItem) {
nsCOMPtr<nsIDocShellTreeItem>tmp;
parentItem->GetParent(getter_AddRefs(tmp));
@ -2139,13 +2136,10 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode)
}
if (!parentItem) {
parentItem = do_QueryInterface(aParentNode);
parentItem = aParentNode;
}
if (parentItem) {
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(parentItem));
PrintDocTree(parentAsNode, 0);
}
PrintDocTree(parentItem, 0);
}
#endif
@ -2153,9 +2147,9 @@ NS_IMETHODIMP
nsDocShell::SetTreeOwner(nsIDocShellTreeOwner * aTreeOwner)
{
#ifdef DEBUG_DOCSHELL_FOCUS
nsCOMPtr<nsIDocShellTreeNode> node(do_QueryInterface(aTreeOwner));
if (node) {
PrintDocTree(node);
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(aTreeOwner));
if (item) {
PrintDocTree(item);
}
#endif
@ -2420,23 +2414,19 @@ nsDocShell::FindChildWithName(const PRUnichar * aName,
if (aRecurse && (aRequestor != child)) // Only ask the child if it isn't the requestor
{
// See if child contains the shell with the given name
nsCOMPtr<nsIDocShellTreeNode>
childAsNode(do_QueryInterface(child));
if (childAsNode) {
#ifdef DEBUG
nsresult rv =
nsresult rv =
#endif
childAsNode->FindChildWithName(aName, PR_TRUE,
aSameType,
NS_STATIC_CAST(nsIDocShellTreeItem*,
this),
aOriginalRequestor,
_retval);
NS_ASSERTION(NS_SUCCEEDED(rv),
"FindChildWithName should not fail here");
if (*_retval) // found it
return NS_OK;
}
child->FindChildWithName(aName, PR_TRUE,
aSameType,
NS_STATIC_CAST(nsIDocShellTreeItem*,
this),
aOriginalRequestor,
_retval);
NS_ASSERTION(NS_SUCCEEDED(rv),
"FindChildWithName should not fail here");
if (*_retval) // found it
return NS_OK;
}
}
return NS_OK;
@ -3491,10 +3481,10 @@ nsDocShell::Destroy()
PersistLayoutHistoryState();
// Remove this docshell from its parent's child list
nsCOMPtr<nsIDocShellTreeNode> docShellParentAsNode =
nsCOMPtr<nsIDocShellTreeItem> docShellParentAsItem =
do_QueryInterface(GetAsSupports(mParent));
if (docShellParentAsNode)
docShellParentAsNode->RemoveChild(this);
if (docShellParentAsItem)
docShellParentAsItem->RemoveChild(this);
if (mContentViewer) {
mContentViewer->Close(nsnull);

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

@ -148,7 +148,6 @@ protected:
class nsDocShell : public nsDocLoader,
public nsIDocShell,
public nsIDocShellTreeItem,
public nsIDocShellTreeNode,
public nsIDocShellHistory,
public nsIWebNavigation,
public nsIBaseWindow,

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

@ -39,6 +39,7 @@
#include "nsDocShellEnumerator.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
nsDocShellEnumerator::nsDocShellEnumerator(PRInt32 inEnumerationDirection)

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

@ -37,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIDocShellTreeNode.idl"
interface nsIDocShellTreeOwner;
@ -48,8 +48,8 @@ interface nsIDocShellTreeOwner;
* node or a leaf.
*/
[scriptable, uuid(7d935d63-6d2a-4600-afb5-9a4f7d68b825)]
interface nsIDocShellTreeItem : nsISupports
[scriptable, uuid(377d6996-c703-497d-9330-536562fcfff5)]
interface nsIDocShellTreeItem : nsIDocShellTreeNode
{
/*
name of the DocShellTreeItem

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

@ -39,7 +39,8 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIDocShellTreeItem.idl"
interface nsIDocShellTreeItem;
/**
* The nsIDocShellTreeNode supplies the methods for interacting with children
@ -47,8 +48,11 @@
* into a docshell tree.
*/
// XXXbz this interface should probably inherit from nsIDocShellTreeItem, and
// some methods should move from there to here...
/*
* 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
@ -64,18 +68,22 @@ interface nsIDocShellTreeNode : nsISupports
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.
// XXXbz this should take an nsIDocShellTreeNode, I think.
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.
// XXXbz this should take an nsIDocShellTreeNode, I think.
@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.*/
/**
* 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);
/*
@ -91,7 +99,6 @@ interface nsIDocShellTreeNode : nsISupports
This is used to ensure that we don't run into cross-site issues.
Note the search is depth first when recursing.
// XXXbz this should return an nsIDocShellTreeNode, I think.
*/
nsIDocShellTreeItem findChildWithName(in wstring aName,
in boolean aRecurse,

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

@ -625,6 +625,46 @@ NS_IMETHODIMP nsWebBrowser::GetChildOffset(PRInt32 *aChildOffset)
return NS_OK;
}
//*****************************************************************************
// nsWebBrowser::nsIDocShellTreeItem
//*****************************************************************************
NS_IMETHODIMP nsWebBrowser::GetChildCount(PRInt32 * aChildCount)
{
NS_ENSURE_ARG_POINTER(aChildCount);
*aChildCount = 0;
return NS_OK;
}
NS_IMETHODIMP nsWebBrowser::AddChild(nsIDocShellTreeItem * aChild)
{
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsWebBrowser::RemoveChild(nsIDocShellTreeItem * aChild)
{
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsWebBrowser::GetChildAt(PRInt32 aIndex,
nsIDocShellTreeItem ** aChild)
{
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsWebBrowser::FindChildWithName(
const PRUnichar * aName,
PRBool aRecurse, PRBool aSameType,
nsIDocShellTreeItem * aRequestor,
nsIDocShellTreeItem * aOriginalRequestor,
nsIDocShellTreeItem ** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
return NS_OK;
}
//*****************************************************************************
// nsWebBrowser::nsIWebNavigation
//*****************************************************************************

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

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