Blame docshell/base/nsIDocShellTreeItem.idl

Packit f0b94e
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
Packit f0b94e
 *
Packit f0b94e
 * This Source Code Form is subject to the terms of the Mozilla Public
Packit f0b94e
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit f0b94e
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit f0b94e
Packit f0b94e
#include "nsISupports.idl"
Packit f0b94e
Packit f0b94e
interface nsIDocShellTreeOwner;
Packit f0b94e
interface nsIDocument;
Packit f0b94e
interface nsPIDOMWindowOuter;
Packit f0b94e
Packit f0b94e
Packit f0b94e
/**
Packit f0b94e
 * The nsIDocShellTreeItem supplies the methods that are required of any item
Packit f0b94e
 * that wishes to be able to live within the docshell tree either as a middle
Packit f0b94e
 * node or a leaf. 
Packit f0b94e
 */
Packit f0b94e
Packit f0b94e
[scriptable, uuid(9b7c586f-9214-480c-a2c4-49b526fff1a6)]
Packit f0b94e
interface nsIDocShellTreeItem : nsISupports
Packit f0b94e
{
Packit f0b94e
	/*
Packit f0b94e
	name of the DocShellTreeItem
Packit f0b94e
	*/
Packit f0b94e
	attribute AString name;
Packit f0b94e
Packit f0b94e
        /**
Packit f0b94e
         * Compares the provided name against the item's name and
Packit f0b94e
         * returns the appropriate result.
Packit f0b94e
         *
Packit f0b94e
         * @return PR_TRUE if names match;
Packit f0b94e
         *         PR_FALSE otherwise.
Packit f0b94e
         */
Packit f0b94e
        boolean nameEquals(in AString name);
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Definitions for the item types.
Packit f0b94e
	*/
Packit f0b94e
	const long typeChrome=0;            // typeChrome must equal 0
Packit f0b94e
	const long typeContent=1;           // typeContent must equal 1
Packit f0b94e
	const long typeContentWrapper=2;    // typeContentWrapper must equal 2
Packit f0b94e
	const long typeChromeWrapper=3;     // typeChromeWrapper must equal 3
Packit f0b94e
Packit f0b94e
	const long typeAll=0x7FFFFFFF;
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	The type this item is.  
Packit f0b94e
	*/
Packit f0b94e
	attribute long itemType;
Packit f0b94e
	[noscript,notxpcom,nostdcall] long ItemType();
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Parent DocShell.
Packit f0b94e
	*/
Packit f0b94e
	readonly attribute nsIDocShellTreeItem parent;
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	This getter returns the same thing parent does however if the parent
Packit f0b94e
	is of a different itemType, or if the parent is an <iframe mozbrowser>.
Packit f0b94e
	It will instead return nullptr.  This call is a convience function for
Packit f0b94e
	Ithose wishing to not cross the boundaries at which item types change.
Packit f0b94e
	*/
Packit f0b94e
	readonly attribute nsIDocShellTreeItem sameTypeParent;
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Returns the root DocShellTreeItem.  This is a convience equivalent to 
Packit f0b94e
	getting the parent and its parent until there isn't a parent.
Packit f0b94e
	*/
Packit f0b94e
	readonly attribute nsIDocShellTreeItem rootTreeItem;
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Returns the root DocShellTreeItem of the same type.  This is a convience 
Packit f0b94e
	equivalent to getting the parent of the same type and its parent until 
Packit f0b94e
	there isn't a parent.
Packit f0b94e
	*/
Packit f0b94e
	readonly attribute nsIDocShellTreeItem sameTypeRootTreeItem;
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Returns the docShellTreeItem with the specified name.  Search order is as 
Packit f0b94e
	follows...
Packit f0b94e
	1.)  Check name of self, if it matches return it.
Packit f0b94e
	2.)  For each immediate child.
Packit f0b94e
		a.) Check name of child and if it matches return it.
Packit f0b94e
		b.)  Ask the child to perform the check
Packit f0b94e
			i.) Do not ask a child if it is the aRequestor
Packit f0b94e
			ii.) Do not ask a child if it is of a different item type.
Packit f0b94e
	3.)  If there is a parent of the same item type ask parent to perform the check
Packit f0b94e
		a.) Do not ask parent if it is the aRequestor
Packit f0b94e
	4.)  If there is a tab group ask the tab group to perform the check
Packit f0b94e
		a.)  Do not ask the tab group if aSkipTabGroup
Packit f0b94e
		b.)  This should only be done if there is no parent of the same type.
Packit f0b94e
Packit f0b94e
	Return the child DocShellTreeItem with the specified name.
Packit f0b94e
	name - This is the name of the item that is trying to be found.
Packit f0b94e
	aRequestor - This is the object that is requesting the find.  This
Packit f0b94e
		parameter is used to identify when the child is asking its parent to find
Packit f0b94e
		a child with the specific name.  The parent uses this parameter to ensure
Packit f0b94e
		a resursive state does not occur by not again asking the requestor to find
Packit f0b94e
		a shell by the specified name.  Inversely the child uses it to ensure it
