nsIDocShellTreeItem.idl 7.2 KB

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