1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/base/nsIDocShellTreeItem.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,179 @@ 1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsISupports.idl" 1.11 + 1.12 +interface nsIDocShellTreeOwner; 1.13 + 1.14 + 1.15 +/** 1.16 + * The nsIDocShellTreeItem supplies the methods that are required of any item 1.17 + * that wishes to be able to live within the docshell tree either as a middle 1.18 + * node or a leaf. 1.19 + */ 1.20 + 1.21 +[scriptable, uuid(f897f4af-f67e-4115-9d37-ce09f71122e2)] 1.22 +interface nsIDocShellTreeItem : nsISupports 1.23 +{ 1.24 + /* 1.25 + name of the DocShellTreeItem 1.26 + */ 1.27 + attribute AString name; 1.28 + 1.29 + /** 1.30 + * Compares the provided name against the item's name and 1.31 + * returns the appropriate result. 1.32 + * 1.33 + * @return <CODE>PR_TRUE</CODE> if names match; 1.34 + * <CODE>PR_FALSE</CODE> otherwise. 1.35 + */ 1.36 + boolean nameEquals(in wstring name); 1.37 + 1.38 + /* 1.39 + Definitions for the item types. 1.40 + */ 1.41 + const long typeChrome=0; // typeChrome must equal 0 1.42 + const long typeContent=1; // typeContent must equal 1 1.43 + const long typeContentWrapper=2; // typeContentWrapper must equal 2 1.44 + const long typeChromeWrapper=3; // typeChromeWrapper must equal 3 1.45 + 1.46 + const long typeAll=0x7FFFFFFF; 1.47 + 1.48 + /* 1.49 + The type this item is. 1.50 + */ 1.51 + attribute long itemType; 1.52 + [noscript,notxpcom,nostdcall] long ItemType(); 1.53 + 1.54 + /* 1.55 + Parent DocShell. 1.56 + */ 1.57 + readonly attribute nsIDocShellTreeItem parent; 1.58 + 1.59 + /* 1.60 + This getter returns the same thing parent does however if the parent 1.61 + is of a different itemType, or if the parent is an <iframe mozbrowser> 1.62 + or <iframe mozapp>, it will instead return nullptr. This call is a 1.63 + convience function for those wishing to not cross the boundaries at 1.64 + which item types change. 1.65 + */ 1.66 + readonly attribute nsIDocShellTreeItem sameTypeParent; 1.67 + 1.68 + /* 1.69 + Returns the root DocShellTreeItem. This is a convience equivalent to 1.70 + getting the parent and its parent until there isn't a parent. 1.71 + */ 1.72 + readonly attribute nsIDocShellTreeItem rootTreeItem; 1.73 + 1.74 + /* 1.75 + Returns the root DocShellTreeItem of the same type. This is a convience 1.76 + equivalent to getting the parent of the same type and its parent until 1.77 + there isn't a parent. 1.78 + */ 1.79 + readonly attribute nsIDocShellTreeItem sameTypeRootTreeItem; 1.80 + 1.81 + /* 1.82 + Returns the docShellTreeItem with the specified name. Search order is as 1.83 + follows... 1.84 + 1.) Check name of self, if it matches return it. 1.85 + 2.) For each immediate child. 1.86 + a.) Check name of child and if it matches return it. 1.87 + b.) Ask the child to perform the check 1.88 + i.) Do not ask a child if it is the aRequestor 1.89 + ii.) Do not ask a child if it is of a different item type. 1.90 + 3.) If there is a parent of the same item type ask parent to perform the check 1.91 + a.) Do not ask parent if it is the aRequestor 1.92 + 4.) If there is a tree owner ask the tree owner to perform the check 1.93 + a.) Do not ask the tree owner if it is the aRequestor 1.94 + b.) This should only be done if there is no parent of the same type. 1.95 + 1.96 + Return the child DocShellTreeItem with the specified name. 1.97 + name - This is the name of the item that is trying to be found. 1.98 + aRequestor - This is the object that is requesting the find. This 1.99 + parameter is used to identify when the child is asking its parent to find 1.100 + a child with the specific name. The parent uses this parameter to ensure 1.101 + a resursive state does not occur by not again asking the requestor to find 1.102 + a shell by the specified name. Inversely the child uses it to ensure it 1.103 + does not ask its parent to do the search if its parent is the one that 1.104 + asked it to search. Children also use this to test against the treeOwner; 1.105 + aOriginalRequestor - The original treeitem that made the request, if any. 1.106 + This is used to ensure that we don't run into cross-site issues. 1.107 + */ 1.108 + nsIDocShellTreeItem findItemWithName(in wstring name, 1.109 + in nsISupports aRequestor, 1.110 + in nsIDocShellTreeItem aOriginalRequestor); 1.111 + 1.112 + /* 1.113 + The owner of the DocShell Tree. This interface will be called upon when 1.114 + the docshell has things it needs to tell to the owner of the docshell. 1.115 + Note that docShell tree ownership does not cross tree types. Meaning 1.116 + setting ownership on a chrome tree does not set ownership on the content 1.117 + sub-trees. A given tree's boundaries are identified by the type changes. 1.118 + Trees of different types may be connected, but should not be traversed 1.119 + for things such as ownership. 1.120 + 1.121 + Note implementers of this interface should NOT effect the lifetime of the 1.122 + parent DocShell by holding this reference as it creates a cycle. Owners 1.123 + when releasing this interface should set the treeOwner to nullptr. 1.124 + Implementers of this interface are guaranteed that when treeOwner is 1.125 + set that the poitner is valid without having to addref. 1.126 + 1.127 + Further note however when others try to get the interface it should be 1.128 + addref'd before handing it to them. 1.129 + */ 1.130 + readonly attribute nsIDocShellTreeOwner treeOwner; 1.131 + [noscript] void setTreeOwner(in nsIDocShellTreeOwner treeOwner); 1.132 + 1.133 + /* 1.134 + The current number of DocShells which are immediate children of the 1.135 + this object. 1.136 + */ 1.137 + readonly attribute long childCount; 1.138 + 1.139 + /* 1.140 + Add a new child DocShellTreeItem. Adds to the end of the list. 1.141 + Note that this does NOT take a reference to the child. The child stays 1.142 + alive only as long as it's referenced from outside the docshell tree. 1.143 + @throws NS_ERROR_ILLEGAL_VALUE if child corresponds to the same 1.144 + object as this treenode or an ancestor of this treenode 1.145 + @throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree. 1.146 + */ 1.147 + void addChild(in nsIDocShellTreeItem child); 1.148 + 1.149 + /* 1.150 + Removes a child DocShellTreeItem. 1.151 + @throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree. 1.152 + */ 1.153 + void removeChild(in nsIDocShellTreeItem child); 1.154 + 1.155 + /** 1.156 + * Return the child at the index requested. This is 0-based. 1.157 + * 1.158 + * @throws NS_ERROR_UNEXPECTED if the index is out of range 1.159 + */ 1.160 + nsIDocShellTreeItem getChildAt(in long index); 1.161 + 1.162 + /* 1.163 + Return the child DocShellTreeItem with the specified name. 1.164 + aName - This is the name of the item that is trying to be found. 1.165 + aRecurse - Is used to tell the function to recurse through children. 1.166 + Note, recursion will only happen through items of the same type. 1.167 + aSameType - If this is set only children of the same type will be returned. 1.168 + aRequestor - This is the docshellTreeItem that is requesting the find. This 1.169 + parameter is used when recursion is being used to avoid searching the same 1.170 + tree again when a child has asked a parent to search for children. 1.171 + aOriginalRequestor - The original treeitem that made the request, if any. 1.172 + This is used to ensure that we don't run into cross-site issues. 1.173 + 1.174 + Note the search is depth first when recursing. 1.175 + */ 1.176 + nsIDocShellTreeItem findChildWithName(in wstring aName, 1.177 + in boolean aRecurse, 1.178 + in boolean aSameType, 1.179 + in nsIDocShellTreeItem aRequestor, 1.180 + in nsIDocShellTreeItem aOriginalRequestor); 1.181 +}; 1.182 +