Logo Search packages:      
Sourcecode: xulrunner version File versions  Download package

void nsContentList::PopulateWith ( nsIContent aContent,
PRBool  aIncludeRoot,
PRUint32 &  aElementsToAppend 
) [protected]

Add elements in the subtree rooted in aContent that match our criterion to our list until we've picked up aElementsToAppend elements. This function enforces the invariant that |aElementsToAppend + mElements.Count()| is a constant.

aContent the root of the subtree we want to traverse
aIncludeRoot whether to include the root in the traversal
aElementsToAppend how many elements to append to the list before stopping

Definition at line 753 of file nsContentList.cpp.

References nsIContent::GetChildAt(), nsIContent::GetChildCount(), nsIContent::GetParent(), Match(), and mDeep.

Referenced by PopulateSelf(), and PopulateWithStartingAfter().

  NS_PRECONDITION(mDeep || aContent == mRootContent ||
                  aContent->GetParent() == mRootContent,
                  "PopulateWith called on nodes we can't possibly match");
  NS_PRECONDITION(mDeep || aIncludeRoot || aContent == mRootContent,
                  "Bogus root passed to PopulateWith in non-deep list");
  NS_PRECONDITION(!aIncludeRoot || aContent != mRootContent,
                  "We should never be trying to match mRootContent");
  if (aIncludeRoot) {
    if (Match(aContent)) {
      if (aElementsToAppend == 0)

  // Don't recurse down if we're not doing a deep match and we're
  // already looking at kids of the root.
  if (!mDeep && aIncludeRoot)
  PRUint32 i, count = aContent->GetChildCount();

  for (i = 0; i < count; i++) {
    PopulateWith(aContent->GetChildAt(i), PR_TRUE, aElementsToAppend);
    if (aElementsToAppend == 0)

Generated by  Doxygen 1.6.0   Back to index