Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIDocShellTreeOwner; |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | /** |
michael@0 | 13 | * The nsIDocShellTreeItem supplies the methods that are required of any item |
michael@0 | 14 | * that wishes to be able to live within the docshell tree either as a middle |
michael@0 | 15 | * node or a leaf. |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | [scriptable, uuid(f897f4af-f67e-4115-9d37-ce09f71122e2)] |
michael@0 | 19 | interface nsIDocShellTreeItem : nsISupports |
michael@0 | 20 | { |
michael@0 | 21 | /* |
michael@0 | 22 | name of the DocShellTreeItem |
michael@0 | 23 | */ |
michael@0 | 24 | attribute AString name; |
michael@0 | 25 | |
michael@0 | 26 | /** |
michael@0 | 27 | * Compares the provided name against the item's name and |
michael@0 | 28 | * returns the appropriate result. |
michael@0 | 29 | * |
michael@0 | 30 | * @return <CODE>PR_TRUE</CODE> if names match; |
michael@0 | 31 | * <CODE>PR_FALSE</CODE> otherwise. |
michael@0 | 32 | */ |
michael@0 | 33 | boolean nameEquals(in wstring name); |
michael@0 | 34 | |
michael@0 | 35 | /* |
michael@0 | 36 | Definitions for the item types. |
michael@0 | 37 | */ |
michael@0 | 38 | const long typeChrome=0; // typeChrome must equal 0 |
michael@0 | 39 | const long typeContent=1; // typeContent must equal 1 |
michael@0 | 40 | const long typeContentWrapper=2; // typeContentWrapper must equal 2 |
michael@0 | 41 | const long typeChromeWrapper=3; // typeChromeWrapper must equal 3 |
michael@0 | 42 | |
michael@0 | 43 | const long typeAll=0x7FFFFFFF; |
michael@0 | 44 | |
michael@0 | 45 | /* |
michael@0 | 46 | The type this item is. |
michael@0 | 47 | */ |
michael@0 | 48 | attribute long itemType; |
michael@0 | 49 | [noscript,notxpcom,nostdcall] long ItemType(); |
michael@0 | 50 | |
michael@0 | 51 | /* |
michael@0 | 52 | Parent DocShell. |
michael@0 | 53 | */ |
michael@0 | 54 | readonly attribute nsIDocShellTreeItem parent; |
michael@0 | 55 | |
michael@0 | 56 | /* |
michael@0 | 57 | This getter returns the same thing parent does however if the parent |
michael@0 | 58 | is of a different itemType, or if the parent is an <iframe mozbrowser> |
michael@0 | 59 | or <iframe mozapp>, it will instead return nullptr. This call is a |
michael@0 | 60 | convience function for those wishing to not cross the boundaries at |
michael@0 | 61 | which item types change. |
michael@0 | 62 | */ |
michael@0 | 63 | readonly attribute nsIDocShellTreeItem sameTypeParent; |
michael@0 | 64 | |
michael@0 | 65 | /* |
michael@0 | 66 | Returns the root DocShellTreeItem. This is a convience equivalent to |
michael@0 | 67 | getting the parent and its parent until there isn't a parent. |
michael@0 | 68 | */ |
michael@0 | 69 | readonly attribute nsIDocShellTreeItem rootTreeItem; |
michael@0 | 70 | |
michael@0 | 71 | /* |
michael@0 | 72 | Returns the root DocShellTreeItem of the same type. This is a convience |
michael@0 | 73 | equivalent to getting the parent of the same type and its parent until |
michael@0 | 74 | there isn't a parent. |
michael@0 | 75 | */ |
michael@0 | 76 | readonly attribute nsIDocShellTreeItem sameTypeRootTreeItem; |
michael@0 | 77 | |
michael@0 | 78 | /* |
michael@0 | 79 | Returns the docShellTreeItem with the specified name. Search order is as |
michael@0 | 80 | follows... |
michael@0 | 81 | 1.) Check name of self, if it matches return it. |
michael@0 | 82 | 2.) For each immediate child. |
michael@0 | 83 | a.) Check name of child and if it matches return it. |
michael@0 | 84 | b.) Ask the child to perform the check |
michael@0 | 85 | i.) Do not ask a child if it is the aRequestor |
michael@0 | 86 | ii.) Do not ask a child if it is of a different item type. |
michael@0 | 87 | 3.) If there is a parent of the same item type ask parent to perform the check |
michael@0 | 88 | a.) Do not ask parent if it is the aRequestor |
michael@0 | 89 | 4.) If there is a tree owner ask the tree owner to perform the check |
michael@0 | 90 | a.) Do not ask the tree owner if it is the aRequestor |
michael@0 | 91 | b.) This should only be done if there is no parent of the same type. |
michael@0 | 92 | |
michael@0 | 93 | Return the child DocShellTreeItem with the specified name. |
michael@0 | 94 | name - This is the name of the item that is trying to be found. |
michael@0 | 95 | aRequestor - This is the object that is requesting the find. This |
michael@0 | 96 | parameter is used to identify when the child is asking its parent to find |
michael@0 | 97 | a child with the specific name. The parent uses this parameter to ensure |
michael@0 | 98 | a resursive state does not occur by not again asking the requestor to find |
michael@0 | 99 | a shell by the specified name. Inversely the child uses it to ensure it |
michael@0 | 100 | does not ask its parent to do the search if its parent is the one that |
michael@0 | 101 | asked it to search. Children also use this to test against the treeOwner; |
michael@0 | 102 | aOriginalRequestor - The original treeitem that made the request, if any. |
michael@0 | 103 | This is used to ensure that we don't run into cross-site issues. |
michael@0 | 104 | */ |
michael@0 | 105 | nsIDocShellTreeItem findItemWithName(in wstring name, |
michael@0 | 106 | in nsISupports aRequestor, |
michael@0 | 107 | in nsIDocShellTreeItem aOriginalRequestor); |
michael@0 | 108 | |
michael@0 | 109 | /* |
michael@0 | 110 | The owner of the DocShell Tree. This interface will be called upon when |
michael@0 | 111 | the docshell has things it needs to tell to the owner of the docshell. |
michael@0 | 112 | Note that docShell tree ownership does not cross tree types. Meaning |
michael@0 | 113 | setting ownership on a chrome tree does not set ownership on the content |
michael@0 | 114 | sub-trees. A given tree's boundaries are identified by the type changes. |
michael@0 | 115 | Trees of different types may be connected, but should not be traversed |
michael@0 | 116 | for things such as ownership. |
michael@0 | 117 | |
michael@0 | 118 | Note implementers of this interface should NOT effect the lifetime of the |
michael@0 | 119 | parent DocShell by holding this reference as it creates a cycle. Owners |
michael@0 | 120 | when releasing this interface should set the treeOwner to nullptr. |
michael@0 | 121 | Implementers of this interface are guaranteed that when treeOwner is |
michael@0 | 122 | set that the poitner is valid without having to addref. |
michael@0 | 123 | |
michael@0 | 124 | Further note however when others try to get the interface it should be |
michael@0 | 125 | addref'd before handing it to them. |
michael@0 | 126 | */ |
michael@0 | 127 | readonly attribute nsIDocShellTreeOwner treeOwner; |
michael@0 | 128 | [noscript] void setTreeOwner(in nsIDocShellTreeOwner treeOwner); |
michael@0 | 129 | |
michael@0 | 130 | /* |
michael@0 | 131 | The current number of DocShells which are immediate children of the |
michael@0 | 132 | this object. |
michael@0 | 133 | */ |
michael@0 | 134 | readonly attribute long childCount; |
michael@0 | 135 | |
michael@0 | 136 | /* |
michael@0 | 137 | Add a new child DocShellTreeItem. Adds to the end of the list. |
michael@0 | 138 | Note that this does NOT take a reference to the child. The child stays |
michael@0 | 139 | alive only as long as it's referenced from outside the docshell tree. |
michael@0 | 140 | @throws NS_ERROR_ILLEGAL_VALUE if child corresponds to the same |
michael@0 | 141 | object as this treenode or an ancestor of this treenode |
michael@0 | 142 | @throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree. |
michael@0 | 143 | */ |
michael@0 | 144 | void addChild(in nsIDocShellTreeItem child); |
michael@0 | 145 | |
michael@0 | 146 | /* |
michael@0 | 147 | Removes a child DocShellTreeItem. |
michael@0 | 148 | @throws NS_ERROR_UNEXPECTED if this node is a leaf in the tree. |
michael@0 | 149 | */ |
michael@0 | 150 | void removeChild(in nsIDocShellTreeItem child); |
michael@0 | 151 | |
michael@0 | 152 | /** |
michael@0 | 153 | * Return the child at the index requested. This is 0-based. |
michael@0 | 154 | * |
michael@0 | 155 | * @throws NS_ERROR_UNEXPECTED if the index is out of range |
michael@0 | 156 | */ |
michael@0 | 157 | nsIDocShellTreeItem getChildAt(in long index); |
michael@0 | 158 | |
michael@0 | 159 | /* |
michael@0 | 160 | Return the child DocShellTreeItem with the specified name. |
michael@0 | 161 | aName - This is the name of the item that is trying to be found. |
michael@0 | 162 | aRecurse - Is used to tell the function to recurse through children. |
michael@0 | 163 | Note, recursion will only happen through items of the same type. |
michael@0 | 164 | aSameType - If this is set only children of the same type will be returned. |
michael@0 | 165 | aRequestor - This is the docshellTreeItem that is requesting the find. This |
michael@0 | 166 | parameter is used when recursion is being used to avoid searching the same |
michael@0 | 167 | tree again when a child has asked a parent to search for children. |
michael@0 | 168 | aOriginalRequestor - The original treeitem that made the request, if any. |
michael@0 | 169 | This is used to ensure that we don't run into cross-site issues. |
michael@0 | 170 | |
michael@0 | 171 | Note the search is depth first when recursing. |
michael@0 | 172 | */ |
michael@0 | 173 | nsIDocShellTreeItem findChildWithName(in wstring aName, |
michael@0 | 174 | in boolean aRecurse, |
michael@0 | 175 | in boolean aSameType, |
michael@0 | 176 | in nsIDocShellTreeItem aRequestor, |
michael@0 | 177 | in nsIDocShellTreeItem aOriginalRequestor); |
michael@0 | 178 | }; |
michael@0 | 179 |