Packit f0b94e
		does not ask its parent to do the search if its parent is the one that
Packit f0b94e
		asked it to search.  Children also use this to test against the treeOwner;
Packit f0b94e
	aOriginalRequestor - The original treeitem that made the request, if any.
Packit f0b94e
		This is used to ensure that we don't run into cross-site issues.
Packit f0b94e
	aSkipTabGroup - Whether the tab group should be checked.
Packit f0b94e
	*/
Packit f0b94e
	nsIDocShellTreeItem findItemWithName(in AString name,
Packit f0b94e
	                                     in nsIDocShellTreeItem aRequestor,
Packit f0b94e
	                                     in nsIDocShellTreeItem aOriginalRequestor,
Packit f0b94e
	                                     in bool aSkipTabGroup);
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	The owner of the DocShell Tree.  This interface will be called upon when
Packit f0b94e
	the docshell has things it needs to tell to the owner of the docshell.
Packit f0b94e
	Note that docShell tree ownership does not cross tree types.  Meaning
Packit f0b94e
	setting ownership on a chrome tree does not set ownership on the content 
Packit f0b94e
	sub-trees.  A given tree's boundaries are identified by the type changes.
Packit f0b94e
	Trees of different types may be connected, but should not be traversed
Packit f0b94e
	for things such as ownership.
Packit f0b94e
	
Packit f0b94e
	Note implementers of this interface should NOT effect the lifetime of the 
Packit f0b94e
	parent DocShell by holding this reference as it creates a cycle.  Owners
Packit f0b94e
	when releasing this interface should set the treeOwner to nullptr.
Packit f0b94e
	Implementers of this interface are guaranteed that when treeOwner is
Packit f0b94e
	set that the poitner is valid without having to addref.
Packit f0b94e
	
Packit f0b94e
	Further note however when others try to get the interface it should be 
Packit f0b94e
	addref'd before handing it to them. 
Packit f0b94e
	*/
Packit f0b94e
	readonly attribute nsIDocShellTreeOwner treeOwner;
Packit f0b94e
	[noscript] void setTreeOwner(in nsIDocShellTreeOwner treeOwner);
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	The current number of DocShells which are immediate children of the 
Packit f0b94e
	this object.
Packit f0b94e
	*/
Packit f0b94e
	readonly attribute long childCount;
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Add a new child DocShellTreeItem.  Adds to the end of the list.
Packit f0b94e
	Note that this does NOT take a reference to the child.  The child stays
Packit f0b94e
	alive only as long as it's referenced from outside the docshell tree.
Packit f0b94e
	@throws NS_ERROR_ILLEGAL_VALUE if child corresponds to the same
Packit f0b94e
	        object as this treenode or an ancestor of this treenode
Packit f0b94e
	@throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree.
Packit f0b94e
	*/
Packit f0b94e
	void addChild(in nsIDocShellTreeItem child);
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Removes a child DocShellTreeItem.
Packit f0b94e
	@throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree.
Packit f0b94e
	*/
Packit f0b94e
	void removeChild(in nsIDocShellTreeItem child);
Packit f0b94e
Packit f0b94e
	/**
Packit f0b94e
	 * Return the child at the index requested.  This is 0-based.
Packit f0b94e
	 *
Packit f0b94e
	 * @throws NS_ERROR_UNEXPECTED if the index is out of range
Packit f0b94e
	 */
Packit f0b94e
	nsIDocShellTreeItem getChildAt(in long index);
Packit f0b94e
Packit f0b94e
	/*
Packit f0b94e
	Return the child DocShellTreeItem with the specified name.
Packit f0b94e
	aName - This is the name of the item that is trying to be found.
Packit f0b94e
	aRecurse - Is used to tell the function to recurse through children.
Packit f0b94e
		Note, recursion will only happen through items of the same type.
Packit f0b94e
	aSameType - If this is set only children of the same type will be returned.
Packit f0b94e
	aRequestor - This is the docshellTreeItem that is requesting the find.  This
Packit f0b94e
		parameter is used when recursion is being used to avoid searching the same
Packit f0b94e
		tree again when a child has asked a parent to search for children.
Packit f0b94e
	aOriginalRequestor - The original treeitem that made the request, if any.
Packit f0b94e
    	This is used to ensure that we don't run into cross-site issues.
Packit f0b94e
Packit f0b94e
	Note the search is depth first when recursing.
Packit f0b94e
	*/
Packit f0b94e
	nsIDocShellTreeItem findChildWithName(in AString aName,
Packit f0b94e
	                                      in boolean aRecurse,
Packit f0b94e
	                                      in boolean aSameType,
Packit f0b94e
	                                      in nsIDocShellTreeItem aRequestor,
Packit f0b94e
	                                      in nsIDocShellTreeItem aOriginalRequestor);
Packit f0b94e
Packit f0b94e
  [noscript,nostdcall,notxpcom] nsIDocument getDocument();
Packit f0b94e
  [noscript,nostdcall,notxpcom] nsPIDOMWindowOuter getWindow();
Packit f0b94e
};
Packit f0b94e