Logo Search packages:      
Sourcecode: xulrunner version File versions

PRBool nsContentList::IsContentAnonymous ( nsIContent aContent  )  [protected]

A function to check whether aContent is anonymous from our point of view. If it is, we don't care about it, since we should never contain it or any of its kids.

The goal of this function is to filter out content that is "anonymous" from our point of view, so that we don't end up with it in the list. Note that in some cases content can be anonymous but NOT from our point of view. For example, say we're the result of calling getElementsByTagName on an anonymous node in a XBL binding. In that case, all descendants of that node that it can see are not anonymous from our point of view.

If we have no root, that means we correspond to a list gotten off the "document" object, so will always contain only nodes that the document can see, which means only nodes with a null bindingParent.

If mRootContent and aContent have _different_ bindingParents, then there are two possibilities:

1) aContent or one of its ancestors is an anonymous child of a descendant of mRootContent (or of mRootContent itself). 2) mRootContent is not an ancestor of aContent.

In either case, we don't want to be matching aContent or any of its descendants.

On the other hand, if mRootContent and aContent have the same bindingParent then they are part of the same binding (or native anonymous content chunk) and then aContent may be a descendant of mRootContent and we may want to match it.

So we return true if the binding parents don't match; if the binding parents are the same, the checks we normally do to determine whether we match a node should be done.

Definition at line 969 of file nsContentList.cpp.

References nsIContent::GetBindingParent().

{
  NS_PRECONDITION(aContent, "Must have a content node to work with");
  
  /**
   * The goal of this function is to filter out content that is "anonymous"
   * from our point of view, so that we don't end up with it in the list.  Note
   * that in some cases content can be anonymous but NOT from our point of
   * view.  For example, say we're the result of calling getElementsByTagName
   * on an anonymous node in a XBL binding.  In that case, all descendants of
   * that node that it can see are not anonymous from our point of view.
   */

  if (!mRootContent) {
    /**
     * If we have no root, that means we correspond to a list gotten off the
     * "document" object, so will always contain only nodes that the document
     * can see, which means only nodes with a null bindingParent.
     */
    return aContent->GetBindingParent() != nsnull;
  }

  /**
   * If mRootContent and aContent have _different_ bindingParents, then there
   * are two possibilities:
   *
   * 1) aContent or one of its ancestors is an anonymous child of a descendant
   *    of mRootContent (or of mRootContent itself).
   * 2) mRootContent is not an ancestor of aContent.
   *
   * In either case, we don't want to be matching aContent or any of its
   * descendants.
   *
   * On the other hand, if mRootContent and aContent have the same
   * bindingParent then they are part of the same binding (or native anonymous
   * content chunk) and then aContent may be a descendant of mRootContent and
   * we may want to match it.
   *
   * So we return true if the binding parents don't match; if the binding
   * parents are the same, the checks we normally do to determine whether we
   * match a node should be done.
   */
  return mRootContent->GetBindingParent() != aContent->GetBindingParent();
}


Generated by  Doxygen 1.6.0   Back to index